Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinoptions/main.cpp
Show All 27 Lines | |||||
28 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> | ||
30 | #include <kaboutdata.h> | 30 | #include <kaboutdata.h> | ||
31 | #include <KPluginFactory> | 31 | #include <KPluginFactory> | ||
32 | #include <KPluginLoader> | 32 | #include <KPluginLoader> | ||
33 | 33 | | |||
34 | #include "mouse.h" | 34 | #include "mouse.h" | ||
35 | #include "windows.h" | 35 | #include "windows.h" | ||
36 | #include "kwinoptions_settings.h" | ||||
36 | 37 | | |||
37 | K_PLUGIN_FACTORY_DECLARATION(KWinOptionsFactory) | 38 | K_PLUGIN_FACTORY_DECLARATION(KWinOptionsFactory) | ||
38 | 39 | | |||
39 | class KFocusConfigStandalone : public KFocusConfig | 40 | class KFocusConfigStandalone : public KFocusConfig | ||
40 | { | 41 | { | ||
41 | Q_OBJECT | 42 | Q_OBJECT | ||
42 | public: | 43 | public: | ||
43 | KFocusConfigStandalone(QWidget* parent, const QVariantList &) | 44 | KFocusConfigStandalone(QWidget* parent, const QVariantList &) | ||
44 | : KFocusConfig(true, new KConfig("kwinrc"), parent) | 45 | : KFocusConfig(true, new KWinOptionsSettings(parent), parent) | ||
45 | {} | 46 | {} | ||
46 | }; | 47 | }; | ||
47 | 48 | | |||
48 | class KMovingConfigStandalone : public KMovingConfig | 49 | class KMovingConfigStandalone : public KMovingConfig | ||
49 | { | 50 | { | ||
50 | Q_OBJECT | 51 | Q_OBJECT | ||
51 | public: | 52 | public: | ||
52 | KMovingConfigStandalone(QWidget* parent, const QVariantList &) | 53 | KMovingConfigStandalone(QWidget* parent, const QVariantList &) | ||
53 | : KMovingConfig(true, parent) | 54 | : KMovingConfig(true, new KWinOptionsSettings(parent), parent) | ||
54 | {} | 55 | {} | ||
55 | }; | 56 | }; | ||
56 | 57 | | |||
57 | class KAdvancedConfigStandalone : public KAdvancedConfig | 58 | class KAdvancedConfigStandalone : public KAdvancedConfig | ||
58 | { | 59 | { | ||
59 | Q_OBJECT | 60 | Q_OBJECT | ||
60 | public: | 61 | public: | ||
61 | KAdvancedConfigStandalone(QWidget* parent, const QVariantList &) | 62 | KAdvancedConfigStandalone(QWidget* parent, const QVariantList &) | ||
62 | : KAdvancedConfig(true, parent) | 63 | : KAdvancedConfig(true, new KWinOptionsSettings(parent), parent) | ||
63 | {} | 64 | {} | ||
64 | }; | 65 | }; | ||
65 | 66 | | |||
66 | KWinOptions::KWinOptions(QWidget *parent, const QVariantList &) | 67 | KWinOptions::KWinOptions(QWidget *parent, const QVariantList &) | ||
67 | : KCModule(parent) | 68 | : KCModule(parent) | ||
68 | { | 69 | { | ||
69 | mConfig = new KConfig("kwinrc"); | 70 | mSettings = new KWinOptionsSettings(parent); | ||
70 | 71 | | |||
71 | QVBoxLayout *layout = new QVBoxLayout(this); | 72 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
72 | layout->setContentsMargins(0, 0, 0, 0); | 73 | layout->setContentsMargins(0, 0, 0, 0); | ||
73 | tab = new QTabWidget(this); | 74 | tab = new QTabWidget(this); | ||
74 | layout->addWidget(tab); | 75 | layout->addWidget(tab); | ||
75 | 76 | | |||
76 | mFocus = new KFocusConfig(false, mConfig, this); | 77 | mFocus = new KFocusConfig(false, mSettings, this); | ||
77 | mFocus->setObjectName(QLatin1String("KWin Focus Config")); | 78 | mFocus->setObjectName(QLatin1String("KWin Focus Config")); | ||
78 | tab->addTab(mFocus, i18n("&Focus")); | 79 | tab->addTab(mFocus, i18n("&Focus")); | ||
79 | connect(mFocus, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 80 | connect(mFocus, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
81 | connect(mFocus, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||||
80 | 82 | | |||
81 | mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this); | 83 | // Need to relay unmanagedWidgetDefaultState and unmanagedWidgetChangeState to wrapping KCModule | ||
84 | connect(mFocus, &KFocusConfig::unmanagedWidgetDefaulted, this, [this](bool defaulted){ | ||||
85 | unmanagedWidgetDefaultState(defaulted); | ||||
86 | }); | ||||
87 | connect(mFocus, &KFocusConfig::unmanagedWidgetChanged, this, [this](bool changed){ | ||||
88 | unmanagedWidgetChangeState(changed); | ||||
89 | }); | ||||
90 | | ||||
91 | mTitleBarActions = new KTitleBarActionsConfig(false, mSettings, this); | ||||
82 | mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); | 92 | mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); | ||
83 | tab->addTab(mTitleBarActions, i18n("Titlebar A&ctions")); | 93 | tab->addTab(mTitleBarActions, i18n("Titlebar A&ctions")); | ||
84 | connect(mTitleBarActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 94 | connect(mTitleBarActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
95 | connect(mTitleBarActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||||
85 | 96 | | |||
86 | mWindowActions = new KWindowActionsConfig(false, mConfig, this); | 97 | mWindowActions = new KWindowActionsConfig(false, mSettings, this); | ||
87 | mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); | 98 | mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); | ||
88 | tab->addTab(mWindowActions, i18n("W&indow Actions")); | 99 | tab->addTab(mWindowActions, i18n("W&indow Actions")); | ||
89 | connect(mWindowActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 100 | connect(mWindowActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
101 | connect(mWindowActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||||
90 | 102 | | |||
91 | mMoving = new KMovingConfig(false, this); | 103 | mMoving = new KMovingConfig(false, mSettings, this); | ||
92 | mMoving->setObjectName(QLatin1String("KWin Moving")); | 104 | mMoving->setObjectName(QLatin1String("KWin Moving")); | ||
93 | tab->addTab(mMoving, i18n("Mo&vement")); | 105 | tab->addTab(mMoving, i18n("Mo&vement")); | ||
94 | connect(mMoving, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 106 | connect(mMoving, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
95 | connect(mMoving, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | 107 | connect(mMoving, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||
96 | 108 | | |||
97 | mAdvanced = new KAdvancedConfig(false, this); | 109 | mAdvanced = new KAdvancedConfig(false, mSettings, this); | ||
98 | mAdvanced->setObjectName(QLatin1String("KWin Advanced")); | 110 | mAdvanced->setObjectName(QLatin1String("KWin Advanced")); | ||
99 | tab->addTab(mAdvanced, i18n("Adva&nced")); | 111 | tab->addTab(mAdvanced, i18n("Adva&nced")); | ||
100 | connect(mAdvanced, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 112 | connect(mAdvanced, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
101 | connect(mAdvanced, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | 113 | connect(mAdvanced, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||
102 | 114 | | |||
103 | KAboutData *about = | 115 | KAboutData *about = | ||
104 | new KAboutData(QStringLiteral("kcmkwinoptions"), i18n("Window Behavior Configuration Module"), | 116 | new KAboutData(QStringLiteral("kcmkwinoptions"), i18n("Window Behavior Configuration Module"), | ||
105 | QString(), QString(), KAboutLicense::GPL, | 117 | QString(), QString(), KAboutLicense::GPL, | ||
106 | i18n("(c) 1997 - 2002 KWin and KControl Authors")); | 118 | i18n("(c) 1997 - 2002 KWin and KControl Authors")); | ||
107 | 119 | | |||
108 | about->addAuthor(i18n("Matthias Ettrich"), QString(), "ettrich@kde.org"); | 120 | about->addAuthor(i18n("Matthias Ettrich"), QString(), "ettrich@kde.org"); | ||
109 | about->addAuthor(i18n("Waldo Bastian"), QString(), "bastian@kde.org"); | 121 | about->addAuthor(i18n("Waldo Bastian"), QString(), "bastian@kde.org"); | ||
110 | about->addAuthor(i18n("Cristian Tibirna"), QString(), "tibirna@kde.org"); | 122 | about->addAuthor(i18n("Cristian Tibirna"), QString(), "tibirna@kde.org"); | ||
111 | about->addAuthor(i18n("Matthias Kalle Dalheimer"), QString(), "kalle@kde.org"); | 123 | about->addAuthor(i18n("Matthias Kalle Dalheimer"), QString(), "kalle@kde.org"); | ||
112 | about->addAuthor(i18n("Daniel Molkentin"), QString(), "molkentin@kde.org"); | 124 | about->addAuthor(i18n("Daniel Molkentin"), QString(), "molkentin@kde.org"); | ||
113 | about->addAuthor(i18n("Wynn Wilkes"), QString(), "wynnw@caldera.com"); | 125 | about->addAuthor(i18n("Wynn Wilkes"), QString(), "wynnw@caldera.com"); | ||
114 | about->addAuthor(i18n("Pat Dowler"), QString(), "dowler@pt1B1106.FSH.UVic.CA"); | 126 | about->addAuthor(i18n("Pat Dowler"), QString(), "dowler@pt1B1106.FSH.UVic.CA"); | ||
115 | about->addAuthor(i18n("Bernd Wuebben"), QString(), "wuebben@kde.org"); | 127 | about->addAuthor(i18n("Bernd Wuebben"), QString(), "wuebben@kde.org"); | ||
116 | about->addAuthor(i18n("Matthias Hoelzer-Kluepfel"), QString(), "hoelzer@kde.org"); | 128 | about->addAuthor(i18n("Matthias Hoelzer-Kluepfel"), QString(), "hoelzer@kde.org"); | ||
117 | setAboutData(about); | 129 | setAboutData(about); | ||
118 | } | 130 | } | ||
119 | 131 | | |||
120 | KWinOptions::~KWinOptions() | | |||
121 | { | | |||
122 | delete mConfig; | | |||
123 | } | | |||
124 | | ||||
125 | void KWinOptions::load() | 132 | void KWinOptions::load() | ||
126 | { | 133 | { | ||
127 | mConfig->reparseConfiguration(); | | |||
128 | mFocus->load(); | | |||
129 | mTitleBarActions->load(); | 134 | mTitleBarActions->load(); | ||
130 | mWindowActions->load(); | 135 | mWindowActions->load(); | ||
131 | mMoving->load(); | 136 | mMoving->load(); | ||
132 | mAdvanced->load(); | 137 | mAdvanced->load(); | ||
133 | emit KCModule::changed(false); | 138 | mFocus->load(); | ||
134 | } | 139 | } | ||
135 | 140 | | |||
136 | | ||||
137 | void KWinOptions::save() | 141 | void KWinOptions::save() | ||
138 | { | 142 | { | ||
139 | mFocus->save(); | 143 | mFocus->save(); | ||
140 | mTitleBarActions->save(); | 144 | mTitleBarActions->save(); | ||
141 | mWindowActions->save(); | 145 | mWindowActions->save(); | ||
142 | mMoving->save(); | 146 | mMoving->save(); | ||
143 | mAdvanced->save(); | 147 | mAdvanced->save(); | ||
144 | 148 | | |||
145 | emit KCModule::changed(false); | 149 | emit KCModule::changed(false); | ||
146 | // Send signal to kwin | 150 | | ||
147 | mConfig->sync(); | | |||
148 | // Send signal to all kwin instances | 151 | // Send signal to all kwin instances | ||
149 | QDBusMessage message = | 152 | QDBusMessage message = | ||
150 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | 153 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | ||
151 | QDBusConnection::sessionBus().send(message); | 154 | QDBusConnection::sessionBus().send(message); | ||
152 | | ||||
153 | | ||||
154 | } | 155 | } | ||
155 | 156 | | |||
156 | 157 | | |||
157 | void KWinOptions::defaults() | 158 | void KWinOptions::defaults() | ||
158 | { | 159 | { | ||
159 | mFocus->defaults(); | | |||
160 | mTitleBarActions->defaults(); | 160 | mTitleBarActions->defaults(); | ||
161 | mWindowActions->defaults(); | 161 | mWindowActions->defaults(); | ||
162 | mMoving->defaults(); | 162 | mMoving->defaults(); | ||
163 | mAdvanced->defaults(); | 163 | mAdvanced->defaults(); | ||
164 | mFocus->defaults(); | ||||
164 | } | 165 | } | ||
165 | 166 | | |||
166 | QString KWinOptions::quickHelp() const | 167 | QString KWinOptions::quickHelp() const | ||
167 | { | 168 | { | ||
168 | return i18n("<p><h1>Window Behavior</h1> Here you can customize the way windows behave when being" | 169 | return i18n("<p><h1>Window Behavior</h1> Here you can customize the way windows behave when being" | ||
169 | " moved, resized or clicked on. You can also specify a focus policy as well as a placement" | 170 | " moved, resized or clicked on. You can also specify a focus policy as well as a placement" | ||
170 | " policy for new windows.</p>" | 171 | " policy for new windows.</p>" | ||
171 | " <p>Please note that this configuration will not take effect if you do not use" | 172 | " <p>Please note that this configuration will not take effect if you do not use" | ||
172 | " KWin as your window manager. If you do use a different window manager, please refer to its documentation" | 173 | " KWin as your window manager. If you do use a different window manager, please refer to its documentation" | ||
173 | " for how to customize window behavior.</p>"); | 174 | " for how to customize window behavior.</p>"); | ||
174 | } | 175 | } | ||
175 | 176 | | |||
176 | void KWinOptions::moduleChanged(bool state) | | |||
177 | { | | |||
178 | emit KCModule::changed(state); | | |||
179 | } | | |||
180 | | ||||
181 | KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &) | 177 | KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &) | ||
182 | : KCModule(parent) | 178 | : KCModule(parent) | ||
183 | { | 179 | { | ||
184 | mConfig = new KConfig("kwinrc"); | 180 | mSettings = new KWinOptionsSettings(parent); | ||
185 | 181 | | |||
186 | QVBoxLayout *layout = new QVBoxLayout(this); | 182 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
187 | layout->setContentsMargins(0, 0, 0, 0); | 183 | layout->setContentsMargins(0, 0, 0, 0); | ||
188 | tab = new QTabWidget(this); | 184 | tab = new QTabWidget(this); | ||
189 | layout->addWidget(tab); | 185 | layout->addWidget(tab); | ||
190 | 186 | | |||
191 | mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this); | 187 | mTitleBarActions = new KTitleBarActionsConfig(false, mSettings, this); | ||
192 | mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); | 188 | mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); | ||
193 | tab->addTab(mTitleBarActions, i18n("&Titlebar Actions")); | 189 | tab->addTab(mTitleBarActions, i18n("&Titlebar Actions")); | ||
194 | connect(mTitleBarActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 190 | connect(mTitleBarActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
191 | connect(mTitleBarActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||||
195 | 192 | | |||
196 | mWindowActions = new KWindowActionsConfig(false, mConfig, this); | 193 | mWindowActions = new KWindowActionsConfig(false, mSettings, this); | ||
meven: That's wrong, those lines should not be removed | |||||
197 | mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); | 194 | mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); | ||
198 | tab->addTab(mWindowActions, i18n("Window Actio&ns")); | 195 | tab->addTab(mWindowActions, i18n("Window Actio&ns")); | ||
199 | connect(mWindowActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | 196 | connect(mWindowActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed)); | ||
200 | } | 197 | connect(mWindowActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted)); | ||
201 | | ||||
202 | KActionsOptions::~KActionsOptions() | | |||
203 | { | | |||
204 | delete mConfig; | | |||
205 | } | 198 | } | ||
206 | 199 | | |||
207 | void KActionsOptions::load() | 200 | void KActionsOptions::load() | ||
208 | { | 201 | { | ||
209 | mTitleBarActions->load(); | 202 | mTitleBarActions->load(); | ||
210 | mWindowActions->load(); | | |||
ervin: Sure about that? | |||||
211 | emit KCModule::changed(false); | | |||
212 | } | 203 | } | ||
213 | 204 | | |||
214 | | ||||
215 | void KActionsOptions::save() | 205 | void KActionsOptions::save() | ||
216 | { | 206 | { | ||
217 | mTitleBarActions->save(); | 207 | mTitleBarActions->save(); | ||
218 | mWindowActions->save(); | 208 | mWindowActions->save(); | ||
219 | 209 | | |||
220 | emit KCModule::changed(false); | 210 | emit KCModule::changed(false); | ||
221 | // Send signal to kwin | | |||
222 | mConfig->sync(); | | |||
223 | // Send signal to all kwin instances | 211 | // Send signal to all kwin instances | ||
224 | QDBusMessage message = | 212 | QDBusMessage message = | ||
225 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | 213 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | ||
226 | QDBusConnection::sessionBus().send(message); | 214 | QDBusConnection::sessionBus().send(message); | ||
227 | | ||||
228 | } | 215 | } | ||
229 | 216 | | |||
230 | | ||||
231 | void KActionsOptions::defaults() | 217 | void KActionsOptions::defaults() | ||
232 | { | 218 | { | ||
233 | mTitleBarActions->defaults(); | 219 | mTitleBarActions->defaults(); | ||
234 | mWindowActions->defaults(); | | |||
Sure about that? (This comment and the previous one are due to you apparently reverting a past mistake but I wonder if you missed a bit of it) ervin: Sure about that?
(This comment and the previous one are due to you apparently reverting a past… | |||||
235 | | ||||
236 | emit defaulted(true); | | |||
237 | } | 220 | } | ||
238 | 221 | | |||
239 | void KActionsOptions::moduleChanged(bool state) | 222 | void KActionsOptions::moduleChanged(bool state) | ||
240 | { | 223 | { | ||
241 | emit KCModule::changed(state); | 224 | emit KCModule::changed(state); | ||
242 | } | 225 | } | ||
243 | 226 | | |||
244 | K_PLUGIN_FACTORY_DEFINITION(KWinOptionsFactory, | 227 | K_PLUGIN_FACTORY_DEFINITION(KWinOptionsFactory, | ||
Show All 9 Lines |
That's wrong, those lines should not be removed