2 Copyright (C) 2015-2024 Ben Kibbey <bjk@luxsci.net>
4 This file is part of qpwmc.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22 #include <QPushButton>
23 #include <QColorDialog>
25 #include "pwmdOptionsDialog.h"
27 PwmdOptionsDialog::PwmdOptionsDialog (QWidget
*p
) : QDialog (p
)
29 QSettings
cfg ("qpwmc");
33 ui
.ck_requireUnlock
->setChecked (cfg
.value ("requireUnlock", true).toBool ());
35 ui
.ck_startsInTray
->setChecked (cfg
.value ("startsInTray", false).toBool ());
36 ui
.ck_sortElementTree
->setChecked (cfg
.value ("sortElementTree", true).toBool ());
37 ui
.ck_executeOnEnter
->setChecked (cfg
.value ("executeOnEnter", true).toBool ());
38 ui
.ck_updateOnEnter
->setChecked (cfg
.value ("updateOnEnter", true).toBool ());
39 ui
.ck_incrementalSearch
->setChecked (cfg
.value ("incrementalSearch", true).toBool ());
40 ui
.ck_confirmQuit
->setChecked (cfg
.value ("confirmQuit", true).toBool ());
41 ui
.sp_clipboardTimeout
->setValue (cfg
.value ("clipboardTimeout", 20).
43 ui
.sp_lockTimeout
->setValue (cfg
.value ("lockTimeout", 5).toInt ());
44 ui
.sp_releaseTimeout
->setValue (cfg
.value ("releaseTimeout", 0).toInt ());
45 ui
.ck_reopenLastFile
->setChecked (cfg
.value ("reopenLastFile", false).
47 targetColor
= cfg
.value ("targetColor", "DarkOrange").value
< QColor
> ();
48 permissionsColor
= cfg
.value ("permissionsColor", "DarkRed").value
< QColor
> ();
49 invalidTargetColor
= cfg
.value ("invalidTargetColor", "Red").value
< QColor
> ();
50 hilightColor
= cfg
.value ("hilightColor", "Green").value
< QColor
> ();
51 targetLoopColor
= cfg
.value ("targetLoopColor", "DarkCyan").value
< QColor
> ();
52 targetColorBg
= cfg
.value ("targetColorBg", "DarkGray").value
< QColor
> ();
53 permissionsColorBg
= cfg
.value ("permissionsColorBg", "DarkGray").value
< QColor
> ();
54 invalidTargetColorBg
= cfg
.value ("invalidTargetColorBg", "DarkGray").value
< QColor
> ();
55 hilightColorBg
= cfg
.value ("hilightColorBg", "DarkGray").value
< QColor
> ();
56 targetLoopColorBg
= cfg
.value ("targetLoopColorBg", "DarkGray").value
< QColor
> ();
57 ui
.ck_cacheContent
->setChecked (cfg
.value ("cacheContent", true).toBool ());
58 ui
.ck_geometry
->setChecked (cfg
.value ("rememberGeometry", true).toBool ());
60 ui
.pb_targetColor
->setStyleSheet (QString ("background-color: %1;").arg (targetColor
.name ()));
61 ui
.pb_permissionsColor
->setStyleSheet (QString ("background-color: %1;").arg (permissionsColor
.name ()));
62 ui
.pb_invalidTargetColor
->setStyleSheet (QString ("background-color: %1;").arg (invalidTargetColor
.name ()));
63 ui
.pb_hilightColor
->setStyleSheet (QString ("background-color: %1;").arg (hilightColor
.name ()));
64 ui
.pb_targetLoopColor
->setStyleSheet (QString ("background-color: %1;").arg (targetLoopColor
.name ()));
65 ui
.pb_targetColorBg
->setStyleSheet (QString ("background-color: %1;").arg (targetColorBg
.name ()));
66 ui
.pb_permissionsColorBg
->setStyleSheet (QString ("background-color: %1;").arg (permissionsColorBg
.name ()));
67 ui
.pb_invalidTargetColorBg
->setStyleSheet (QString ("background-color: %1;").arg (invalidTargetColorBg
.name ()));
68 ui
.pb_hilightColorBg
->setStyleSheet (QString ("background-color: %1;").arg (hilightColorBg
.name ()));
69 ui
.pb_targetLoopColorBg
->setStyleSheet (QString ("background-color: %1;").arg (targetLoopColorBg
.name ()));
70 ui
.sp_constraints
->setValue (cfg
.value ("constraintsFreq", 30).toInt ());
72 connect (ui
.pb_targetColor
, SIGNAL (clicked ()), this,
73 SLOT (slotChooseTargetColor ()));
74 connect (ui
.pb_permissionsColor
, SIGNAL (clicked ()), this,
75 SLOT (slotChoosePermissionColor ()));
76 connect (ui
.pb_invalidTargetColor
, SIGNAL (clicked ()), this,
77 SLOT (slotChooseInvalidTargetColor ()));
78 connect (ui
.pb_hilightColor
, SIGNAL (clicked ()), this,
79 SLOT (slotChooseHilightColor ()));
80 connect (ui
.pb_targetLoopColor
, SIGNAL (clicked ()), this,
81 SLOT (slotChooseTargetLoopColor ()));
82 connect (ui
.pb_targetColorBg
, SIGNAL (clicked ()), this,
83 SLOT (slotChooseTargetColorBg ()));
84 connect (ui
.pb_permissionsColorBg
, SIGNAL (clicked ()), this,
85 SLOT (slotChoosePermissionColorBg ()));
86 connect (ui
.pb_invalidTargetColorBg
, SIGNAL (clicked ()), this,
87 SLOT (slotChooseInvalidTargetColorBg ()));
88 connect (ui
.pb_hilightColorBg
, SIGNAL (clicked ()), this,
89 SLOT (slotChooseHilightColorBg ()));
90 connect (ui
.pb_targetLoopColorBg
, SIGNAL (clicked ()), this,
91 SLOT (slotChooseTargetLoopColorBg ()));
93 QScroller::grabGesture (ui
.scrollArea
, QScroller::TouchGesture
);
95 ui
.l_startsInTray
->setHidden (true);
96 ui
.ck_startsInTray
->setHidden (true);
99 ui
.l_requireUnlock
->setHidden (true);
100 ui
.ck_requireUnlock
->setHidden (true);
105 PwmdOptionsDialog::~PwmdOptionsDialog ()
110 QSettings
cfg ("qpwmc");
111 cfg
.setValue ("executeOnEnter", ui
.ck_executeOnEnter
->isChecked ());
112 cfg
.setValue ("updateOnEnter", ui
.ck_updateOnEnter
->isChecked ());
113 cfg
.setValue ("incrementalSearch", ui
.ck_incrementalSearch
->isChecked ());
114 cfg
.setValue ("confirmQuit", ui
.ck_confirmQuit
->isChecked ());
115 // FIXME cfg.setValue ("defaultSocket", ui.socketWidget->ui.le_socket->text ());
116 cfg
.setValue ("reopenLastFile", ui
.ck_reopenLastFile
->isChecked ());
117 cfg
.setValue ("invalidTargetColor", invalidTargetColor
);
118 cfg
.setValue ("targetLoopColor", targetLoopColor
);
119 cfg
.setValue ("targetColor", targetColor
);
120 cfg
.setValue ("permissionsColor", permissionsColor
);
121 cfg
.setValue ("hilightColor", hilightColor
);
122 cfg
.setValue ("invalidTargetColorBg", invalidTargetColorBg
);
123 cfg
.setValue ("targetLoopColorBg", targetLoopColorBg
);
124 cfg
.setValue ("targetColorBg", targetColorBg
);
125 cfg
.setValue ("permissionsColorBg", permissionsColorBg
);
126 cfg
.setValue ("hilightColorBg", hilightColorBg
);
127 cfg
.setValue ("cacheContent", ui
.ck_cacheContent
->isChecked ());
128 cfg
.setValue ("rememberGeometry", ui
.ck_geometry
->isChecked ());
129 cfg
.setValue ("clipboardTimeout", ui
.sp_clipboardTimeout
->value ());
130 cfg
.setValue ("lockTimeout", ui
.sp_lockTimeout
->value ());
131 cfg
.setValue ("releaseTimeout", ui
.sp_releaseTimeout
->value ());
132 cfg
.setValue ("sortElementTree", ui
.ck_sortElementTree
->isChecked ());
133 cfg
.setValue ("startsInTray", ui
.ck_startsInTray
->isChecked ());
134 cfg
.setValue ("constraintsFreq", ui
.sp_constraints
->value ());
136 cfg
.setValue ("requireUnlock", ui
.ck_requireUnlock
->isChecked ());
141 PwmdOptionsDialog::reject ()
143 writeChanges
= false;
148 PwmdOptionsDialog::slotChooseHilightColor ()
150 QColor c
= QColorDialog::getColor (hilightColor
);
155 hilightColor
.setRgba (c
.rgba ());
156 ui
.pb_hilightColor
->setStyleSheet (QString ("background-color: %1;").arg (hilightColor
.name ()));
160 PwmdOptionsDialog::slotChooseHilightColorBg ()
162 QColor c
= QColorDialog::getColor (hilightColorBg
);
167 hilightColorBg
.setRgba (c
.rgba ());
168 ui
.pb_hilightColorBg
->setStyleSheet (QString ("background-color: %1;").arg (hilightColorBg
.name ()));
172 PwmdOptionsDialog::slotChooseTargetColor ()
174 QColor c
= QColorDialog::getColor (targetColor
);
179 targetColor
.setRgba (c
.rgba ());
180 ui
.pb_targetColor
->setStyleSheet (QString ("background-color: %1;").arg (targetColor
.name ()));
184 PwmdOptionsDialog::slotChooseTargetColorBg ()
186 QColor c
= QColorDialog::getColor (targetColorBg
);
191 targetColorBg
.setRgba (c
.rgba ());
192 ui
.pb_targetColorBg
->setStyleSheet (QString ("background-color: %1;").arg (targetColorBg
.name ()));
196 PwmdOptionsDialog::slotChoosePermissionColor ()
198 QColor c
= QColorDialog::getColor (permissionsColor
);
203 permissionsColor
.setRgba (c
.rgba ());
204 ui
.pb_permissionsColor
->setStyleSheet (QString ("background-color: %1;").arg (permissionsColor
.name ()));
208 PwmdOptionsDialog::slotChoosePermissionColorBg ()
210 QColor c
= QColorDialog::getColor (permissionsColorBg
);
215 permissionsColorBg
.setRgba (c
.rgba ());
216 ui
.pb_permissionsColorBg
->setStyleSheet (QString ("background-color: %1;").arg (permissionsColorBg
.name ()));
220 PwmdOptionsDialog::slotChooseInvalidTargetColor ()
222 QColor c
= QColorDialog::getColor (invalidTargetColor
);
227 invalidTargetColor
.setRgba (c
.rgba ());
228 ui
.pb_invalidTargetColor
->setStyleSheet (QString ("background-color: %1;").arg (invalidTargetColor
.name ()));
232 PwmdOptionsDialog::slotChooseInvalidTargetColorBg ()
234 QColor c
= QColorDialog::getColor (invalidTargetColorBg
);
239 invalidTargetColorBg
.setRgba (c
.rgba ());
240 ui
.pb_invalidTargetColorBg
->setStyleSheet (QString ("background-color: %1;").arg (invalidTargetColorBg
.name ()));
244 PwmdOptionsDialog::slotChooseTargetLoopColor ()
246 QColor c
= QColorDialog::getColor (targetLoopColor
);
251 targetLoopColor
.setRgba (c
.rgba ());
252 ui
.pb_targetLoopColor
->setStyleSheet (QString ("background-color: %1;").arg (targetLoopColor
.name ()));
256 PwmdOptionsDialog::slotChooseTargetLoopColorBg ()
258 QColor c
= QColorDialog::getColor (targetLoopColorBg
);
263 targetLoopColorBg
.setRgba (c
.rgba ());
264 ui
.pb_targetLoopColorBg
->setStyleSheet (QString ("background-color: %1;").arg (targetLoopColorBg
.name ()));