Added action to trayicon - minimize to tray on left-click
authorAlexander von Renteln <phon@quassel-irc.org>
Thu, 24 Jan 2008 21:41:43 +0000 (21:41 +0000)
committerAlexander von Renteln <phon@quassel-irc.org>
Thu, 24 Jan 2008 21:41:43 +0000 (21:41 +0000)
src/qtui/mainwin.cpp
src/qtui/mainwin.h

index 12d4915..6041d31 100644 (file)
@@ -71,6 +71,8 @@ void MainWin::init() {
   systray = new QSystemTrayIcon(this);
   systray->setIcon(QIcon(":/icons/quassel-icon.png"));
   systray->show();
+  connect(systray, SIGNAL(activated( QSystemTrayIcon::ActivationReason )), 
+          this, SLOT(systrayActivated( QSystemTrayIcon::ActivationReason )));
 
   //setupSettingsDlg();
 
@@ -277,10 +279,20 @@ void MainWin::closeEvent(QCloseEvent *event)
     s.setValue("MainWinSize", size());
     s.setValue("MainWinPos", pos());
     s.setValue("MainWinState", saveState());
-    delete systray;
     event->accept();
   //} else {
     //event->ignore();
   //}
 }
 
+void MainWin::systrayActivated( QSystemTrayIcon::ActivationReason activationReason) {
+  if (activationReason == QSystemTrayIcon::Trigger) {
+    if (isHidden())
+      show();
+    else
+      hide();
+  }
+  
+  
+  
+}
\ No newline at end of file
index b84a85c..3f262d4 100644 (file)
@@ -55,6 +55,7 @@ class MainWin : public QMainWindow {
   protected slots:
     void connectedToCore();
     void disconnectedFromCore();
+    void systrayActivated( QSystemTrayIcon::ActivationReason );
 
   private slots: