Skip to content

Commit 356aafa

Browse files
committed
Merge pull request #3 from bdutro/master
Quick Feature Addition
2 parents ec56190 + a992465 commit 356aafa

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

code/control_box/controlbox.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,25 @@ void ControlBox::assembleTrayIcon()
972972
return;
973973
}
974974

975+
//Handler for left click on tray icon
976+
void ControlBox::iconActivated(QSystemTrayIcon::ActivationReason reason)
977+
{
978+
//Only handling left click case
979+
if(reason == QSystemTrayIcon::Trigger)
980+
{
981+
//Show the window if it is currently hidden/minimized
982+
if(this->isHidden() || this->isMinimized())
983+
{
984+
minMaxWindow(maximizeAction);
985+
}
986+
//Otherwise hide the window
987+
else
988+
{
989+
minMaxWindow(minimizeAction);
990+
}
991+
}
992+
}
993+
975994
//
976995
// Function to create the systemtray icon. Really part of the constructor
977996
// and called by a single shot QTimer (actually via a slot between the timer
@@ -989,6 +1008,7 @@ void ControlBox::createSystemTrayIcon(bool b_startminimized)
9891008

9901009
trayicon = new QSystemTrayIcon(this);
9911010
trayicon->setContextMenu(trayIconMenu);
1011+
connect(trayicon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
9921012
ui.checkBox_hideIcon->setEnabled(true);
9931013
this->updateDisplayWidgets();
9941014
trayicon->setVisible(true);

code/control_box/controlbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class ControlBox : public QDialog
146146
void showWhatsThis();
147147
inline void startSystemTrayMinimized() {createSystemTrayIcon(true);}
148148
inline void startSystemTrayNormal() {createSystemTrayIcon(false);}
149+
void iconActivated(QSystemTrayIcon::ActivationReason reason);
149150
};
150151

151152
#endif

0 commit comments

Comments
 (0)