diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h --- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h @@ -26,6 +26,8 @@ #include #include +class QQuickItem; + class KPluginFactory; namespace KDecoration2 @@ -70,7 +72,7 @@ KDecoration2::DecorationButton *createButton(KDecoration2::Decoration *decoration, KDecoration2::DecorationButtonType type, QObject *parent = nullptr); public Q_SLOTS: - void configure(); + void configure(QQuickItem *ctx); Q_SIGNALS: void pluginChanged(); diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp --- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp +++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp @@ -36,7 +36,11 @@ #include #include #include +#include +#include +#include #include +#include namespace KDecoration2 { @@ -173,23 +177,24 @@ return m_factory->create(QStringLiteral("button"), parent, QVariantList({QVariant::fromValue(type), QVariant::fromValue(decoration)})); } -void PreviewBridge::configure() +void PreviewBridge::configure(QQuickItem *ctx) { if (!m_valid) { return; } //setup the UI - QDialog dialog; + QDialog *dialog = new QDialog(); + dialog->setAttribute(Qt::WA_DeleteOnClose); if (m_lastCreatedClient) { - dialog.setWindowTitle(m_lastCreatedClient->caption()); + dialog->setWindowTitle(m_lastCreatedClient->caption()); } // create the KCModule through the plugintrader QVariantMap args; if (!m_theme.isNull()) { args.insert(QStringLiteral("theme"), m_theme); } - KCModule *kcm = m_factory->create(QStringLiteral("kcmodule"), &dialog, QVariantList({args})); + KCModule *kcm = m_factory->create(QStringLiteral("kcmodule"), dialog, QVariantList({args})); if (!kcm) { return; } @@ -205,28 +210,35 @@ QStringLiteral("reloadConfig")); QDBusConnection::sessionBus().send(message); }; - connect(&dialog, &QDialog::accepted, this, save); + connect(dialog, &QDialog::accepted, this, save); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Reset, - &dialog); + dialog); QPushButton *reset = buttons->button(QDialogButtonBox::Reset); reset->setEnabled(false); // Here we connect our buttons with the dialog - connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); - connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); + connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject); connect(reset, &QPushButton::clicked, kcm, &KCModule::load); auto changedSignal = static_cast(&KCModule::changed); connect(kcm, changedSignal, reset, &QPushButton::setEnabled); connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults); - QVBoxLayout *layout = new QVBoxLayout(&dialog); + QVBoxLayout *layout = new QVBoxLayout(dialog); layout->addWidget(kcm); layout->addWidget(buttons); - dialog.exec(); + + if (ctx->window()) { + dialog->winId(); // so it creates windowHandle + dialog->windowHandle()->setTransientParent(QQuickRenderControl::renderWindowFor(ctx->window())); + dialog->setModal(true); + } + + dialog->show(); } BridgeItem::BridgeItem(QObject *parent) diff --git a/kcmkwin/kwindecoration/package/contents/ui/Themes.qml b/kcmkwin/kwindecoration/package/contents/ui/Themes.qml --- a/kcmkwin/kwindecoration/package/contents/ui/Themes.qml +++ b/kcmkwin/kwindecoration/package/contents/ui/Themes.qml @@ -40,6 +40,7 @@ view.implicitCellWidth: Kirigami.Units.gridUnit * 18 view.delegate: KCM.GridDelegate { + id: delegate text: model.display thumbnailAvailable: true @@ -101,7 +102,7 @@ onTriggered: { kcm.theme = index view.currentIndex = index - bridgeItem.bridge.configure() + bridgeItem.bridge.configure(delegate) } } ]