Commit 687fcd82 authored by Cyril Rossi's avatar Cyril Rossi
Browse files

KCM KWinDecoration port to KConfigXT

Summary: Port to KConfigXt and also consider immutable element

Reviewers: #kwin, ervin, bport, mart, davidedmundson

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25949
parent 7c8431af
......@@ -10,6 +10,8 @@ set(kcmkwindecoration_SRCS
utils.cpp
)
kconfig_add_kcfg_files(kcmkwindecoration_SRCS kwindecorationsettings.kcfgc GENERATE_MOC)
add_library(kcm_kwindecoration MODULE ${kcmkwindecoration_SRCS})
target_link_libraries(kcm_kwindecoration
......@@ -23,6 +25,7 @@ target_link_libraries(kcm_kwindecoration
kcoreaddons_desktop_to_json(kcm_kwindecoration "kwindecoration.desktop" SERVICE_TYPES kcmodule.desktop)
# This desktop file is installed only for retrocompatibility with sycoca
install(FILES kwindecorationsettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES kwindecoration.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES window-decorations.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR})
install(TARGETS kcm_kwindecoration DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
......
/*
* Copyright (c) 2019 Valerio Pilo <vpilo@coldshock.net>
* Copyright (c) 2019 Cyril Rossi <cyril.rossi@enioka.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -36,6 +37,7 @@
#include <KNewStuff3/KNS3/DownloadDialog>
#include "kwindecorationsettings.h"
K_PLUGIN_FACTORY_WITH_JSON(KCMKWinDecorationFactory, "kwindecoration.json", registerPlugin<KCMKWinDecoration>();)
......@@ -44,52 +46,17 @@ Q_DECLARE_METATYPE(KDecoration2::BorderSize)
namespace
{
const QString s_configFile { QStringLiteral("kwinrc") };
const QString s_configGroup { QStringLiteral("org.kde.kdecoration2") };
const QString s_configPlugin { QStringLiteral("library") };
const QString s_configTheme { QStringLiteral("theme") };
const QString s_configBorderSize { QStringLiteral("BorderSize") };
const QString s_configBorderSizeAuto { QStringLiteral("BorderSizeAuto") };
const QString s_configCloseOnDoubleClickOnMenu { QStringLiteral("CloseOnDoubleClickOnMenu") };
const QString s_configShowToolTips { QStringLiteral("ShowToolTips") };
const QString s_configDecoButtonsOnLeft { QStringLiteral("ButtonsOnLeft") };
const QString s_configDecoButtonsOnRight { QStringLiteral("ButtonsOnRight") };
const KDecoration2::BorderSize s_defaultBorderSize = KDecoration2::BorderSize::Normal;
const KDecoration2::BorderSize s_defaultRecommendedBorderSize = KDecoration2::BorderSize::Normal;
const bool s_defaultBorderSizeAuto = true;
const bool s_defaultCloseOnDoubleClickOnMenu = false;
const bool s_defaultShowToolTips = true;
const DecorationButtonsList s_defaultDecoButtonsOnLeft {
KDecoration2::DecorationButtonType::Menu,
KDecoration2::DecorationButtonType::OnAllDesktops
};
const DecorationButtonsList s_defaultDecoButtonsOnRight {
KDecoration2::DecorationButtonType::ContextHelp,
KDecoration2::DecorationButtonType::Minimize,
KDecoration2::DecorationButtonType::Maximize,
KDecoration2::DecorationButtonType::Close
};
#if HAVE_BREEZE_DECO
const QString s_defaultPlugin { QStringLiteral(BREEZE_KDECORATION_PLUGIN_ID) };
const QString s_defaultTheme { QStringLiteral("Breeze") };
#else
const QString s_defaultPlugin { QStringLiteral("org.kde.kwin.aurorae") };
const QString s_defaultTheme { QStringLiteral("kwin4_decoration_qml_plastik") };
#endif
}
KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &arguments)
: KQuickAddons::ConfigModule(parent, arguments)
: KQuickAddons::ManagedConfigModule(parent, arguments)
, m_themesModel(new KDecoration2::Configuration::DecorationsModel(this))
, m_proxyThemesModel(new QSortFilterProxyModel(this))
, m_leftButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this))
, m_rightButtonsModel(new KDecoration2::Preview::ButtonsModel(DecorationButtonsList(), this))
, m_availableButtonsModel(new KDecoration2::Preview::ButtonsModel(this))
, m_savedSettings{ s_defaultBorderSize, s_defaultBorderSizeAuto, -2 /* for setTheme() */, false, s_defaultShowToolTips, s_defaultDecoButtonsOnLeft, s_defaultDecoButtonsOnRight }
, m_currentSettings(m_savedSettings)
, m_settings(new KWinDecorationSettings(this))
{
auto about = new KAboutData(QStringLiteral("kcm_kwindecoration"),
i18n("Window Decorations"),
......@@ -100,26 +67,35 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
i18n("Author"),
QStringLiteral("vpilo@coldshock.net"));
setAboutData(about);
setButtons(Apply | Default | Help);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
qmlRegisterType<QAbstractListModel>();
qmlRegisterType<QSortFilterProxyModel>();
qmlRegisterType<KWinDecorationSettings>();
#else
qmlRegisterAnonymousType<QAbstractListModel>("org.kde.kwin.KWinDecoration", 1);
qmlRegisterAnonymousType<QSortFilterProxyModel>("org.kde.kwin.KWinDecoration", 1);
qmlRegisterAnonymousType<KWinDecorationSettings>("org.kde.kwin.KWinDecoration", 1);
#endif
m_proxyThemesModel->setSourceModel(m_themesModel);
m_proxyThemesModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_proxyThemesModel->setSortCaseSensitivity(Qt::CaseInsensitive);
m_proxyThemesModel->sort(0);
connect(m_leftButtonsModel, &QAbstractItemModel::rowsInserted, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_leftButtonsModel, &QAbstractItemModel::rowsMoved, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_leftButtonsModel, &QAbstractItemModel::rowsRemoved, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_leftButtonsModel, &QAbstractItemModel::modelReset, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_rightButtonsModel, &QAbstractItemModel::rowsInserted, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_rightButtonsModel, &QAbstractItemModel::rowsMoved, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_rightButtonsModel, &QAbstractItemModel::rowsRemoved, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_rightButtonsModel, &QAbstractItemModel::modelReset, this, &KCMKWinDecoration::updateNeedsSave);
connect(m_settings, &KWinDecorationSettings::themeChanged, this, &KCMKWinDecoration::themeChanged);
connect(m_settings, &KWinDecorationSettings::borderSizeChanged, this, &KCMKWinDecoration::borderSizeChanged);
connect(m_leftButtonsModel, &QAbstractItemModel::rowsInserted, this, &KCMKWinDecoration::onLeftButtonsChanged);
connect(m_leftButtonsModel, &QAbstractItemModel::rowsMoved, this, &KCMKWinDecoration::onLeftButtonsChanged);
connect(m_leftButtonsModel, &QAbstractItemModel::rowsRemoved, this, &KCMKWinDecoration::onLeftButtonsChanged);
connect(m_leftButtonsModel, &QAbstractItemModel::modelReset, this, &KCMKWinDecoration::onLeftButtonsChanged);
connect(m_rightButtonsModel, &QAbstractItemModel::rowsInserted, this, &KCMKWinDecoration::onRightButtonsChanged);
connect(m_rightButtonsModel, &QAbstractItemModel::rowsMoved, this, &KCMKWinDecoration::onRightButtonsChanged);
connect(m_rightButtonsModel, &QAbstractItemModel::rowsRemoved, this, &KCMKWinDecoration::onRightButtonsChanged);
connect(m_rightButtonsModel, &QAbstractItemModel::modelReset, this, &KCMKWinDecoration::onRightButtonsChanged);
connect(this, &KCMKWinDecoration::borderSizeChanged, this, &KCMKWinDecoration::settingsChanged);
// Update the themes when the color scheme or a theme's settings change
QDBusConnection::sessionBus()
......@@ -129,6 +105,11 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
QMetaObject::invokeMethod(m_themesModel, "init", Qt::QueuedConnection);
}
KWinDecorationSettings *KCMKWinDecoration::settings() const
{
return m_settings;
}
void KCMKWinDecoration::reloadKWinSettings()
{
QMetaObject::invokeMethod(m_themesModel, "init", Qt::QueuedConnection);
......@@ -155,101 +136,51 @@ void KCMKWinDecoration::getNewStuff(QQuickItem *context)
void KCMKWinDecoration::load()
{
const KConfigGroup config = KSharedConfig::openConfig(s_configFile)->group(s_configGroup);
const QString plugin = config.readEntry(s_configPlugin, s_defaultPlugin);
const QString theme = config.readEntry(s_configTheme, s_defaultTheme);
int themeIndex = m_proxyThemesModel->mapFromSource(m_themesModel->findDecoration(plugin, theme)).row();
if (themeIndex < 0) {
qWarning() << "Plugin" << plugin << "and theme" << theme << "not found";
} else {
qDebug() << "Current theme: plugin" << plugin << "and theme" << theme;
}
setTheme(themeIndex);
ManagedConfigModule::load();
setCloseOnDoubleClickOnMenu(config.readEntry(s_configCloseOnDoubleClickOnMenu, s_defaultCloseOnDoubleClickOnMenu));
setShowToolTips(config.readEntry(s_configShowToolTips, s_defaultShowToolTips));
m_leftButtonsModel->replace(Utils::buttonsFromString(m_settings->buttonsOnLeft()));
m_rightButtonsModel->replace(Utils::buttonsFromString(m_settings->buttonsOnRight()));
const QString defaultSizeName = Utils::borderSizeToString(s_defaultBorderSize);
setBorderSize(Utils::stringToBorderSize(config.readEntry(s_configBorderSize, defaultSizeName)));
setBorderSizeAuto(config.readEntry(s_configBorderSizeAuto, s_defaultBorderSizeAuto));
setBorderSize(borderSizeIndexFromString(m_settings->borderSize()));
m_leftButtonsModel->replace(Utils::readDecorationButtons(config, s_configDecoButtonsOnLeft, s_defaultDecoButtonsOnLeft));
m_rightButtonsModel->replace(Utils::readDecorationButtons(config, s_configDecoButtonsOnRight, s_defaultDecoButtonsOnRight));
m_currentSettings.buttonsOnLeft = m_leftButtonsModel->buttons();
m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons();
m_savedSettings = m_currentSettings;
updateNeedsSave();
emit themeChanged();
}
void KCMKWinDecoration::save()
{
KConfigGroup config = KSharedConfig::openConfig(s_configFile)->group(s_configGroup);
if (m_currentSettings.themeIndex >= 0) {
const QModelIndex index = m_proxyThemesModel->index(m_currentSettings.themeIndex, 0);
if (index.isValid()) {
const QString plugin = index.data(KDecoration2::Configuration::DecorationsModel::PluginNameRole).toString();
const QString theme = index.data(KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString();
config.writeEntry(s_configPlugin, plugin);
config.writeEntry(s_configTheme, theme);
qDebug() << "Saved theme: plugin" << plugin << "and theme" << theme;
} else {
qWarning() << "Cannot match theme index" << m_currentSettings.themeIndex << "in model";
}
if (!m_settings->borderSizeAuto()) {
m_settings->setBorderSize(borderSizeIndexToString(m_borderSizeIndex));
} else {
m_settings->setBorderSize(m_settings->defaultBorderSizeValue());
}
config.writeEntry(s_configCloseOnDoubleClickOnMenu, m_currentSettings.closeOnDoubleClickOnMenu);
config.writeEntry(s_configShowToolTips, m_currentSettings.showToolTips);
config.writeEntry(s_configBorderSize, Utils::borderSizeToString(m_currentSettings.borderSize));
config.writeEntry(s_configBorderSizeAuto, m_currentSettings.borderSizeAuto);
config.writeEntry(s_configDecoButtonsOnLeft, Utils::buttonsToString(m_currentSettings.buttonsOnLeft), KConfigGroup::Notify);
config.writeEntry(s_configDecoButtonsOnRight, Utils::buttonsToString(m_currentSettings.buttonsOnRight), KConfigGroup::Notify);
config.sync();
m_savedSettings = m_currentSettings;
ManagedConfigModule::save();
// Send a signal to all kwin instances
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"),
QStringLiteral("org.kde.KWin"),
QStringLiteral("reloadConfig"));
QDBusConnection::sessionBus().send(message);
updateNeedsSave();
}
void KCMKWinDecoration::defaults()
{
int themeIndex = m_proxyThemesModel->mapFromSource(m_themesModel->findDecoration(s_defaultPlugin, s_defaultTheme)).row();
if (themeIndex < 0) {
qWarning() << "Default plugin" << s_defaultPlugin << "and theme" << s_defaultTheme << "not found";
}
setTheme(themeIndex);
setBorderSize(s_defaultBorderSize);
setBorderSizeAuto(s_defaultBorderSizeAuto);
setCloseOnDoubleClickOnMenu(s_defaultCloseOnDoubleClickOnMenu);
setShowToolTips(s_defaultShowToolTips);
ManagedConfigModule::defaults();
m_leftButtonsModel->replace(s_defaultDecoButtonsOnLeft);
m_rightButtonsModel->replace(s_defaultDecoButtonsOnRight);
setBorderSize(recommendedBorderSize());
updateNeedsSave();
m_leftButtonsModel->replace(Utils::buttonsFromString(m_settings->buttonsOnLeft()));
m_rightButtonsModel->replace(Utils::buttonsFromString(m_settings->buttonsOnRight()));
}
void KCMKWinDecoration::updateNeedsSave()
void KCMKWinDecoration::onLeftButtonsChanged()
{
m_currentSettings.buttonsOnLeft = m_leftButtonsModel->buttons();
m_currentSettings.buttonsOnRight = m_rightButtonsModel->buttons();
setNeedsSave(m_savedSettings.closeOnDoubleClickOnMenu != m_currentSettings.closeOnDoubleClickOnMenu
|| m_savedSettings.showToolTips != m_currentSettings.showToolTips
|| m_savedSettings.borderSize != m_currentSettings.borderSize
|| m_savedSettings.borderSizeAuto != m_currentSettings.borderSizeAuto
|| m_savedSettings.themeIndex != m_currentSettings.themeIndex
|| m_savedSettings.buttonsOnLeft != m_currentSettings.buttonsOnLeft
|| m_savedSettings.buttonsOnRight != m_currentSettings.buttonsOnRight);
m_settings->setButtonsOnLeft(Utils::buttonsToString(m_leftButtonsModel->buttons()));
}
void KCMKWinDecoration::onRightButtonsChanged()
{
m_settings->setButtonsOnRight(Utils::buttonsToString(m_rightButtonsModel->buttons()));
}
QSortFilterProxyModel *KCMKWinDecoration::themesModel() const
......@@ -279,13 +210,13 @@ QStringList KCMKWinDecoration::borderSizesModel() const
int KCMKWinDecoration::borderSize() const
{
return Utils::getBorderSizeNames().keys().indexOf(m_currentSettings.borderSize);
return m_borderSizeIndex;
}
int KCMKWinDecoration::recommendedBorderSize() const
{
typedef KDecoration2::Configuration::DecorationsModel::DecorationRole DecoRole;
const QModelIndex proxyIndex = m_proxyThemesModel->index(m_currentSettings.themeIndex, 0);
const QModelIndex proxyIndex = m_proxyThemesModel->index(theme(), 0);
if (proxyIndex.isValid()) {
const QModelIndex index = m_proxyThemesModel->mapToSource(proxyIndex);
if (index.isValid()) {
......@@ -296,80 +227,52 @@ int KCMKWinDecoration::recommendedBorderSize() const
return Utils::getBorderSizeNames().keys().indexOf(s_defaultRecommendedBorderSize);
}
bool KCMKWinDecoration::borderSizeAuto() const
{
return m_currentSettings.borderSizeAuto;
}
int KCMKWinDecoration::theme() const
{
return m_currentSettings.themeIndex;
return m_proxyThemesModel->mapFromSource(m_themesModel->findDecoration(m_settings->pluginName(), m_settings->theme())).row();
}
bool KCMKWinDecoration::closeOnDoubleClickOnMenu() const
{
return m_currentSettings.closeOnDoubleClickOnMenu;
}
bool KCMKWinDecoration::showToolTips() const
void KCMKWinDecoration::setBorderSize(int index)
{
return m_currentSettings.showToolTips;
if (m_borderSizeIndex != index) {
m_borderSizeIndex = index;
emit borderSizeChanged();
}
}
void KCMKWinDecoration::setBorderSize(int index)
void KCMKWinDecoration::setBorderSize(KDecoration2::BorderSize size)
{
setBorderSize(Utils::getBorderSizeNames().keys().at(index));
m_settings->setBorderSize(Utils::borderSizeToString(size));
}
void KCMKWinDecoration::setBorderSize(KDecoration2::BorderSize size)
void KCMKWinDecoration::setTheme(int index)
{
if (m_currentSettings.borderSize == size) {
return;
QModelIndex dataIndex = m_proxyThemesModel->index(index, 0);
if (dataIndex.isValid()) {
m_settings->setTheme(m_proxyThemesModel->data(dataIndex, KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString());
m_settings->setPluginName(m_proxyThemesModel->data(dataIndex, KDecoration2::Configuration::DecorationsModel::PluginNameRole).toString());
emit themeChanged();
}
m_currentSettings.borderSize = size;
emit borderSizeChanged();
updateNeedsSave();
}
void KCMKWinDecoration::setBorderSizeAuto(bool set)
bool KCMKWinDecoration::isSaveNeeded() const
{
if (m_currentSettings.borderSizeAuto == set) {
return;
}
m_currentSettings.borderSizeAuto = set;
emit borderSizeAutoChanged();
updateNeedsSave();
return !m_settings->borderSizeAuto() && borderSizeIndexFromString(m_settings->borderSize()) != m_borderSizeIndex;
}
void KCMKWinDecoration::setTheme(int index)
bool KCMKWinDecoration::isDefaults() const
{
// The initial themeIndex is set to -2 to always initially apply a theme, any theme
if (m_currentSettings.themeIndex == index) {
return;
}
m_currentSettings.themeIndex = index;
emit themeChanged();
updateNeedsSave();
return m_settings->borderSizeAuto() && recommendedBorderSize() == m_borderSizeIndex;
}
void KCMKWinDecoration::setCloseOnDoubleClickOnMenu(bool enable)
int KCMKWinDecoration::borderSizeIndexFromString(const QString &size) const
{
if (m_currentSettings.closeOnDoubleClickOnMenu == enable) {
return;
}
m_currentSettings.closeOnDoubleClickOnMenu = enable;
emit closeOnDoubleClickOnMenuChanged();
updateNeedsSave();
return Utils::getBorderSizeNames().keys().indexOf(Utils::stringToBorderSize(size));
}
void KCMKWinDecoration::setShowToolTips(bool show)
QString KCMKWinDecoration::borderSizeIndexToString(int index) const
{
if (m_currentSettings.showToolTips == show) {
return;
}
m_currentSettings.showToolTips = show;
emit showToolTipsChanged();
updateNeedsSave();
return Utils::borderSizeToString(Utils::getBorderSizeNames().keys().at(index));
}
#include "kcm.moc"
/*
* Copyright (c) 2019 Valerio Pilo <vpilo@coldshock.net>
* Copyright (c) 2019 Cyril Rossi <cyril.rossi@enioka.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -20,7 +21,7 @@
#include "utils.h"
#include <KQuickAddons/ConfigModule>
#include <KQuickAddons/ManagedConfigModule>
class QAbstractItemModel;
......@@ -46,24 +47,25 @@ class DecorationsModel;
}
}
class KCMKWinDecoration : public KQuickAddons::ConfigModule
class KWinDecorationSettings;
class KCMKWinDecoration : public KQuickAddons::ManagedConfigModule
{
Q_OBJECT
Q_PROPERTY(KWinDecorationSettings *settings READ settings CONSTANT)
Q_PROPERTY(QSortFilterProxyModel *themesModel READ themesModel CONSTANT)
Q_PROPERTY(QStringList borderSizesModel READ borderSizesModel CONSTANT)
Q_PROPERTY(int borderSize READ borderSize WRITE setBorderSize NOTIFY borderSizeChanged)
Q_PROPERTY(int recommendedBorderSize READ recommendedBorderSize CONSTANT)
Q_PROPERTY(bool borderSizeAuto READ borderSizeAuto WRITE setBorderSizeAuto NOTIFY borderSizeAutoChanged)
Q_PROPERTY(int theme READ theme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(QAbstractListModel *leftButtonsModel READ leftButtonsModel NOTIFY buttonsChanged)
Q_PROPERTY(QAbstractListModel *rightButtonsModel READ rightButtonsModel NOTIFY buttonsChanged)
Q_PROPERTY(QAbstractListModel *availableButtonsModel READ availableButtonsModel CONSTANT)
Q_PROPERTY(bool closeOnDoubleClickOnMenu READ closeOnDoubleClickOnMenu WRITE setCloseOnDoubleClickOnMenu NOTIFY closeOnDoubleClickOnMenuChanged)
Q_PROPERTY(bool showToolTips READ showToolTips WRITE setShowToolTips NOTIFY showToolTipsChanged)
public:
KCMKWinDecoration(QObject *parent, const QVariantList &arguments);
KWinDecorationSettings *settings() const;
QSortFilterProxyModel *themesModel() const;
QAbstractListModel *leftButtonsModel();
QAbstractListModel *rightButtonsModel();
......@@ -71,17 +73,11 @@ public:
QStringList borderSizesModel() const;
int borderSize() const;
int recommendedBorderSize() const;
bool borderSizeAuto() const;
int theme() const;
bool closeOnDoubleClickOnMenu() const;
bool showToolTips() const;
void setBorderSize(int index);
void setBorderSize(KDecoration2::BorderSize size);
void setBorderSizeAuto(bool set);
void setTheme(int index);
void setCloseOnDoubleClickOnMenu(bool enable);
void setShowToolTips(bool show);
Q_INVOKABLE void getNewStuff(QQuickItem *context);
......@@ -89,9 +85,6 @@ Q_SIGNALS:
void themeChanged();
void buttonsChanged();
void borderSizeChanged();
void borderSizeAutoChanged();
void closeOnDoubleClickOnMenuChanged();
void showToolTipsChanged();
public Q_SLOTS:
void load() override;
......@@ -99,10 +92,17 @@ public Q_SLOTS:
void defaults() override;
private Q_SLOTS:
void updateNeedsSave();
void onLeftButtonsChanged();
void onRightButtonsChanged();
void reloadKWinSettings();
private:
bool isSaveNeeded() const override;
bool isDefaults() const override;
int borderSizeIndexFromString(const QString &size) const;
QString borderSizeIndexToString(int index) const;
KDecoration2::Configuration::DecorationsModel *m_themesModel;
QSortFilterProxyModel *m_proxyThemesModel;
......@@ -112,17 +112,6 @@ private:
QPointer<KNS3::DownloadDialog> m_newStuffDialog;
struct Settings
{
KDecoration2::BorderSize borderSize;
bool borderSizeAuto;
int themeIndex;
bool closeOnDoubleClickOnMenu;
bool showToolTips;
DecorationButtonsList buttonsOnLeft;
DecorationButtonsList buttonsOnRight;
};
Settings m_savedSettings;
Settings m_currentSettings;
int m_borderSizeIndex = -1;
KWinDecorationSettings *m_settings;
};
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc" />
<group name="org.kde.kdecoration2">
<entry name="pluginName" key="library" type="String">
<label>Plugin name</label>
<code>#if HAVE_BREEZE_DECO
const QString s_defaultPlugin { QStringLiteral(BREEZE_KDECORATION_PLUGIN_ID) };
#else
const QString s_defaultPlugin { QStringLiteral("org.kde.kwin.aurorae") };
#endif
</code>
<default code="true">s_defaultPlugin</default>
</entry>
<entry name="theme" key="theme" type="String">
<label>Theme name</label>
<code>#if HAVE_BREEZE_DECO
const QString s_defaultTheme { QStringLiteral("Breeze") };
#else
const QString s_defaultTheme { QStringLiteral("kwin4_decoration_qml_plastik") };
#endif
</code>
<default code="true">s_defaultTheme</default>
</entry>
<entry name="borderSize" key="BorderSize" type="String">
<label>Window border size</label>
<default>Normal</default>
</entry>
<entry name="borderSizeAuto" key="BorderSizeAuto" type="Bool">
<label>Use theme's default window border size</label>
<default>true</default>
</entry>
<entry name="closeOnDoubleClickOnMenu" key="CloseOnDoubleClickOnMenu" type="Bool">
<label>Close windows by double clicking the menu button</label>
<default>false</default>
</entry>
<entry name="showToolTips" key="ShowToolTips" type="Bool">
<label>Show titlebar button tooltips</label>
<default>true</default>
</entry>
<entry name="buttonsOnLeft" key="ButtonsOnLeft" type="String">
<label>Titlebar left buttons</label>
<default>MS</default>
</entry>
<entry name="buttonsOnRight" key="ButtonsOnRight" type="String">
<label>Titlebar right buttons</label>
<default>HIAX</default>
</entry>
</group>
</kcfg>
File=kwindecorationsettings.kcfgc
ClassName=KWinDecorationSettings
Mutators=true
DefaultValueGetters=true
GenerateProperties=true
ParentInConstructor=true
......@@ -31,6 +31,8 @@ ColumnLayout {
Layout.fillHeight: true
property int buttonIconSize: units.iconSizes.medium
property int titleBarSpacing: units.smallSpacing * 2
readonly property bool draggingTitlebarButtons: leftButtonsView.dragging || rightButtonsView.dragging
readonly property bool hideDragHint: draggingTitlebarButtons || availableButtonsGrid.dragging
KDecoration.Bridge {
id: bridgeItem
......@@ -122,12 +124,12 @@ ColumnLayout {
}
index = childIndex + 1
}
if (drop.keys.indexOf("decoButtonAdd") != -1) {
if (drop.keys.indexOf("decoButtonAdd") !== -1) {
view.model.add(index, drag.source.type);
} else if (drop.keys.indexOf("decoButtonLeft") != -1) {
if (view == leftButtonsView) {
} else if (drop.keys.indexOf("decoButtonLeft") !== -1) {
if (view === leftButtonsView) {
// move in same view
if (index != drag.source.itemIndex) {
if (index !== drag.source.itemIndex) {
drag.source.buttonsModel.move(drag.source.itemIndex, index);
}
} else {
......@@ -135,10 +137,10 @@ ColumnLayout {
view.model.add(index, drag.source.type);
drag.source.buttonsModel.remove(drag.source.itemIndex);
}
} else if (drop.keys.indexOf("decoButtonRight") != -1) {
if (view == rightButtonsView) {
} else if (drop.keys.indexOf("decoButtonRight") !== -1) {
if (view === rightButtonsView) {
// move in same view
if (index != drag.source.itemIndex) {
if (index !== drag.source.itemIndex) {
drag.source.buttonsModel.move(drag.source.itemIndex, index);
}
} else {
......@@ -152,6 +154,7 @@ ColumnLayout {
}
GridView {
id: availableButtonsGrid
property bool dragging: false