From e94ef2bd3b512a091c8b9283c6230a4b7123eb6e Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Fri, 28 Jul 2017 23:58:40 +0200 Subject: [PATCH] Add graphical option to disable the trayicon --- src/config/geneneralconf.cpp | 23 +++++++++++++++++++++++ src/config/geneneralconf.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp index 6faacdee..bbdbf65e 100644 --- a/src/config/geneneralconf.cpp +++ b/src/config/geneneralconf.cpp @@ -17,6 +17,7 @@ #include "geneneralconf.h" #include "src/utils/confighandler.h" +#include "src/core/controller.h" #include #include @@ -25,6 +26,7 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QGroupBox(parent) { m_layout->setAlignment(Qt::AlignTop); initShowHelp(); initShowDesktopNotification(); + initShowTrayIcon(); } void GeneneralConf::showHelpChanged(bool checked) { @@ -35,6 +37,15 @@ void GeneneralConf::showDesktopNotificationChanged(bool checked) { ConfigHandler().setDesktopNotification(checked); } +void GeneneralConf::showTrayIconChanged(bool checked) { + auto controller = Controller::getInstance(); + if(checked) { + controller->enableTrayIcon(); + } else { + controller->disableTrayIcon(); + } +} + void GeneneralConf::initShowHelp() { QCheckBox *c = new QCheckBox(tr("Show help message"), this); ConfigHandler config; @@ -58,3 +69,15 @@ void GeneneralConf::initShowDesktopNotification() { connect(c, &QCheckBox::clicked, this, &GeneneralConf::showDesktopNotificationChanged); } + +void GeneneralConf::initShowTrayIcon() { + QCheckBox *c = new QCheckBox(tr("Show tray icon"), this); + ConfigHandler config; + bool checked = !config.getDisabledTrayIcon(); + c->setChecked(checked); + c->setToolTip(tr("Show systemtray icons")); + m_layout->addWidget(c); + + connect(c, &QCheckBox::clicked, this, + &GeneneralConf::showTrayIconChanged); +} diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index b97410ea..0e7b8d27 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -30,12 +30,14 @@ public: private slots: void showHelpChanged(bool checked); void showDesktopNotificationChanged(bool checked); + void showTrayIconChanged(bool checked); private: QVBoxLayout *m_layout; void initShowHelp(); void initShowDesktopNotification(); + void initShowTrayIcon(); }; #endif // GENENERALCONF_H