Merge pull request #632 from ryanccn/macos-app-heuristic
This commit is contained in:
commit
91301ec7fe
@ -875,6 +875,12 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
m_mcedit.reset(new MCEditTool(m_settings));
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
connect(this, &Application::clickedOnDock, [this]() {
|
||||
this->showMainWindow();
|
||||
});
|
||||
#endif
|
||||
|
||||
connect(this, &Application::aboutToQuit, [this](){
|
||||
if(m_instances)
|
||||
{
|
||||
@ -958,6 +964,21 @@ bool Application::createSetupWizard()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Application::event(QEvent* event) {
|
||||
#ifdef Q_OS_MACOS
|
||||
if (event->type() == QEvent::ApplicationStateChange) {
|
||||
auto ev = static_cast<QApplicationStateChangeEvent*>(event);
|
||||
|
||||
if (m_prevAppState == Qt::ApplicationActive
|
||||
&& ev->applicationState() == Qt::ApplicationActive) {
|
||||
emit clickedOnDock();
|
||||
}
|
||||
m_prevAppState = ev->applicationState();
|
||||
}
|
||||
#endif
|
||||
return QApplication::event(event);
|
||||
}
|
||||
|
||||
void Application::setupWizardFinished(int status)
|
||||
{
|
||||
qDebug() << "Wizard result =" << status;
|
||||
|
@ -94,6 +94,8 @@ public:
|
||||
Application(int &argc, char **argv);
|
||||
virtual ~Application();
|
||||
|
||||
bool event(QEvent* event) override;
|
||||
|
||||
std::shared_ptr<SettingsObject> settings() const {
|
||||
return m_settings;
|
||||
}
|
||||
@ -183,6 +185,10 @@ signals:
|
||||
void globalSettingsAboutToOpen();
|
||||
void globalSettingsClosed();
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
void clickedOnDock();
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
bool launch(
|
||||
InstancePtr instance,
|
||||
@ -240,6 +246,10 @@ private:
|
||||
QString m_rootPath;
|
||||
Status m_status = Application::StartingUp;
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
Qt::ApplicationState m_prevAppState = Qt::ApplicationInactive;
|
||||
#endif
|
||||
|
||||
#if defined Q_OS_WIN32
|
||||
// used on Windows to attach the standard IO streams
|
||||
bool consoleAttached = false;
|
||||
|
Loading…
Reference in New Issue
Block a user