Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/kcm.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 83 | { | |||
---|---|---|---|---|---|
93 | 93 | | |||
94 | qmlRegisterType<QAbstractItemModel>(); | 94 | qmlRegisterType<QAbstractItemModel>(); | ||
95 | QWidget *widget = QWidget::createWindowContainer(m_quickView, this); | 95 | QWidget *widget = QWidget::createWindowContainer(m_quickView, this); | ||
96 | QVBoxLayout* layout = new QVBoxLayout(m_ui->view); | 96 | QVBoxLayout* layout = new QVBoxLayout(m_ui->view); | ||
97 | layout->setContentsMargins(0,0,0,0); | 97 | layout->setContentsMargins(0,0,0,0); | ||
98 | layout->addWidget(widget); | 98 | layout->addWidget(widget); | ||
99 | 99 | | |||
100 | m_quickView->rootContext()->setContextProperty(QStringLiteral("decorationsModel"), m_proxyModel); | 100 | m_quickView->rootContext()->setContextProperty(QStringLiteral("decorationsModel"), m_proxyModel); | ||
101 | //this should be the only context property | ||||
102 | m_quickView->rootContext()->setContextProperty(QStringLiteral("kcm"), this); | ||||
davidedmundson: We can't do this.
You've just restored the crash when hitting back.
See… | |||||
mart: aww, right, this one is a qwidget,
will move it into the model code | |||||
101 | updateColors(); | 103 | updateColors(); | ||
102 | m_quickView->rootContext()->setContextProperty("_borderSizesIndex", 3); // 3 is normal | 104 | m_quickView->rootContext()->setContextProperty("_borderSizesIndex", 3); // 3 is normal | ||
103 | m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons); | 105 | m_quickView->rootContext()->setContextProperty("leftButtons", m_leftButtons); | ||
104 | m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons); | 106 | m_quickView->rootContext()->setContextProperty("rightButtons", m_rightButtons); | ||
105 | m_quickView->rootContext()->setContextProperty("availableButtons", m_availableButtons); | 107 | m_quickView->rootContext()->setContextProperty("availableButtons", m_availableButtons); | ||
106 | 108 | | |||
107 | m_quickView->rootContext()->setContextProperty("titleFont", QFontDatabase::systemFont(QFontDatabase::TitleFont)); | 109 | m_quickView->rootContext()->setContextProperty("titleFont", QFontDatabase::systemFont(QFontDatabase::TitleFont)); | ||
108 | m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); | 110 | m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); | ||
▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Line(s) | 293 | for (auto it2 = s_buttonNames.constBegin(); it2 != s_buttonNames.constEnd(); ++it2) { | |||
294 | } | 296 | } | ||
295 | } | 297 | } | ||
296 | } | 298 | } | ||
297 | return ret; | 299 | return ret; | ||
298 | }; | 300 | }; | ||
299 | return buttonsFromString(config.readEntry(key, buttonsToString(defaultValue))); | 301 | return buttonsFromString(config.readEntry(key, buttonsToString(defaultValue))); | ||
300 | } | 302 | } | ||
301 | 303 | | |||
304 | int ConfigurationModule::savedIndex() const | ||||
305 | { | ||||
306 | const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); | ||||
307 | const QString plugin = config.readEntry("library", s_defaultPlugin); | ||||
308 | const QString theme = config.readEntry("theme", s_defaultTheme); | ||||
309 | return m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)).row(); | ||||
310 | } | ||||
311 | | ||||
302 | void ConfigurationModule::load() | 312 | void ConfigurationModule::load() | ||
303 | { | 313 | { | ||
304 | s_loading = true; | 314 | s_loading = true; | ||
305 | const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); | 315 | const KConfigGroup config = KSharedConfig::openConfig("kwinrc")->group(s_pluginName); | ||
306 | const QString plugin = config.readEntry("library", s_defaultPlugin); | 316 | const QString plugin = config.readEntry("library", s_defaultPlugin); | ||
307 | const QString theme = config.readEntry("theme", s_defaultTheme); | 317 | const QString theme = config.readEntry("theme", s_defaultTheme); | ||
308 | const QModelIndex index = m_proxyModel->mapFromSource(m_model->findDecoration(plugin, theme)); | | |||
309 | if (auto listView = m_quickView->rootObject()->findChild<QQuickItem*>("listView")) { | | |||
310 | listView->setProperty("currentIndex", index.isValid() ? index.row() : -1); | | |||
311 | } | | |||
312 | m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); | 318 | m_ui->closeWindowsDoubleClick->setChecked(config.readEntry("CloseOnDoubleClickOnMenu", false)); | ||
We're doing the exact same logic here. Duplicating it without deleting this is definitely wrong. It looks like this should work as we've loaded the model and the model is populated at startup. Or at an absolute minimum delete this. davidedmundson: We're doing the exact same logic here. Duplicating it without deleting this is definitely wrong. | |||||
can be safely deleted. mart: can be safely deleted.
it was working because was selecting the same index, makigng this… | |||||
313 | const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal))); | 319 | const QVariant border = QVariant::fromValue(stringToSize(config.readEntry("BorderSize", s_borderSizeNormal))); | ||
314 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); | 320 | m_ui->borderSizesCombo->setCurrentIndex(m_ui->borderSizesCombo->findData(border)); | ||
315 | 321 | | |||
316 | // buttons | 322 | // buttons | ||
317 | const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{ | 323 | const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector<KDecoration2::DecorationButtonType >{ | ||
318 | KDecoration2::DecorationButtonType::Menu, | 324 | KDecoration2::DecorationButtonType::Menu, | ||
319 | KDecoration2::DecorationButtonType::OnAllDesktops | 325 | KDecoration2::DecorationButtonType::OnAllDesktops | ||
320 | }); | 326 | }); | ||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |
We can't do this.
You've just restored the crash when hitting back.
See 70d2fb2378d636ef6d052da08417b27c99182fb0