diff --git a/kcmkwin/kwinoptions/CMakeLists.txt b/kcmkwin/kwinoptions/CMakeLists.txt --- a/kcmkwin/kwinoptions/CMakeLists.txt +++ b/kcmkwin/kwinoptions/CMakeLists.txt @@ -17,6 +17,8 @@ moving.ui ) +kconfig_add_kcfg_files(kcm_kwinoptions_PART_SRCS kwinoptions_settings.kcfgc GENERATE_MOC) + qt5_add_dbus_interface(kcm_kwinoptions_PART_SRCS ${KWin_SOURCE_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface) add_library(kcm_kwinoptions MODULE ${kcm_kwinoptions_PART_SRCS}) target_link_libraries(kcm_kwinoptions Qt5::DBus KF5::Completion KF5::I18n KF5::ConfigWidgets KF5::Service KF5::WindowSystem) diff --git a/kcmkwin/kwinoptions/kwinoptions_settings.kcfg b/kcmkwin/kwinoptions/kwinoptions_settings.kcfg new file mode 100644 --- /dev/null +++ b/kcmkwin/kwinoptions/kwinoptions_settings.kcfg @@ -0,0 +1,36 @@ + + + + + + + false + + + + 10 + 0 + 100 + + + + 10 + 0 + 100 + + + + 0 + 0 + 100 + + + + false + + + + diff --git a/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc b/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc new file mode 100644 --- /dev/null +++ b/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc @@ -0,0 +1,6 @@ +File=kwinoptions_settings.kcfg +ClassName=KWinOptionsSettings +Mutators=true +DefaultValueGetters=true +ParentInConstructor=true +Singleton=true diff --git a/kcmkwin/kwinoptions/main.cpp b/kcmkwin/kwinoptions/main.cpp --- a/kcmkwin/kwinoptions/main.cpp +++ b/kcmkwin/kwinoptions/main.cpp @@ -50,7 +50,7 @@ Q_OBJECT public: KMovingConfigStandalone(QWidget* parent, const QVariantList &) - : KMovingConfig(true, new KConfig("kwinrc"), parent) + : KMovingConfig(true, parent) {} }; @@ -88,7 +88,7 @@ tab->addTab(mWindowActions, i18n("W&indow Actions")); connect(mWindowActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool))); - mMoving = new KMovingConfig(false, mConfig, this); + 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))); @@ -230,6 +230,8 @@ { mTitleBarActions->defaults(); mWindowActions->defaults(); + + emit defaulted(true); } void KActionsOptions::moduleChanged(bool state) diff --git a/kcmkwin/kwinoptions/moving.ui b/kcmkwin/kwinoptions/moving.ui --- a/kcmkwin/kwinoptions/moving.ui +++ b/kcmkwin/kwinoptions/moving.ui @@ -20,12 +20,12 @@ Window &geometry: - geometryTipOn + kcfg_GeometryTip - + Enable this option if you want a window's geometry to be displayed while it is being moved or resized. The window position relative to the top-left corner of the screen is displayed together with its size. @@ -40,12 +40,12 @@ Screen &edge snap zone: - borderSnap + kcfg_BorderSnapZone - + Here you can set the snap zone for screen edges, i.e. the 'strength' of the magnetic field which will make windows snap to the border when moved near it. @@ -67,7 +67,7 @@ - + Here you can set the snap zone for windows, i.e. the 'strength' of the magnetic field which will make windows snap to each other when they are moved near another window. @@ -89,7 +89,7 @@ - + Here you can set the snap zone for the screen center, i.e. the 'strength' of the magnetic field which will make windows snap to the center of the screen when moved near it. @@ -108,7 +108,7 @@ - + Here you can set that windows will be only snapped if you try to overlap them, i.e. they will not be snapped if the windows comes only near another window or border. @@ -123,7 +123,7 @@ &Window snap zone: - windowSnap + kcfg_WindowSnapZone @@ -133,7 +133,7 @@ &Center snap zone: - centerSnap + kcfg_CenterSnapZone @@ -143,7 +143,7 @@ &Snap windows: - OverlapSnap + kcfg_SnapOnlyWhenOverlapping diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h --- a/kcmkwin/kwinoptions/windows.h +++ b/kcmkwin/kwinoptions/windows.h @@ -41,6 +41,7 @@ class KColorButton; +class KWinOptionsSettings; class KWinFocusConfigForm : public QWidget, public Ui::KWinFocusConfigForm { @@ -118,37 +119,18 @@ { Q_OBJECT public: - KMovingConfig(bool _standAlone, KConfig *config, QWidget *parent); + KMovingConfig(bool _standAlone, QWidget *parent); ~KMovingConfig() override; - void load() override; void save() override; - void defaults() override; protected: void showEvent(QShowEvent *ev) override; -private Q_SLOTS: - void changed() { - emit KCModule::changed(true); - } - private: - bool getGeometryTip(void); //KS - - void setGeometryTip(bool); //KS - - KConfig *config; + KWinOptionsSettings *m_config; bool standAlone; KWinMovingConfigForm *m_ui; - - int getBorderSnapZone(); - void setBorderSnapZone(int); - int getWindowSnapZone(); - void setWindowSnapZone(int); - int getCenterSnapZone(); - void setCenterSnapZone(int); - }; class KAdvancedConfig : public KCModule diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -37,13 +37,13 @@ #include #include "windows.h" +#include "kwinoptions_settings.h" #include #include // kwin config keywords #define KWIN_FOCUS "FocusPolicy" #define KWIN_PLACEMENT "Placement" -#define KWIN_GEOMETRY "GeometryTip" #define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval" #define KWIN_AUTORAISE "AutoRaise" #define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval" @@ -56,19 +56,6 @@ #define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus" #define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen" -//CT 15mar 98 - magics -#define KWM_BRDR_SNAP_ZONE "BorderSnapZone" -#define KWM_BRDR_SNAP_ZONE_DEFAULT 10 -#define KWM_WNDW_SNAP_ZONE "WindowSnapZone" -#define KWM_WNDW_SNAP_ZONE_DEFAULT 10 -#define KWM_CNTR_SNAP_ZONE "CenterSnapZone" -#define KWM_CNTR_SNAP_ZONE_DEFAULT 0 - -#define MAX_BRDR_SNAP 100 -#define MAX_WNDW_SNAP 100 -#define MAX_CNTR_SNAP 100 -#define MAX_EDGE_RES 1000 - #define CLICK_TO_FOCUS 0 #define FOCUS_FOLLOWS_MOUSE 2 #define FOCUS_UNDER_MOUSE 4 @@ -492,34 +479,16 @@ KMovingConfig::~KMovingConfig() { - if (standAlone) - delete config; } -KMovingConfig::KMovingConfig(bool _standAlone, KConfig *_config, QWidget *parent) - : KCModule(parent), config(_config), standAlone(_standAlone) +KMovingConfig::KMovingConfig(bool _standAlone, QWidget *parent) + : KCModule(parent), m_config(KWinOptionsSettings::self()), standAlone(_standAlone) , m_ui(new KWinMovingConfigForm(this)) { - // Any changes goes to slotChanged() - connect(m_ui->geometryTipOn, SIGNAL(clicked()), SLOT(changed())); - connect(m_ui->borderSnap, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(m_ui->windowSnap, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(m_ui->centerSnap, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(m_ui->OverlapSnap, SIGNAL(clicked()), SLOT(changed())); - + addConfig(m_config, m_ui); load(); } -void KMovingConfig::setGeometryTip(bool showGeometryTip) -{ - m_ui->geometryTipOn->setChecked(showGeometryTip); -} - -bool KMovingConfig::getGeometryTip() -{ - return m_ui->geometryTipOn->isChecked(); -} - void KMovingConfig::showEvent(QShowEvent *ev) { if (!standAlone) { @@ -529,54 +498,11 @@ KCModule::showEvent(ev); } -void KMovingConfig::load(void) -{ - QString key; - - KConfigGroup cg(config, "Windows"); - - //KS 10Jan2003 - Geometry Tip during window move/resize - bool showGeomTip = cg.readEntry(KWIN_GEOMETRY, false); - setGeometryTip(showGeomTip); - - - int v; - - v = cg.readEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT); - if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP); - else if (v < 0) setBorderSnapZone(0); - else setBorderSnapZone(v); - - v = cg.readEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT); - if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP); - else if (v < 0) setWindowSnapZone(0); - else setWindowSnapZone(v); - - v = cg.readEntry(KWM_CNTR_SNAP_ZONE, KWM_CNTR_SNAP_ZONE_DEFAULT); - if (v > MAX_CNTR_SNAP) setCenterSnapZone(MAX_CNTR_SNAP); - else if (v < 0) setCenterSnapZone(0); - else setCenterSnapZone(v); - - m_ui->OverlapSnap->setChecked(cg.readEntry("SnapOnlyWhenOverlapping", false)); - emit KCModule::changed(false); -} - void KMovingConfig::save(void) { - KConfigGroup cg(config, "Windows"); - cg.writeEntry(KWIN_GEOMETRY, getGeometryTip()); - - - cg.writeEntry(KWM_BRDR_SNAP_ZONE, getBorderSnapZone()); - cg.writeEntry(KWM_WNDW_SNAP_ZONE, getWindowSnapZone()); - cg.writeEntry(KWM_CNTR_SNAP_ZONE, getCenterSnapZone()); - cg.writeEntry("SnapOnlyWhenOverlapping", m_ui->OverlapSnap->isChecked()); - - const bool geometryTip = getGeometryTip(); - KConfigGroup(config, "Plugins").writeEntry("windowgeometryEnabled", geometryTip); + m_config->save(); if (standAlone) { - config->sync(); // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); @@ -586,54 +512,9 @@ OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); - if (geometryTip) { + if (m_config->geometryTip()) { interface.loadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); } else { interface.unloadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); } - emit KCModule::changed(false); } - -void KMovingConfig::defaults() -{ - setGeometryTip(false); - - //copied from kcontrol/konq/kwindesktop, aleXXX - setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT); - setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT); - setCenterSnapZone(KWM_CNTR_SNAP_ZONE_DEFAULT); - m_ui->OverlapSnap->setChecked(false); - - emit KCModule::changed(true); -} - -int KMovingConfig::getBorderSnapZone() -{ - return m_ui->borderSnap->value(); -} - -void KMovingConfig::setBorderSnapZone(int pxls) -{ - m_ui->borderSnap->setValue(pxls); -} - -int KMovingConfig::getWindowSnapZone() -{ - return m_ui->windowSnap->value(); -} - -void KMovingConfig::setWindowSnapZone(int pxls) -{ - m_ui->windowSnap->setValue(pxls); -} - -int KMovingConfig::getCenterSnapZone() -{ - return m_ui->centerSnap->value(); -} - -void KMovingConfig::setCenterSnapZone(int pxls) -{ - m_ui->centerSnap->setValue(pxls); -} -