From 479644833e900a3c213a3bdb4dd43e4fa5939145 Mon Sep 17 00:00:00 2001 From: novist Date: Wed, 26 Nov 2014 19:58:30 +0200 Subject: [PATCH 1/3] Option for tray icon to display user status --- src/misc/settings.cpp | 12 ++ src/misc/settings.h | 4 + src/widget/form/settings/generalform.cpp | 8 + src/widget/form/settings/generalform.h | 1 + src/widget/form/settings/generalsettings.ui | 171 ++++++++++---------- src/widget/widget.cpp | 24 ++- src/widget/widget.h | 1 + 7 files changed, 135 insertions(+), 86 deletions(-) diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index 874913ec5..5ad19cb81 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -125,6 +125,7 @@ void Settings::load() makeToxPortable = s.value("makeToxPortable", false).toBool(); autostartInTray = s.value("autostartInTray", false).toBool(); closeToTray = s.value("closeToTray", false).toBool(); + trayShowsUserStatus = s.value("trayShowsUserStatus", false).toBool(); forceTCP = s.value("forceTCP", false).toBool(); useProxy = s.value("useProxy", false).toBool(); proxyAddr = s.value("proxyAddr", "").toString(); @@ -266,6 +267,7 @@ void Settings::save(QString path) s.setValue("showSystemTray", showSystemTray); s.setValue("autostartInTray",autostartInTray); s.setValue("closeToTray", closeToTray); + s.setValue("trayShowsUserStatus", trayShowsUserStatus); s.setValue("useProxy", useProxy); s.setValue("forceTCP", forceTCP); s.setValue("proxyAddr", proxyAddr); @@ -487,6 +489,16 @@ void Settings::setCloseToTray(bool newValue) closeToTray = newValue; } +bool Settings::getTrayShowsUserStatus() const +{ + return trayShowsUserStatus; +} + +void Settings::setTrayShowsUserStatus(bool newValue) +{ + trayShowsUserStatus = newValue; +} + bool Settings::getMinimizeToTray() const { return minimizeToTray; diff --git a/src/misc/settings.h b/src/misc/settings.h index 5b923d8b1..9e7c8076a 100644 --- a/src/misc/settings.h +++ b/src/misc/settings.h @@ -57,6 +57,9 @@ public: bool getCloseToTray() const; void setCloseToTray(bool newValue); + + bool getTrayShowsUserStatus() const; + void setTrayShowsUserStatus(bool newValue); bool getMinimizeToTray() const; void setMinimizeToTray(bool newValue); @@ -240,6 +243,7 @@ private: bool autostartInTray; bool closeToTray; bool minimizeToTray; + bool trayShowsUserStatus; bool useEmoticons; bool checkUpdates; bool showInFront; diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index 7cae0847f..fc4b5ed20 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -56,6 +56,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray()); bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray()); bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray()); + bodyUI->trayShowsUserStatus->setChecked(Settings::getInstance().getTrayShowsUserStatus()); bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled()); bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons()); bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled()); @@ -114,6 +115,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray); connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray); connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray); + connect(bodyUI->trayShowsUserStatus, &QCheckBox::stateChanged, this, &GeneralForm::onSettrayShowsUserStatus); connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange); connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged())); connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront); @@ -179,6 +181,12 @@ void GeneralForm::onSetMinimizeToTray() Settings::getInstance().setMinimizeToTray(bodyUI->minimizeToTray->isChecked()); } +void GeneralForm::onSettrayShowsUserStatus() +{ + Settings::getInstance().setTrayShowsUserStatus(bodyUI->trayShowsUserStatus->isChecked()); + Widget::getInstance()->updateTrayIcon(); +} + void GeneralForm::onStyleSelected(QString style) { if(bodyUI->styleBrowser->currentIndex() == 0) diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h index ec41fb0ad..dba72d404 100644 --- a/src/widget/form/settings/generalform.h +++ b/src/widget/form/settings/generalform.h @@ -49,6 +49,7 @@ private slots: void onAutoAwayChanged(); void onUseEmoticonsChange(); void onSetMinimizeToTray(); + void onSettrayShowsUserStatus(); void onReconnectClicked(); void onAutoAcceptFileChange(); void onAutoSaveDirChange(); diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui index 3b745c8e8..0bf981d69 100644 --- a/src/widget/form/settings/generalsettings.ui +++ b/src/widget/form/settings/generalsettings.ui @@ -143,6 +143,19 @@ + + + + + 0 + 0 + + + + Tray icon displays user status + + + @@ -274,15 +287,21 @@ - - + + + 0 + + + 0 + + Smiley Pack - + @@ -292,75 +311,14 @@ - - - - - - QLayout::SetDefaultConstraint - - - - - :) - - - - - - - - - - ;) - - - - - - - - - - :p - - - - - - - - - - :O - - - - - - - - - - :'( - - - - - - - - - - - + Style - + @@ -370,18 +328,71 @@ - - - - - + + + + QLayout::SetDefaultConstraint + + + + + :) + + + + + + + + + + ;) + + + + + + + + + + :p + + + + + + + + + + :O + + + + + + + + + + :'( + + + + + + + + + Theme color - + @@ -391,18 +402,14 @@ - - - - - + Emoticon size - + @@ -427,18 +434,14 @@ - - - - - + Timestamp format - + diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 9256d4e97..70ade7fcd 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -77,7 +77,7 @@ void Widget::init() if (QSystemTrayIcon::isSystemTrayAvailable()) { icon = new QSystemTrayIcon(this); - icon->setIcon(this->windowIcon()); + updateTrayIcon(); trayMenu = new QMenu; statusOnline = new QAction(tr("Online"), this); @@ -292,6 +292,26 @@ void Widget::setTranslation() QCoreApplication::installTranslator(translator); } +void Widget::updateTrayIcon() +{ + if(Settings::getInstance().getTrayShowsUserStatus()) + { + QString status = ui->statusButton->property("status").toString(); + QString icon; + if(status == "online") + icon = ":img/status/dot_online_2x.png"; + else if(status == "away") + icon = ":img/status/dot_idle_2x.png"; + else if(status == "busy") + icon = ":img/status/dot_busy_2x.png"; + else + icon = ":img/status/dot_away_2x.png"; + this->icon->setIcon(QIcon(icon)); + } + else + icon->setIcon(windowIcon()); +} + Widget::~Widget() { core->saveConfiguration(); @@ -535,7 +555,7 @@ void Widget::onStatusSet(Status status) ui->statusButton->setProperty("status" ,"offline"); break; } - + updateTrayIcon(); Style::repolish(ui->statusButton); } diff --git a/src/widget/widget.h b/src/widget/widget.h index 285e59bf6..bfd34c1f2 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -64,6 +64,7 @@ public: void clearContactsList(); void setIdleTimer(int minutes); void setTranslation(); + void updateTrayIcon(); Q_INVOKABLE QMessageBox::StandardButton showWarningMsgBox(const QString& title, const QString& msg, QMessageBox::StandardButtons buttonss = QMessageBox::Ok); Q_INVOKABLE void setEnabledThreadsafe(bool enabled); From e989379535ae4f9c1edeea62633b4e7a5b5395b9 Mon Sep 17 00:00:00 2001 From: Maximilian Date: Wed, 26 Nov 2014 16:57:25 +0100 Subject: [PATCH 2/3] Refactored system tray settings in generalform --- src/widget/form/settings/generalform.cpp | 12 +- src/widget/form/settings/generalsettings.ui | 180 +++++++++++--------- 2 files changed, 114 insertions(+), 78 deletions(-) diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index fc4b5ed20..d1a31a2ec 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -45,18 +45,26 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) : bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED); bodyUI->checkUpdates->setChecked(Settings::getInstance().getCheckUpdates()); - bodyUI->trayLayout->addStretch(); + bodyUI->trayBehavior->addStretch(); bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6()); for (int i = 0; i < langs.size(); i++) 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()); + + bool showSystemTray = Settings::getInstance().getShowSystemTray(); + + bodyUI->showSystemTray->setChecked(showSystemTray); bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray()); + bodyUI->startInTray->setEnabled(showSystemTray); bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray()); + bodyUI->closeToTray->setEnabled(showSystemTray); bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray()); + bodyUI->minimizeToTray->setEnabled(showSystemTray); bodyUI->trayShowsUserStatus->setChecked(Settings::getInstance().getTrayShowsUserStatus()); + bodyUI->trayShowsUserStatus->setEnabled(showSystemTray); bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled()); bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons()); bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled()); diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui index 0bf981d69..79dc5712f 100644 --- a/src/widget/form/settings/generalsettings.ui +++ b/src/widget/form/settings/generalsettings.ui @@ -39,8 +39,8 @@ 0 0 - 524 - 726 + 509 + 849 @@ -94,66 +94,78 @@ - - - - - Show system tray icon - - - - - - - - 0 - 0 - - - - Start in tray - - - - - - - - 0 - 0 - - - - Close to tray - - - - - - - - 0 - 0 - - - - Minimize to tray - - - - - - - - - - 0 - 0 - - - - Tray icon displays user status + + + System tray integration + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Show system tray icon + + + + + + + + + + 0 + 0 + + + + Start in tray + + + + + + + + 0 + 0 + + + + Close to tray + + + + + + + + 0 + 0 + + + + Minimize to tray + + + + + + + + + + 0 + 0 + + + + Tray icon displays user status + + + + @@ -210,9 +222,6 @@ Set to 0 to disable - - true - minutes @@ -222,6 +231,9 @@ 2147483647 + + true + @@ -551,12 +563,12 @@ setEnabled(bool) - 125 - 122 + 105 + 144 - 207 - 124 + 119 + 177 @@ -567,12 +579,12 @@ setEnabled(bool) - 66 - 119 + 205 + 146 - 346 - 116 + 224 + 178 @@ -583,12 +595,28 @@ setEnabled(bool) - 83 - 121 + 180 + 144 - 476 - 120 + 359 + 178 + + + + + showSystemTray + toggled(bool) + trayShowsUserStatus + setEnabled(bool) + + + 148 + 143 + + + 158 + 205 From 5f1bf8ce3bd2ced0c70d2515c97e168da5556f7b Mon Sep 17 00:00:00 2001 From: novist Date: Thu, 27 Nov 2014 15:39:35 +0200 Subject: [PATCH 3/3] Checkboxes in settings grayed out when disabled --- ui/settings/mainContent.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/settings/mainContent.css b/ui/settings/mainContent.css index ee239f209..76fcef3b4 100644 --- a/ui/settings/mainContent.css +++ b/ui/settings/mainContent.css @@ -29,6 +29,11 @@ QCheckBox color: black; } +QCheckBox:disabled +{ + color: grey; +} + QSpinBox { background: white;