Commit 3f7fa8e4 authored by Méven Car's avatar Méven Car

kcms/kwinoptions : convert Advanced part to KConfigXT

Reviewers: ervin, #kwin, bport, crossi, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27171
parent 90489bde
......@@ -20,14 +20,14 @@
<string>Window &amp;unshading:</string>
</property>
<property name="buddy">
<cstring>shadeHoverOn</cstring>
<cstring>kcfg_ShadeHover</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QCheckBox" name="shadeHoverOn">
<widget class="QCheckBox" name="kcfg_ShadeHover">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If this option is enabled, a shaded window will unshade automatically when the mouse pointer has been over the titlebar for some time.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
......@@ -37,7 +37,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="shadeHover">
<widget class="QSpinBox" name="kcfg_ShadeHoverInterval">
<property name="whatsThis">
<string>Sets the time in milliseconds before the window unshades when the mouse pointer goes over the shaded window.</string>
</property>
......@@ -66,12 +66,12 @@
<string>Window &amp;placement:</string>
</property>
<property name="buddy">
<cstring>placementCombo</cstring>
<cstring>kcfg_Placement</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="placementCombo">
<widget class="KComboBox" name="kcfg_Placement">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The placement policy determines where a new window will appear on the desktop.&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Smart&lt;/span&gt; will try to achieve a minimum overlap of windows&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Maximizing&lt;/span&gt; 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.&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Cascade&lt;/span&gt; will cascade the windows&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Random&lt;/span&gt; will use a random position&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Centered&lt;/span&gt; will place the window centered&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Zero-cornered&lt;/span&gt; will place the window in the top-left corner&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Under mouse&lt;/span&gt; will place the window under the pointer&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
......@@ -118,12 +118,12 @@
<string>&amp;Special windows:</string>
</property>
<property name="buddy">
<cstring>hideUtilityWindowsForInactive</cstring>
<cstring>kcfg_HideUtilityWindowsForInactive</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="hideUtilityWindowsForInactive">
<widget class="QCheckBox" name="kcfg_HideUtilityWindowsForInactive">
<property name="whatsThis">
<string>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.</string>
</property>
......
......@@ -32,5 +32,31 @@
<default>false</default>
</entry>
<entry key="ShadeHover" type="Bool">
<default>false</default>
</entry>
<entry key="ShadeHoverInterval" type="Int">
<default>250</default>
<min>0</min>
</entry>
<entry name="Placement" type="Enum">
<choices name="PlacementChoices">
<choice name="Smart"></choice>
<choice name="Maximizing"></choice>
<choice name="Cascade"></choice>
<choice name="Random"></choice>
<choice name="Centered"></choice>
<choice name="ZeroCornered"></choice>
<choice name="UnderMouse"></choice>
</choices>
<default>0</default>
</entry>
<entry key="HideUtilityWindowsForInactive" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>
......@@ -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<bool>(&KCModule::changed), this, qOverload<bool>(&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<bool>(&KCModule::changed), this, qOverload<bool>(&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<bool>(&KCModule::changed), this, qOverload<bool>(&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<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mMoving, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&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<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mAdvanced, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&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<bool>(&KCModule::changed), this, qOverload<bool>(&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<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
}
KActionsOptions::~KActionsOptions()
......
......@@ -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");
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()));
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();
}
addConfig(m_config, this);
void KAdvancedConfig::shadeHoverChanged(bool a)
{
m_ui->shadeHover->setEnabled(a);
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::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();
}
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment