kcms/kwinoptions : convert Moving part to KConfigXT
Test Plan: Behavior unchanged Reviewers: ervin, #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D27164
This commit is contained in:
parent
bdd20f61e6
commit
b6ab50e6b7
7 changed files with 67 additions and 158 deletions
|
@ -17,6 +17,8 @@ ki18n_wrap_ui(kcm_kwinoptions_PART_SRCS
|
|||
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)
|
||||
|
|
36
kcmkwin/kwinoptions/kwinoptions_settings.kcfg
Normal file
36
kcmkwin/kwinoptions/kwinoptions_settings.kcfg
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile name="kwinrc"/>
|
||||
|
||||
<group name="Windows">
|
||||
<entry key="GeometryTip" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
||||
<entry key="BorderSnapZone" type="Int">
|
||||
<default>10</default>
|
||||
<min>0</min>
|
||||
<max>100</max>
|
||||
</entry>
|
||||
|
||||
<entry key="WindowSnapZone" type="Int">
|
||||
<default>10</default>
|
||||
<min>0</min>
|
||||
<max>100</max>
|
||||
</entry>
|
||||
|
||||
<entry key="CenterSnapZone" type="Int">
|
||||
<default>0</default>
|
||||
<min>0</min>
|
||||
<max>100</max>
|
||||
</entry>
|
||||
|
||||
<entry key="SnapOnlyWhenOverlapping" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
||||
</group>
|
||||
</kcfg>
|
6
kcmkwin/kwinoptions/kwinoptions_settings.kcfgc
Normal file
6
kcmkwin/kwinoptions/kwinoptions_settings.kcfgc
Normal file
|
@ -0,0 +1,6 @@
|
|||
File=kwinoptions_settings.kcfg
|
||||
ClassName=KWinOptionsSettings
|
||||
Mutators=true
|
||||
DefaultValueGetters=true
|
||||
ParentInConstructor=true
|
||||
Singleton=true
|
|
@ -50,7 +50,7 @@ class KMovingConfigStandalone : public KMovingConfig
|
|||
Q_OBJECT
|
||||
public:
|
||||
KMovingConfigStandalone(QWidget* parent, const QVariantList &)
|
||||
: KMovingConfig(true, new KConfig("kwinrc"), parent)
|
||||
: KMovingConfig(true, parent)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -88,7 +88,7 @@ KWinOptions::KWinOptions(QWidget *parent, const QVariantList &)
|
|||
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 @@ void KActionsOptions::defaults()
|
|||
{
|
||||
mTitleBarActions->defaults();
|
||||
mWindowActions->defaults();
|
||||
|
||||
emit defaulted(true);
|
||||
}
|
||||
|
||||
void KActionsOptions::moduleChanged(bool state)
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
<string>Window &geometry:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>geometryTipOn</cstring>
|
||||
<cstring>kcfg_GeometryTip</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="geometryTipOn">
|
||||
<widget class="QCheckBox" name="kcfg_GeometryTip">
|
||||
<property name="whatsThis">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
|
@ -40,12 +40,12 @@
|
|||
<string>Screen &edge snap zone:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>borderSnap</cstring>
|
||||
<cstring>kcfg_BorderSnapZone</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="borderSnap">
|
||||
<widget class="QSpinBox" name="kcfg_BorderSnapZone">
|
||||
<property name="whatsThis">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
|
@ -67,7 +67,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="windowSnap">
|
||||
<widget class="QSpinBox" name="kcfg_WindowSnapZone">
|
||||
<property name="whatsThis">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
|
@ -89,7 +89,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="centerSnap">
|
||||
<widget class="QSpinBox" name="kcfg_CenterSnapZone">
|
||||
<property name="whatsThis">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
|
@ -108,7 +108,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="OverlapSnap">
|
||||
<widget class="QCheckBox" name="kcfg_SnapOnlyWhenOverlapping">
|
||||
<property name="whatsThis">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
|
@ -123,7 +123,7 @@
|
|||
<string>&Window snap zone:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>windowSnap</cstring>
|
||||
<cstring>kcfg_WindowSnapZone</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -133,7 +133,7 @@
|
|||
<string>&Center snap zone:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>centerSnap</cstring>
|
||||
<cstring>kcfg_CenterSnapZone</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -143,7 +143,7 @@
|
|||
<string>&Snap windows:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>OverlapSnap</cstring>
|
||||
<cstring>kcfg_SnapOnlyWhenOverlapping</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
#include "windows.h"
|
||||
#include "kwinoptions_settings.h"
|
||||
#include <effect_builtins.h>
|
||||
#include <kwin_effects_interface.h>
|
||||
|
||||
// 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 @@ KWinMovingConfigForm::KWinMovingConfigForm(QWidget* parent)
|
|||
|
||||
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 @@ void KMovingConfig::showEvent(QShowEvent *ev)
|
|||
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 @@ void KMovingConfig::save(void)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ class QSpinBox;
|
|||
|
||||
class KColorButton;
|
||||
|
||||
class KWinOptionsSettings;
|
||||
|
||||
class KWinFocusConfigForm : public QWidget, public Ui::KWinFocusConfigForm
|
||||
{
|
||||
|
@ -118,37 +119,18 @@ class KMovingConfig : public KCModule
|
|||
{
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue