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

View File

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