summaryrefslogtreecommitdiffstats
path: root/src/gui/mphoneform.cpp
diff options
context:
space:
mode:
authorFrédéric Brière <fbriere@fbriere.net>2019-06-30 17:00:34 -0400
committerFrédéric Brière <fbriere@fbriere.net>2019-06-30 21:49:56 -0400
commit3377008db04ac8d7e4928b7abfbe84a4c694d6b8 (patch)
tree27ee081313b1ba5f169403c6136cd4e39f1a8f52 /src/gui/mphoneform.cpp
parentd358a52e6124b528fb0bc09eaf4d28c8215e07e7 (diff)
downloadtwinkle-3377008db04ac8d7e4928b7abfbe84a4c694d6b8.tar
twinkle-3377008db04ac8d7e4928b7abfbe84a4c694d6b8.tar.gz
twinkle-3377008db04ac8d7e4928b7abfbe84a4c694d6b8.tar.lz
twinkle-3377008db04ac8d7e4928b7abfbe84a4c694d6b8.tar.xz
twinkle-3377008db04ac8d7e4928b7abfbe84a4c694d6b8.zip
Add a "Show/Hide window" entry to the systray icon menu
It's customary for applications embedding themselves in the system tray to offer a "Show/Hide window" menu entry on right-click, even for those applications which offer the same functionality via a single left-click. (Thanks to qBittorrent for the idea of using QMenu::aboutToShow to update the label of this menu entry.)
Diffstat (limited to 'src/gui/mphoneform.cpp')
-rw-r--r--src/gui/mphoneform.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/mphoneform.cpp b/src/gui/mphoneform.cpp
index b829be8..a724eb0 100644
--- a/src/gui/mphoneform.cpp
+++ b/src/gui/mphoneform.cpp
@@ -200,6 +200,12 @@ void MphoneForm::init()
connect(sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(sysTrayIconClicked(QSystemTrayIcon::ActivationReason)));
+ connect(menu, &QMenu::aboutToShow, this, &MphoneForm::updateTrayIconMenu);
+
+ // Toggle window visibility
+ menu->addAction(toggleWindowAction);
+
+ menu->addSeparator();
// Call menu
menu->addAction(callInvite);
@@ -3239,7 +3245,20 @@ void MphoneForm::whatsThis()
void MphoneForm::sysTrayIconClicked(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::DoubleClick)
- setVisible(!isVisible());
+ toggleWindow();
+}
+
+void MphoneForm::toggleWindow()
+{
+ setVisible(!isVisible());
+}
+
+void MphoneForm::updateTrayIconMenu()
+{
+ if (isVisible())
+ toggleWindowAction->setText(tr("Hide window"));
+ else
+ toggleWindowAction->setText(tr("Show window"));
}
bool MphoneForm::event(QEvent * event)