[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 Valerio Pilo <vpilo@coldshock.net>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-only
|
|
|
|
*/
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
const QMap<QString, KDecoration2::BorderSize> s_borderSizes {
|
|
|
|
{ QStringLiteral("None"), KDecoration2::BorderSize::None },
|
|
|
|
{ QStringLiteral("NoSides"), KDecoration2::BorderSize::NoSides },
|
|
|
|
{ QStringLiteral("Tiny"), KDecoration2::BorderSize::Tiny },
|
|
|
|
{ QStringLiteral("Normal"), KDecoration2::BorderSize::Normal },
|
|
|
|
{ QStringLiteral("Large"), KDecoration2::BorderSize::Large },
|
|
|
|
{ QStringLiteral("VeryLarge"), KDecoration2::BorderSize::VeryLarge },
|
|
|
|
{ QStringLiteral("Huge"), KDecoration2::BorderSize::Huge },
|
|
|
|
{ QStringLiteral("VeryHuge"), KDecoration2::BorderSize::VeryHuge },
|
|
|
|
{ QStringLiteral("Oversized"), KDecoration2::BorderSize::Oversized }
|
|
|
|
};
|
|
|
|
const QMap<KDecoration2::BorderSize, QString> s_borderSizeNames {
|
|
|
|
{ KDecoration2::BorderSize::None, i18n("No Borders") },
|
|
|
|
{ KDecoration2::BorderSize::NoSides, i18n("No Side Borders") },
|
|
|
|
{ KDecoration2::BorderSize::Tiny, i18n("Tiny") },
|
|
|
|
{ KDecoration2::BorderSize::Normal, i18n("Normal") },
|
|
|
|
{ KDecoration2::BorderSize::Large, i18n("Large") },
|
|
|
|
{ KDecoration2::BorderSize::VeryLarge, i18n("Very Large") },
|
|
|
|
{ KDecoration2::BorderSize::Huge, i18n("Huge") },
|
|
|
|
{ KDecoration2::BorderSize::VeryHuge, i18n("Very Huge") },
|
|
|
|
{ KDecoration2::BorderSize::Oversized, i18n("Oversized") }
|
|
|
|
};
|
|
|
|
|
|
|
|
const QHash<KDecoration2::DecorationButtonType, QChar> s_buttonNames {
|
|
|
|
{KDecoration2::DecorationButtonType::Menu, QChar('M') },
|
|
|
|
{KDecoration2::DecorationButtonType::ApplicationMenu, QChar('N') },
|
|
|
|
{KDecoration2::DecorationButtonType::OnAllDesktops, QChar('S') },
|
|
|
|
{KDecoration2::DecorationButtonType::ContextHelp, QChar('H') },
|
|
|
|
{KDecoration2::DecorationButtonType::Minimize, QChar('I') },
|
|
|
|
{KDecoration2::DecorationButtonType::Maximize, QChar('A') },
|
|
|
|
{KDecoration2::DecorationButtonType::Close, QChar('X') },
|
|
|
|
{KDecoration2::DecorationButtonType::KeepAbove, QChar('F') },
|
|
|
|
{KDecoration2::DecorationButtonType::KeepBelow, QChar('B') },
|
|
|
|
{KDecoration2::DecorationButtonType::Shade, QChar('L') }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace Utils
|
|
|
|
{
|
|
|
|
|
|
|
|
QString buttonsToString(const DecorationButtonsList &buttons)
|
|
|
|
{
|
|
|
|
auto buttonToString = [](KDecoration2::DecorationButtonType button) -> QChar {
|
|
|
|
const auto it = s_buttonNames.constFind(button);
|
|
|
|
if (it != s_buttonNames.constEnd()) {
|
|
|
|
return it.value();
|
|
|
|
}
|
|
|
|
return QChar();
|
|
|
|
};
|
|
|
|
QString ret;
|
|
|
|
for (auto button : buttons) {
|
|
|
|
ret.append(buttonToString(button));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-12-06 13:11:29 +00:00
|
|
|
DecorationButtonsList buttonsFromString(const QString &buttons)
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
{
|
2019-12-06 13:11:29 +00:00
|
|
|
DecorationButtonsList ret;
|
|
|
|
for (auto it = buttons.begin(); it != buttons.end(); ++it) {
|
|
|
|
for (auto it2 = s_buttonNames.constBegin(); it2 != s_buttonNames.constEnd(); ++it2) {
|
|
|
|
if (it2.value() == (*it)) {
|
|
|
|
ret << it2.key();
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-06 13:11:29 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
DecorationButtonsList readDecorationButtons(const KConfigGroup &config, const QString &key, const DecorationButtonsList &defaultValue)
|
|
|
|
{
|
[kcmkwin/kwindecoration] Rewrite the KWin decorations settings as a ConfigModule
Summary:
* Wrote new KCM based on KQuickAddons::ConfigModule.
* Remade QMLs for Buttons and Themes tabs.
* Updated bridge model code for new plugin lookup API (fixes warnings).
* Fixed decoration shadow changing messing with the previews sizes.
* Fixed button drag and drop issues (see D18104).
* Fixed default settings button behavior and detection of settings changes.
* Updated Get Hot New Stuff.
* Removed apply button in previewbridge.cpp: After applying changes, a theme's KCModule is invalidated.
BUG: 389431
BUG: 350122
BUG: 346222
BUG: 342816
BUG: 397595
{F6574963} | {F6574962} | {F6574961} | {F6574960}
Test Plan:
* Verified saving and loading for every setting
* Checked shadows of Breeze and Oxygen
* Tested all possible drag&drop operations on both sides of the fake titlebar
* Changed color schemes (with `kcmshell5 colors`) while showing the Themes tab to see if all previews update correctly their palettes
* Tested on a fresh Neon-developer account, via kcmshell and systemsettings
Reviewers: #vdg, abetts, ngraham, #kwin, davidedmundson
Reviewed By: #vdg, #kwin, davidedmundson
Subscribers: zzag, GB_2, ngraham, broulik, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18458
2019-02-07 15:32:05 +00:00
|
|
|
return buttonsFromString(config.readEntry(key, buttonsToString(defaultValue)));
|
|
|
|
}
|
|
|
|
|
|
|
|
KDecoration2::BorderSize stringToBorderSize(const QString &name)
|
|
|
|
{
|
|
|
|
auto it = s_borderSizes.constFind(name);
|
|
|
|
if (it == s_borderSizes.constEnd()) {
|
|
|
|
// non sense values are interpreted just like normal
|
|
|
|
return KDecoration2::BorderSize::Normal;
|
|
|
|
}
|
|
|
|
return it.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString borderSizeToString(KDecoration2::BorderSize size)
|
|
|
|
{
|
|
|
|
return s_borderSizes.key(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QMap<KDecoration2::BorderSize, QString> &getBorderSizeNames()
|
|
|
|
{
|
|
|
|
return s_borderSizeNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Utils
|