Skip to content

Commit

Permalink
kcm: add ability to toggle rules
Browse files Browse the repository at this point in the history
  • Loading branch information
taj-ny committed May 4, 2024
1 parent 5f6cfa5 commit 29228d4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/kcm/blur_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// KConfigSkeleton

#include <KPluginFactory>
#include <QAbstractItemView>
#include <QCheckBox>
#include <QLabel>
#include "kwineffects_interface.h"
Expand All @@ -27,12 +28,18 @@ BlurEffectConfig::BlurEffectConfig(QObject *parent, const KPluginMetaData &data)
BlurConfig::instance()->read();

ui.rulesTable->horizontalHeader()->setStretchLastSection(true);
ui.rulesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.rulesTable->setSelectionMode(QAbstractItemView::SingleSelection);
ui.rulesTable->setRowCount(BlurConfig::instance()->rules()->rules.size());
int row = 0;

int row = 0;
for (const auto &rule : BlurConfig::instance()->rules()->rules) {
auto checkBox = new QCheckBox();
checkBox->setChecked(rule->enabled);
connect(checkBox, &QCheckBox::checkStateChanged, [=](const Qt::CheckState &checkState) {
rule->enabled = checkState == Qt::CheckState::Checked;
markAsChanged();
});

ui.rulesTable->setCellWidget(row, 0, checkBox);
ui.rulesTable->setCellWidget(row, 1, new QLabel(rule->name));
Expand All @@ -47,6 +54,7 @@ BlurEffectConfig::~BlurEffectConfig()
void BlurEffectConfig::save()
{
KCModule::save();
BlurConfig::instance()->write();

OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
Expand Down

0 comments on commit 29228d4

Please sign in to comment.