Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/kcm.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
56 | static const QString s_pluginName = QStringLiteral("org.kde.kdecoration2"); | 56 | static const QString s_pluginName = QStringLiteral("org.kde.kdecoration2"); | ||
57 | #if HAVE_BREEZE_DECO | 57 | #if HAVE_BREEZE_DECO | ||
58 | static const QString s_defaultPlugin = QStringLiteral(BREEZE_KDECORATION_PLUGIN_ID); | 58 | static const QString s_defaultPlugin = QStringLiteral(BREEZE_KDECORATION_PLUGIN_ID); | ||
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_defaultBorderSize = QStringLiteral("None"); | ||
davidedmundson: That variable name is misleading. Especially on line 224.
Renaming as border size default… | |||||
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 | ConfigurationForm::ConfigurationForm(QWidget *parent) | 67 | ConfigurationForm::ConfigurationForm(QWidget *parent) | ||
68 | : QWidget(parent) | 68 | : QWidget(parent) | ||
69 | { | 69 | { | ||
70 | setupUi(this); | 70 | setupUi(this); | ||
71 | } | 71 | } | ||
72 | 72 | | |||
Show All 23 Lines | 83 | { | |||
96 | qmlRegisterType<QAbstractItemModel>(); | 96 | qmlRegisterType<QAbstractItemModel>(); | ||
97 | QWidget *widget = QWidget::createWindowContainer(m_quickView, this); | 97 | QWidget *widget = QWidget::createWindowContainer(m_quickView, this); | ||
98 | QVBoxLayout* layout = new QVBoxLayout(m_ui->view); | 98 | QVBoxLayout* layout = new QVBoxLayout(m_ui->view); | ||
99 | layout->setContentsMargins(0,0,0,0); | 99 | layout->setContentsMargins(0,0,0,0); | ||
100 | layout->addWidget(widget); | 100 | layout->addWidget(widget); | ||
101 | 101 | | |||
102 | m_quickView->rootContext()->setContextProperty(QStringLiteral("decorationsModel"), m_proxyModel); | 102 | m_quickView->rootContext()->setContextProperty(QStringLiteral("decorationsModel"), m_proxyModel); | ||
103 | updateColors(); | 103 | updateColors(); | ||
104 | m_quickView->rootContext()->setContextProperty("_borderSizesIndex", 3); // 3 is normal | 104 | m_quickView->rootContext()->setContextProperty("_borderSizesIndex", 0); // 0 is none | ||
105 | m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons); | 105 | m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons); | ||
106 | m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons); | 106 | m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons); | ||
107 | m_quickView->rootContext()->setContextProperty("availableButtons", m_availableButtons); | 107 | m_quickView->rootContext()->setContextProperty("availableButtons", m_availableButtons); | ||
108 | 108 | | |||
109 | m_quickView->rootContext()->setContextProperty("titleFont", QFontDatabase::systemFont(QFontDatabase::TitleFont)); | 109 | m_quickView->rootContext()->setContextProperty("titleFont", QFontDatabase::systemFont(QFontDatabase::TitleFont)); | ||
110 | m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); | 110 | m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); | ||
111 | m_quickView->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/kcm_kwindecoration/main.qml")))); | 111 | m_quickView->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/kcm_kwindecoration/main.qml")))); | ||
112 | if (m_quickView->status() == QQuickView::Ready) { | 112 | if (m_quickView->status() == QQuickView::Ready) { | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | |||||
216 | ConfigurationModule::~ConfigurationModule() = default; | 216 | ConfigurationModule::~ConfigurationModule() = default; | ||
217 | 217 | | |||
218 | void ConfigurationModule::showEvent(QShowEvent *ev) | 218 | void ConfigurationModule::showEvent(QShowEvent *ev) | ||
219 | { | 219 | { | ||
220 | KCModule::showEvent(ev); | 220 | KCModule::showEvent(ev); | ||
221 | } | 221 | } | ||
222 | 222 | | |||
223 | static const QMap<QString, KDecoration2::BorderSize> s_sizes = QMap<QString, KDecoration2::BorderSize>({ | 223 | static const QMap<QString, KDecoration2::BorderSize> s_sizes = QMap<QString, KDecoration2::BorderSize>({ | ||
224 | {QStringLiteral("None"), BorderSize::None}, | 224 | {s_defaultBorderSize, BorderSize::None}, | ||
225 | {QStringLiteral("NoSides"), BorderSize::NoSides}, | 225 | {QStringLiteral("NoSides"), BorderSize::NoSides}, | ||
226 | {QStringLiteral("Tiny"), BorderSize::Tiny}, | 226 | {QStringLiteral("Tiny"), BorderSize::Tiny}, | ||
227 | {s_borderSizeNormal, BorderSize::Normal}, | 227 | {QStringLiteral("Normal"), BorderSize::Normal}, | ||
228 | {QStringLiteral("Large"), BorderSize::Large}, | 228 | {QStringLiteral("Large"), BorderSize::Large}, | ||
229 | {QStringLiteral("VeryLarge"), BorderSize::VeryLarge}, | 229 | {QStringLiteral("VeryLarge"), BorderSize::VeryLarge}, | ||
230 | {QStringLiteral("Huge"), BorderSize::Huge}, | 230 | {QStringLiteral("Huge"), BorderSize::Huge}, | ||
231 | {QStringLiteral("VeryHuge"), BorderSize::VeryHuge}, | 231 | {QStringLiteral("VeryHuge"), BorderSize::VeryHuge}, | ||
232 | {QStringLiteral("Oversized"), BorderSize::Oversized} | 232 | {QStringLiteral("Oversized"), BorderSize::Oversized} | ||
233 | }); | 233 | }); | ||
234 | 234 | | |||
235 | static BorderSize stringToSize(const QString &name) | 235 | static BorderSize stringToSize(const QString &name) | ||
236 | { | 236 | { | ||
237 | auto it = s_sizes.constFind(name); | 237 | auto it = s_sizes.constFind(name); | ||
238 | if (it == s_sizes.constEnd()) { | 238 | if (it == s_sizes.constEnd()) { | ||
239 | // non sense values are interpreted just like normal | 239 | // nonsense values are interpreted just like none | ||
240 | return BorderSize::Normal; | 240 | return BorderSize::None; | ||
241 | } | 241 | } | ||
242 | return it.value(); | 242 | return it.value(); | ||
243 | } | 243 | } | ||
244 | 244 | | |||
245 | static QString sizeToString(BorderSize size) | 245 | static QString sizeToString(BorderSize size) | ||
246 | { | 246 | { | ||
247 | return s_sizes.key(size, s_borderSizeNormal); | 247 | return s_sizes.key(size, s_defaultBorderSize); | ||
248 | } | 248 | } | ||
249 | 249 | | |||
250 | static QHash<KDecoration2::DecorationButtonType, QChar> s_buttonNames; | 250 | static QHash<KDecoration2::DecorationButtonType, QChar> s_buttonNames; | ||
251 | static void initButtons() | 251 | static void initButtons() | ||
252 | { | 252 | { | ||
253 | if (!s_buttonNames.isEmpty()) { | 253 | if (!s_buttonNames.isEmpty()) { | ||
254 | return; | 254 | return; | ||
255 | } | 255 | } | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
303 | 303 | | |||
304 | void ConfigurationModule::load() | 304 | void ConfigurationModule::load() | ||
305 | { | 305 | { | ||
306 | s_loading = true; | 306 | s_loading = true; | ||
307 | const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); | 307 | const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); | ||
308 | const QString plugin = config.readEntry("library", s_defaultPlugin); | 308 | const QString plugin = config.readEntry("library", s_defaultPlugin); | ||
309 | const QString theme = config.readEntry("theme", s_defaultTheme); | 309 | const QString theme = config.readEntry("theme", s_defaultTheme); | ||
310 | m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); | 310 | m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); | ||
311 | const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal))); | 311 | const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_defaultBorderSize))); | ||
312 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); | 312 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); | ||
313 | 313 | | |||
314 | int themeIndex = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row(); | 314 | int themeIndex = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row(); | ||
315 | m_quickView->rootContext()->setContextProperty("savedIndex", themeIndex); | 315 | m_quickView->rootContext()->setContextProperty("savedIndex", themeIndex); | ||
316 | 316 | | |||
317 | // buttons | 317 | // buttons | ||
318 | const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{ | 318 | const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{ | ||
319 | KDecoration2::DecorationButtonType::Menu, | 319 | KDecoration2::DecorationButtonType::Menu, | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
374 | } | 374 | } | ||
375 | 375 | | |||
376 | void ConfigurationModule::defaults() | 376 | void ConfigurationModule::defaults() | ||
377 | { | 377 | { | ||
378 | if (auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView")) { | 378 | if (auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView")) { | ||
379 | const QModelIndex index = m_proxyModel->mapFromSource(m_model->findDecoration(s_defaultPlugin)); | 379 | const QModelIndex index = m_proxyModel->mapFromSource(m_model->findDecoration(s_defaultPlugin)); | ||
380 | listView->setProperty("currentIndex", index.isValid() ? index.row() : -1); | 380 | listView->setProperty("currentIndex", index.isValid() ? index.row() : -1); | ||
381 | } | 381 | } | ||
382 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(QVariant::fromValue(stringToSize(s_borderSizeNormal)))); | 382 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(QVariant::fromValue(stringToSize(s_defaultBorderSize)))); | ||
383 | m_ui->closeWindowsDoubleClick->setChecked(false); | 383 | m_ui->closeWindowsDoubleClick->setChecked(false); | ||
384 | KCModule::defaults(); | 384 | KCModule::defaults(); | ||
385 | } | 385 | } | ||
386 | 386 | | |||
387 | void ConfigurationModule::showKNS(const QString &config) | 387 | void ConfigurationModule::showKNS(const QString &config) | ||
388 | { | 388 | { | ||
389 | QPointer<KNS3::DownloadDialog> downloadDialog = new KNS3::DownloadDialog(config, this); | 389 | QPointer<KNS3::DownloadDialog> downloadDialog = new KNS3::DownloadDialog(config, this); | ||
390 | if (downloadDialog->exec() == QDialog::Accepted && !downloadDialog->changedEntries().isEmpty()) { | 390 | if (downloadDialog->exec() == QDialog::Accepted && !downloadDialog->changedEntries().isEmpty()) { | ||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
That variable name is misleading. Especially on line 224.
Renaming as border size default might be better