This repository has been archived by the owner on Nov 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathlightlyshaders_config.cpp
101 lines (87 loc) · 2.86 KB
/
lightlyshaders_config.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
#include "lightlyshaders_config.h"
#include "ui_lightlyshaders_config.h"
#include <QDialog>
#include <QVBoxLayout>
#include <kwineffects.h>
#include <kwineffects_interface.h>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusArgument>
#include <KConfigGroup>
#include <KPluginFactory>
#include <KAboutData>
K_PLUGIN_FACTORY_WITH_JSON(LightlyShadersConfigFactory,
"lightlyshaders_config.json",
registerPlugin<LightlyShadersConfig>();)
class ConfigDialog : public QWidget , public Ui::Form
{
public:
explicit ConfigDialog(QWidget *parent) : QWidget(parent)
{
setupUi(this);
}
};
class LightlyShadersConfig::Private
{
public:
Private(LightlyShadersConfig *config)
: q(config)
, roundness("roundness")
, outline("outline")
, alpha("alpha")
, defaultRoundness(6)
, defaultOutline(false)
, defaultAlpha(12)
{}
LightlyShadersConfig *q;
QString roundness, outline, alpha;
QVariant defaultRoundness, defaultOutline, defaultAlpha;
ConfigDialog *ui;
};
LightlyShadersConfig::LightlyShadersConfig(QWidget* parent, const QVariantList& args)
: KCModule(KAboutData::pluginData(QStringLiteral("kwin4_effect_lightlyshaders")), parent, args)
, d(new Private(this))
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(d->ui = new ConfigDialog(this));
setLayout(layout);
}
LightlyShadersConfig::~LightlyShadersConfig()
{
delete d;
}
void
LightlyShadersConfig::load()
{
KCModule::load();
KConfigGroup conf = KSharedConfig::openConfig("lightlyshaders.conf")->group("General");
d->ui->roundness->setValue(conf.readEntry(d->roundness, d->defaultRoundness).toInt());
d->ui->outline->setChecked(conf.readEntry(d->outline, d->defaultOutline).toBool());
d->ui->alpha->setValue(conf.readEntry(d->alpha, d->defaultAlpha).toInt());
emit changed(false);
}
void
LightlyShadersConfig::save()
{
KCModule::save();
KConfigGroup conf = KSharedConfig::openConfig("lightlyshaders.conf")->group("General");
conf.writeEntry(d->roundness, d->ui->roundness->value());
conf.writeEntry(d->outline, d->ui->outline->isChecked());
conf.writeEntry(d->alpha, d->ui->alpha->value());
conf.sync();
emit changed(false);
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("kwin4_effect_lightlyshaders"));
}
void
LightlyShadersConfig::defaults()
{
KCModule::defaults();
d->ui->roundness->setValue(d->defaultRoundness.toInt());
d->ui->outline->setChecked(d->defaultOutline.toBool());
d->ui->alpha->setValue(d->defaultAlpha.toInt());
emit changed(true);
}
#include "lightlyshaders_config.moc"