diff options
author | Luboš Doležel <lubos@dolezel.info> | 2020-02-23 09:45:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 09:45:13 +0100 |
commit | a25b22bd43997726a911c69d1d82e08250a3a8b4 (patch) | |
tree | 8a139c4791ea60ef7c3875d940e053650f71f639 /src/gui | |
parent | 0b4252721a1767d1c891b51e68c30b2eb4a22920 (diff) | |
parent | 3377008db04ac8d7e4928b7abfbe84a4c694d6b8 (diff) | |
download | twinkle-a25b22bd43997726a911c69d1d82e08250a3a8b4.tar twinkle-a25b22bd43997726a911c69d1d82e08250a3a8b4.tar.gz twinkle-a25b22bd43997726a911c69d1d82e08250a3a8b4.tar.lz twinkle-a25b22bd43997726a911c69d1d82e08250a3a8b4.tar.xz twinkle-a25b22bd43997726a911c69d1d82e08250a3a8b4.zip |
Merge pull request #149 from fbriere/issue/121-toggle-window-menu-entry
Systray icon: Always toggle visibility when clicking & Add "Show/Hide" menu entry
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/mphoneform.cpp | 26 | ||||
-rw-r--r-- | src/gui/mphoneform.h | 2 | ||||
-rw-r--r-- | src/gui/mphoneform.ui | 11 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/gui/mphoneform.cpp b/src/gui/mphoneform.cpp index 2d4f10f..9f90b29 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,12 +3245,20 @@ void MphoneForm::whatsThis() void MphoneForm::sysTrayIconClicked(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::DoubleClick) - { - if (sys_config->get_gui_hide_on_close()) - setVisible(!isVisible()); - else - activateWindow(); - } + 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) diff --git a/src/gui/mphoneform.h b/src/gui/mphoneform.h index 1527e8d..508072d 100644 --- a/src/gui/mphoneform.h +++ b/src/gui/mphoneform.h @@ -172,6 +172,8 @@ public slots: void DiamondcardAdminCenter(); void whatsThis(); void sysTrayIconClicked(QSystemTrayIcon::ActivationReason); + void toggleWindow(); + void updateTrayIconMenu(); void osdMuteClicked(); diff --git a/src/gui/mphoneform.ui b/src/gui/mphoneform.ui index 196b098..8857394 100644 --- a/src/gui/mphoneform.ui +++ b/src/gui/mphoneform.ui @@ -1822,6 +1822,11 @@ <cstring>actgrActivateLine</cstring> </property> </actiongroup> + <action name="toggleWindowAction"> + <property name="text"> + <string>Toggle window visibility</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <tabstops> @@ -2503,6 +2508,12 @@ </hint> </hints> </connection> + <connection> + <sender>toggleWindowAction</sender> + <signal>triggered()</signal> + <receiver>MphoneForm</receiver> + <slot>toggleWindow()</slot> + </connection> </connections> <slots> <slot>doMessageBuddy(QTreeWidgetItem*)</slot> |