standard macOS app behavior
This commit is contained in:
parent
dca4ea5cea
commit
0426149580
@ -871,6 +871,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_mcedit.reset(new MCEditTool(m_settings));
|
m_mcedit.reset(new MCEditTool(m_settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(this, &Application::clickedOnDock, [this]() {
|
||||||
|
this->showMainWindow();
|
||||||
|
});
|
||||||
|
|
||||||
connect(this, &Application::aboutToQuit, [this](){
|
connect(this, &Application::aboutToQuit, [this](){
|
||||||
if(m_instances)
|
if(m_instances)
|
||||||
{
|
{
|
||||||
@ -954,6 +958,22 @@ bool Application::createSetupWizard()
|
|||||||
return false;
|
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) {
|
||||||
|
qDebug() << "Clicked on dock!";
|
||||||
|
emit clickedOnDock();
|
||||||
|
}
|
||||||
|
m_prevAppState = ev->applicationState();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return QApplication::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::setupWizardFinished(int status)
|
void Application::setupWizardFinished(int status)
|
||||||
{
|
{
|
||||||
qDebug() << "Wizard result =" << status;
|
qDebug() << "Wizard result =" << status;
|
||||||
@ -1284,6 +1304,10 @@ void Application::subRunningInstance()
|
|||||||
|
|
||||||
bool Application::shouldExitNow() const
|
bool Application::shouldExitNow() const
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
return m_runningInstances == 0 && m_openWindows == 0;
|
return m_runningInstances == 0 && m_openWindows == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ public:
|
|||||||
Application(int &argc, char **argv);
|
Application(int &argc, char **argv);
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
|
bool event(QEvent* event) override;
|
||||||
|
|
||||||
std::shared_ptr<SettingsObject> settings() const {
|
std::shared_ptr<SettingsObject> settings() const {
|
||||||
return m_settings;
|
return m_settings;
|
||||||
}
|
}
|
||||||
@ -180,6 +182,7 @@ signals:
|
|||||||
void updateAllowedChanged(bool status);
|
void updateAllowedChanged(bool status);
|
||||||
void globalSettingsAboutToOpen();
|
void globalSettingsAboutToOpen();
|
||||||
void globalSettingsClosed();
|
void globalSettingsClosed();
|
||||||
|
void clickedOnDock();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool launch(
|
bool launch(
|
||||||
@ -238,6 +241,10 @@ private:
|
|||||||
QString m_rootPath;
|
QString m_rootPath;
|
||||||
Status m_status = Application::StartingUp;
|
Status m_status = Application::StartingUp;
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
Qt::ApplicationState m_prevAppState = Qt::ApplicationInactive;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined Q_OS_WIN32
|
#if defined Q_OS_WIN32
|
||||||
// used on Windows to attach the standard IO streams
|
// used on Windows to attach the standard IO streams
|
||||||
bool consoleAttached = false;
|
bool consoleAttached = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user