diff --git a/kcmkwin/kwinoptions/advanced.ui b/kcmkwin/kwinoptions/advanced.ui index 9d9211084b..76c2f51144 100644 --- a/kcmkwin/kwinoptions/advanced.ui +++ b/kcmkwin/kwinoptions/advanced.ui @@ -20,14 +20,14 @@ Window &unshading: - shadeHoverOn + kcfg_ShadeHover - + <html><head/><body><p>If this option is enabled, a shaded window will unshade automatically when the mouse pointer has been over the titlebar for some time.</p></body></html> @@ -37,7 +37,7 @@ - + Sets the time in milliseconds before the window unshades when the mouse pointer goes over the shaded window. @@ -66,12 +66,12 @@ Window &placement: - placementCombo + kcfg_Placement - + <html><head/><body><p>The placement policy determines where a new window will appear on the desktop.</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Smart</span> will try to achieve a minimum overlap of windows</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Maximizing</span> will try to maximize every window to fill the whole screen. It might be useful to selectively affect placement of some windows using the window-specific settings.</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Cascade</span> will cascade the windows</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Random</span> will use a random position</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Centered</span> will place the window centered</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Zero-cornered</span> will place the window in the top-left corner</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Under mouse</span> will place the window under the pointer</li></ul></body></html> @@ -118,12 +118,12 @@ &Special windows: - hideUtilityWindowsForInactive + kcfg_HideUtilityWindowsForInactive - + When turned on, utility windows (tool windows, torn-off menus,...) of inactive applications will be hidden and will be shown only when the application becomes active. Note that applications have to mark the windows with the proper window type for this feature to work. diff --git a/kcmkwin/kwinoptions/kwinoptions_settings.kcfg b/kcmkwin/kwinoptions/kwinoptions_settings.kcfg index c664ee5dfe..8a3a124aae 100644 --- a/kcmkwin/kwinoptions/kwinoptions_settings.kcfg +++ b/kcmkwin/kwinoptions/kwinoptions_settings.kcfg @@ -32,5 +32,31 @@ false + + false + + + + 250 + 0 + + + + + + + + + + + + + 0 + + + + true + + diff --git a/kcmkwin/kwinoptions/main.cpp b/kcmkwin/kwinoptions/main.cpp index 198e088567..9c0b317e42 100644 --- a/kcmkwin/kwinoptions/main.cpp +++ b/kcmkwin/kwinoptions/main.cpp @@ -59,7 +59,7 @@ class KAdvancedConfigStandalone : public KAdvancedConfig Q_OBJECT public: KAdvancedConfigStandalone(QWidget* parent, const QVariantList &) - : KAdvancedConfig(true, new KConfig("kwinrc"), parent) + : KAdvancedConfig(true, parent) {} }; @@ -76,27 +76,29 @@ KWinOptions::KWinOptions(QWidget *parent, const QVariantList &) mFocus = new KFocusConfig(false, mConfig, this); mFocus->setObjectName(QLatin1String("KWin Focus Config")); tab->addTab(mFocus, i18n("&Focus")); - connect(mFocus, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mFocus, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this); mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); tab->addTab(mTitleBarActions, i18n("Titlebar A&ctions")); - connect(mTitleBarActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mTitleBarActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); mWindowActions = new KWindowActionsConfig(false, mConfig, this); mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); tab->addTab(mWindowActions, i18n("W&indow Actions")); - connect(mWindowActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mWindowActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); mMoving = new KMovingConfig(false, this); mMoving->setObjectName(QLatin1String("KWin Moving")); tab->addTab(mMoving, i18n("Mo&vement")); - connect(mMoving, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mMoving, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); + connect(mMoving, qOverload(&KCModule::defaulted), this, qOverload(&KCModule::defaulted)); - mAdvanced = new KAdvancedConfig(false, mConfig, this); + mAdvanced = new KAdvancedConfig(false, this); mAdvanced->setObjectName(QLatin1String("KWin Advanced")); tab->addTab(mAdvanced, i18n("Adva&nced")); - connect(mAdvanced, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mAdvanced, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); + connect(mAdvanced, qOverload(&KCModule::defaulted), this, qOverload(&KCModule::defaulted)); KAboutData *about = new KAboutData(QStringLiteral("kcmkwinoptions"), i18n("Window Behavior Configuration Module"), @@ -189,12 +191,12 @@ KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &) mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this); mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); tab->addTab(mTitleBarActions, i18n("&Titlebar Actions")); - connect(mTitleBarActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mTitleBarActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); mWindowActions = new KWindowActionsConfig(false, mConfig, this); mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); tab->addTab(mWindowActions, i18n("Window Actio&ns")); - connect(mWindowActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); + connect(mWindowActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); } KActionsOptions::~KActionsOptions() diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp index 2e5f5a041f..a05015031f 100644 --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -43,15 +43,11 @@ // kwin config keywords #define KWIN_FOCUS "FocusPolicy" -#define KWIN_PLACEMENT "Placement" #define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval" #define KWIN_AUTORAISE "AutoRaise" #define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval" #define KWIN_CLICKRAISE "ClickRaise" -#define KWIN_SHADEHOVER "ShadeHover" -#define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval" #define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel" -#define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive" #define KWIN_INACTIVE_SKIP_TASKBAR "InactiveTabsSkipTaskbar" #define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus" #define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen" @@ -357,51 +353,22 @@ KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent) KAdvancedConfig::~KAdvancedConfig() { - if (standAlone) - delete config; } -KAdvancedConfig::KAdvancedConfig(bool _standAlone, KConfig *_config, QWidget *parent) - : KCModule(parent), config(_config), standAlone(_standAlone) +KAdvancedConfig::KAdvancedConfig(bool _standAlone, QWidget *parent) + : KCModule(parent), m_config(KWinOptionsSettings::self()), standAlone(_standAlone) , m_ui(new KWinAdvancedConfigForm(this)) { - m_ui->placementCombo->setItemData(0, "Smart"); - m_ui->placementCombo->setItemData(1, "Maximizing"); - m_ui->placementCombo->setItemData(2, "Cascade"); - m_ui->placementCombo->setItemData(3, "Random"); - m_ui->placementCombo->setItemData(4, "Centered"); - m_ui->placementCombo->setItemData(5, "ZeroCornered"); - m_ui->placementCombo->setItemData(6, "UnderMouse"); + addConfig(m_config, this); - connect(m_ui->shadeHoverOn, SIGNAL(toggled(bool)), this, SLOT(shadeHoverChanged(bool))); - connect(m_ui->shadeHoverOn, SIGNAL(toggled(bool)), SLOT(changed())); - connect(m_ui->shadeHover, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(m_ui->placementCombo, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->hideUtilityWindowsForInactive, SIGNAL(toggled(bool)), SLOT(changed())); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Smart, "Smart"); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Maximizing, "Maximizing"); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Cascade, "Cascade"); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Random, "Random"); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Centered, "Centered"); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::ZeroCornered, "ZeroCornered"); + m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::UnderMouse, "UnderMouse"); load(); - -} - -void KAdvancedConfig::setShadeHover(bool on) -{ - m_ui->shadeHoverOn->setChecked(on); - m_ui->shadeHover->setEnabled(on); -} - -void KAdvancedConfig::setShadeHoverInterval(int k) -{ - m_ui->shadeHover->setValue(k); -} - -int KAdvancedConfig::getShadeHoverInterval() -{ - - return m_ui->shadeHover->value(); -} - -void KAdvancedConfig::shadeHoverChanged(bool a) -{ - m_ui->shadeHover->setEnabled(a); } void KAdvancedConfig::showEvent(QShowEvent *ev) @@ -413,62 +380,17 @@ void KAdvancedConfig::showEvent(QShowEvent *ev) KCModule::showEvent(ev); } -void KAdvancedConfig::load(void) -{ - KConfigGroup cg(config, "Windows"); - - setShadeHover(cg.readEntry(KWIN_SHADEHOVER, false)); - setShadeHoverInterval(cg.readEntry(KWIN_SHADEHOVER_INTERVAL, 250)); - - QString key; - key = cg.readEntry(KWIN_PLACEMENT); - int idx = m_ui->placementCombo->findData(key); - if (idx < 0) - idx = m_ui->placementCombo->findData("Smart"); - m_ui->placementCombo->setCurrentIndex(idx); - - setHideUtilityWindowsForInactive(cg.readEntry(KWIN_HIDE_UTILITY, true)); - - emit KCModule::changed(false); -} - void KAdvancedConfig::save(void) { - int v; - - KConfigGroup cg(config, "Windows"); - cg.writeEntry(KWIN_SHADEHOVER, m_ui->shadeHoverOn->isChecked()); - - v = getShadeHoverInterval(); - if (v < 0) v = 0; - cg.writeEntry(KWIN_SHADEHOVER_INTERVAL, v); - cg.writeEntry(KWIN_PLACEMENT, m_ui->placementCombo->itemData(m_ui->placementCombo->currentIndex()).toString()); - cg.writeEntry(KWIN_HIDE_UTILITY, m_ui->hideUtilityWindowsForInactive->isChecked()); + KCModule::save(); if (standAlone) { - config->sync(); // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); } - emit KCModule::changed(false); -} - -void KAdvancedConfig::defaults() -{ - setShadeHover(false); - setShadeHoverInterval(250); - m_ui->placementCombo->setCurrentIndex(0); // default to Smart - setHideUtilityWindowsForInactive(true); - emit KCModule::changed(true); -} - - -void KAdvancedConfig::setHideUtilityWindowsForInactive(bool s) -{ - m_ui->hideUtilityWindowsForInactive->setChecked(s); } KWinMovingConfigForm::KWinMovingConfigForm(QWidget* parent) @@ -485,7 +407,7 @@ KMovingConfig::KMovingConfig(bool _standAlone, QWidget *parent) : KCModule(parent), m_config(KWinOptionsSettings::self()), standAlone(_standAlone) , m_ui(new KWinMovingConfigForm(this)) { - addConfig(m_config, m_ui); + addConfig(m_config, this); load(); } diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h index 2c24151429..80f6ac3d6c 100644 --- a/kcmkwin/kwinoptions/windows.h +++ b/kcmkwin/kwinoptions/windows.h @@ -137,34 +137,19 @@ class KAdvancedConfig : public KCModule { Q_OBJECT public: - KAdvancedConfig(bool _standAlone, KConfig *config, QWidget *parent); + KAdvancedConfig(bool _standAlone, QWidget *parent); ~KAdvancedConfig() override; - void load() override; void save() override; - void defaults() override; protected: void showEvent(QShowEvent *ev) override; -private Q_SLOTS: - void shadeHoverChanged(bool); - - void changed() { - emit KCModule::changed(true); - } - private: - int getShadeHoverInterval(void); - void setShadeHover(bool); - void setShadeHoverInterval(int); - - KConfig *config; + KWinOptionsSettings *m_config; bool standAlone; KWinAdvancedConfigForm *m_ui; - - void setHideUtilityWindowsForInactive(bool); }; #endif // KKWMWINDOWS_H