KCM/Kwinoptions: Port title bar and window actions tabs UI and conf to KConfigXT

Summary: Depends on D27463

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

Reviewed By: ervin, #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27477
This commit is contained in:
Méven Car 2020-03-19 12:30:22 +01:00 committed by Méven Car
parent 9f3b817bdc
commit d571457bbe
8 changed files with 340 additions and 470 deletions

View file

@ -5,7 +5,7 @@ set(PROJECT_VERSION "5.18.80")
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})

View file

@ -29,12 +29,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coWin1</cstring>
<cstring>kcfg_CommandWindow1</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="coWin1">
<widget class="KComboBox" name="kcfg_CommandWindow1">
<property name="whatsThis">
<string>In this row you can customize left click behavior when clicking into an inactive inner window ('inner' means: not titlebar, not frame).</string>
</property>
@ -69,12 +69,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coWin2</cstring>
<cstring>kcfg_CommandWindow2</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="coWin2">
<widget class="KComboBox" name="kcfg_CommandWindow2">
<property name="whatsThis">
<string>In this row you can customize middle click behavior when clicking into an inactive inner window ('inner' means: not titlebar, not frame).</string>
</property>
@ -109,12 +109,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coWin3</cstring>
<cstring>kcfg_CommandWindow3</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="coWin3">
<widget class="KComboBox" name="kcfg_CommandWindow3">
<property name="whatsThis">
<string>In this row you can customize right click behavior when clicking into an inactive inner window ('inner' means: not titlebar, not frame).</string>
</property>
@ -149,12 +149,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coWinWheel</cstring>
<cstring>kcfg_CommandWindowWheel</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KComboBox" name="coWinWheel">
<widget class="KComboBox" name="kcfg_CommandWindowWheel">
<property name="whatsThis">
<string>In this row you can customize behavior when scrolling into an inactive inner window ('inner' means: not titlebar, not frame).</string>
</property>
@ -195,12 +195,12 @@
<string>Mo&amp;difier key:</string>
</property>
<property name="buddy">
<cstring>coAllKey</cstring>
<cstring>kcfg_CommandAllKey</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="coAllKey">
<widget class="KComboBox" name="kcfg_CommandAllKey">
<property name="whatsThis">
<string>Here you select whether holding the Meta key or Alt key will allow you to perform the following actions.</string>
</property>
@ -251,12 +251,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coAll1</cstring>
<cstring>kcfg_CommandAll1</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="coAll1">
<widget class="KComboBox" name="kcfg_CommandAll1">
<property name="whatsThis">
<string>In this row you can customize left click behavior when clicking into the titlebar or the frame.</string>
</property>
@ -321,12 +321,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coAll2</cstring>
<cstring>kcfg_CommandAll2</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="coAll2">
<widget class="KComboBox" name="kcfg_CommandAll2">
<property name="whatsThis">
<string>In this row you can customize middle click behavior when clicking into the titlebar or the frame.</string>
</property>
@ -391,12 +391,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coAll3</cstring>
<cstring>kcfg_CommandAll3</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="coAll3">
<widget class="KComboBox" name="kcfg_CommandAll3">
<property name="whatsThis">
<string>In this row you can customize right click behavior when clicking into the titlebar or the frame.</string>
</property>
@ -461,12 +461,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coAllW</cstring>
<cstring>kcfg_CommandAllWheel</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KComboBox" name="coAllW">
<widget class="KComboBox" name="kcfg_CommandAllWheel">
<property name="whatsThis">
<string>Here you can customize KDE's behavior when scrolling with the mouse wheel in a window while pressing the modifier key.</string>
</property>

View file

@ -58,5 +58,265 @@
<default>true</default>
</entry>
<entry key="TitlebarDoubleClickCommand" type="Enum">
<default>Maximize</default>
<choices>
<choice name="Maximize"></choice>
<choice name="MaximizeVerticalOnly" value="Maximize (vertical only)"></choice>
<choice name="MaximizeHorizontalOnly" value="Maximize (horizontal only)"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Lower"></choice>
<choice name="Close"></choice>
<choice name="OnAllDesktops"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="MaximizeButtonLeftClickCommand" type="Enum">
<default>Maximize</default>
<choices>
<choice name="Maximize"></choice>
<choice name="MaximizeVerticalOnly" value="Maximize (vertical only)"></choice>
<choice name="MaximizeHorizontalOnly" value="Maximize (horizontal only)"></choice>
</choices>
</entry>
<entry key="MaximizeButtonMiddleClickCommand" type="Enum">
<default>MaximizeVerticalOnly</default>
<choices>
<choice name="Maximize"></choice>
<choice name="MaximizeVerticalOnly" value="Maximize (vertical only)"></choice>
<choice name="MaximizeHorizontalOnly" value="Maximize (horizontal only)"></choice>
</choices>
</entry>
<entry key="MaximizeButtonRightClickCommand" type="Enum">
<default>MaximizeVerticalOnly</default>
<choices>
<choice name="Maximize"></choice>
<choice name="MaximizeVerticalOnly" value="Maximize (vertical only)"></choice>
<choice name="MaximizeHorizontalOnly" value="Maximize (horizontal only)"></choice>
</choices>
</entry>
</group>
<group name="MouseBindings">
<entry key="CommandActiveTitlebar1" type="Enum">
<default>Raise</default>
<choices>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Close"></choice>
<choice name="OperationsMenu" value="Operations menu"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandActiveTitlebar2" type="Enum">
<default>Nothing</default>
<choices>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Close"></choice>
<choice name="OperationsMenu" value="Operations menu"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandActiveTitlebar3" type="Enum">
<default>OperationsMenu</default>
<choices>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Close"></choice>
<choice name="OperationsMenu" value="Operations menu"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandTitlebarWheel" type="Enum">
<default>Nothing</default>
<choices>
<choice name="RaiseLower" value="Raise/Lower"></choice>
<choice name="ShadeUnshade" value="Shade/Unshade"></choice>
<choice name="MaxmizeRestore" value="Maximize/Restore"></choice>
<choice name="AboveBelow" value="Above/Below"></choice>
<choice name="PreviousNextDesktop" value="Previous/Next Desktop"></choice>
<choice name="ChangeOpacity" value="Change Opacity"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandInactiveTitlebar1" type="Enum">
<default>ActivateAndRaise</default>
<choices>
<choice name="ActivateAndRaise" value="Activate and raise"></choice>
<choice name="ActivateAndLower" value="Activate and lower"></choice>
<choice name="Activate"></choice>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Close"></choice>
<choice name="OperationsMenu" value="Operations menu"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandInactiveTitlebar2" type="Enum">
<default>Nothing</default>
<choices>
<choice name="ActivateAndRaise" value="Activate and raise"></choice>
<choice name="ActivateAndLower" value="Activate and lower"></choice>
<choice name="Activate"></choice>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Close"></choice>
<choice name="OperationsMenu" value="Operations menu"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandInactiveTitlebar3" type="Enum">
<default>OperationsMenu</default>
<choices>
<choice name="ActivateAndRaise" value="Activate and raise"></choice>
<choice name="ActivateAndLower" value="Activate and lower"></choice>
<choice name="Activate"></choice>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Minimize"></choice>
<choice name="Shade"></choice>
<choice name="Close"></choice>
<choice name="OperationsMenu" value="Operations menu"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandWindow1" type="Enum">
<default>ActivateRaisePassClick</default>
<choices>
<choice name="ActivateRaisePassClick" value="Activate, raise and pass click"></choice>
<choice name="ActivatePassClick" value="Activate and pass click"></choice>
<choice name="Activate"></choice>
<choice name="ActivateRaise" value="Activate and raise"></choice>
</choices>
</entry>
<entry key="CommandWindow2" type="Enum">
<default>ActivatePassClick</default>
<choices>
<choice name="ActivateRaisePassClick" value="Activate, raise and pass click"></choice>
<choice name="ActivatePassClick" value="Activate and pass click"></choice>
<choice name="Activate"></choice>
<choice name="ActivateRaise" value="Activate and raise"></choice>
</choices>
</entry>
<entry key="CommandWindow3" type="Enum">
<default>ActivatePassClick</default>
<choices>
<choice name="ActivateRaisePassClick" value="Activate, raise and pass click"></choice>
<choice name="ActivatePassClick" value="Activate and pass click"></choice>
<choice name="Activate"></choice>
<choice name="ActivateRaise" value="Activate and raise"></choice>
</choices>
</entry>
<entry key="CommandWindowWheel" type="Enum">
<default>Scroll</default>
<choices>
<choice name="Scroll"></choice>
<choice name="ActivateScroll" value="Activate and scroll"></choice>
<choice name="ActivateRaiseAndScroll" value="Activate, raise and scroll"></choice>
</choices>
</entry>
<entry key="CommandAllKey" type="Enum">
<default>Alt</default>
<choices>
<choice name="Alt"></choice>
<choice name="Meta"></choice>
</choices>
</entry>
<entry key="CommandAll1" type="Enum">
<default>Move</default>
<choices>
<choice name="Move"></choice>
<choice name="ActivateRaiseAndMove" value="Activate, raise and move"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Resize"></choice>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="Minimize"></choice>
<choice name="DecreaseOpacity" value="Decrease Opacity"></choice>
<choice name="IncreaseOpactiy" value="Increase Opacity"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandAll2" type="Enum">
<default>ToggleRaiseAndLower</default>
<choices>
<choice name="Move"></choice>
<choice name="ActivateRaiseAndMove" value="Activate, raise and move"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Resize"></choice>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="Minimize"></choice>
<choice name="DecreaseOpacity" value="Decrease Opacity"></choice>
<choice name="IncreaseOpactiy" value="Increase Opacity"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandAll3" type="Enum">
<default>Resize</default>
<choices>
<choice name="Move"></choice>
<choice name="ActivateRaiseAndMove" value="Activate, raise and move"></choice>
<choice name="ToggleRaiseAndLower" value="Toggle raise and lower"></choice>
<choice name="Resize"></choice>
<choice name="Raise"></choice>
<choice name="Lower"></choice>
<choice name="Minimize"></choice>
<choice name="DecreaseOpacity" value="Decrease Opacity"></choice>
<choice name="IncreaseOpactiy" value="Increase Opacity"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
<entry key="CommandAllWheel" type="Enum">
<default>Nothing</default>
<choices>
<choice name="RaiseLower" value="Raise/Lower"></choice>
<choice name="ShadeUnshade" value="Shade/Unshade"></choice>
<choice name="MaxmizeRestore" value="Maximize/Restore"></choice>
<choice name="AboveBelow" value="Above/Below"></choice>
<choice name="PreviousNextDesktop" value="Previous/Next Desktop"></choice>
<choice name="ChangeOpacity" value="Change Opacity"></choice>
<choice name="Nothing"></choice>
</choices>
</entry>
</group>
</kcfg>

View file

@ -78,15 +78,17 @@ KWinOptions::KWinOptions(QWidget *parent, const QVariantList &)
tab->addTab(mFocus, i18n("&Focus"));
connect(mFocus, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this);
mTitleBarActions = new KTitleBarActionsConfig(false, 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, mConfig, this);
mWindowActions = new KWindowActionsConfig(false, 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->setObjectName(QLatin1String("KWin Moving"));
@ -149,8 +151,6 @@ void KWinOptions::save()
QDBusMessage message =
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
QDBusConnection::sessionBus().send(message);
}
@ -173,11 +173,6 @@ QString KWinOptions::quickHelp() const
" for how to customize window behavior.</p>");
}
void KWinOptions::moduleChanged(bool state)
{
emit KCModule::changed(state);
}
KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &)
: KCModule(parent)
{
@ -188,15 +183,17 @@ KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &)
tab = new QTabWidget(this);
layout->addWidget(tab);
mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, this);
mTitleBarActions = new KTitleBarActionsConfig(false, 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, mConfig, this);
mWindowActions = new KWindowActionsConfig(false, 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()
@ -208,10 +205,8 @@ void KActionsOptions::load()
{
mTitleBarActions->load();
mWindowActions->load();
emit KCModule::changed(false);
}
void KActionsOptions::save()
{
mTitleBarActions->save();
@ -224,16 +219,12 @@ void KActionsOptions::save()
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)

View file

@ -49,12 +49,6 @@ public:
void defaults() override;
QString quickHelp() const override;
protected Q_SLOTS:
void moduleChanged(bool state);
private:
QTabWidget *tab;

View file

@ -32,8 +32,6 @@
#include <QHBoxLayout>
#include <QFormLayout>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <QDebug>
#include <kcolorscheme.h>
#include <kseparator.h>
@ -41,23 +39,12 @@
#include <cstdlib>
#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()
@ -142,49 +129,33 @@ void KTitleBarActionsConfig::paletteChanged()
{
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, QWidget *parent)
: KCModule(parent), standAlone(_standAlone)
, m_ui(new KWinMouseConfigForm(this))
{
addConfig(KWinOptionsSettings::self(), 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);
@ -192,174 +163,6 @@ void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo)
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 +181,26 @@ void KTitleBarActionsConfig::changeEvent(QEvent *ev)
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, QWidget *parent)
: KCModule(parent), standAlone(_standAlone)
, m_ui(new KWinActionsConfigForm(this))
{
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(KWinOptionsSettings::self(), 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 +210,14 @@ void KWindowActionsConfig::showEvent(QShowEvent *ev)
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");
}

View file

@ -53,38 +53,20 @@ class KTitleBarActionsConfig : public KCModule
public:
KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent);
~KTitleBarActionsConfig() override;
KTitleBarActionsConfig(bool _standAlone, 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;
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 +79,17 @@ class KWindowActionsConfig : public KCModule
public:
KWindowActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent);
~KWindowActionsConfig() override;
KWindowActionsConfig(bool _standAlone, 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);
};
#endif

View file

@ -26,12 +26,12 @@
<string>&amp;Double-click:</string>
</property>
<property name="buddy">
<cstring>coTiDbl</cstring>
<cstring>kcfg_TitlebarDoubleClickCommand</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="coTiDbl">
<widget class="KComboBox" name="kcfg_TitlebarDoubleClickCommand">
<property name="whatsThis">
<string>Behavior on &lt;em&gt;double&lt;/em&gt; click into the titlebar.</string>
</property>
@ -88,12 +88,12 @@
<string>Mouse &amp;wheel:</string>
</property>
<property name="buddy">
<cstring>coTiAct4</cstring>
<cstring>kcfg_CommandTitlebarWheel</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="coTiAct4">
<widget class="KComboBox" name="kcfg_CommandTitlebarWheel">
<property name="whatsThis">
<string>Behavior on &lt;em&gt;mouse wheel&lt;/em&gt; scroll over the titlebar.</string>
</property>
@ -180,7 +180,7 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coTiAct1</cstring>
<cstring>kcfg_CommandActiveTitlebar1</cstring>
</property>
</widget>
</item>
@ -203,7 +203,7 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coTiAct2</cstring>
<cstring>kcfg_CommandActiveTitlebar2</cstring>
</property>
</widget>
</item>
@ -216,12 +216,12 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>coTiAct3</cstring>
<cstring>kcfg_CommandActiveTitlebar3</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="coTiAct1">
<widget class="KComboBox" name="kcfg_CommandActiveTitlebar1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -274,7 +274,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="KComboBox" name="coTiInAct1">
<widget class="KComboBox" name="kcfg_CommandInactiveTitlebar1">
<property name="whatsThis">
<string>Behavior on &lt;em&gt;left&lt;/em&gt; click into the titlebar or frame of an &lt;em&gt;inactive&lt;/em&gt; window.</string>
</property>
@ -336,7 +336,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="coTiAct2">
<widget class="KComboBox" name="kcfg_CommandActiveTitlebar2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -389,7 +389,7 @@
</widget>
</item>
<item row="2" column="2">
<widget class="KComboBox" name="coTiInAct2">
<widget class="KComboBox" name="kcfg_CommandInactiveTitlebar2">
<property name="whatsThis">
<string>Behavior on &lt;em&gt;left&lt;/em&gt; click into the titlebar or frame of an &lt;em&gt;inactive&lt;/em&gt; window.</string>
</property>
@ -451,7 +451,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="KComboBox" name="coTiAct3">
<widget class="KComboBox" name="kcfg_CommandActiveTitlebar3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -504,7 +504,7 @@
</widget>
</item>
<item row="3" column="2">
<widget class="KComboBox" name="coTiInAct3">
<widget class="KComboBox" name="kcfg_CommandInactiveTitlebar3">
<property name="whatsThis">
<string>Behavior on &lt;em&gt;left&lt;/em&gt; click into the titlebar or frame of an &lt;em&gt;inactive&lt;/em&gt; window.</string>
</property>
@ -601,12 +601,12 @@
<string>L&amp;eft click:</string>
</property>
<property name="buddy">
<cstring>leftClickMaximizeButton</cstring>
<cstring>kcfg_MaximizeButtonLeftClickCommand</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="leftClickMaximizeButton">
<widget class="KComboBox" name="kcfg_MaximizeButtonLeftClickCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -627,12 +627,12 @@
<string>Middle c&amp;lick:</string>
</property>
<property name="buddy">
<cstring>middleClickMaximizeButton</cstring>
<cstring>kcfg_MaximizeButtonMiddleClickCommand</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="middleClickMaximizeButton">
<widget class="KComboBox" name="kcfg_MaximizeButtonMiddleClickCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -653,12 +653,12 @@
<string>Right clic&amp;k:</string>
</property>
<property name="buddy">
<cstring>rightClickMaximizeButton</cstring>
<cstring>kcfg_MaximizeButtonRightClickCommand</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="rightClickMaximizeButton">
<widget class="KComboBox" name="kcfg_MaximizeButtonRightClickCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -696,17 +696,17 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>coTiDbl</tabstop>
<tabstop>coTiAct4</tabstop>
<tabstop>coTiAct1</tabstop>
<tabstop>coTiInAct1</tabstop>
<tabstop>coTiAct2</tabstop>
<tabstop>coTiInAct2</tabstop>
<tabstop>coTiAct3</tabstop>
<tabstop>coTiInAct3</tabstop>
<tabstop>leftClickMaximizeButton</tabstop>
<tabstop>middleClickMaximizeButton</tabstop>
<tabstop>rightClickMaximizeButton</tabstop>
<tabstop>kcfg_TitlebarDoubleClickCommand</tabstop>
<tabstop>kcfg_CommandTitlebarWheel</tabstop>
<tabstop>kcfg_CommandActiveTitlebar1</tabstop>
<tabstop>kcfg_CommandInactiveTitlebar1</tabstop>
<tabstop>kcfg_CommandActiveTitlebar2</tabstop>
<tabstop>kcfg_CommandInactiveTitlebar2</tabstop>
<tabstop>kcfg_CommandActiveTitlebar3</tabstop>
<tabstop>kcfg_CommandInactiveTitlebar3</tabstop>
<tabstop>kcfg_MaximizeButtonLeftClickCommand</tabstop>
<tabstop>kcfg_MaximizeButtonMiddleClickCommand</tabstop>
<tabstop>kcfg_MaximizeButtonRightClickCommand</tabstop>
</tabstops>
<resources/>
<connections/>