forked from vnotex/vnote
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADDED] MacOS下点击x按钮不退出程序 (vnotex#1102)
Stay in the tray after closing main window on macOS.
- Loading branch information
1 parent
a2841c3
commit 2b6493c
Showing
6 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "vapplication.h" | ||
|
||
VApplication::VApplication(int &argc, char **argv) | ||
: QApplication(argc, argv) | ||
{ | ||
connect(this, &QApplication::applicationStateChanged, this, &VApplication::onApplicationStateChanged); | ||
} | ||
|
||
void VApplication::onApplicationStateChanged(Qt::ApplicationState state) | ||
{ | ||
#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) | ||
if(state == Qt::ApplicationActive) { | ||
this->window->show(); | ||
// Need to call raise() in macOS. | ||
this->window->raise(); | ||
} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef VAPPLICATION_H | ||
#define VAPPLICATION_H | ||
|
||
#include <QApplication> | ||
#include <QDebug> | ||
#include "vmainwindow.h" | ||
|
||
class VApplication : public QApplication | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit VApplication(int &argc, char **argv); | ||
|
||
void setWindow(VMainWindow * window) | ||
{ | ||
this->window = window; | ||
} | ||
|
||
|
||
public slots: | ||
void onApplicationStateChanged(Qt::ApplicationState state); | ||
|
||
private: | ||
VMainWindow *window; | ||
}; | ||
|
||
#endif // VAPPLICATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters