Skip to content

Commit 917d00e

Browse files
committed
appearance: change dropShadow from QComboBox to QCheckBox
1 parent 3687a12 commit 917d00e

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/appearance.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ void Appearance::activate()
2525
ui->cornerRadius->setValue(getInt("/labwc_config/theme/cornerRadius"));
2626

2727
/* Drop Shadows */
28-
ui->dropShadows->addItem("no");
29-
ui->dropShadows->addItem("yes");
30-
ui->dropShadows->setCurrentIndex(getBool("/labwc_config/theme/dropShadows"));
28+
ui->dropShadows->setChecked(getBool("/labwc_config/theme/dropShadows"));
3129

3230
/* Icon Theme */
3331
QStringList themes = findIconThemes(LAB_ICON_THEME_TYPE_ICON);
@@ -39,6 +37,6 @@ void Appearance::onApply()
3937
{
4038
setInt("/labwc_config/theme/cornerRadius", ui->cornerRadius->value());
4139
setStr("/labwc_config/theme/name", TEXT(ui->openboxTheme));
42-
setBool("/labwc_config/theme/dropShadows", TEXT(ui->dropShadows));
40+
setBool("/labwc_config/theme/dropShadows", ui->dropShadows->isChecked());
4341
setStr("/labwc_config/theme/icon", TEXT(ui->iconTheme));
4442
}

src/appearance.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
<widget class="QSpinBox" name="cornerRadius"/>
4545
</item>
4646
<item row="2" column="0">
47-
<widget class="QLabel" name="label_8">
47+
<widget class="QLabel" name="label_3">
4848
<property name="text">
4949
<string>Drop Shadows</string>
5050
</property>
5151
</widget>
5252
</item>
5353
<item row="2" column="1">
54-
<widget class="QComboBox" name="dropShadows"/>
54+
<widget class="QCheckBox" name="dropShadows"/>
5555
</item>
5656
<item row="3" column="0">
5757
<widget class="QLabel" name="label_1">

src/maindialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void MainDialog::onApply()
9393
ui->pageBehaviour->onApply();
9494

9595
/* ~/.config/labwc/rc.xml */
96-
setBool("/labwc_config/libinput/device/naturalScroll", TEXT(ui->naturalScroll));
96+
setBoolfromString("/labwc_config/libinput/device/naturalScroll", TEXT(ui->naturalScroll));
9797
xml_save();
9898

9999
/* ~/.config/labwc/environment */

src/settings.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ int parseBool(const char *str, int defaultValue)
248248
return defaultValue;
249249
}
250250

251-
// TODO: make this more bool-ish
252-
void setBool(QString name, QString value)
251+
void setBool(QString name, int value)
253252
{
254253
std::shared_ptr<Setting> setting = retrieve(name);
255254
if (setting == nullptr) {
@@ -259,11 +258,16 @@ void setBool(QString name, QString value)
259258
if (setting->valueType() != LAB_VALUE_TYPE_BOOL) {
260259
qDebug() << "setBool(): not valid bool setting" << name << value;
261260
}
262-
int boolValue = parseBool(value.toStdString().c_str(), -1);
263-
if (boolValue != std::get<int>(setting->value())) {
264-
info("'{} has changed to '{}'", name.toStdString(), value.toStdString());
261+
if (value != std::get<int>(setting->value())) {
262+
info("'{} has changed to '{}'", name.toStdString(), value);
265263
xpath_add_node(name.toStdString().c_str());
266-
xml_set(name.toStdString().c_str(), value.toStdString().c_str());
264+
xml_set(name.toStdString().c_str(), value ? "yes" : "no");
267265
setting->setValue(value);
268266
}
269267
}
268+
269+
void setBoolfromString(QString name, QString value)
270+
{
271+
int boolValue = parseBool(value.toStdString().c_str(), -1);
272+
setBool(name, boolValue);
273+
}

src/settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ int getBool(QString name);
6363
void setInt(QString name, int value);
6464
void setStr(QString name, QString value);
6565
int parseBool(const char *str, int defaultValue);
66-
void setBool(QString name, QString value);
66+
void setBool(QString name, int value);
67+
void setBoolfromString(QString name, QString value);

0 commit comments

Comments
 (0)