From 51703da120aa4b2c364c6ebf144e48168210d0b1 Mon Sep 17 00:00:00 2001 From: Andrew Bibb Date: Sat, 18 Dec 2021 14:36:56 -0500 Subject: [PATCH] automatically hide from tray issue #235 --- apps/cmstapp/code/control_box/controlbox.cpp | 82 +++++------ apps/cmstapp/code/control_box/controlbox.h | 3 +- .../cmstapp/code/control_box/ui/controlbox.ui | 134 ++++++++++-------- apps/resource.h | 2 +- text/changelog.txt | 1 + 5 files changed, 114 insertions(+), 108 deletions(-) diff --git a/apps/cmstapp/code/control_box/controlbox.cpp b/apps/cmstapp/code/control_box/controlbox.cpp index 40975eba..3d9779af 100755 --- a/apps/cmstapp/code/control_box/controlbox.cpp +++ b/apps/cmstapp/code/control_box/controlbox.cpp @@ -415,7 +415,6 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent) connect(ui.comboBox_service, SIGNAL(currentIndexChanged(int)), this, SLOT(getServiceDetails(int))); connect(ui.pushButton_exit, SIGNAL(clicked()), exitAction, SLOT(trigger())); connect(ui.pushButton_minimize, SIGNAL(clicked()), minimizeAction, SLOT(trigger())); - connect(ui.checkBox_hideIcon, SIGNAL(clicked(bool)), this, SLOT(toggleTrayIcon(bool))); connect(ui.pushButton_connect, SIGNAL(clicked()), this, SLOT(connectPressed())); connect(ui.pushButton_vpn_connect, SIGNAL(clicked()), this, SLOT(connectPressed())); connect(ui.pushButton_disconnect, SIGNAL(clicked()), this, SLOT(disconnectPressed())); @@ -433,6 +432,8 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent) connect(ui.checkBox_hidetethering, SIGNAL (toggled(bool)), this, SLOT(updateDisplayWidgets())); connect(ui.checkBox_systemtraynotifications, SIGNAL (clicked(bool)), this, SLOT(trayNotifications(bool))); connect(ui.checkBox_notifydaemon, SIGNAL (clicked(bool)), this, SLOT(daemonNotifications(bool))); + connect(ui.checkBox_hideIconFull, SIGNAL(clicked(bool)), this, SLOT(iconFullHide(bool))); + connect(ui.checkBox_hideIconPartial, SIGNAL(clicked(bool)), this, SLOT(iconPartialHide(bool))); connect(ui.pushButton_configuration, SIGNAL (clicked()), this, SLOT(configureService())); connect(ui.pushButton_provisioning_editor, SIGNAL (clicked()), this, SLOT(provisionService())); connect(ui.pushButton_vpn_editor, SIGNAL (clicked()), this, SLOT(provisionService())); @@ -454,7 +455,8 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent) // the settings, otherwise set a singleshot timer to create the tray icon. if (parser.isSet("disable-tray-icon") ? true : (b_so && ui.checkBox_disabletrayicon->isChecked()) ) { trayicon = NULL; - ui.checkBox_hideIcon->setDisabled(true); + ui.checkBox_hideIconFull->setDisabled(true); + ui.checkBox_hideIconPartial->setDisabled(true); this->updateDisplayWidgets(); qApp->setQuitOnLastWindowClosed(true); // not running systemtray icon so normal close this->showNormal(); // no place to minimize to, so showMaximized @@ -1351,25 +1353,6 @@ void ControlBox::toggleOfflineMode(bool checked) return; } -// -// Slot to toggle the visibility of the tray icon -// Called when ui.checkBox_hideIcon is clicked -void ControlBox::toggleTrayIcon(bool b_checked) -{ - if (trayicon != NULL ) { - if (b_checked) { - trayicon->setVisible(false); - ui.pushButton_minimize->setDisabled(true); - } // if - else { - trayicon->setVisible(true); - ui.pushButton_minimize->setDisabled(false); - } // else - } //if - - return; -} - // // Slot to toggle the powered state of a technology // Called when our custom idButton in the powered cell in the page 1 technology tableWidget is clicked @@ -1416,32 +1399,36 @@ void ControlBox::toggleTethered(QString object_id, bool checkstate) } // -// Slot to minimize the input window. QWidget.hide() if the tray icon -// is visible, QWidget.showMinmized() if the tray icon is not visible. -// Do it this way as otherwise there is no way to get the dialog back if -// the tray icon is not shown. -// called when actionMinimize is activated +// Slot to minimize or maximize the input window, called when action group minMaxGroup is +// triggered. showMinimized() has no visible effect unless there is a place, such as the +// tray icon or a panel, where the app can go.If there is no tray icon just run showMinimized() +// and hope for the best. If there is a tray icon use hide() (same as pressing the ESC key). +// If the icon if visible just click it to get back, if it is hidden start CMST again which +// will abort because there is another instance running, howver the first instance will then +// be shown full window. void ControlBox::minMaxWindow(QAction* act) { if (act == minimizeAction ) { this->writeSettings(); - if (trayicon != NULL ) trayicon->isVisible() ? this->hide() : this->showMinimized(); - else this->showMinimized(); + if (trayicon == NULL ) this->showMinimized(); + else this->hide(); } // if minimizeAction - else if (act == maximizeAction) { - this->showNormal(); - } - - // Called from the systemtrayicon context menu. Actions are - // created dynamically and we don't know them up front. Actions here - // we want to open the details page and set the combo box to display - // information on the service. else { - ui.tabWidget->setCurrentIndex(1); - ui.comboBox_service->setCurrentIndex(ui.comboBox_service->findText(act->text()) ); - this->showNormal(); - } + if (act == maximizeAction) { + this->showNormal(); + } + + // Called from the systemtrayicon context menu. Actions are + // created dynamically and we don't know them up front. Actions here + // we want to open the details page and set the combo box to display + // information on the service. + else { + ui.tabWidget->setCurrentIndex(1); + ui.comboBox_service->setCurrentIndex(ui.comboBox_service->findText(act->text()) ); + this->showNormal(); + } // inner else + } // outer else return; } @@ -2357,6 +2344,13 @@ void ControlBox::assembleTrayIcon() else trayicon->setToolTip(QString()); + // show or hide the icon depending on checkBoxes and connection state + if (ui.checkBox_hideIconFull->isChecked() ) trayicon->hide(); + else + if (ui.checkBox_hideIconPartial->isChecked() && ((properties_map.value("State").toString() == "online") || (properties_map.value("State").toString() == "ready")) ) + trayicon->hide(); + else trayicon->show(); + // Don't continue if we can't get properties if ( (q16_errors & CMST::Err_Properties & CMST::Err_Technologies & CMST::Err_Services) != 0x00 ) return; @@ -2542,7 +2536,7 @@ void ControlBox::writeSettings() settings->endGroup(); settings->beginGroup("CheckBoxes"); - settings->setValue("hide_tray_icon", ui.checkBox_hideIcon->isChecked() ); + settings->setValue("hide_tray_icon", ui.checkBox_hideIconFull->isChecked() ); settings->setValue("devices_off", ui.checkBox_devicesoff->isChecked() ); settings->setValue("retain_settings", ui.checkBox_usestartoptions->isChecked() ); settings->setValue("retain_state", ui.checkBox_retainstate->isChecked() ); @@ -2598,7 +2592,7 @@ void ControlBox::writeSettings() void ControlBox::readSettings() { settings->beginGroup("CheckBoxes"); - ui.checkBox_hideIcon->setChecked(settings->value("hide_tray_icon").toBool() ); + ui.checkBox_hideIconFull->setChecked(settings->value("hide_tray_icon").toBool() ); ui.checkBox_devicesoff->setChecked(settings->value("devices_off").toBool() ); ui.checkBox_usestartoptions->setChecked(settings->value("retain_settings").toBool() ); ui.checkBox_retainstate->setChecked(settings->value("retain_state").toBool() ); @@ -2729,14 +2723,14 @@ void ControlBox::createSystemTrayIcon() } // if use xfce // Sync the visibility to the checkbox - ui.checkBox_hideIcon->setEnabled(true); + ui.checkBox_hideIconFull->setEnabled(true); trayicon->setVisible(true); } // if there is a systemtray available // else no systemtray available else { - ui.checkBox_hideIcon->setDisabled(true); + ui.checkBox_hideIconFull->setDisabled(true); trayicon = NULL; QMessageBox::warning(this, diff --git a/apps/cmstapp/code/control_box/controlbox.h b/apps/cmstapp/code/control_box/controlbox.h index 981f9643..a6506c25 100755 --- a/apps/cmstapp/code/control_box/controlbox.h +++ b/apps/cmstapp/code/control_box/controlbox.h @@ -195,7 +195,6 @@ class ControlBox : public QDialog void scanWiFi(); void wifiIDPass(const QString& obj_path = QString() ); void toggleOfflineMode(bool); - void toggleTrayIcon(bool); void togglePowered(QString, bool); void toggleTethered(QString, bool); void minMaxWindow(QAction* = 0); @@ -207,6 +206,8 @@ class ControlBox : public QDialog void showWhatsThis(); inline void trayNotifications(bool checked) {if (checked) ui.checkBox_notifydaemon->setChecked(false);} inline void daemonNotifications(bool checked) {if (checked) ui.checkBox_systemtraynotifications->setChecked(false);} + inline void iconFullHide(bool checked) {if (checked) ui.checkBox_hideIconPartial->setChecked(false); updateDisplayWidgets();} + inline void iconPartialHide(bool checked) {if (checked) ui.checkBox_hideIconFull->setChecked(false);updateDisplayWidgets();} inline void closeSystemTrayTearOffMenu() {trayiconmenu->hideTearOffMenu();} void iconActivated(QSystemTrayIcon::ActivationReason reason); void enableRunOnStartup(bool enabled); diff --git a/apps/cmstapp/code/control_box/ui/controlbox.ui b/apps/cmstapp/code/control_box/ui/controlbox.ui index a69e0efe..5297d576 100644 --- a/apps/cmstapp/code/control_box/ui/controlbox.ui +++ b/apps/cmstapp/code/control_box/ui/controlbox.ui @@ -35,7 +35,7 @@ <html><head/><body><p><br/></p></body></html> - 1 + 5 true @@ -1111,7 +1111,17 @@ Notifications - + + + + true + + + Notification Daemon + + + + @@ -1127,16 +1137,6 @@ - - - - true - - - Notification Daemon - - - @@ -1266,7 +1266,20 @@ System Tray - + + + + true + + + <html><head/><body><p>If checked the system tray will popup a notify message when a significant connman related event is received.</p><p>Notifications can be handled by the System Tray Icon, or by a Notify daemon if one is installed. Both can not be active at the same time.</p></body></html> + + + System Tray Notifications + + + + <html><head/><body><p>If checked the system tray icon will popup a status message when you hover the mouse over it.</p></body></html> @@ -1280,25 +1293,22 @@ - + - <html><head/><body><p>If checked an icon will not be displayed in the system tray. </p></body></html> + <html><head/><body><p>If checked the CMST icon will be hidden in the system tray. CMST is still running even if the icon is hidden.</p><p>If CMST is minimized while the icon is hiddden you will need to start another instance CMST to get the interface back. This second instance will restore interface from the first instance and then immediately abort. </p><p>If CMST is minimized while the tray icon is visible then simply clicking the tray icon will restore the interface. </p></body></html> Hide Tray Icon - - - - true - + + - <html><head/><body><p>If checked the system tray will popup a notify message when a significant connman related event is received.</p><p>Notifications can be handled by the System Tray Icon, or by a Notify daemon if one is installed. Both can not be active at the same time.</p></body></html> + <html><head/><body><p>Hide the CMST tray icon during normal operations. Normal operations are defined as having the Global state in an <span style=" font-weight:600;">Online</span> or <span style=" font-weight:600;">Ready</span> mode. Any other state will cause the icon to be displayed in the system tray. CMST is still running even if the icon is hidden.</p><p>If CMST is minimized while the icon is hiddden you will need to start another instance CMST to get the interface back. This second instance will restore interface from the first instance and then immediately abort. </p><p>If CMST is minimized while the tray icon is visible then simply clicking the tray icon will restore the interface. </p></body></html> - System Tray Notifications + Hide Tray Icon Unless Needed @@ -2028,12 +2038,12 @@ p, li { white-space: pre-wrap; } setVisible(bool) - 157 - -59 + 180 + 193 245 - 619 + 593 @@ -2044,12 +2054,12 @@ p, li { white-space: pre-wrap; } setVisible(bool) - 102 - -59 + 125 + 193 - 149 - 601 + 159 + 593 @@ -2060,7 +2070,7 @@ p, li { white-space: pre-wrap; } trigger() - 117 + 122 312 @@ -2108,12 +2118,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 501 - -2 + 524 + 250 - 632 - 0 + 692 + 249 @@ -2124,8 +2134,8 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 205 - -167 + 228 + 85 492 @@ -2140,12 +2150,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 501 - -85 + 524 + 167 - 632 - -84 + 692 + 166 @@ -2156,12 +2166,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 501 - 88 + 524 + 360 - 632 - 90 + 692 + 362 @@ -2172,12 +2182,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 501 - 28 + 524 + 289 - 632 - 30 + 692 + 290 @@ -2188,12 +2198,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 501 - 58 + 524 + 330 - 632 - 60 + 692 + 332 @@ -2208,7 +2218,7 @@ p, li { white-space: pre-wrap; } -1 - 642 + 691 106 @@ -2252,7 +2262,7 @@ p, li { white-space: pre-wrap; } trigger() - 642 + 691 106 @@ -2284,12 +2294,12 @@ p, li { white-space: pre-wrap; } setEnabled(bool) - 384 - 349 + 421 + 624 - 452 - 373 + 525 + 652 @@ -2300,12 +2310,12 @@ p, li { white-space: pre-wrap; } setVisible(bool) - 103 - -59 + 126 + 193 - 610 - 444 + 622 + 505 diff --git a/apps/resource.h b/apps/resource.h index acac2f31..e22fb0e6 100755 --- a/apps/resource.h +++ b/apps/resource.h @@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE. ///////////////////////////////// Program Values /////////////////////// // // Program Info (may be visible, but don't mark for tranalation) -#define VERSION "2021.12.17-1" +#define VERSION "2021.12.18-1" #define RELEASE_DATE "02 December 2021" #define COPYRIGHT_DATE "2013-2021" diff --git a/text/changelog.txt b/text/changelog.txt index 741b0ba4..149a55f7 100644 --- a/text/changelog.txt +++ b/text/changelog.txt @@ -2,6 +2,7 @@
Change Log
IN PROGRESS
    +
  • Added new option to hide the system tray icon in normal operations (issue #235)
  • Auto run lupdate and embed translations automatically from make via qmake.
  • Added scroll bars to Agent dialog (issue #242).