Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/kcm.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
59 | static const QString s_defaultTheme; | 59 | static const QString s_defaultTheme; | ||
60 | #else | 60 | #else | ||
61 | static const QString s_defaultPlugin = QStringLiteral("org.kde.kwin.aurorae"); | 61 | static const QString s_defaultPlugin = QStringLiteral("org.kde.kwin.aurorae"); | ||
62 | static const QString s_defaultTheme = QStringLiteral("kwin4_decoration_qml_plastik"); | 62 | static const QString s_defaultTheme = QStringLiteral("kwin4_decoration_qml_plastik"); | ||
63 | #endif | 63 | #endif | ||
64 | static const QString s_borderSizeNormal = QStringLiteral("Normal"); | 64 | static const QString s_borderSizeNormal = QStringLiteral("Normal"); | ||
65 | static const QString s_ghnsIcon = QStringLiteral("get-hot-new-stuff"); | 65 | static const QString s_ghnsIcon = QStringLiteral("get-hot-new-stuff"); | ||
66 | 66 | | |||
67 | static const QVector<KDecoration2::DecorationButtonType> s_defaultButtonsOnLeft { | ||||
68 | KDecoration2::DecorationButtonType::Menu, | ||||
69 | KDecoration2::DecorationButtonType::OnAllDesktops | ||||
70 | }; | ||||
71 | static const QVector<KDecoration2::DecorationButtonType> s_defaultButtonsOnRight { | ||||
72 | KDecoration2::DecorationButtonType::ContextHelp, | ||||
73 | KDecoration2::DecorationButtonType::Minimize, | ||||
74 | KDecoration2::DecorationButtonType::Maximize, | ||||
75 | KDecoration2::DecorationButtonType::Close | ||||
76 | }; | ||||
77 | | ||||
67 | ConfigurationForm::ConfigurationForm(QWidget *parent) | 78 | ConfigurationForm::ConfigurationForm(QWidget *parent) | ||
68 | : QWidget(parent) | 79 | : QWidget(parent) | ||
69 | { | 80 | { | ||
70 | setupUi(this); | 81 | setupUi(this); | ||
71 | } | 82 | } | ||
72 | 83 | | |||
73 | static bool s_loading = false; | 84 | static bool s_loading = false; | ||
74 | 85 | | |||
▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Line(s) | 318 | { | |||
312 | m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); | 323 | m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); | ||
313 | const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal))); | 324 | const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal))); | ||
314 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); | 325 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); | ||
315 | 326 | | |||
316 | int themeIndex = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row(); | 327 | int themeIndex = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row(); | ||
317 | m_quickView->rootContext()->setContextProperty("initialThemeIndex", themeIndex); | 328 | m_quickView->rootContext()->setContextProperty("initialThemeIndex", themeIndex); | ||
318 | 329 | | |||
319 | // buttons | 330 | // buttons | ||
320 | const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{ | 331 | const auto &left = readDecorationButtons(config, "ButtonsOnLeft", s_defaultButtonsOnLeft); | ||
321 | KDecoration2::DecorationButtonType::Menu, | 332 | m_leftButtons->clear(); | ||
322 | KDecoration2::DecorationButtonType::OnAllDesktops | | |||
323 | }); | | |||
324 | while (m_leftButtons->rowCount() > 0) { | | |||
325 | m_leftButtons->remove(0); | | |||
326 | } | | |||
327 | for (auto it = left.begin(); it != left.end(); ++it) { | 333 | for (auto it = left.begin(); it != left.end(); ++it) { | ||
328 | m_leftButtons->add(*it); | 334 | m_leftButtons->add(*it); | ||
329 | } | 335 | } | ||
330 | const auto &right = readDecorationButtons(config, "ButtonsOnRight", QVector<KDecoration2::DecorationButtonType >{ | 336 | const auto &right = readDecorationButtons(config, "ButtonsOnRight", s_defaultButtonsOnRight); | ||
331 | KDecoration2::DecorationButtonType::ContextHelp, | 337 | m_rightButtons->clear(); | ||
332 | KDecoration2::DecorationButtonType::Minimize, | | |||
333 | KDecoration2::DecorationButtonType::Maximize, | | |||
334 | KDecoration2::DecorationButtonType::Close | | |||
335 | }); | | |||
336 | while (m_rightButtons->rowCount() > 0) { | | |||
337 | m_rightButtons->remove(0); | | |||
338 | } | | |||
339 | for (auto it = right.begin(); it != right.end(); ++it) { | 338 | for (auto it = right.begin(); it != right.end(); ++it) { | ||
340 | m_rightButtons->add(*it); | 339 | m_rightButtons->add(*it); | ||
341 | } | 340 | } | ||
342 | 341 | | |||
343 | KCModule::load(); | 342 | KCModule::load(); | ||
344 | s_loading = false; | 343 | s_loading = false; | ||
345 | } | 344 | } | ||
346 | 345 | | |||
Show All 31 Lines | |||||
378 | void ConfigurationModule::defaults() | 377 | void ConfigurationModule::defaults() | ||
379 | { | 378 | { | ||
380 | if (auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView")) { | 379 | if (auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView")) { | ||
381 | const QModelIndex index = m_proxyModel->mapFromSource(m_model->findDecoration(s_defaultPlugin)); | 380 | const QModelIndex index = m_proxyModel->mapFromSource(m_model->findDecoration(s_defaultPlugin)); | ||
382 | listView->setProperty("currentIndex", index.isValid() ? index.row() : -1); | 381 | listView->setProperty("currentIndex", index.isValid() ? index.row() : -1); | ||
383 | } | 382 | } | ||
384 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(QVariant::fromValue(stringToSize(s_borderSizeNormal)))); | 383 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(QVariant::fromValue(stringToSize(s_borderSizeNormal)))); | ||
385 | m_ui->closeWindowsDoubleClick->setChecked(false); | 384 | m_ui->closeWindowsDoubleClick->setChecked(false); | ||
385 | | ||||
386 | // Buttons reset | ||||
387 | m_leftButtons->clear(); | ||||
388 | for (auto it = s_defaultButtonsOnLeft.begin(); it != s_defaultButtonsOnLeft.end(); ++it) { | ||||
389 | m_leftButtons->add(*it); | ||||
390 | } | ||||
391 | m_rightButtons->clear(); | ||||
392 | for (auto it = s_defaultButtonsOnRight.begin(); it != s_defaultButtonsOnRight.end(); ++it) { | ||||
393 | m_rightButtons->add(*it); | ||||
394 | } | ||||
395 | | ||||
386 | KCModule::defaults(); | 396 | KCModule::defaults(); | ||
387 | } | 397 | } | ||
388 | 398 | | |||
389 | void ConfigurationModule::showKNS(const QString &config) | 399 | void ConfigurationModule::showKNS(const QString &config) | ||
390 | { | 400 | { | ||
391 | QPointer<KNS3::DownloadDialog> downloadDialog = new KNS3::DownloadDialog(config, this); | 401 | QPointer<KNS3::DownloadDialog> downloadDialog = new KNS3::DownloadDialog(config, this); | ||
392 | if (downloadDialog->exec() == QDialog::Accepted && !downloadDialog->changedEntries().isEmpty()) { | 402 | if (downloadDialog->exec() == QDialog::Accepted && !downloadDialog->changedEntries().isEmpty()) { | ||
393 | auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView"); | 403 | auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView"); | ||
Show All 27 Lines | 430 | if (e->type() == QEvent::PaletteChange) { | |||
421 | updateColors(); | 431 | updateColors(); | ||
422 | } | 432 | } | ||
423 | return false; | 433 | return false; | ||
424 | } | 434 | } | ||
425 | 435 | | |||
426 | void ConfigurationModule::updateColors() | 436 | void ConfigurationModule::updateColors() | ||
427 | { | 437 | { | ||
428 | m_quickView->rootContext()->setContextProperty("backgroundColor", m_ui->palette().color(QPalette::Active, QPalette::Window)); | 438 | m_quickView->rootContext()->setContextProperty("backgroundColor", m_ui->palette().color(QPalette::Active, QPalette::Window)); | ||
429 | m_quickView->rootContext()->setContextProperty("highlightColor", m_ui->palette().color(QPalette::Active, QPalette::Shadow)); | 439 | m_quickView->rootContext()->setContextProperty("borderColor", m_ui->palette().color(QPalette::Active, QPalette::Shadow)); | ||
430 | m_quickView->rootContext()->setContextProperty("baseColor", m_ui->palette().color(QPalette::Active, QPalette::Base)); | 440 | m_quickView->rootContext()->setContextProperty("highlightColor", m_ui->palette().color(QPalette::Active, QPalette::Highlight)); | ||
441 | m_quickView->rootContext()->setContextProperty("titleBarColor", m_ui->palette().color(QPalette::Active, QPalette::Base)); | ||||
431 | } | 442 | } | ||
432 | 443 | | |||
433 | } | 444 | } | ||
434 | } | 445 | } | ||
435 | 446 | | |||
436 | #include "kcm.moc" | 447 | #include "kcm.moc" |