Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/kcm.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | namespace | 45 | namespace | ||
46 | { | 46 | { | ||
47 | const QString s_configFile { QStringLiteral("kwinrc") }; | 47 | const QString s_configFile { QStringLiteral("kwinrc") }; | ||
48 | const QString s_configGroup { QStringLiteral("org.kde.kdecoration2") }; | 48 | const QString s_configGroup { QStringLiteral("org.kde.kdecoration2") }; | ||
49 | const QString s_configPlugin { QStringLiteral("library") }; | 49 | const QString s_configPlugin { QStringLiteral("library") }; | ||
50 | const QString s_configTheme { QStringLiteral("theme") }; | 50 | const QString s_configTheme { QStringLiteral("theme") }; | ||
51 | const QString s_configBorderSize { QStringLiteral("BorderSize") }; | 51 | const QString s_configBorderSize { QStringLiteral("BorderSize") }; | ||
52 | const QString s_configCloseOnDoubleClickOnMenu { QStringLiteral("CloseOnDoubleClickOnMenu") }; | 52 | const QString s_configCloseOnDoubleClickOnMenu { QStringLiteral("CloseOnDoubleClickOnMenu") }; | ||
53 | const QString s_configShowToolTips { QStringLiteral("ShowToolTips") }; | ||||
53 | const QString s_configDecoButtonsOnLeft { QStringLiteral("ButtonsOnLeft") }; | 54 | const QString s_configDecoButtonsOnLeft { QStringLiteral("ButtonsOnLeft") }; | ||
54 | const QString s_configDecoButtonsOnRight { QStringLiteral("ButtonsOnRight") }; | 55 | const QString s_configDecoButtonsOnRight { QStringLiteral("ButtonsOnRight") }; | ||
55 | 56 | | |||
56 | const KDecoration2::BorderSize s_defaultBorderSize = KDecoration2::BorderSize::Normal; | 57 | const KDecoration2::BorderSize s_defaultBorderSize = KDecoration2::BorderSize::Normal; | ||
57 | const bool s_defaultCloseOnDoubleClickOnMenu = false; | 58 | const bool s_defaultCloseOnDoubleClickOnMenu = false; | ||
59 | const bool s_defaultShowToolTips = true; | ||||
58 | 60 | | |||
59 | const DecorationButtonsList s_defaultDecoButtonsOnLeft { | 61 | const DecorationButtonsList s_defaultDecoButtonsOnLeft { | ||
60 | KDecoration2::DecorationButtonType::Menu, | 62 | KDecoration2::DecorationButtonType::Menu, | ||
61 | KDecoration2::DecorationButtonType::OnAllDesktops | 63 | KDecoration2::DecorationButtonType::OnAllDesktops | ||
62 | }; | 64 | }; | ||
63 | const DecorationButtonsList s_defaultDecoButtonsOnRight { | 65 | const DecorationButtonsList s_defaultDecoButtonsOnRight { | ||
64 | KDecoration2::DecorationButtonType::ContextHelp, | 66 | KDecoration2::DecorationButtonType::ContextHelp, | ||
65 | KDecoration2::DecorationButtonType::Minimize, | 67 | KDecoration2::DecorationButtonType::Minimize, | ||
Show All 12 Lines | |||||
78 | 80 | | |||
79 | KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &arguments) | 81 | KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &arguments) | ||
80 | : KQuickAddons::ConfigModule(parent, arguments) | 82 | : KQuickAddons::ConfigModule(parent, arguments) | ||
81 | , m_themesModel(new KDecoration2::Configuration::DecorationsModel(this)) | 83 | , m_themesModel(new KDecoration2::Configuration::DecorationsModel(this)) | ||
82 | , m_proxyThemesModel(new QSortFilterProxyModel(this)) | 84 | , m_proxyThemesModel(new QSortFilterProxyModel(this)) | ||
83 | , m_leftButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this)) | 85 | , m_leftButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this)) | ||
84 | , m_rightButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this)) | 86 | , m_rightButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this)) | ||
85 | , m_availableButtonsModel(new KDecoration2::Preview::ButtonsModel(this)) | 87 | , m_availableButtonsModel(new KDecoration2::Preview::ButtonsModel(this)) | ||
86 | , m_savedSettings{ s_defaultBorderSize, -2 /* for setTheme() */, false, s_defaultDecoButtonsOnLeft, s_defaultDecoButtonsOnRight } | 88 | , m_savedSettings{ s_defaultBorderSize, -2 /* for setTheme() */, false, s_defaultShowToolTips, s_defaultDecoButtonsOnLeft, s_defaultDecoButtonsOnRight } | ||
87 | , m_currentSettings(m_savedSettings) | 89 | , m_currentSettings(m_savedSettings) | ||
88 | { | 90 | { | ||
89 | auto about = new KAboutData(QStringLiteral("kcm_kwindecoration"), | 91 | auto about = new KAboutData(QStringLiteral("kcm_kwindecoration"), | ||
90 | i18n("Window Decorations"), | 92 | i18n("Window Decorations"), | ||
91 | QStringLiteral("1.0"), | 93 | QStringLiteral("1.0"), | ||
92 | QString(), | 94 | QString(), | ||
93 | KAboutLicense::GPL); | 95 | KAboutLicense::GPL); | ||
94 | about->addAuthor(i18n("Valerio Pilo"), | 96 | about->addAuthor(i18n("Valerio Pilo"), | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 151 | { | |||
155 | if (themeIndex < 0) { | 157 | if (themeIndex < 0) { | ||
156 | qWarning() << "Plugin" << plugin << "and theme" << theme << "not found"; | 158 | qWarning() << "Plugin" << plugin << "and theme" << theme << "not found"; | ||
157 | } else { | 159 | } else { | ||
158 | qDebug() << "Current theme: plugin" << plugin << "and theme" << theme; | 160 | qDebug() << "Current theme: plugin" << plugin << "and theme" << theme; | ||
159 | } | 161 | } | ||
160 | setTheme(themeIndex); | 162 | setTheme(themeIndex); | ||
161 | 163 | | |||
162 | setCloseOnDoubleClickOnMenu(config.readEntry(s_configCloseOnDoubleClickOnMenu, s_defaultCloseOnDoubleClickOnMenu)); | 164 | setCloseOnDoubleClickOnMenu(config.readEntry(s_configCloseOnDoubleClickOnMenu, s_defaultCloseOnDoubleClickOnMenu)); | ||
165 | setShowToolTips(config.readEntry(s_configShowToolTips, s_defaultShowToolTips)); | ||||
163 | 166 | | |||
164 | const QString defaultSizeName = Utils::borderSizeToString(s_defaultBorderSize); | 167 | const QString defaultSizeName = Utils::borderSizeToString(s_defaultBorderSize); | ||
165 | setBorderSize(Utils::stringToBorderSize(config.readEntry(s_configBorderSize, defaultSizeName))); | 168 | setBorderSize(Utils::stringToBorderSize(config.readEntry(s_configBorderSize, defaultSizeName))); | ||
166 | 169 | | |||
167 | m_leftButtonsModel->replace(Utils::readDecorationButtons(config, s_configDecoButtonsOnLeft, s_defaultDecoButtonsOnLeft)); | 170 | m_leftButtonsModel->replace(Utils::readDecorationButtons(config, s_configDecoButtonsOnLeft, s_defaultDecoButtonsOnLeft)); | ||
168 | m_rightButtonsModel->replace(Utils::readDecorationButtons(config, s_configDecoButtonsOnRight, s_defaultDecoButtonsOnRight)); | 171 | m_rightButtonsModel->replace(Utils::readDecorationButtons(config, s_configDecoButtonsOnRight, s_defaultDecoButtonsOnRight)); | ||
169 | m_currentSettings.buttonsOnLeft = m_leftButtonsModel->buttons(); | 172 | m_currentSettings.buttonsOnLeft = m_leftButtonsModel->buttons(); | ||
170 | m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons(); | 173 | m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons(); | ||
Show All 16 Lines | 186 | if (index.isValid()) { | |||
187 | config.writeEntry(s_configTheme, theme); | 190 | config.writeEntry(s_configTheme, theme); | ||
188 | qDebug() << "Saved theme: plugin" << plugin << "and theme" << theme; | 191 | qDebug() << "Saved theme: plugin" << plugin << "and theme" << theme; | ||
189 | } else { | 192 | } else { | ||
190 | qWarning() << "Cannot match theme index" << m_currentSettings.themeIndex << "in model"; | 193 | qWarning() << "Cannot match theme index" << m_currentSettings.themeIndex << "in model"; | ||
191 | } | 194 | } | ||
192 | } | 195 | } | ||
193 | 196 | | |||
194 | config.writeEntry(s_configCloseOnDoubleClickOnMenu, m_currentSettings.closeOnDoubleClickOnMenu); | 197 | config.writeEntry(s_configCloseOnDoubleClickOnMenu, m_currentSettings.closeOnDoubleClickOnMenu); | ||
198 | config.writeEntry(s_configShowToolTips, m_currentSettings.showToolTips); | ||||
195 | config.writeEntry(s_configBorderSize, Utils::borderSizeToString(m_currentSettings.borderSize)); | 199 | config.writeEntry(s_configBorderSize, Utils::borderSizeToString(m_currentSettings.borderSize)); | ||
196 | config.writeEntry(s_configDecoButtonsOnLeft, Utils::buttonsToString(m_currentSettings.buttonsOnLeft)); | 200 | config.writeEntry(s_configDecoButtonsOnLeft, Utils::buttonsToString(m_currentSettings.buttonsOnLeft)); | ||
197 | config.writeEntry(s_configDecoButtonsOnRight, Utils::buttonsToString(m_currentSettings.buttonsOnRight)); | 201 | config.writeEntry(s_configDecoButtonsOnRight, Utils::buttonsToString(m_currentSettings.buttonsOnRight)); | ||
198 | config.sync(); | 202 | config.sync(); | ||
199 | 203 | | |||
200 | m_savedSettings = m_currentSettings; | 204 | m_savedSettings = m_currentSettings; | ||
201 | 205 | | |||
202 | // Send a signal to all kwin instances | 206 | // Send a signal to all kwin instances | ||
Show All 9 Lines | |||||
212 | { | 216 | { | ||
213 | int themeIndex = m_proxyThemesModel->mapFromSource(m_themesModel->findDecoration(s_defaultPlugin, s_defaultTheme)).row(); | 217 | int themeIndex = m_proxyThemesModel->mapFromSource(m_themesModel->findDecoration(s_defaultPlugin, s_defaultTheme)).row(); | ||
214 | if (themeIndex < 0) { | 218 | if (themeIndex < 0) { | ||
215 | qWarning() << "Default plugin" << s_defaultPlugin << "and theme" << s_defaultTheme << "not found"; | 219 | qWarning() << "Default plugin" << s_defaultPlugin << "and theme" << s_defaultTheme << "not found"; | ||
216 | } | 220 | } | ||
217 | setTheme(themeIndex); | 221 | setTheme(themeIndex); | ||
218 | setBorderSize(s_defaultBorderSize); | 222 | setBorderSize(s_defaultBorderSize); | ||
219 | setCloseOnDoubleClickOnMenu(s_defaultCloseOnDoubleClickOnMenu); | 223 | setCloseOnDoubleClickOnMenu(s_defaultCloseOnDoubleClickOnMenu); | ||
224 | setShowToolTips(s_defaultShowToolTips); | ||||
220 | 225 | | |||
221 | m_leftButtonsModel->replace(s_defaultDecoButtonsOnLeft); | 226 | m_leftButtonsModel->replace(s_defaultDecoButtonsOnLeft); | ||
222 | m_rightButtonsModel->replace(s_defaultDecoButtonsOnRight); | 227 | m_rightButtonsModel->replace(s_defaultDecoButtonsOnRight); | ||
223 | 228 | | |||
224 | updateNeedsSave(); | 229 | updateNeedsSave(); | ||
225 | } | 230 | } | ||
226 | 231 | | |||
227 | void KCMKWinDecoration::updateNeedsSave() | 232 | void KCMKWinDecoration::updateNeedsSave() | ||
228 | { | 233 | { | ||
229 | m_currentSettings.buttonsOnLeft = m_leftButtonsModel->buttons(); | 234 | m_currentSettings.buttonsOnLeft = m_leftButtonsModel->buttons(); | ||
230 | m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons(); | 235 | m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons(); | ||
231 | 236 | | |||
232 | setNeedsSave(m_savedSettings.closeOnDoubleClickOnMenu != m_currentSettings.closeOnDoubleClickOnMenu | 237 | setNeedsSave(m_savedSettings.closeOnDoubleClickOnMenu != m_currentSettings.closeOnDoubleClickOnMenu | ||
238 | || m_savedSettings.showToolTips != m_currentSettings.showToolTips | ||||
233 | || m_savedSettings.borderSize != m_currentSettings.borderSize | 239 | || m_savedSettings.borderSize != m_currentSettings.borderSize | ||
234 | || m_savedSettings.themeIndex != m_currentSettings.themeIndex | 240 | || m_savedSettings.themeIndex != m_currentSettings.themeIndex | ||
235 | || m_savedSettings.buttonsOnLeft != m_currentSettings.buttonsOnLeft | 241 | || m_savedSettings.buttonsOnLeft != m_currentSettings.buttonsOnLeft | ||
236 | || m_savedSettings.buttonsOnRight != m_currentSettings.buttonsOnRight); | 242 | || m_savedSettings.buttonsOnRight != m_currentSettings.buttonsOnRight); | ||
237 | } | 243 | } | ||
238 | 244 | | |||
239 | QSortFilterProxyModel *KCMKWinDecoration::themesModel() const | 245 | QSortFilterProxyModel *KCMKWinDecoration::themesModel() const | ||
240 | { | 246 | { | ||
Show All 30 Lines | 276 | { | |||
271 | return m_currentSettings.themeIndex; | 277 | return m_currentSettings.themeIndex; | ||
272 | } | 278 | } | ||
273 | 279 | | |||
274 | bool KCMKWinDecoration::closeOnDoubleClickOnMenu() const | 280 | bool KCMKWinDecoration::closeOnDoubleClickOnMenu() const | ||
275 | { | 281 | { | ||
276 | return m_currentSettings.closeOnDoubleClickOnMenu; | 282 | return m_currentSettings.closeOnDoubleClickOnMenu; | ||
277 | } | 283 | } | ||
278 | 284 | | |||
285 | bool KCMKWinDecoration::showToolTips() const | ||||
286 | { | ||||
287 | return m_currentSettings.showToolTips; | ||||
288 | } | ||||
289 | | ||||
279 | void KCMKWinDecoration::setBorderSize(int index) | 290 | void KCMKWinDecoration::setBorderSize(int index) | ||
280 | { | 291 | { | ||
281 | setBorderSize(Utils::getBorderSizeNames().keys().at(index)); | 292 | setBorderSize(Utils::getBorderSizeNames().keys().at(index)); | ||
282 | } | 293 | } | ||
283 | 294 | | |||
284 | void KCMKWinDecoration::setBorderSize(KDecoration2::BorderSize size) | 295 | void KCMKWinDecoration::setBorderSize(KDecoration2::BorderSize size) | ||
285 | { | 296 | { | ||
286 | if (m_currentSettings.borderSize == size) { | 297 | if (m_currentSettings.borderSize == size) { | ||
Show All 20 Lines | 317 | { | |||
307 | if (m_currentSettings.closeOnDoubleClickOnMenu == enable) { | 318 | if (m_currentSettings.closeOnDoubleClickOnMenu == enable) { | ||
308 | return; | 319 | return; | ||
309 | } | 320 | } | ||
310 | m_currentSettings.closeOnDoubleClickOnMenu = enable; | 321 | m_currentSettings.closeOnDoubleClickOnMenu = enable; | ||
311 | emit closeOnDoubleClickOnMenuChanged(); | 322 | emit closeOnDoubleClickOnMenuChanged(); | ||
312 | updateNeedsSave(); | 323 | updateNeedsSave(); | ||
313 | } | 324 | } | ||
314 | 325 | | |||
326 | void KCMKWinDecoration::setShowToolTips(bool show) | ||||
327 | { | ||||
328 | if (m_currentSettings.showToolTips == show) { | ||||
329 | return; | ||||
330 | } | ||||
331 | m_currentSettings.showToolTips = show; | ||||
332 | emit showToolTipsChanged(); | ||||
333 | updateNeedsSave(); | ||||
334 | } | ||||
335 | | ||||
315 | #include "kcm.moc" | 336 | #include "kcm.moc" |