diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp
index d9c746a76..d6ef0b506 100644
--- a/src/misc/settings.cpp
+++ b/src/misc/settings.cpp
@@ -112,6 +112,7 @@ void Settings::load()
s.beginGroup("General");
enableIPv6 = s.value("enableIPv6", true).toBool();
translation = s.value("translation", "en").toString();
+ showSystemTray = s.value("showSystemTray", false).toBool();
makeToxPortable = s.value("makeToxPortable", false).toBool();
autostartInTray = s.value("autostartInTray", false).toBool();
closeToTray = s.value("closeToTray", false).toBool();
@@ -252,6 +253,7 @@ void Settings::save(QString path)
s.setValue("enableIPv6", enableIPv6);
s.setValue("translation",translation);
s.setValue("makeToxPortable",makeToxPortable);
+ s.setValue("showSystemTray", showSystemTray);
s.setValue("autostartInTray",autostartInTray);
s.setValue("closeToTray", closeToTray);
s.setValue("useProxy", useProxy);
@@ -430,6 +432,16 @@ void Settings::setStyle(const QString& newStyle)
style = newStyle;
}
+bool Settings::getShowSystemTray() const
+{
+ return showSystemTray;
+}
+
+void Settings::setShowSystemTray(const bool& newValue)
+{
+ showSystemTray = newValue;
+}
+
void Settings::setUseEmoticons(bool newValue)
{
useEmoticons = newValue;
diff --git a/src/misc/settings.h b/src/misc/settings.h
index cebb20986..1ec15bbdd 100644
--- a/src/misc/settings.h
+++ b/src/misc/settings.h
@@ -62,6 +62,9 @@ public:
QString getStyle() const;
void setStyle(const QString& newValue);
+
+ bool getShowSystemTray() const;
+ void setShowSystemTray(const bool& newValue);
bool getUseEmoticons() const;
void setUseEmoticons(bool newValue);
@@ -265,7 +268,8 @@ private:
QByteArray windowState;
QByteArray splitterState;
QString style;
-
+ bool showSystemTray;
+
// ChatView
int firstColumnHandlePos;
int secondColumnHandlePosFromRight;
diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp
index 496dccc9f..a4c305a16 100644
--- a/src/widget/form/settings/generalform.cpp
+++ b/src/widget/form/settings/generalform.cpp
@@ -51,6 +51,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->transComboBox->insertItem(i, langs[i]);
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
+ bodyUI->showSystemTray->setChecked(Settings::getInstance().getShowSystemTray());
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
@@ -104,6 +105,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->checkUpdates, &QCheckBox::stateChanged, this, &GeneralForm::onCheckUpdateChanged);
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
+ connect(bodyUI->showSystemTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowSystemTray);
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
@@ -150,6 +152,12 @@ void GeneralForm::onMakeToxPortableUpdated()
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
}
+void GeneralForm::onSetShowSystemTray()
+{
+ Settings::getInstance().setShowSystemTray(bodyUI->showSystemTray->isChecked());
+ emit parent->setShowSystemTray(bodyUI->showSystemTray->isChecked());
+}
+
void GeneralForm::onSetAutostartInTray()
{
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h
index 493cdd499..6f902a523 100644
--- a/src/widget/form/settings/generalform.h
+++ b/src/widget/form/settings/generalform.h
@@ -34,6 +34,7 @@ private slots:
void onEnableIPv6Updated();
void onTranslationUpdated();
void onMakeToxPortableUpdated();
+ void onSetShowSystemTray();
void onSetAutostartInTray();
void onSetCloseToTray();
void onSmileyBrowserIndexChanged(int index);
diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui
index 19a18c8cd..b0bf7d38d 100644
--- a/src/widget/form/settings/generalsettings.ui
+++ b/src/widget/form/settings/generalsettings.ui
@@ -39,8 +39,8 @@
0
0
- 511
- 698
+ 583
+ 748
@@ -95,6 +95,13 @@
-
+
-
+
+
+ Show system tray
+
+
+
-
@@ -190,9 +197,6 @@
Set to 0 to disable
-
- true
-
minutes
@@ -202,6 +206,9 @@
2147483647
+
+ true
+
@@ -503,5 +510,54 @@
-
+
+
+ showSystemTray
+ toggled(bool)
+ startInTray
+ setEnabled(bool)
+
+
+ 125
+ 122
+
+
+ 207
+ 124
+
+
+
+
+ showSystemTray
+ toggled(bool)
+ closeToTray
+ setEnabled(bool)
+
+
+ 66
+ 119
+
+
+ 346
+ 116
+
+
+
+
+ showSystemTray
+ toggled(bool)
+ minimizeToTray
+ setEnabled(bool)
+
+
+ 83
+ 121
+
+
+ 476
+ 120
+
+
+
+
diff --git a/src/widget/form/settingswidget.h b/src/widget/form/settingswidget.h
index 175a3f56e..2c415f696 100644
--- a/src/widget/form/settingswidget.h
+++ b/src/widget/form/settingswidget.h
@@ -45,6 +45,9 @@ public:
private slots:
void onTabChanged(int);
+signals:
+ void setShowSystemTray(bool newValue);
+
private:
QWidget *head, *body; // keep the others private
IdentityForm *ifrm;
diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp
index b9cc9b3ce..0828cd0d5 100644
--- a/src/widget/widget.cpp
+++ b/src/widget/widget.cpp
@@ -96,7 +96,9 @@ void Widget::init()
this,
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
- icon->show();
+ if (Settings::getInstance().getShowSystemTray()){
+ icon->show();
+ }
if(Settings::getInstance().getAutostartInTray() == false)
this->show();
@@ -197,6 +199,8 @@ void Widget::init()
addFriendForm = new AddFriendForm;
settingsWidget = new SettingsWidget();
+ connect(settingsWidget, SIGNAL(setShowSystemTray(bool)), this, SLOT(onSetShowSystemTray(bool)));
+
connect(core, &Core::connected, this, &Widget::onConnected);
connect(core, &Core::disconnected, this, &Widget::onDisconnected);
connect(core, &Core::failedToStart, this, &Widget::onFailedToStartCore);
@@ -1105,6 +1109,11 @@ void Widget::getPassword(QString info, int passtype, uint8_t* salt)
}
}
+void Widget::onSetShowSystemTray(bool newValue){
+ icon->setVisible(newValue);
+}
+
+
QMessageBox::StandardButton Widget::showWarningMsgBox(const QString& title, const QString& msg, QMessageBox::StandardButtons buttons)
{
// We can only display widgets from the GUI thread
diff --git a/src/widget/widget.h b/src/widget/widget.h
index 17c737ce2..1131da49a 100644
--- a/src/widget/widget.h
+++ b/src/widget/widget.h
@@ -127,6 +127,7 @@ private slots:
void onIconClick(QSystemTrayIcon::ActivationReason);
void onUserAway();
void getPassword(QString info, int passtype, uint8_t* salt);
+ void onSetShowSystemTray(bool newValue);
private:
void init();