summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/main.cpp2
-rw-r--r--src/gui/mphoneform.cpp16
-rw-r--r--src/gui/mphoneform.h4
3 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index ff8ec00..6401fea 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -523,6 +523,8 @@ QApplication *create_user_interface(bool cli_mode, int argc, char **argv, QTrans
qtranslator->load(QString("twinkle_") + langName,
QString(sys_config->get_dir_lang().c_str()));
qa->installTranslator(qtranslator);
+
+ qa->setQuitOnLastWindowClosed(false);
// Create translator for translation of strings from the core
translator = new t_qt_translator(qa);
diff --git a/src/gui/mphoneform.cpp b/src/gui/mphoneform.cpp
index 7726a41..96a3519 100644
--- a/src/gui/mphoneform.cpp
+++ b/src/gui/mphoneform.cpp
@@ -183,6 +183,9 @@ void MphoneForm::init()
menu = new QMenu(this);
sysTray->setContextMenu(menu);
+
+ connect(sysTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+ this, SLOT(sysTrayIconClicked(QSystemTrayIcon::ActivationReason)));
// Call menu
menu->addAction(callInvite);
@@ -363,7 +366,7 @@ void MphoneForm::closeEvent( QCloseEvent *e )
void MphoneForm::fileExit()
{
hide();
- QApplication::exit(0);
+ qApp->quit();
}
// Append a string to the display window
@@ -3186,3 +3189,14 @@ void MphoneForm::whatsThis()
{
QWhatsThis::enterWhatsThisMode();
}
+
+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();
+ }
+}
diff --git a/src/gui/mphoneform.h b/src/gui/mphoneform.h
index 5be738e..14e490f 100644
--- a/src/gui/mphoneform.h
+++ b/src/gui/mphoneform.h
@@ -39,8 +39,9 @@ public:
bool getViewDisplay();
bool getViewBuddyList();
bool getViewCompactLineStatus();
+protected:
+ virtual void closeEvent( QCloseEvent * e ) override;
public slots:
- void closeEvent( QCloseEvent * e );
void fileExit();
void display( const QString & s );
void displayHeader();
@@ -166,6 +167,7 @@ public slots:
void DiamondcardCallHistory();
void DiamondcardAdminCenter();
void whatsThis();
+ void sysTrayIconClicked(QSystemTrayIcon::ActivationReason);
private:
void init();