diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 585f82adc..363f3d082 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -741,52 +741,31 @@ void Widget::confirmExecutableOpen(const QFileInfo &file) void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason) { - switch (reason) + if (reason == QSystemTrayIcon::Trigger) { - case QSystemTrayIcon::Trigger: + if (isHidden() || isMinimized()) { - if (isHidden()) - { - show(); - activateWindow(); - if (wasMaximized) - showMaximized(); - else - showNormal(); - } - else if (isMinimized()) - { - forceShow(); - activateWindow(); - if (wasMaximized) - showMaximized(); - else - showNormal(); - } + if (wasMaximized) + showMaximized(); else - { - wasMaximized = isMaximized(); - if (Settings::getInstance().getMinimizeToTray()) - hide(); - else - showMinimized(); - } + showNormal(); - break; + activateWindow(); } - case QSystemTrayIcon::MiddleClick: + else if (!isActiveWindow()) + { + activateWindow(); + } + else + { wasMaximized = isMaximized(); - if (Settings::getInstance().getMinimizeToTray()) - hide(); - else - showMinimized(); - break; - case QSystemTrayIcon::Unknown: - if (isHidden()) - forceShow(); - break; - default: - break; + hide(); + } + } + else if (reason == QSystemTrayIcon::Unknown) + { + if (isHidden()) + forceShow(); } }