From 310433fb54d1d07e37941e40beb4dc1b920428c8 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 21 Jul 2010 18:02:29 +0000 Subject: [PATCH] Process Mac toolbar toggling event --- src/GUI.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 34f690e2d..c73c6c859 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -624,21 +624,32 @@ void GUI::on_actionCreate_torrent_triggered() { } bool GUI::event(QEvent * e) { - if(e->type() == QEvent::WindowStateChange) { - qDebug("Window change event"); - //Now check to see if the window is minimised - if(isMinimized()) { - qDebug("minimisation"); - QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - if(systrayIcon && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) { - if(!qApp->activeWindow() || !qApp->activeWindow()->isModal()) { - qDebug("Minimize to Tray enabled, hiding!"); - e->accept(); - QTimer::singleShot(0, this, SLOT(hide())); - return true; + switch(e->type()) { + case QEvent::WindowStateChange: { + qDebug("Window change event"); + //Now check to see if the window is minimised + if(isMinimized()) { + qDebug("minimisation"); + QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + if(systrayIcon && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) { + if(!qApp->activeWindow() || !qApp->activeWindow()->isModal()) { + qDebug("Minimize to Tray enabled, hiding!"); + e->accept(); + QTimer::singleShot(0, this, SLOT(hide())); + return true; + } } } + break; } +#ifdef Q_WS_MAC + case QEvent::ToolBarChange: { + actionTop_tool_bar->setChecked(toolBar->isVisible()); + break; + } +#endif + default: + break; } return QMainWindow::event(e); }