diff options
author | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-07-25 01:17:15 +0400 |
---|---|---|
committer | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-07-25 01:17:15 +0400 |
commit | f5704a07daf0755aac2f2d79d67d4a06c128693c (patch) | |
tree | 0d0256293b2d02ed177617141520fbaec1b2c3da /src | |
parent | c24b79e5f026446ab57b67a660a1251681f36c20 (diff) |
Clicking tray icon now activates the window if it is inactive instead of hiding it
Diffstat (limited to 'src')
-rw-r--r-- | src/mumble/MainWindow.cpp | 17 | ||||
-rw-r--r-- | src/mumble/MainWindow.h | 1 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index d6bd6fd65..c3bdfbe3f 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -349,6 +349,9 @@ void MainWindow::msgBox(QString msg) { bool MainWindow::winEvent(MSG *msg, long *) { if (msg->message == WM_DEVICECHANGE && msg->wParam == DBT_DEVNODES_CHANGED) uiNewHardware++; + else if (msg->message == WM_ACTIVATE && msg->wParam == WA_INACTIVE) + tInactive.restart(); + return false; } #endif @@ -2267,17 +2270,25 @@ void MainWindow::on_Icon_activated(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::DoubleClick) { bDoubleClick = true; tDoubleClick.restart(); - } else if (bDoubleClick && (reason == QSystemTrayIcon::Trigger) && !(tDoubleClick.elapsed() > 100000UL)) { - return; + } else if (bDoubleClick && (reason == QSystemTrayIcon::Trigger)) { + if(tDoubleClick.elapsed() > 100000UL) + bDoubleClick = false; + else + return; } if (reason == QSystemTrayIcon::Trigger) { - if (!isVisible() || isMinimized()) { +#ifdef Q_OS_WIN + if (!isVisible() || isMinimized() || tInactive.elapsed() > 300000UL) { +#elif + if (!isVisible() || isMinimized() || !isActiveWindow()) { +#endif if (isMaximized()) showMaximized(); else showNormal(); activateWindow(); + raise(); } else { if (g.s.bHideInTray) hide(); diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index d5f4d923b..f999c7c69 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -109,6 +109,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin static const QString defaultStyleSheet; #ifdef Q_OS_WIN + Timer tInactive; bool winEvent(MSG *, long *); unsigned int uiNewHardware; #endif |