Changeset View
Changeset View
Standalone View
Standalone View
kcms/workspaceoptions/workspaceoptions.cpp
- This file was deleted.
1 | /* | | |||
---|---|---|---|---|---|
2 | * Copyright (C) 2009 Marco Martin <notmart@gmail.com> | | |||
3 | * | | |||
4 | * This program is free software; you can redistribute it and/or modify | | |||
5 | * it under the terms of the GNU General Public License as published by | | |||
6 | * the Free Software Foundation; either version 2 of the License, or | | |||
7 | * (at your option) any later version. | | |||
8 | * | | |||
9 | * This program is distributed in the hope that it will be useful, | | |||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | | |||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |||
12 | * GNU General Public License for more details. | | |||
13 | * | | |||
14 | * You should have received a copy of the GNU General Public License | | |||
15 | * along with this program; if not, write to the Free Software | | |||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | | |||
17 | * | | |||
18 | */ | | |||
19 | #include "workspaceoptions.h" | | |||
20 | | ||||
21 | #include "ui_mainpage.h" | | |||
22 | | ||||
23 | #include <KAboutData> | | |||
24 | #include <KPluginFactory> | | |||
25 | #include <KConfigGroup> | | |||
26 | | ||||
27 | using namespace KAuth; | | |||
28 | | ||||
29 | K_PLUGIN_FACTORY(WorkspaceOptionsModuleFactory, registerPlugin<WorkspaceOptionsModule>();) | | |||
30 | K_EXPORT_PLUGIN(WorkspaceOptionsModuleFactory("kcmworkspaceoptions")) | | |||
31 | | ||||
32 | static const QString s_osdKey = QStringLiteral("OSD"); | | |||
33 | | ||||
34 | WorkspaceOptionsModule::WorkspaceOptionsModule(QWidget *parent, const QVariantList &args) | | |||
35 | : KCModule(parent, args), | | |||
36 | m_kwinConfig( KSharedConfig::openConfig(QStringLiteral("kwinrc"))), | | |||
37 | m_ownConfig( KSharedConfig::openConfig(QStringLiteral("workspaceoptionsrc"))), | | |||
38 | m_plasmaShellAutostart(QStringLiteral("plasmashell")), | | |||
39 | m_krunnerAutostart(QStringLiteral("krunner")), | | |||
40 | m_ui(new Ui::MainPage) | | |||
41 | { | | |||
42 | KAboutData *about = | | |||
43 | new KAboutData(QStringLiteral("kcmworkspaceoptions"), i18n("Global options for the Plasma Workspace"), | | |||
44 | QStringLiteral("1.0"), QString(), KAboutLicense::GPL, | | |||
45 | i18n("(c) 2009 Marco Martin")); | | |||
46 | | ||||
47 | about->addAuthor(i18n("Marco Martin"), i18n("Maintainer"), QStringLiteral("notmart@gmail.com")); | | |||
48 | | ||||
49 | setAboutData(about); | | |||
50 | | ||||
51 | setButtons(Apply); | | |||
52 | | ||||
53 | m_ui->setupUi(this); | | |||
54 | | ||||
55 | connect(m_ui->showToolTips, SIGNAL(toggled(bool)), this, SLOT(changed())); | | |||
56 | connect(m_ui->showOsd, &QCheckBox::toggled, this, static_cast<void(WorkspaceOptionsModule::*)()>(&WorkspaceOptionsModule::changed)); | | |||
57 | } | | |||
58 | | ||||
59 | WorkspaceOptionsModule::~WorkspaceOptionsModule() | | |||
60 | { | | |||
61 | delete m_ui; | | |||
62 | } | | |||
63 | | ||||
64 | | ||||
65 | void WorkspaceOptionsModule::save() | | |||
66 | { | | |||
67 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); | | |||
68 | | ||||
69 | { | | |||
70 | KConfigGroup cg(config, "PlasmaToolTips"); | | |||
71 | cg.writeEntry("Delay", m_ui->showToolTips->isChecked() ? 0.7 : -1); | | |||
72 | } | | |||
73 | | ||||
74 | { | | |||
75 | KConfigGroup cg(config, QStringLiteral("OSD")); | | |||
76 | cg.writeEntry("Enabled", m_ui->showOsd->isChecked()); | | |||
77 | } | | |||
78 | | ||||
79 | config->sync(); | | |||
80 | } | | |||
81 | | ||||
82 | void WorkspaceOptionsModule::load() | | |||
83 | { | | |||
84 | KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); | | |||
85 | | ||||
86 | { | | |||
87 | const KConfigGroup cg(config, "PlasmaToolTips"); | | |||
88 | m_ui->showToolTips->setChecked(cg.readEntry("Delay", 0.7) > 0); | | |||
89 | } | | |||
90 | | ||||
91 | { | | |||
92 | const KConfigGroup cg(config, s_osdKey); | | |||
93 | m_ui->showOsd->setChecked(cg.readEntry(QStringLiteral("Enabled"), true)); | | |||
94 | } | | |||
95 | } | | |||
96 | | ||||
97 | void WorkspaceOptionsModule::defaults() | | |||
98 | { | | |||
99 | m_ui->showToolTips->setChecked(true); | | |||
100 | m_ui->showOsd->setChecked(true); | | |||
101 | } | | |||
102 | | ||||
103 | #include "workspaceoptions.moc" | |