Add graphical option to disable the trayicon

This commit is contained in:
lupoDharkael
2017-07-28 23:58:40 +02:00
parent 260561f074
commit e94ef2bd3b
2 changed files with 25 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
#include "geneneralconf.h"
#include "src/utils/confighandler.h"
#include "src/core/controller.h"
#include <QVBoxLayout>
#include <QCheckBox>
@@ -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);
}

View File

@@ -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