From 7bbb2f542b708023817ffcd5b9888a0ce41837a6 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 1 Aug 2008 20:03:16 +0000 Subject: [PATCH] - Slightly improved minimize to systray code (but still experiencing the virtual desktop switching bug) --- src/GUI.cpp | 19 +++++++++++-------- src/GUI.h | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 31f953ed0..2dab8429e 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -656,15 +656,18 @@ void GUI::on_actionCreate_torrent_triggered() { connect(ct, SIGNAL(torrent_to_seed(QString)), this, SLOT(addTorrent(QString))); } -// Called when we minimize the program -void GUI::hideEvent(QHideEvent *e) { - QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - if(systrayIntegration && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) { - // Hide window - hide(); +bool GUI::event(QEvent * e) { + if(e->type() == QEvent::WindowStateChange) { + //Now check to see if the window is minimised + if(isMinimized()) { + qDebug("minimisation"); + QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + if(systrayIntegration && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) { + hide(); + } + } } - // Accept hiding - e->accept(); + return QMainWindow::event(e); } // Action executed when a file is dropped diff --git a/src/GUI.h b/src/GUI.h index 4cc075b9e..e7cd99aee 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -183,7 +183,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ protected: void closeEvent(QCloseEvent *); - void hideEvent(QHideEvent *); + bool event(QEvent * event); void displayRSSTab(bool enable); public: