/
behaviour_settings.cpp
137 lines (96 loc) · 4.19 KB
/
behaviour_settings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/******************************************************************************
* Cleps Video Player. Simply a media player, no more, no less. *
* Copyright (C) 2014 Eshton Robateau <eshtonrob@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#include "behaviour_settings.h"
behaviour_settings::behaviour_settings(QWidget *parent) :
QWidget(parent)
{
QLabel *lbl = new QLabel(tr("<b>Under the Hood</b>"));
trCon = new QCheckBox(tr("Tray Icon *May Require Restart"));
notifi = new QCheckBox(tr("Allow Notifications"));
runBhd = new QCheckBox(tr("Keep Running in the Background"));
quitPlistEnd = new QCheckBox(tr("Quit at the end of playlist"));
QPushButton * apli = new QPushButton(tr("Apply"));
QBoxLayout *hlay = new QHBoxLayout;
hlay->addStretch(1);
hlay->addWidget(apli);
QBoxLayout *vlay = new QVBoxLayout;
vlay->setMargin(0);
vlay->setSpacing(0);
vlay->addWidget(lbl);
vlay->addWidget(trCon);
vlay->addWidget(runBhd);
vlay->addWidget(notifi);
vlay->addWidget(quitPlistEnd);
vlay->addLayout(hlay);
vlay->insertStretch(12);
setLayout(vlay);
flags = new QMap<QString, QVariant>;
connect(notifi,SIGNAL(stateChanged(int)),this,SLOT(ntfyType(int)));
connect(trCon, SIGNAL(stateChanged(int)),this,SLOT(tray(int)));
connect(runBhd, SIGNAL(stateChanged(int)),this,SLOT(bckgd(int)));
connect(quitPlistEnd,SIGNAL(stateChanged(int)),this,SLOT(quitPlaylistEnd(int)));
connect(apli,SIGNAL(clicked()),this,SLOT(writeAll()));
readSettings();
}
void behaviour_settings::bckgd(int stea)
{
flags->insert("Run_Background", stea);
}
void behaviour_settings::ntfyType(int state){
flags->insert("Notify", state);
}
void behaviour_settings::quitPlaylistEnd(int quitt)
{
if(quitt == 0){
quitPlistEnd->setCheckState(Qt::Unchecked);
}
flags->insert("playlist_quit", quitt);
}
void behaviour_settings::tray(int state){
if(state == 0){
runBhd->setCheckState(Qt::Unchecked);
}
flags->insert("Tray", state);
}
void behaviour_settings::writeAll(){
QSettings settings;
settings.setValue("system/notify", flags->value("Notify",0));
settings.setValue("system/tray", flags->value("Tray",0));
settings.setValue("system/run_background", flags->value("Run_Background",0));
settings.setValue("system/playlist_quit", flags->value("playlist_quit",0));
this->parentWidget()->parentWidget()->close();
}
void behaviour_settings::readSettings(){
QSettings settings;
flags->insert("Notify", settings.value("system/notify"));
flags->insert("Tray", settings.value("system/tray"));
flags->insert("Run_Background", settings.value("system/run_background"));
flags->insert("playlist_quit",settings.value("system/playlist_quit"));
if(flags->value("Notify").toInt() != 0){
notifi->setCheckState(Qt::Checked);
}
if(flags->value("Tray").toInt() != 0){
trCon->setCheckState(Qt::Checked);
}
if(settings.value("system/run_background").toInt() != 0){
runBhd->setCheckState(Qt::Checked);
}
if(settings.value("system/playlist_quit").toInt() != 0){
quitPlistEnd->setCheckState(Qt::Checked);
}
}