Only override MainWindow::nativeEvent for Windows

This commit is contained in:
Jonas Kvinge 2020-10-27 20:17:28 +01:00
parent 224d5d46c1
commit d9d39d8e25
2 changed files with 13 additions and 11 deletions

View File

@ -1530,12 +1530,16 @@ void MainWindow::showEvent(QShowEvent *e) {
void MainWindow::closeEvent(QCloseEvent *e) { void MainWindow::closeEvent(QCloseEvent *e) {
#ifdef Q_OS_MACOS
Exit();
#else
if (!hidden_ && keep_running_ && e->spontaneous() && QSystemTrayIcon::isSystemTrayAvailable()) { if (!hidden_ && keep_running_ && e->spontaneous() && QSystemTrayIcon::isSystemTrayAvailable()) {
SetHiddenInTray(true); SetHiddenInTray(true);
} }
else { else {
Exit(); Exit();
} }
#endif
QMainWindow::closeEvent(e); QMainWindow::closeEvent(e);
@ -2745,25 +2749,21 @@ void MainWindow::Raise() {
} }
#ifdef Q_OS_WIN
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) { bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) {
#else #else
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) { bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) {
#endif #endif
Q_UNUSED(eventType); if (exit_count_ == 0 && message) {
Q_UNUSED(result);
#ifdef Q_OS_WIN
MSG *msg = static_cast<MSG*>(message); MSG *msg = static_cast<MSG*>(message);
thumbbar_->HandleWinEvent(msg); thumbbar_->HandleWinEvent(msg);
#else }
Q_UNUSED(message); return QMainWindow::nativeEvent(eventType, message, result);
#endif
return false;
} }
#endif // Q_OS_WIN
void MainWindow::AutoCompleteTags() { void MainWindow::AutoCompleteTags() {

View File

@ -117,10 +117,12 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void showEvent(QShowEvent *e) override; void showEvent(QShowEvent *e) override;
void closeEvent(QCloseEvent *e) override; void closeEvent(QCloseEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
#ifdef Q_OS_WIN
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#else #else
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
#endif #endif
// PlatformInterface // PlatformInterface