diff --git a/kcmkwin/kwinoptions/main.cpp b/kcmkwin/kwinoptions/main.cpp index 2116567c73..aabf3af347 100644 --- a/kcmkwin/kwinoptions/main.cpp +++ b/kcmkwin/kwinoptions/main.cpp @@ -42,8 +42,10 @@ class KFocusConfigStandalone : public KFocusConfig Q_OBJECT public: KFocusConfigStandalone(QWidget* parent, const QVariantList &) - : KFocusConfig(true, new KWinOptionsSettings(this), parent) - {} + : KFocusConfig(true, nullptr, parent) + { + initialize(new KWinOptionsSettings(this)); + } }; class KMovingConfigStandalone : public KMovingConfig @@ -51,8 +53,10 @@ class KMovingConfigStandalone : public KMovingConfig Q_OBJECT public: KMovingConfigStandalone(QWidget* parent, const QVariantList &) - : KMovingConfig(true, new KWinOptionsSettings(this), parent) - {} + : KMovingConfig(true, nullptr, parent) + { + initialize(new KWinOptionsSettings(this)); + } }; class KAdvancedConfigStandalone : public KAdvancedConfig @@ -60,8 +64,10 @@ class KAdvancedConfigStandalone : public KAdvancedConfig Q_OBJECT public: KAdvancedConfigStandalone(QWidget* parent, const QVariantList &) - : KAdvancedConfig(true, new KWinOptionsSettings(this), parent) - {} + : KAdvancedConfig(true, nullptr, parent) + { + initialize(new KWinOptionsSettings(this)); + } }; KWinOptions::KWinOptions(QWidget *parent, const QVariantList &) diff --git a/kcmkwin/kwinoptions/mouse.cpp b/kcmkwin/kwinoptions/mouse.cpp index a1f0fc8103..c1d6a370cf 100644 --- a/kcmkwin/kwinoptions/mouse.cpp +++ b/kcmkwin/kwinoptions/mouse.cpp @@ -41,8 +41,15 @@ KWinActionsConfigForm::KWinActionsConfigForm(QWidget *parent) KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinMouseConfigForm(this)) - , m_settings(settings) { + if (settings) { + initialize(settings); + } +} + +void KTitleBarActionsConfig::initialize(KWinOptionsSettings *settings) +{ + m_settings = settings; addConfig(m_settings, this); load(); } @@ -77,8 +84,15 @@ void KTitleBarActionsConfig::save() KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinActionsConfigForm(this)) - , m_settings(settings) { + if (settings) { + initialize(settings); + } +} + +void KWindowActionsConfig::initialize(KWinOptionsSettings *settings) +{ + m_settings = settings; addConfig(m_settings, this); load(); } diff --git a/kcmkwin/kwinoptions/mouse.h b/kcmkwin/kwinoptions/mouse.h index 8302e1b232..c70a23afae 100644 --- a/kcmkwin/kwinoptions/mouse.h +++ b/kcmkwin/kwinoptions/mouse.h @@ -59,6 +59,7 @@ public: void save() override; protected: + void initialize(KWinOptionsSettings *settings); void showEvent(QShowEvent *ev) override; void changeEvent(QEvent *ev) override; @@ -80,6 +81,7 @@ public: void save() override; protected: + void initialize(KWinOptionsSettings *settings); void showEvent(QShowEvent *ev) override; private: diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp index ecc81b6538..f88cf9123b 100644 --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -61,8 +61,15 @@ KWinFocusConfigForm::KWinFocusConfigForm(QWidget* parent) KFocusConfig::KFocusConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget * parent) : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinFocusConfigForm(this)) - , m_settings(settings) { + if (settings) { + initialize(settings); + } +} + +void KFocusConfig::initialize(KWinOptionsSettings *settings) +{ + m_settings = settings; addConfig(m_settings, this); connect(m_ui->windowFocusPolicy, qOverload(&QComboBox::currentIndexChanged), this, &KFocusConfig::focusPolicyChanged); @@ -224,8 +231,15 @@ KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent) KAdvancedConfig::KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinAdvancedConfigForm(this)) - , m_settings(settings) { + if (settings) { + initialize(settings); + } +} + +void KAdvancedConfig::initialize(KWinOptionsSettings *settings) +{ + m_settings = settings; addConfig(m_settings, this); m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Smart, "Smart"); @@ -267,10 +281,18 @@ KWinMovingConfigForm::KWinMovingConfigForm(QWidget* parent) } KMovingConfig::KMovingConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) - : KCModule(parent), m_config(settings), standAlone(_standAlone) + : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinMovingConfigForm(this)) { - addConfig(m_config, this); + if (settings) { + initialize(settings); + } +} + +void KMovingConfig::initialize(KWinOptionsSettings *settings) +{ + m_settings = settings; + addConfig(m_settings, this); load(); } @@ -297,7 +319,7 @@ void KMovingConfig::save(void) OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); - if (m_config->geometryTip()) { + if (m_settings->geometryTip()) { interface.loadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); } else { interface.unloadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h index 938411998d..279a968a21 100644 --- a/kcmkwin/kwinoptions/windows.h +++ b/kcmkwin/kwinoptions/windows.h @@ -82,6 +82,7 @@ Q_SIGNALS: void unmanagedWidgetStateChanged(bool changed); protected: + void initialize(KWinOptionsSettings *settings); void showEvent(QShowEvent *ev) override; private Q_SLOTS: @@ -105,10 +106,11 @@ public: void save() override; protected: + void initialize(KWinOptionsSettings *settings); void showEvent(QShowEvent *ev) override; private: - KWinOptionsSettings *m_config; + KWinOptionsSettings *m_settings; bool standAlone; KWinMovingConfigForm *m_ui; }; @@ -122,6 +124,7 @@ public: void save() override; protected: + void initialize(KWinOptionsSettings *settings); void showEvent(QShowEvent *ev) override; private: