diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(PROJECT_VERSION_MAJOR 5) set(QT_MIN_VERSION "5.12.0") -set(KF5_MIN_VERSION "5.66.0") +set(KF5_MIN_VERSION "5.68.0") set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) diff --git a/kcmkwin/kwinoptions/actions.ui b/kcmkwin/kwinoptions/actions.ui --- a/kcmkwin/kwinoptions/actions.ui +++ b/kcmkwin/kwinoptions/actions.ui @@ -29,12 +29,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coWin1 + kcfg_CommandWindow1 - + In this row you can customize left click behavior when clicking into an inactive inner window ('inner' means: not titlebar, not frame). @@ -69,12 +69,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coWin2 + kcfg_CommandWindow2 - + In this row you can customize middle click behavior when clicking into an inactive inner window ('inner' means: not titlebar, not frame). @@ -109,12 +109,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coWin3 + kcfg_CommandWindow3 - + In this row you can customize right click behavior when clicking into an inactive inner window ('inner' means: not titlebar, not frame). @@ -149,12 +149,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coWinWheel + kcfg_CommandWindowWheel - + In this row you can customize behavior when scrolling into an inactive inner window ('inner' means: not titlebar, not frame). @@ -195,12 +195,12 @@ Mo&difier key: - coAllKey + kcfg_CommandAllKey - + Here you select whether holding the Meta key or Alt key will allow you to perform the following actions. @@ -251,12 +251,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coAll1 + kcfg_CommandAll1 - + In this row you can customize left click behavior when clicking into the titlebar or the frame. @@ -321,12 +321,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coAll2 + kcfg_CommandAll2 - + In this row you can customize middle click behavior when clicking into the titlebar or the frame. @@ -391,12 +391,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coAll3 + kcfg_CommandAll3 - + In this row you can customize right click behavior when clicking into the titlebar or the frame. @@ -461,12 +461,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coAllW + kcfg_CommandAllWheel - + Here you can customize KDE's behavior when scrolling with the mouse wheel in a window while pressing the modifier key. diff --git a/kcmkwin/kwinoptions/focus.ui b/kcmkwin/kwinoptions/focus.ui --- a/kcmkwin/kwinoptions/focus.ui +++ b/kcmkwin/kwinoptions/focus.ui @@ -22,12 +22,12 @@ Window &activation policy: - windowFocusPolicyCombo + unmanagedFocusPolicy - + With this option you can specify how and when windows will be focused. @@ -72,12 +72,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - delayFocus + kcfg_DelayFocusInterval - + This is the delay after which the window the mouse pointer is over will automatically receive focus. @@ -104,12 +104,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - focusStealing + kcfg_FocusStealingPreventionLevel - + <html><head/><body><p>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 <span style=" font-style:italic;">Focus under mouse</span> or <span style=" font-style:italic;">Focus strictly under mouse</span> focus policies.) </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;">None:</span> Prevention is turned off and new windows always become activated.</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;">Low:</span> 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.</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;">Medium:</span> Prevention is enabled.</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;">High:</span> 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.</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;">Extreme:</span> All windows must be explicitly activated by the user.</li></ul><p>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.</p></body></html> @@ -148,7 +148,7 @@ - + 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. @@ -160,7 +160,7 @@ - + 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. @@ -170,7 +170,7 @@ - + This is the delay after which the window that the mouse pointer is over will automatically come to the front. @@ -198,7 +198,7 @@ - + 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. @@ -208,7 +208,7 @@ - + When this option is enabled, focus operations are limited only to the active Xinerama screen @@ -261,5 +261,38 @@ - + + + kcfg_AutoRaise + toggled(bool) + kcfg_AutoRaiseInterval + setEnabled(bool) + + + 338 + 189 + + + 485 + 189 + + + + + kcfg_AutoRaise + toggled(bool) + kcfg_ClickRaise + setDisabled(bool) + + + 338 + 189 + + + 333 + 155 + + + + diff --git a/kcmkwin/kwinoptions/kwinoptions_settings.kcfg b/kcmkwin/kwinoptions/kwinoptions_settings.kcfg --- a/kcmkwin/kwinoptions/kwinoptions_settings.kcfg +++ b/kcmkwin/kwinoptions/kwinoptions_settings.kcfg @@ -58,5 +58,311 @@ true + + Maximize + + + + + + + + + + + + + + + Maximize + + + + + + + + + MaximizeVerticalOnly + + + + + + + + + MaximizeVerticalOnly + + + + + + + + + ClickToFocus + + + + + + + + + + false + + + + 750 + 0 + + + + 300 + 0 + + + + false + + + + true + + + + false + + + + true + + + + 1 + 0 + 4 + + + + + + + + Raise + + + + + + + + + + + + + + Nothing + + + + + + + + + + + + + + OperationsMenu + + + + + + + + + + + + + + Nothing + + + + + + + + + + + + + ActivateAndRaise + + + + + + + + + + + + + + + + + Nothing + + + + + + + + + + + + + + + + + OperationsMenu + + + + + + + + + + + + + + + + + ActivateRaisePassClick + + + + + + + + + + ActivatePassClick + + + + + + + + + + ActivatePassClick + + + + + + + + + + Scroll + + + + + + + + + Alt + + + + + + + + Move + + + + + + + + + + + + + + + + ToggleRaiseAndLower + + + + + + + + + + + + + + + + Resize + + + + + + + + + + + + + + + + Nothing + + + + + + + + + + + diff --git a/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc b/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc --- a/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc +++ b/kcmkwin/kwinoptions/kwinoptions_settings.kcfgc @@ -3,4 +3,3 @@ Mutators=true DefaultValueGetters=true ParentInConstructor=true -Singleton=true diff --git a/kcmkwin/kwinoptions/main.h b/kcmkwin/kwinoptions/main.h --- a/kcmkwin/kwinoptions/main.h +++ b/kcmkwin/kwinoptions/main.h @@ -28,7 +28,7 @@ #include #include -class KConfig; +class KWinOptionsSettings; class KFocusConfig; class KTitleBarActionsConfig; class KWindowActionsConfig; @@ -42,19 +42,12 @@ public: KWinOptions(QWidget *parent, const QVariantList &args); - ~KWinOptions() override; void load() override; void save() override; void defaults() override; QString quickHelp() const override; - -protected Q_SLOTS: - - void moduleChanged(bool state); - - private: QTabWidget *tab; @@ -65,7 +58,7 @@ KMovingConfig *mMoving; KAdvancedConfig *mAdvanced; - KConfig *mConfig; + KWinOptionsSettings *mSettings; }; class KActionsOptions : public KCModule @@ -75,7 +68,6 @@ public: KActionsOptions(QWidget *parent, const QVariantList &args); - ~KActionsOptions() override; void load() override; void save() override; @@ -85,15 +77,14 @@ void moduleChanged(bool state); - private: QTabWidget *tab; KTitleBarActionsConfig *mTitleBarActions; KWindowActionsConfig *mWindowActions; - KConfig *mConfig; + KWinOptionsSettings *mSettings; }; #endif diff --git a/kcmkwin/kwinoptions/main.cpp b/kcmkwin/kwinoptions/main.cpp --- a/kcmkwin/kwinoptions/main.cpp +++ b/kcmkwin/kwinoptions/main.cpp @@ -33,68 +33,80 @@ #include "mouse.h" #include "windows.h" +#include "kwinoptions_settings.h" K_PLUGIN_FACTORY_DECLARATION(KWinOptionsFactory) class KFocusConfigStandalone : public KFocusConfig { Q_OBJECT public: KFocusConfigStandalone(QWidget* parent, const QVariantList &) - : KFocusConfig(true, new KConfig("kwinrc"), parent) + : KFocusConfig(true, new KWinOptionsSettings(parent), parent) {} }; class KMovingConfigStandalone : public KMovingConfig { Q_OBJECT public: KMovingConfigStandalone(QWidget* parent, const QVariantList &) - : KMovingConfig(true, parent) + : KMovingConfig(true, new KWinOptionsSettings(parent), parent) {} }; class KAdvancedConfigStandalone : public KAdvancedConfig { Q_OBJECT public: KAdvancedConfigStandalone(QWidget* parent, const QVariantList &) - : KAdvancedConfig(true, parent) + : KAdvancedConfig(true, new KWinOptionsSettings(parent), parent) {} }; KWinOptions::KWinOptions(QWidget *parent, const QVariantList &) : KCModule(parent) { - mConfig = new KConfig("kwinrc"); + mSettings = new KWinOptionsSettings(parent); 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(&KCModule::changed), this, qOverload(&KCModule::changed)); + connect(mFocus, qOverload(&KCModule::defaulted), this, qOverload(&KCModule::defaulted)); - mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this); + // Need to relay unmanagedWidgetDefaultState and unmanagedWidgetChangeState to wrapping KCModule + connect(mFocus, &KFocusConfig::unmanagedWidgetDefaulted, this, [this](bool defaulted){ + unmanagedWidgetDefaultState(defaulted); + }); + connect(mFocus, &KFocusConfig::unmanagedWidgetChanged, this, [this](bool changed){ + unmanagedWidgetChangeState(changed); + }); + + mTitleBarActions = new KTitleBarActionsConfig(false, mSettings, this); mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); tab->addTab(mTitleBarActions, i18n("Titlebar A&ctions")); connect(mTitleBarActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); + connect(mTitleBarActions, qOverload(&KCModule::defaulted), this, qOverload(&KCModule::defaulted)); - mWindowActions = new KWindowActionsConfig(false, mConfig, this); + mWindowActions = new KWindowActionsConfig(false, mSettings, this); mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); tab->addTab(mWindowActions, i18n("W&indow Actions")); connect(mWindowActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); + connect(mWindowActions, qOverload(&KCModule::defaulted), this, qOverload(&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(&KCModule::changed), this, qOverload(&KCModule::changed)); connect(mMoving, qOverload(&KCModule::defaulted), this, qOverload(&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(&KCModule::changed), this, qOverload(&KCModule::changed)); @@ -117,23 +129,15 @@ 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->load(); } - void KWinOptions::save() { mFocus->save(); @@ -143,24 +147,21 @@ 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"); QDBusConnection::sessionBus().send(message); - - } void KWinOptions::defaults() { - mFocus->defaults(); mTitleBarActions->defaults(); mWindowActions->defaults(); mMoving->defaults(); mAdvanced->defaults(); + mFocus->defaults(); } QString KWinOptions::quickHelp() const @@ -173,67 +174,49 @@ " for how to customize window behavior.

"); } -void KWinOptions::moduleChanged(bool state) -{ - emit KCModule::changed(state); -} - KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &) : KCModule(parent) { - mConfig = new KConfig("kwinrc"); + mSettings = new KWinOptionsSettings(parent); QVBoxLayout *layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); tab = new QTabWidget(this); layout->addWidget(tab); - mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this); + mTitleBarActions = new KTitleBarActionsConfig(false, mSettings, this); mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions")); tab->addTab(mTitleBarActions, i18n("&Titlebar Actions")); connect(mTitleBarActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); + connect(mTitleBarActions, qOverload(&KCModule::defaulted), this, qOverload(&KCModule::defaulted)); - mWindowActions = new KWindowActionsConfig(false, mConfig, this); + mWindowActions = new KWindowActionsConfig(false, mSettings, this); mWindowActions->setObjectName(QLatin1String("KWin Window Actions")); tab->addTab(mWindowActions, i18n("Window Actio&ns")); connect(mWindowActions, qOverload(&KCModule::changed), this, qOverload(&KCModule::changed)); -} - -KActionsOptions::~KActionsOptions() -{ - delete mConfig; + connect(mWindowActions, qOverload(&KCModule::defaulted), this, qOverload(&KCModule::defaulted)); } void KActionsOptions::load() { mTitleBarActions->load(); - mWindowActions->load(); - emit KCModule::changed(false); } - void KActionsOptions::save() { mTitleBarActions->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"); QDBusConnection::sessionBus().send(message); - } - void KActionsOptions::defaults() { mTitleBarActions->defaults(); - mWindowActions->defaults(); - - emit defaulted(true); } void KActionsOptions::moduleChanged(bool state) diff --git a/kcmkwin/kwinoptions/mouse.h b/kcmkwin/kwinoptions/mouse.h --- a/kcmkwin/kwinoptions/mouse.h +++ b/kcmkwin/kwinoptions/mouse.h @@ -31,6 +31,8 @@ #include "ui_actions.h" #include "ui_mouse.h" +class KWinOptionsSettings; + class KWinMouseConfigForm : public QWidget, public Ui::KWinMouseConfigForm { Q_OBJECT @@ -53,38 +55,21 @@ public: - KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent); - ~KTitleBarActionsConfig() override; + KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent); - void load() override; void save() override; - void defaults() override; protected: void showEvent(QShowEvent *ev) override; void changeEvent(QEvent *ev) override; -public Q_SLOTS: - void changed() { - emit KCModule::changed(true); - } - private: - - KConfig *config; bool standAlone; KWinMouseConfigForm *m_ui; + KWinOptionsSettings *m_settings; - const char* functionTiDbl(int); - const char* functionTiAc(int); - const char* functionTiWAc(int); - const char* functionTiInAc(int); - const char* functionMax(int); - - void setComboText(KComboBox* combo, const char* text); void createMaximizeButtonTooltips(KComboBox* combo); - const char* fixup(const char* s); private Q_SLOTS: void paletteChanged(); @@ -97,35 +82,18 @@ public: - KWindowActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent); - ~KWindowActionsConfig() override; + KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent); - void load() override; void save() override; - void defaults() override; protected: void showEvent(QShowEvent *ev) override; -public Q_SLOTS: - void changed() { - emit KCModule::changed(true); - } - private: - KConfig *config; bool standAlone; KWinActionsConfigForm *m_ui; - - const char* functionWin(int); - const char* functionWinWheel(int); - const char* functionAllKey(int); - const char* functionAll(int); - const char* functionAllW(int); - - void setComboText(KComboBox* combo, const char* text); - const char* fixup(const char* s); + KWinOptionsSettings *m_settings; }; #endif diff --git a/kcmkwin/kwinoptions/mouse.cpp b/kcmkwin/kwinoptions/mouse.cpp --- a/kcmkwin/kwinoptions/mouse.cpp +++ b/kcmkwin/kwinoptions/mouse.cpp @@ -32,37 +32,24 @@ #include #include -#include -#include #include #include #include #include #include +#include "kwinoptions_settings.h" + namespace { -char const * const cnf_Max[] = { - "MaximizeButtonLeftClickCommand", - "MaximizeButtonMiddleClickCommand", - "MaximizeButtonRightClickCommand", -}; - -char const * const tbl_Max[] = { - "Maximize", - "Maximize (vertical only)", - "Maximize (horizontal only)", - "" -}; - QPixmap maxButtonPixmaps[3]; void createMaxButtonPixmaps() { - char const * maxButtonXpms[][3 + 13] = { + char const *maxButtonXpms[][3 + 13] = { { nullptr, nullptr, nullptr, "...............", @@ -142,224 +129,41 @@ { createMaxButtonPixmaps(); for (int i=0; i<3; ++i) { - m_ui->leftClickMaximizeButton->setItemIcon(i, maxButtonPixmaps[i]); - m_ui->middleClickMaximizeButton->setItemIcon(i, maxButtonPixmaps[i]); - m_ui->rightClickMaximizeButton->setItemIcon(i, maxButtonPixmaps[i]); + m_ui->kcfg_MaximizeButtonLeftClickCommand->setItemIcon(i, maxButtonPixmaps[i]); + m_ui->kcfg_MaximizeButtonMiddleClickCommand->setItemIcon(i, maxButtonPixmaps[i]); + m_ui->kcfg_MaximizeButtonRightClickCommand->setItemIcon(i, maxButtonPixmaps[i]); } } -KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget * parent) - : KCModule(parent), config(_config), standAlone(_standAlone) +KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) + : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinMouseConfigForm(this)) + , m_settings(settings) { + addConfig(m_settings, this); + // create the items for the maximize button actions createMaxButtonPixmaps(); for (int i=0; i<3; ++i) { - m_ui->leftClickMaximizeButton->addItem(maxButtonPixmaps[i], QString()); - m_ui->middleClickMaximizeButton->addItem(maxButtonPixmaps[i], QString()); - m_ui->rightClickMaximizeButton->addItem(maxButtonPixmaps[i], QString()); + m_ui->kcfg_MaximizeButtonLeftClickCommand->addItem(maxButtonPixmaps[i], QString()); + m_ui->kcfg_MaximizeButtonMiddleClickCommand->addItem(maxButtonPixmaps[i], QString()); + m_ui->kcfg_MaximizeButtonRightClickCommand->addItem(maxButtonPixmaps[i], QString()); } - createMaximizeButtonTooltips(m_ui->leftClickMaximizeButton); - createMaximizeButtonTooltips(m_ui->middleClickMaximizeButton); - createMaximizeButtonTooltips(m_ui->rightClickMaximizeButton); - - connect(m_ui->coTiDbl, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiAct1, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiAct2, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiAct3, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiAct4, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiInAct1, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiInAct2, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coTiInAct3, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->leftClickMaximizeButton, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->middleClickMaximizeButton, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->rightClickMaximizeButton, SIGNAL(activated(int)), SLOT(changed())); + createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonLeftClickCommand); + createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonMiddleClickCommand); + createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonRightClickCommand); load(); } -KTitleBarActionsConfig::~KTitleBarActionsConfig() -{ - if (standAlone) - delete config; -} - void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo) { combo->setItemData(0, i18n("Maximize"), Qt::ToolTipRole); combo->setItemData(1, i18n("Maximize (vertical only)"), Qt::ToolTipRole); combo->setItemData(2, i18n("Maximize (horizontal only)"), Qt::ToolTipRole); } -// do NOT change the texts below, they are written to config file -// and are not shown in the GUI -// they have to match the order of items in GUI elements though -const char* const tbl_TiDbl[] = { - "Maximize", - "Maximize (vertical only)", - "Maximize (horizontal only)", - "Minimize", - "Shade", - "Lower", - "Close", - "OnAllDesktops", - "Nothing", - "" -}; - -const char* const tbl_TiAc[] = { - "Raise", - "Lower", - "Toggle raise and lower", - "Minimize", - "Shade", - "Close", - "Operations menu", - "Nothing", - "" -}; - -const char* const tbl_TiInAc[] = { - "Activate and raise", - "Activate and lower", - "Activate", - "Raise", - "Lower", - "Toggle raise and lower", - "Minimize", - "Shade", - "Close", - "Operations menu", - "Nothing", - "" -}; - -const char* const tbl_Win[] = { - "Activate, raise and pass click", - "Activate and pass click", - "Activate", - "Activate and raise", - "" -}; - -const char* const tbl_WinWheel[] = { - "Scroll", - "Activate and scroll", - "Activate, raise and scroll", - "" -}; - -const char* const tbl_AllKey[] = { - "Alt", - "Meta", - "" -}; - -const char* const tbl_All[] = { - "Move", - "Activate, raise and move", - "Toggle raise and lower", - "Resize", - "Raise", - "Lower", - "Minimize", - "Decrease Opacity", - "Increase Opacity", - "Nothing", - "" -}; - -const char* const tbl_TiWAc[] = { - "Raise/Lower", - "Shade/Unshade", - "Maximize/Restore", - "Above/Below", - "Previous/Next Desktop", - "Change Opacity", - "Nothing", - "" -}; - -const char* const tbl_AllW[] = { - "Raise/Lower", - "Shade/Unshade", - "Maximize/Restore", - "Above/Below", - "Previous/Next Desktop", - "Change Opacity", - "Nothing", - "" -}; - -static const char* tbl_num_lookup(const char* const arr[], int pos) -{ - for (int i = 0; - arr[ i ][ 0 ] != '\0' && pos >= 0; - ++i) { - if (pos == 0) - return arr[ i ]; - --pos; - } - abort(); // should never happen this way -} - -static int tbl_txt_lookup(const char* const arr[], const char* txt) -{ - int pos = 0; - for (int i = 0; - arr[ i ][ 0 ] != '\0'; - ++i) { - if (qstricmp(txt, arr[ i ]) == 0) - return pos; - ++pos; - } - return 0; -} - -void KTitleBarActionsConfig::setComboText(KComboBox* combo, const char*txt) -{ - if (combo == m_ui->coTiDbl) - combo->setCurrentIndex(tbl_txt_lookup(tbl_TiDbl, txt)); - else if (combo == m_ui->coTiAct1 || combo == m_ui->coTiAct2 || combo == m_ui->coTiAct3) - combo->setCurrentIndex(tbl_txt_lookup(tbl_TiAc, txt)); - else if (combo == m_ui->coTiInAct1 || combo == m_ui->coTiInAct2 || combo == m_ui->coTiInAct3) - combo->setCurrentIndex(tbl_txt_lookup(tbl_TiInAc, txt)); - else if (combo == m_ui->coTiAct4) - combo->setCurrentIndex(tbl_txt_lookup(tbl_TiWAc, txt)); - else if (combo == m_ui->leftClickMaximizeButton || - combo == m_ui->middleClickMaximizeButton || - combo == m_ui->rightClickMaximizeButton) { - combo->setCurrentIndex(tbl_txt_lookup(tbl_Max, txt)); - } else - abort(); -} - -const char* KTitleBarActionsConfig::functionTiDbl(int i) -{ - return tbl_num_lookup(tbl_TiDbl, i); -} - -const char* KTitleBarActionsConfig::functionTiAc(int i) -{ - return tbl_num_lookup(tbl_TiAc, i); -} - -const char* KTitleBarActionsConfig::functionTiInAc(int i) -{ - return tbl_num_lookup(tbl_TiInAc, i); -} - -const char* KTitleBarActionsConfig::functionTiWAc(int i) -{ - return tbl_num_lookup(tbl_TiWAc, i); -} - -const char* KTitleBarActionsConfig::functionMax(int i) -{ - return tbl_num_lookup(tbl_Max, i); -} - void KTitleBarActionsConfig::showEvent(QShowEvent *ev) { if (!standAlone) { @@ -378,131 +182,27 @@ ev->accept(); } - -void KTitleBarActionsConfig::load() -{ - KConfigGroup windowsConfig(config, "Windows"); - setComboText(m_ui->coTiDbl, windowsConfig.readEntry("TitlebarDoubleClickCommand", "Maximize").toLatin1()); - setComboText(m_ui->leftClickMaximizeButton, windowsConfig.readEntry(cnf_Max[0], tbl_Max[0]).toLatin1()); - setComboText(m_ui->middleClickMaximizeButton, windowsConfig.readEntry(cnf_Max[1], tbl_Max[1]).toLatin1()); - setComboText(m_ui->rightClickMaximizeButton, windowsConfig.readEntry(cnf_Max[2], tbl_Max[2]).toLatin1()); - - KConfigGroup cg(config, "MouseBindings"); - setComboText(m_ui->coTiAct1, cg.readEntry("CommandActiveTitlebar1", "Raise").toLatin1()); - setComboText(m_ui->coTiAct2, cg.readEntry("CommandActiveTitlebar2", "Nothing").toLatin1()); - setComboText(m_ui->coTiAct3, cg.readEntry("CommandActiveTitlebar3", "Operations menu").toLatin1()); - setComboText(m_ui->coTiAct4, cg.readEntry("CommandTitlebarWheel", "Nothing").toLatin1()); - setComboText(m_ui->coTiInAct1, cg.readEntry("CommandInactiveTitlebar1", "Activate and raise").toLatin1()); - setComboText(m_ui->coTiInAct2, cg.readEntry("CommandInactiveTitlebar2", "Nothing").toLatin1()); - setComboText(m_ui->coTiInAct3, cg.readEntry("CommandInactiveTitlebar3", "Operations menu").toLatin1()); -} - void KTitleBarActionsConfig::save() { - KConfigGroup windowsConfig(config, "Windows"); - windowsConfig.writeEntry("TitlebarDoubleClickCommand", functionTiDbl(m_ui->coTiDbl->currentIndex())); - windowsConfig.writeEntry(cnf_Max[0], functionMax(m_ui->leftClickMaximizeButton->currentIndex())); - windowsConfig.writeEntry(cnf_Max[1], functionMax(m_ui->middleClickMaximizeButton->currentIndex())); - windowsConfig.writeEntry(cnf_Max[2], functionMax(m_ui->rightClickMaximizeButton->currentIndex())); - - KConfigGroup cg(config, "MouseBindings"); - cg.writeEntry("CommandActiveTitlebar1", functionTiAc(m_ui->coTiAct1->currentIndex())); - cg.writeEntry("CommandActiveTitlebar2", functionTiAc(m_ui->coTiAct2->currentIndex())); - cg.writeEntry("CommandActiveTitlebar3", functionTiAc(m_ui->coTiAct3->currentIndex())); - cg.writeEntry("CommandInactiveTitlebar1", functionTiInAc(m_ui->coTiInAct1->currentIndex())); - cg.writeEntry("CommandTitlebarWheel", functionTiWAc(m_ui->coTiAct4->currentIndex())); - cg.writeEntry("CommandInactiveTitlebar2", functionTiInAc(m_ui->coTiInAct2->currentIndex())); - cg.writeEntry("CommandInactiveTitlebar3", functionTiInAc(m_ui->coTiInAct3->currentIndex())); + 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); - } } -void KTitleBarActionsConfig::defaults() -{ - setComboText(m_ui->coTiDbl, "Maximize"); - setComboText(m_ui->coTiAct1, "Raise"); - setComboText(m_ui->coTiAct2, "Nothing"); - setComboText(m_ui->coTiAct3, "Operations menu"); - setComboText(m_ui->coTiAct4, "Nothing"); - setComboText(m_ui->coTiInAct1, "Activate and raise"); - setComboText(m_ui->coTiInAct2, "Nothing"); - setComboText(m_ui->coTiInAct3, "Operations menu"); - setComboText(m_ui->leftClickMaximizeButton, tbl_Max[0]); - setComboText(m_ui->middleClickMaximizeButton, tbl_Max[1]); - setComboText(m_ui->rightClickMaximizeButton, tbl_Max[2]); -} - - -KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KConfig *_config, QWidget * parent) - : KCModule(parent), config(_config), standAlone(_standAlone) +KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) + : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinActionsConfigForm(this)) + , m_settings(settings) { - connect(m_ui->coWin1, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coWin2, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coWin3, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coWinWheel, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coAllKey, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coAll1, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coAll2, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coAll3, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->coAllW, SIGNAL(activated(int)), SLOT(changed())); + addConfig(m_settings, this); load(); } -KWindowActionsConfig::~KWindowActionsConfig() -{ - if (standAlone) - delete config; -} - -void KWindowActionsConfig::setComboText(KComboBox* combo, const char*txt) -{ - if (combo == m_ui->coWin1 || combo == m_ui->coWin2 || combo == m_ui->coWin3) - combo->setCurrentIndex(tbl_txt_lookup(tbl_Win, txt)); - else if (combo == m_ui->coWinWheel) - combo->setCurrentIndex(tbl_txt_lookup(tbl_WinWheel, txt)); - else if (combo == m_ui->coAllKey) - combo->setCurrentIndex(tbl_txt_lookup(tbl_AllKey, txt)); - else if (combo == m_ui->coAll1 || combo == m_ui->coAll2 || combo == m_ui->coAll3) - combo->setCurrentIndex(tbl_txt_lookup(tbl_All, txt)); - else if (combo == m_ui->coAllW) - combo->setCurrentIndex(tbl_txt_lookup(tbl_AllW, txt)); - else - abort(); -} - -const char* KWindowActionsConfig::functionWin(int i) -{ - return tbl_num_lookup(tbl_Win, i); -} - -const char* KWindowActionsConfig::functionWinWheel(int i) -{ - return tbl_num_lookup(tbl_WinWheel, i); -} - -const char* KWindowActionsConfig::functionAllKey(int i) -{ - return tbl_num_lookup(tbl_AllKey, i); -} - -const char* KWindowActionsConfig::functionAll(int i) -{ - return tbl_num_lookup(tbl_All, i); -} - -const char* KWindowActionsConfig::functionAllW(int i) -{ - return tbl_num_lookup(tbl_AllW, i); -} - void KWindowActionsConfig::showEvent(QShowEvent *ev) { if (!standAlone) { @@ -512,51 +212,15 @@ KCModule::showEvent(ev); } -void KWindowActionsConfig::load() -{ - KConfigGroup cg(config, "MouseBindings"); - setComboText(m_ui->coWin1, cg.readEntry("CommandWindow1", "Activate, raise and pass click").toLatin1()); - setComboText(m_ui->coWin2, cg.readEntry("CommandWindow2", "Activate and pass click").toLatin1()); - setComboText(m_ui->coWin3, cg.readEntry("CommandWindow3", "Activate and pass click").toLatin1()); - setComboText(m_ui->coWinWheel, cg.readEntry("CommandWindowWheel", "Scroll").toLatin1()); - setComboText(m_ui->coAllKey, cg.readEntry("CommandAllKey", "Alt").toLatin1()); - setComboText(m_ui->coAll1, cg.readEntry("CommandAll1", "Move").toLatin1()); - setComboText(m_ui->coAll2, cg.readEntry("CommandAll2", "Toggle raise and lower").toLatin1()); - setComboText(m_ui->coAll3, cg.readEntry("CommandAll3", "Resize").toLatin1()); - setComboText(m_ui->coAllW, cg.readEntry("CommandAllWheel", "Nothing").toLatin1()); -} - void KWindowActionsConfig::save() { - KConfigGroup cg(config, "MouseBindings"); - cg.writeEntry("CommandWindow1", functionWin(m_ui->coWin1->currentIndex())); - cg.writeEntry("CommandWindow2", functionWin(m_ui->coWin2->currentIndex())); - cg.writeEntry("CommandWindow3", functionWin(m_ui->coWin3->currentIndex())); - cg.writeEntry("CommandWindowWheel", functionWinWheel(m_ui->coWinWheel->currentIndex())); - cg.writeEntry("CommandAllKey", functionAllKey(m_ui->coAllKey->currentIndex())); - cg.writeEntry("CommandAll1", functionAll(m_ui->coAll1->currentIndex())); - cg.writeEntry("CommandAll2", functionAll(m_ui->coAll2->currentIndex())); - cg.writeEntry("CommandAll3", functionAll(m_ui->coAll3->currentIndex())); - cg.writeEntry("CommandAllWheel", functionAllW(m_ui->coAllW->currentIndex())); + 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); } } -void KWindowActionsConfig::defaults() -{ - setComboText(m_ui->coWin1, "Activate, raise and pass click"); - setComboText(m_ui->coWin2, "Activate and pass click"); - setComboText(m_ui->coWin3, "Activate and pass click"); - setComboText(m_ui->coWinWheel, "Scroll"); - setComboText(m_ui->coAllKey, "Alt"); - setComboText(m_ui->coAll1, "Move"); - setComboText(m_ui->coAll2, "Toggle raise and lower"); - setComboText(m_ui->coAll3, "Resize"); - setComboText(m_ui->coAllW, "Nothing"); -} diff --git a/kcmkwin/kwinoptions/mouse.ui b/kcmkwin/kwinoptions/mouse.ui --- a/kcmkwin/kwinoptions/mouse.ui +++ b/kcmkwin/kwinoptions/mouse.ui @@ -26,12 +26,12 @@ &Double-click: - coTiDbl + kcfg_TitlebarDoubleClickCommand
- + Behavior on <em>double</em> click into the titlebar. @@ -88,12 +88,12 @@ Mouse &wheel: - coTiAct4 + kcfg_CommandTitlebarWheel - + Behavior on <em>mouse wheel</em> scroll over the titlebar. @@ -180,7 +180,7 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coTiAct1 + kcfg_CommandActiveTitlebar1 @@ -203,7 +203,7 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coTiAct2 + kcfg_CommandActiveTitlebar2
@@ -216,12 +216,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - coTiAct3 + kcfg_CommandActiveTitlebar3 - + 0 @@ -274,7 +274,7 @@ - + Behavior on <em>left</em> click into the titlebar or frame of an <em>inactive</em> window. @@ -336,7 +336,7 @@ - + 0 @@ -389,7 +389,7 @@ - + Behavior on <em>left</em> click into the titlebar or frame of an <em>inactive</em> window. @@ -451,7 +451,7 @@ - + 0 @@ -504,7 +504,7 @@ - + Behavior on <em>left</em> click into the titlebar or frame of an <em>inactive</em> window. @@ -601,12 +601,12 @@ L&eft click: - leftClickMaximizeButton + kcfg_MaximizeButtonLeftClickCommand - + 0 @@ -627,12 +627,12 @@ Middle c&lick: - middleClickMaximizeButton + kcfg_MaximizeButtonMiddleClickCommand - + 0 @@ -653,12 +653,12 @@ Right clic&k: - rightClickMaximizeButton + kcfg_MaximizeButtonRightClickCommand - + 0 @@ -696,17 +696,17 @@ - coTiDbl - coTiAct4 - coTiAct1 - coTiInAct1 - coTiAct2 - coTiInAct2 - coTiAct3 - coTiInAct3 - leftClickMaximizeButton - middleClickMaximizeButton - rightClickMaximizeButton + kcfg_TitlebarDoubleClickCommand + kcfg_CommandTitlebarWheel + kcfg_CommandActiveTitlebar1 + kcfg_CommandInactiveTitlebar1 + kcfg_CommandActiveTitlebar2 + kcfg_CommandInactiveTitlebar2 + kcfg_CommandActiveTitlebar3 + kcfg_CommandInactiveTitlebar3 + kcfg_MaximizeButtonLeftClickCommand + kcfg_MaximizeButtonMiddleClickCommand + kcfg_MaximizeButtonRightClickCommand diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h --- a/kcmkwin/kwinoptions/windows.h +++ b/kcmkwin/kwinoptions/windows.h @@ -42,6 +42,7 @@ class KColorButton; class KWinOptionsSettings; +class QScreen; class KWinFocusConfigForm : public QWidget, public Ui::KWinFocusConfigForm { @@ -71,56 +72,39 @@ { 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 unmanagedWidgetChanged(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; + + bool mDefaulted = false; + bool mChanged = false; }; 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,19 +121,18 @@ { Q_OBJECT public: - KAdvancedConfig(bool _standAlone, QWidget *parent); - ~KAdvancedConfig() override; + KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent); void save() override; protected: void showEvent(QShowEvent *ev) override; private: - KWinOptionsSettings *m_config; bool standAlone; KWinAdvancedConfigForm *m_ui; + KWinOptionsSettings *m_settings; }; #endif // KKWMWINDOWS_H diff --git a/kcmkwin/kwinoptions/windows.cpp b/kcmkwin/kwinoptions/windows.cpp --- a/kcmkwin/kwinoptions/windows.cpp +++ b/kcmkwin/kwinoptions/windows.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -41,191 +42,102 @@ #include #include -// kwin config keywords -#define KWIN_FOCUS "FocusPolicy" -#define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval" -#define KWIN_AUTORAISE "AutoRaise" -#define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval" -#define KWIN_CLICKRAISE "ClickRaise" -#define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel" -#define KWIN_INACTIVE_SKIP_TASKBAR "InactiveTabsSkipTaskbar" -#define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus" -#define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen" - -#define CLICK_TO_FOCUS 0 -#define FOCUS_FOLLOWS_MOUSE 2 -#define FOCUS_UNDER_MOUSE 4 -#define FOCUS_STRICTLY_UNDER_MOUSE 5 +#include "kwinoptions_settings.h" +#include - -KFocusConfig::~KFocusConfig() -{ - if (standAlone) - delete config; -} +#define CLICK_TO_FOCUS 0 +#define CLICK_TO_FOCUS_MOUSE_PRECEDENT 1 +#define FOCUS_FOLLOWS_MOUSE 2 +#define FOCUS_FOLLOWS_MOUSE_PRECEDENT 3 +#define FOCUS_UNDER_MOUSE 4 +#define FOCUS_STRICTLY_UNDER_MOUSE 5 KWinFocusConfigForm::KWinFocusConfigForm(QWidget* parent) : QWidget(parent) { setupUi(parent); } -// removed the LCD display over the slider - this is not good GUI design :) RNolden 051701 -KFocusConfig::KFocusConfig(bool _standAlone, KConfig *_config, QWidget * parent) - : KCModule(parent), config(_config), standAlone(_standAlone) +KFocusConfig::KFocusConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget * parent) + : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinFocusConfigForm(this)) + , m_settings(settings) { - connect(m_ui->focusStealing, SIGNAL(activated(int)), SLOT(changed())); - connect(m_ui->windowFocusPolicyCombo, SIGNAL(currentIndexChanged(int)), SLOT(changed())); - connect(m_ui->windowFocusPolicyCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(focusPolicyChanged())); - connect(m_ui->windowFocusPolicyCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setDelayFocusEnabled())); - connect(m_ui->windowFocusPolicyCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActiveMouseScreen())); - connect(m_ui->autoRaiseOn, SIGNAL(clicked()), SLOT(changed())); - connect(m_ui->autoRaiseOn, SIGNAL(toggled(bool)), SLOT(autoRaiseOnTog(bool))); - connect(m_ui->clickRaiseOn, SIGNAL(clicked()), SLOT(changed())); - connect(m_ui->autoRaise, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(m_ui->delayFocus, SIGNAL(valueChanged(int)), SLOT(changed())); - connect(m_ui->separateScreenFocus, SIGNAL(clicked()), SLOT(changed())); - connect(m_ui->activeMouseScreen, SIGNAL(clicked()), SLOT(changed())); - - connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(updateMultiScreen())); + addConfig(m_settings, this); + + connect(m_ui->unmanagedFocusPolicy, qOverload(&QComboBox::currentIndexChanged), this, &KFocusConfig::focusPolicyChanged); + + connect(qApp, &QGuiApplication::screenAdded, this, &KFocusConfig::updateMultiScreen); + connect(qApp, &QGuiApplication::screenRemoved, this, &KFocusConfig::updateMultiScreen); updateMultiScreen(); load(); } void KFocusConfig::updateMultiScreen() { m_ui->multiscreenBehaviorLabel->setVisible(QApplication::screens().count() > 1); - m_ui->activeMouseScreen->setVisible(QApplication::screens().count() > 1); - m_ui->separateScreenFocus->setVisible(QApplication::screens().count() > 1); -} - - -int KFocusConfig::getFocus() -{ - int policy = m_ui->windowFocusPolicyCombo->currentIndex(); - if (policy == 1 || policy == 3) - --policy; // fix the NextFocusPrefersMouse condition - return policy; -} - -void KFocusConfig::setFocus(int foc) -{ - m_ui->windowFocusPolicyCombo->setCurrentIndex(foc); - - // this will disable/hide the auto raise delay widget if focus==click - focusPolicyChanged(); -} - -void KFocusConfig::setAutoRaiseInterval(int tb) -{ - m_ui->autoRaise->setValue(tb); -} - -void KFocusConfig::setDelayFocusInterval(int tb) -{ - m_ui->delayFocus->setValue(tb); -} - -int KFocusConfig::getAutoRaiseInterval() -{ - return m_ui->autoRaise->value(); -} - -int KFocusConfig::getDelayFocusInterval() -{ - return m_ui->delayFocus->value(); -} - -void KFocusConfig::setAutoRaise(bool on) -{ - m_ui->autoRaiseOn->setChecked(on); -} - -void KFocusConfig::setClickRaise(bool on) -{ - m_ui->clickRaiseOn->setChecked(on); + m_ui->kcfg_ActiveMouseScreen->setVisible(QApplication::screens().count() > 1); + m_ui->kcfg_SeparateScreenFocus->setVisible(QApplication::screens().count() > 1); } void KFocusConfig::focusPolicyChanged() { - switch (m_ui->windowFocusPolicyCombo->currentIndex()) { - case 0: + int selectedFocusPolicy = 0; + bool selectedNextFocusPrefersMouseItem = false; + const bool loadedNextFocusPrefersMouseItem = m_settings->nextFocusPrefersMouse(); + + int focusPolicy = m_ui->unmanagedFocusPolicy->currentIndex(); + switch (focusPolicy) { + case CLICK_TO_FOCUS: m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Click to focus: A window becomes active when you click into it. This behavior is common on other operating systems and likely what you want.")); + selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::ClickToFocus; break; - case 1: + case CLICK_TO_FOCUS_MOUSE_PRECEDENT: m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Click to focus (mouse precedence): Mostly the same as Click to focus. If an active window has to be chosen by the system (eg. because the currently active one was closed) the window under the mouse is the preferred candidate. Unusual, but possible variant of Click to focus.")); + selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::ClickToFocus; + selectedNextFocusPrefersMouseItem = true; break; - case 2: + case FOCUS_FOLLOWS_MOUSE: m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus follows mouse: Moving the mouse onto a window will activate it. Eg. windows randomly appearing under the mouse will not gain the focus. Focus stealing prevention takes place as usual. Think as Click to focus just without having to actually click.")); + selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusFollowsMouse; break; - case 3: + case FOCUS_FOLLOWS_MOUSE_PRECEDENT: m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("This is mostly the same as Focus follows mouse. If an active window has to be chosen by the system (eg. because the currently active one was closed) the window under the mouse is the preferred candidate. Choose this, if you want a hover controlled focus.")); + selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusFollowsMouse; + selectedNextFocusPrefersMouseItem = true; break; - case 4: + case FOCUS_UNDER_MOUSE: m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus under mouse: The focus always remains on the window under the mouse.
Warning: Focus stealing prevention and the tabbox ('Alt+Tab') contradict the activation policy and will not work. You very likely want to use Focus follows mouse (mouse precedence) instead!")); + selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusUnderMouse; break; - case 5: + case FOCUS_STRICTLY_UNDER_MOUSE: m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus strictly under mouse: The focus is always on the window under the mouse (in doubt nowhere) very much like the focus behavior in an unmanaged legacy X11 environment.
Warning: Focus stealing prevention and the tabbox ('Alt+Tab') contradict the activation policy and will not work. You very likely want to use Focus follows mouse (mouse precedence) instead!")); + selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusStrictlyUnderMouse; break; } - int policyIndex = getFocus(); - - // the auto raise related widgets are: autoRaise - m_ui->autoRaiseOn->setEnabled(policyIndex != CLICK_TO_FOCUS); - autoRaiseOnTog(policyIndex != CLICK_TO_FOCUS && m_ui->autoRaiseOn->isChecked()); - - m_ui->focusStealing->setDisabled(policyIndex == FOCUS_UNDER_MOUSE || policyIndex == FOCUS_STRICTLY_UNDER_MOUSE); - m_ui->focusStealingLabel->setEnabled(m_ui->focusStealing->isEnabled()); + const bool changed = m_settings->focusPolicy() != selectedFocusPolicy || loadedNextFocusPrefersMouseItem != selectedNextFocusPrefersMouseItem; + unmanagedWidgetChangeState(changed); + emit unmanagedWidgetChanged(changed); - setDelayFocusEnabled(); + const bool isDefault = focusPolicy == CLICK_TO_FOCUS; + unmanagedWidgetDefaultState(isDefault); + emit unmanagedWidgetDefaulted(isDefault); -} + // the auto raise related widgets are: autoRaise + m_ui->kcfg_AutoRaise->setEnabled(focusPolicy != CLICK_TO_FOCUS && focusPolicy != CLICK_TO_FOCUS_MOUSE_PRECEDENT); -void KFocusConfig::setDelayFocusEnabled() -{ - int policyIndex = getFocus(); + m_ui->kcfg_FocusStealingPreventionLevel->setDisabled(focusPolicy == FOCUS_UNDER_MOUSE || focusPolicy == FOCUS_STRICTLY_UNDER_MOUSE); // the delayed focus related widgets are: delayFocus - m_ui->delayFocusOnLabel->setEnabled(policyIndex != CLICK_TO_FOCUS); - delayFocusOnTog(policyIndex != CLICK_TO_FOCUS); -} - -void KFocusConfig::autoRaiseOnTog(bool a) -{ - m_ui->autoRaise->setEnabled(a); - m_ui->clickRaiseOn->setEnabled(!a); -} - -void KFocusConfig::delayFocusOnTog(bool a) -{ - m_ui->delayFocus->setEnabled(a); -} + m_ui->delayFocusOnLabel->setEnabled(focusPolicy != CLICK_TO_FOCUS); + m_ui->kcfg_DelayFocusInterval->setEnabled(focusPolicy != CLICK_TO_FOCUS); -void KFocusConfig::setFocusStealing(int l) -{ - l = qMax(0, qMin(4, l)); - m_ui->focusStealing->setCurrentIndex(l); -} - -void KFocusConfig::setSeparateScreenFocus(bool s) -{ - m_ui->separateScreenFocus->setChecked(s); -} - -void KFocusConfig::setActiveMouseScreen(bool a) -{ - m_ui->activeMouseScreen->setChecked(a); -} - -void KFocusConfig::updateActiveMouseScreen() -{ // on by default for non click to focus policies - KConfigGroup cfg(config, "Windows"); - if (!cfg.hasKey(KWIN_ACTIVE_MOUSE_SCREEN)) - setActiveMouseScreen(getFocus() != 0); + if (m_settings->activeMouseScreen() == m_settings->defaultActiveMouseScreenValue()) { + m_ui->kcfg_ActiveMouseScreen->setChecked(focusPolicy != CLICK_TO_FOCUS && focusPolicy != CLICK_TO_FOCUS_MOUSE_PRECEDENT); + } } void KFocusConfig::showEvent(QShowEvent *ev) @@ -239,85 +151,56 @@ void KFocusConfig::load(void) { - QString key; - - KConfigGroup cg(config, "Windows"); - - const bool focusNextToMouse = cg.readEntry("NextFocusPrefersMouse", false); - - key = cg.readEntry(KWIN_FOCUS); - if (key == "ClickToFocus") - setFocus(CLICK_TO_FOCUS + focusNextToMouse); - else if (key == "FocusFollowsMouse") - setFocus(FOCUS_FOLLOWS_MOUSE + focusNextToMouse); - else if (key == "FocusUnderMouse") - setFocus(FOCUS_UNDER_MOUSE); - else if (key == "FocusStrictlyUnderMouse") - setFocus(FOCUS_STRICTLY_UNDER_MOUSE); + KCModule::load(); - int k = cg.readEntry(KWIN_AUTORAISE_INTERVAL, 750); - setAutoRaiseInterval(k); + const bool loadedNextFocusPrefersMouseItem = m_settings->nextFocusPrefersMouse(); - k = cg.readEntry(KWIN_DELAYFOCUS_INTERVAL, 300); - setDelayFocusInterval(k); + int focusPolicy = m_settings->focusPolicy(); - setAutoRaise(cg.readEntry(KWIN_AUTORAISE, false)); - setClickRaise(cg.readEntry(KWIN_CLICKRAISE, true)); - focusPolicyChanged(); // this will disable/hide the auto raise delay widget if focus==click - - setSeparateScreenFocus(cg.readEntry(KWIN_SEPARATE_SCREEN_FOCUS, false)); - // on by default for non click to focus policies - setActiveMouseScreen(cg.readEntry(KWIN_ACTIVE_MOUSE_SCREEN, getFocus() != 0)); - -// setFocusStealing( cg.readEntry(KWIN_FOCUS_STEALING, 2 )); - // TODO default to low for now - setFocusStealing(cg.readEntry(KWIN_FOCUS_STEALING, 1)); - - - emit KCModule::changed(false); + switch (focusPolicy) { + // the ClickToFocus and FocusFollowsMouse have special values when + // NextFocusPrefersMouse is true + case KWinOptionsSettings::EnumFocusPolicy::ClickToFocus: + m_ui->unmanagedFocusPolicy->setCurrentIndex(CLICK_TO_FOCUS + loadedNextFocusPrefersMouseItem); + break; + case KWinOptionsSettings::EnumFocusPolicy::FocusFollowsMouse: + m_ui->unmanagedFocusPolicy->setCurrentIndex(FOCUS_FOLLOWS_MOUSE + loadedNextFocusPrefersMouseItem); + break; + default: + // +2 to ignore the two special values + m_ui->unmanagedFocusPolicy->setCurrentIndex(focusPolicy + 2); + break; + } } void KFocusConfig::save(void) { - int v; - - KConfigGroup cg(config, "Windows"); - - v = getFocus(); - if (v == CLICK_TO_FOCUS) - cg.writeEntry(KWIN_FOCUS, "ClickToFocus"); - else if (v == FOCUS_UNDER_MOUSE) - cg.writeEntry(KWIN_FOCUS, "FocusUnderMouse"); - else if (v == FOCUS_STRICTLY_UNDER_MOUSE) - cg.writeEntry(KWIN_FOCUS, "FocusStrictlyUnderMouse"); - else - cg.writeEntry(KWIN_FOCUS, "FocusFollowsMouse"); - - cg.writeEntry("NextFocusPrefersMouse", v != m_ui->windowFocusPolicyCombo->currentIndex()); - - v = getAutoRaiseInterval(); - if (v < 0) v = 0; - cg.writeEntry(KWIN_AUTORAISE_INTERVAL, v); - - v = getDelayFocusInterval(); - if (v < 0) v = 0; - cg.writeEntry(KWIN_DELAYFOCUS_INTERVAL, v); - - cg.writeEntry(KWIN_AUTORAISE, m_ui->autoRaiseOn->isChecked()); - - cg.writeEntry(KWIN_CLICKRAISE, m_ui->clickRaiseOn->isChecked()); - - cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, m_ui->separateScreenFocus->isChecked()); - cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, m_ui->activeMouseScreen->isChecked()); - - cg.writeEntry(KWIN_FOCUS_STEALING, m_ui->focusStealing->currentIndex()); + KCModule::save(); - cg.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS, m_ui->separateScreenFocus->isChecked()); - cg.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN, m_ui->activeMouseScreen->isChecked()); + int idxFocusPolicy = m_ui->unmanagedFocusPolicy->currentIndex(); + switch (idxFocusPolicy) { + case CLICK_TO_FOCUS: + case CLICK_TO_FOCUS_MOUSE_PRECEDENT: + m_settings->setFocusPolicy(KWinOptionsSettings::EnumFocusPolicy::ClickToFocus); + break; + case FOCUS_FOLLOWS_MOUSE: + case FOCUS_FOLLOWS_MOUSE_PRECEDENT: + // the ClickToFocus and FocusFollowsMouse have special values when + // NextFocusPrefersMouse is true + m_settings->setFocusPolicy(KWinOptionsSettings::EnumFocusPolicy::FocusFollowsMouse); + break; + case FOCUS_UNDER_MOUSE: + m_settings->setFocusPolicy(KWinOptionsSettings::EnumFocusPolicy::FocusUnderMouse); + break; + case FOCUS_STRICTLY_UNDER_MOUSE: + m_settings->setFocusPolicy(KWinOptionsSettings::EnumFocusPolicy::FocusStrictlyUnderMouse); + break; + } + m_settings->setNextFocusPrefersMouse(idxFocusPolicy == CLICK_TO_FOCUS_MOUSE_PRECEDENT || idxFocusPolicy == FOCUS_FOLLOWS_MOUSE_PRECEDENT); + m_settings->save(); if (standAlone) { - config->sync(); // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); @@ -328,38 +211,22 @@ void KFocusConfig::defaults() { - setAutoRaiseInterval(0); - setDelayFocusInterval(0); - setFocus(CLICK_TO_FOCUS); - setAutoRaise(false); - setClickRaise(true); - setSeparateScreenFocus(false); - -// setFocusStealing(2); - // TODO default to low for now - setFocusStealing(1); - - // on by default for non click to focus policies - setActiveMouseScreen(getFocus() != 0); - setDelayFocusEnabled(); - emit KCModule::changed(true); + KCModule::defaults(); + m_ui->unmanagedFocusPolicy->setCurrentIndex(CLICK_TO_FOCUS); } KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent) : QWidget(parent) { setupUi(parent); } -KAdvancedConfig::~KAdvancedConfig() -{ -} - -KAdvancedConfig::KAdvancedConfig(bool _standAlone, QWidget *parent) - : KCModule(parent), m_config(KWinOptionsSettings::self()), standAlone(_standAlone) +KAdvancedConfig::KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) + : KCModule(parent), standAlone(_standAlone) , m_ui(new KWinAdvancedConfigForm(this)) + , m_settings(settings) { - addConfig(m_config, this); + addConfig(m_settings, this); m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Smart, "Smart"); m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Maximizing, "Maximizing"); @@ -399,12 +266,8 @@ setupUi(parent); } -KMovingConfig::~KMovingConfig() -{ -} - -KMovingConfig::KMovingConfig(bool _standAlone, QWidget *parent) - : KCModule(parent), m_config(KWinOptionsSettings::self()), standAlone(_standAlone) +KMovingConfig::KMovingConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) + : KCModule(parent), m_config(settings), standAlone(_standAlone) , m_ui(new KWinMovingConfigForm(this)) { addConfig(m_config, this); @@ -422,7 +285,7 @@ void KMovingConfig::save(void) { - m_config->save(); + KCModule::save(); if (standAlone) { // Send signal to all kwin instances