Commit 5498ed95 authored by Méven Car's avatar Méven Car Committed by Méven Car

KCM/Kwinoptions: Port focus tab to KConfigXT

Summary:
* remove singleton of KWinOptionsSettings

Depends on D27477

Test Plan:
* No functional change
* default / reset button work as expected.

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

Reviewed By: ervin, #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27934
parent 519c4df5
......@@ -22,12 +22,12 @@
<string>Window &amp;activation policy:</string>
</property>
<property name="buddy">
<cstring>windowFocusPolicyCombo</cstring>
<cstring>windowFocusPolicy</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="windowFocusPolicyCombo">
<widget class="QComboBox" name="windowFocusPolicy">
<property name="whatsThis">
<string>With this option you can specify how and when windows will be focused.</string>
</property>
......@@ -72,12 +72,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>delayFocus</cstring>
<cstring>kcfg_DelayFocusInterval</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="delayFocus">
<widget class="QSpinBox" name="kcfg_DelayFocusInterval">
<property name="whatsThis">
<string>This is the delay after which the window the mouse pointer is over will automatically receive focus.</string>
</property>
......@@ -104,12 +104,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>focusStealing</cstring>
<cstring>kcfg_FocusStealingPreventionLevel</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KComboBox" name="focusStealing">
<widget class="KComboBox" name="kcfg_FocusStealingPreventionLevel">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This option specifies how much KWin will try to prevent unwanted focus stealing caused by unexpected activation of new windows. (Note: This feature does not work with the &lt;span style=&quot; font-style:italic;&quot;&gt;Focus under mouse&lt;/span&gt; or &lt;span style=&quot; font-style:italic;&quot;&gt;Focus strictly under mouse&lt;/span&gt; focus policies.) &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;None:&lt;/span&gt; Prevention is turned off and new windows always become activated.&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;Low:&lt;/span&gt; Prevention is enabled; when some window does not have support for the underlying mechanism and KWin cannot reliably decide whether to activate the window or not, it will be activated. This setting may have both worse and better results than the medium level, depending on the applications.&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;Medium:&lt;/span&gt; Prevention is enabled.&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;High:&lt;/span&gt; New windows get activated only if no window is currently active or if they belong to the currently active application. This setting is probably not really usable when not using mouse focus policy.&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;Extreme:&lt;/span&gt; All windows must be explicitly activated by the user.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Windows that are prevented from stealing focus are marked as demanding attention, which by default means their taskbar entry will be highlighted. This can be changed in the Notifications control module.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
......@@ -148,7 +148,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="clickRaiseOn">
<widget class="QCheckBox" name="kcfg_ClickRaise">
<property name="whatsThis">
<string>When this option is enabled, the active window will be brought to the front when you click somewhere into the window contents. To change it for inactive windows, you need to change the settings in the Actions tab.</string>
</property>
......@@ -160,7 +160,7 @@
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QCheckBox" name="autoRaiseOn">
<widget class="QCheckBox" name="kcfg_AutoRaise">
<property name="whatsThis">
<string>When this option is enabled, a window in the background will automatically come to the front when the mouse pointer has been over it for some time.</string>
</property>
......@@ -170,7 +170,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="autoRaise">
<widget class="QSpinBox" name="kcfg_AutoRaiseInterval">
<property name="whatsThis">
<string>This is the delay after which the window that the mouse pointer is over will automatically come to the front.</string>
</property>
......@@ -198,7 +198,7 @@
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="activeMouseScreen">
<widget class="QCheckBox" name="kcfg_ActiveMouseScreen">
<property name="whatsThis">
<string>When this option is enabled, the active Xinerama screen (where new windows appear, for example) is the screen containing the mouse pointer. When disabled, the active Xinerama screen is the screen containing the focused window. By default this option is disabled for Click to focus and enabled for other focus policies.</string>
</property>
......@@ -208,7 +208,7 @@
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="separateScreenFocus">
<widget class="QCheckBox" name="kcfg_SeparateScreenFocus">
<property name="whatsThis">
<string>When this option is enabled, focus operations are limited only to the active Xinerama screen</string>
</property>
......@@ -261,5 +261,38 @@
</customwidget>
</customwidgets>
<resources/>
<connections/>
<connections>
<connection>
<sender>kcfg_AutoRaise</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_AutoRaiseInterval</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>338</x>
<y>189</y>
</hint>
<hint type="destinationlabel">
<x>485</x>
<y>189</y>
</hint>
</hints>
</connection>
<connection>
<sender>kcfg_AutoRaise</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_ClickRaise</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>338</x>
<y>189</y>
</hint>
<hint type="destinationlabel">
<x>333</x>
<y>155</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -100,6 +100,52 @@
</choices>
</entry>
<entry key="FocusPolicy" type="Enum">
<default>ClickToFocus</default>
<choices>
<choice name="ClickToFocus"/>
<choice name="FocusFollowsMouse"/>
<choice name="FocusUnderMouse"/>
<choice name="FocusStrictlyUnderMouse"/>
</choices>
</entry>
<entry key="NextFocusPrefersMouse" type="Bool">
<default>false</default>
</entry>
<entry key="AutoRaiseInterval" type="Int">
<default>750</default>
<min>0</min>
</entry>
<entry key="DelayFocusInterval" type="Int">
<default>300</default>
<min>0</min>
</entry>
<entry key="AutoRaise" type="Bool">
<default>false</default>
</entry>
<entry key="ClickRaise" type="Bool">
<default>true</default>
</entry>
<entry key="SeparateScreenFocus" type="Bool">
<default>false</default>
</entry>
<entry key="ActiveMouseScreen" type="Bool">
<default>true</default>
</entry>
<entry key="FocusStealingPreventionLevel" type="Int">
<default>1</default>
<min>0</min>
<max>4</max>
</entry>
</group>
<group name="MouseBindings">
......
......@@ -3,4 +3,3 @@ ClassName=KWinOptionsSettings
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true
Singleton=true
......@@ -33,6 +33,7 @@
#include "mouse.h"
#include "windows.h"
#include "kwinoptions_settings.h"
K_PLUGIN_FACTORY_DECLARATION(KWinOptionsFactory)
......@@ -41,7 +42,7 @@ class KFocusConfigStandalone : public KFocusConfig
Q_OBJECT
public:
KFocusConfigStandalone(QWidget* parent, const QVariantList &)
: KFocusConfig(true, new KConfig("kwinrc"), parent)
: KFocusConfig(true, new KWinOptionsSettings(this), parent)
{}
};
......@@ -50,7 +51,7 @@ class KMovingConfigStandalone : public KMovingConfig
Q_OBJECT
public:
KMovingConfigStandalone(QWidget* parent, const QVariantList &)
: KMovingConfig(true, parent)
: KMovingConfig(true, new KWinOptionsSettings(this), parent)
{}
};
......@@ -59,44 +60,49 @@ class KAdvancedConfigStandalone : public KAdvancedConfig
Q_OBJECT
public:
KAdvancedConfigStandalone(QWidget* parent, const QVariantList &)
: KAdvancedConfig(true, parent)
: KAdvancedConfig(true, new KWinOptionsSettings(this), parent)
{}
};
KWinOptions::KWinOptions(QWidget *parent, const QVariantList &)
: KCModule(parent)
{
mConfig = new KConfig("kwinrc");
mSettings = new KWinOptionsSettings(this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
tab = new QTabWidget(this);
layout->addWidget(tab);
mFocus = new KFocusConfig(false, mConfig, this);
mFocus = new KFocusConfig(false, mSettings, this);
mFocus->setObjectName(QLatin1String("KWin Focus Config"));
tab->addTab(mFocus, i18n("&Focus"));
connect(mFocus, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mFocus, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted));
mTitleBarActions = new KTitleBarActionsConfig(false, this);
// Need to relay unmanagedWidgetDefaultState and unmanagedWidgetChangeState to wrapping KCModule
connect(mFocus, &KFocusConfig::unmanagedWidgetDefaulted, this, &KWinOptions::unmanagedWidgetDefaultState);
connect(mFocus, &KFocusConfig::unmanagedWidgetStateChanged, this, &KWinOptions::unmanagedWidgetChangeState);
mTitleBarActions = new KTitleBarActionsConfig(false, mSettings, this);
mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions"));
tab->addTab(mTitleBarActions, i18n("Titlebar A&ctions"));
connect(mTitleBarActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mTitleBarActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted));
mWindowActions = new KWindowActionsConfig(false, this);
mWindowActions = new KWindowActionsConfig(false, mSettings, this);
mWindowActions->setObjectName(QLatin1String("KWin Window Actions"));
tab->addTab(mWindowActions, i18n("W&indow Actions"));
connect(mWindowActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mWindowActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted));
mMoving = new KMovingConfig(false, this);
mMoving = new KMovingConfig(false, mSettings, this);
mMoving->setObjectName(QLatin1String("KWin Moving"));
tab->addTab(mMoving, i18n("Mo&vement"));
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, this);
mAdvanced = new KAdvancedConfig(false, mSettings, this);
mAdvanced->setObjectName(QLatin1String("KWin Advanced"));
tab->addTab(mAdvanced, i18n("Adva&nced"));
connect(mAdvanced, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
......@@ -119,23 +125,17 @@ KWinOptions::KWinOptions(QWidget *parent, const QVariantList &)
setAboutData(about);
}
KWinOptions::~KWinOptions()
{
delete mConfig;
}
void KWinOptions::load()
{
mConfig->reparseConfiguration();
mFocus->load();
mTitleBarActions->load();
mWindowActions->load();
mMoving->load();
mAdvanced->load();
emit KCModule::changed(false);
// mFocus is last because it may send unmanagedWidgetStateChanged
// that need to have the final word
mFocus->load();
}
void KWinOptions::save()
{
mFocus->save();
......@@ -145,8 +145,7 @@ void KWinOptions::save()
mAdvanced->save();
emit KCModule::changed(false);
// Send signal to kwin
mConfig->sync();
// Send signal to all kwin instances
QDBusMessage message =
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
......@@ -156,11 +155,13 @@ void KWinOptions::save()
void KWinOptions::defaults()
{
mFocus->defaults();
mTitleBarActions->defaults();
mWindowActions->defaults();
mMoving->defaults();
mAdvanced->defaults();
// mFocus is last because it may send unmanagedWidgetDefaulted
// that need to have the final word
mFocus->defaults();
}
QString KWinOptions::quickHelp() const
......@@ -176,31 +177,26 @@ QString KWinOptions::quickHelp() const
KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &)
: KCModule(parent)
{
mConfig = new KConfig("kwinrc");
mSettings = new KWinOptionsSettings(this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
tab = new QTabWidget(this);
layout->addWidget(tab);
mTitleBarActions = new KTitleBarActionsConfig(false, this);
mTitleBarActions = new KTitleBarActionsConfig(false, mSettings, this);
mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions"));
tab->addTab(mTitleBarActions, i18n("&Titlebar Actions"));
connect(mTitleBarActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mTitleBarActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted));
mWindowActions = new KWindowActionsConfig(false, this);
mWindowActions = new KWindowActionsConfig(false, mSettings, this);
mWindowActions->setObjectName(QLatin1String("KWin Window Actions"));
tab->addTab(mWindowActions, i18n("Window Actio&ns"));
connect(mWindowActions, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
connect(mWindowActions, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted));
}
KActionsOptions::~KActionsOptions()
{
delete mConfig;
}
void KActionsOptions::load()
{
mTitleBarActions->load();
......@@ -213,8 +209,6 @@ void KActionsOptions::save()
mWindowActions->save();
emit KCModule::changed(false);
// Send signal to kwin
mConfig->sync();
// Send signal to all kwin instances
QDBusMessage message =
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
......
......@@ -28,7 +28,7 @@
#include <QTabWidget>
#include <kcmodule.h>
class KConfig;
class KWinOptionsSettings;
class KFocusConfig;
class KTitleBarActionsConfig;
class KWindowActionsConfig;
......@@ -42,7 +42,6 @@ class KWinOptions : public KCModule
public:
KWinOptions(QWidget *parent, const QVariantList &args);
~KWinOptions() override;
void load() override;
void save() override;
......@@ -59,7 +58,7 @@ private:
KMovingConfig *mMoving;
KAdvancedConfig *mAdvanced;
KConfig *mConfig;
KWinOptionsSettings *mSettings;
};
class KActionsOptions : public KCModule
......@@ -69,7 +68,6 @@ class KActionsOptions : public KCModule
public:
KActionsOptions(QWidget *parent, const QVariantList &args);
~KActionsOptions() override;
void load() override;
void save() override;
......@@ -79,7 +77,6 @@ protected Q_SLOTS:
void moduleChanged(bool state);
private:
QTabWidget *tab;
......@@ -87,7 +84,7 @@ private:
KTitleBarActionsConfig *mTitleBarActions;
KWindowActionsConfig *mWindowActions;
KConfig *mConfig;
KWinOptionsSettings *mSettings;
};
#endif
......@@ -136,11 +136,12 @@ void KTitleBarActionsConfig::paletteChanged()
}
KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, QWidget *parent)
KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent)
: KCModule(parent), standAlone(_standAlone)
, m_ui(new KWinMouseConfigForm(this))
, m_settings(settings)
{
addConfig(KWinOptionsSettings::self(), this);
addConfig(m_settings, this);
// create the items for the maximize button actions
createMaxButtonPixmaps();
......@@ -193,11 +194,12 @@ void KTitleBarActionsConfig::save()
}
}
KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, QWidget *parent)
KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent)
: KCModule(parent), standAlone(_standAlone)
, m_ui(new KWinActionsConfigForm(this))
, m_settings(settings)
{
addConfig(KWinOptionsSettings::self(), this);
addConfig(m_settings, this);
load();
}
......
......@@ -31,6 +31,8 @@ class KConfig;
#include "ui_actions.h"
#include "ui_mouse.h"
class KWinOptionsSettings;
class KWinMouseConfigForm : public QWidget, public Ui::KWinMouseConfigForm
{
Q_OBJECT
......@@ -53,7 +55,7 @@ class KTitleBarActionsConfig : public KCModule
public:
KTitleBarActionsConfig(bool _standAlone, QWidget *parent);
KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent);
void save() override;
......@@ -65,6 +67,7 @@ private:
bool standAlone;
KWinMouseConfigForm *m_ui;
KWinOptionsSettings *m_settings;
void createMaximizeButtonTooltips(KComboBox* combo);
......@@ -79,7 +82,7 @@ class KWindowActionsConfig : public KCModule
public:
KWindowActionsConfig(bool _standAlone, QWidget *parent);
KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent);
void save() override;
......@@ -90,6 +93,7 @@ private:
bool standAlone;
KWinActionsConfigForm *m_ui;
KWinOptionsSettings *m_settings;
};
#endif
......
This diff is collapsed.
......@@ -71,56 +71,36 @@ class KFocusConfig : public KCModule
{
Q_OBJECT
public:
KFocusConfig(bool _standAlone, KConfig *_config, QWidget *parent);
~KFocusConfig() override;
KFocusConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent);
void load() override;
void save() override;
void defaults() override;
Q_SIGNALS:
void unmanagedWidgetDefaulted(bool defaulted);
void unmanagedWidgetStateChanged(bool changed);
protected:
void showEvent(QShowEvent *ev) override;
private Q_SLOTS:
void setDelayFocusEnabled();
void focusPolicyChanged();
void autoRaiseOnTog(bool);//CT 23Oct1998
void delayFocusOnTog(bool);
void updateActiveMouseScreen();
void updateMultiScreen();
void changed() {
emit KCModule::changed(true);
}
private:
int getFocus(void);
int getAutoRaiseInterval(void);
int getDelayFocusInterval(void);
void setFocus(int);
void setAutoRaiseInterval(int);
void setAutoRaise(bool);
void setDelayFocusInterval(int);
void setClickRaise(bool);
void setSeparateScreenFocus(bool);
void setActiveMouseScreen(bool);
void setFocusStealing(int);
KConfig *config;
bool standAlone;
KWinFocusConfigForm *m_ui;
KWinOptionsSettings *m_settings;
};
class KMovingConfig : public KCModule
{
Q_OBJECT
public:
KMovingConfig(bool _standAlone, QWidget *parent);
~KMovingConfig() override;
KMovingConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent);
void save() override;
......@@ -137,8 +117,7 @@ class KAdvancedConfig : public KCModule
{
Q_OBJECT
public:
KAdvancedConfig(bool _standAlone, QWidget *parent);
~KAdvancedConfig() override;
KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent);
void save() override;
......@@ -147,9 +126,9 @@ protected:
private:
KWinOptionsSettings *m_config;
bool standAlone;
KWinAdvancedConfigForm *m_ui;
KWinOptionsSettings *m_settings;
};
#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