From bce7959332018477eda2b5dd725ff6aed6ef71fe Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 10 Jun 2010 19:54:20 +0000 Subject: [PATCH] Attempt to make Ishan's patch lighter (the new patch may not take into consideration all use cases but it seems to work ok) --- src/GUI.cpp | 23 ++--------------------- src/GUI.h | 1 - 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 6408a206c..b2cfa14f1 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -580,20 +580,6 @@ void GUI::on_actionCreate_torrent_triggered() { } } -bool GUI::checkForModals() const { - //Returns true if there are any modal windows visible - QList dialog_list = findChildren(); - QList::const_iterator i; - - for(i = dialog_list.begin(); i != dialog_list.constEnd(); i++) { - if((*i)->isModal() && (*i)->isVisible()) { - return true; - } - } - - return false; -} - bool GUI::event(QEvent * e) { if(e->type() == QEvent::WindowStateChange) { qDebug("Window change event"); @@ -602,16 +588,11 @@ bool GUI::event(QEvent * e) { qDebug("minimisation"); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); if(systrayIcon && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) { - if(checkForModals()) - { - qDebug("Minimize to Tray enabled, but not hiding because of a modal dialog"); - } - else - { + if(!qApp->activeWindow() || !qApp->activeWindow()->isModal()) { qDebug("Minimize to Tray enabled, hiding!"); e->accept(); QTimer::singleShot(0, this, SLOT(hide())); - return true; + return true; } } } diff --git a/src/GUI.h b/src/GUI.h index b2e7b96fa..df67e23f8 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -68,7 +68,6 @@ public: ~GUI(); // Methods int getCurrentTabIndex() const; - bool checkForModals() const; TransferListWidget* getTransferList() const { return transferList; } QMenu* getTrayIconMenu();