kcm/decorations: Simplify border selection
Use a single combobox instead of checkbox + combobox. Adds a new property that acts as a proxy for the configuration value, while internal configuration properties are kept unchanged. BUG: 426157 BUG: 417430 FIXED-IN: 5.21
This commit is contained in:
parent
1829dce1a9
commit
9cf52340ef
3 changed files with 35 additions and 41 deletions
|
@ -68,6 +68,10 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume
|
||||||
connect(m_data->settings(), &KWinDecorationSettings::themeChanged, this, &KCMKWinDecoration::themeChanged);
|
connect(m_data->settings(), &KWinDecorationSettings::themeChanged, this, &KCMKWinDecoration::themeChanged);
|
||||||
connect(m_data->settings(), &KWinDecorationSettings::borderSizeChanged, this, &KCMKWinDecoration::borderSizeChanged);
|
connect(m_data->settings(), &KWinDecorationSettings::borderSizeChanged, this, &KCMKWinDecoration::borderSizeChanged);
|
||||||
|
|
||||||
|
connect(m_data->settings(), &KWinDecorationSettings::borderSizeAutoChanged, this, &KCMKWinDecoration::borderIndexChanged);
|
||||||
|
connect(this, &KCMKWinDecoration::borderSizeChanged, this, &KCMKWinDecoration::borderIndexChanged);
|
||||||
|
connect(this, &KCMKWinDecoration::themeChanged, this, &KCMKWinDecoration::borderIndexChanged);
|
||||||
|
|
||||||
connect(m_leftButtonsModel, &QAbstractItemModel::rowsInserted, this, &KCMKWinDecoration::onLeftButtonsChanged);
|
connect(m_leftButtonsModel, &QAbstractItemModel::rowsInserted, this, &KCMKWinDecoration::onLeftButtonsChanged);
|
||||||
connect(m_leftButtonsModel, &QAbstractItemModel::rowsMoved, this, &KCMKWinDecoration::onLeftButtonsChanged);
|
connect(m_leftButtonsModel, &QAbstractItemModel::rowsMoved, this, &KCMKWinDecoration::onLeftButtonsChanged);
|
||||||
connect(m_leftButtonsModel, &QAbstractItemModel::rowsRemoved, this, &KCMKWinDecoration::onLeftButtonsChanged);
|
connect(m_leftButtonsModel, &QAbstractItemModel::rowsRemoved, this, &KCMKWinDecoration::onLeftButtonsChanged);
|
||||||
|
@ -188,7 +192,24 @@ QAbstractListModel *KCMKWinDecoration::availableButtonsModel() const
|
||||||
|
|
||||||
QStringList KCMKWinDecoration::borderSizesModel() const
|
QStringList KCMKWinDecoration::borderSizesModel() const
|
||||||
{
|
{
|
||||||
return Utils::getBorderSizeNames().values();
|
// Use index 0 for borderSizeAuto == true
|
||||||
|
// The rest of indexes get offset by 1
|
||||||
|
QStringList model = Utils::getBorderSizeNames().values();
|
||||||
|
model.insert(0, i18nc("%1 is the name of a border size",
|
||||||
|
"Theme's default (%1)", model.at(recommendedBorderSize())));
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KCMKWinDecoration::borderIndex() const
|
||||||
|
{
|
||||||
|
return settings()->borderSizeAuto() ? 0 : m_borderSizeIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KCMKWinDecoration::setBorderIndex(int index)
|
||||||
|
{
|
||||||
|
const bool borderAuto = (index == 0);
|
||||||
|
settings()->setBorderSizeAuto(borderAuto);
|
||||||
|
setBorderSize(borderAuto ? recommendedBorderSize() : index - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int KCMKWinDecoration::borderSize() const
|
int KCMKWinDecoration::borderSize() const
|
||||||
|
|
|
@ -43,8 +43,9 @@ class KCMKWinDecoration : public KQuickAddons::ManagedConfigModule
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(KWinDecorationSettings *settings READ settings CONSTANT)
|
Q_PROPERTY(KWinDecorationSettings *settings READ settings CONSTANT)
|
||||||
Q_PROPERTY(QSortFilterProxyModel *themesModel READ themesModel CONSTANT)
|
Q_PROPERTY(QSortFilterProxyModel *themesModel READ themesModel CONSTANT)
|
||||||
Q_PROPERTY(QStringList borderSizesModel READ borderSizesModel CONSTANT)
|
Q_PROPERTY(QStringList borderSizesModel READ borderSizesModel NOTIFY themeChanged)
|
||||||
Q_PROPERTY(int borderSize READ borderSize WRITE setBorderSize NOTIFY borderSizeChanged)
|
Q_PROPERTY(int borderIndex READ borderIndex WRITE setBorderIndex NOTIFY borderIndexChanged)
|
||||||
|
Q_PROPERTY(int borderSize READ borderSize NOTIFY borderSizeChanged)
|
||||||
Q_PROPERTY(int recommendedBorderSize READ recommendedBorderSize CONSTANT)
|
Q_PROPERTY(int recommendedBorderSize READ recommendedBorderSize CONSTANT)
|
||||||
Q_PROPERTY(int theme READ theme WRITE setTheme NOTIFY themeChanged)
|
Q_PROPERTY(int theme READ theme WRITE setTheme NOTIFY themeChanged)
|
||||||
Q_PROPERTY(QAbstractListModel *leftButtonsModel READ leftButtonsModel NOTIFY buttonsChanged)
|
Q_PROPERTY(QAbstractListModel *leftButtonsModel READ leftButtonsModel NOTIFY buttonsChanged)
|
||||||
|
@ -60,10 +61,12 @@ public:
|
||||||
QAbstractListModel *rightButtonsModel();
|
QAbstractListModel *rightButtonsModel();
|
||||||
QAbstractListModel *availableButtonsModel() const;
|
QAbstractListModel *availableButtonsModel() const;
|
||||||
QStringList borderSizesModel() const;
|
QStringList borderSizesModel() const;
|
||||||
|
int borderIndex() const;
|
||||||
int borderSize() const;
|
int borderSize() const;
|
||||||
int recommendedBorderSize() const;
|
int recommendedBorderSize() const;
|
||||||
int theme() const;
|
int theme() const;
|
||||||
|
|
||||||
|
void setBorderIndex(int index);
|
||||||
void setBorderSize(int index);
|
void setBorderSize(int index);
|
||||||
void setBorderSize(KDecoration2::BorderSize size);
|
void setBorderSize(KDecoration2::BorderSize size);
|
||||||
void setTheme(int index);
|
void setTheme(int index);
|
||||||
|
@ -73,6 +76,7 @@ public:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void themeChanged();
|
void themeChanged();
|
||||||
void buttonsChanged();
|
void buttonsChanged();
|
||||||
|
void borderIndexChanged();
|
||||||
void borderSizeChanged();
|
void borderSizeChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtQuick.Controls 2.4 as Controls
|
import QtQuick.Controls 2.4 as Controls
|
||||||
import org.kde.kcm 1.3 as KCM
|
import org.kde.kcm 1.5 as KCM
|
||||||
import org.kde.kconfig 1.0 // for KAuthorized
|
import org.kde.kconfig 1.0 // for KAuthorized
|
||||||
import org.kde.kirigami 2.4 as Kirigami
|
import org.kde.kirigami 2.4 as Kirigami
|
||||||
|
|
||||||
|
@ -81,49 +81,18 @@ Kirigami.Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Controls.CheckBox {
|
Controls.Label {
|
||||||
id: borderSizeAutoCheckbox
|
text: i18nc("Selector label", "Window border size:")
|
||||||
// Let it elide but don't make it push the ComboBox away from it
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.maximumWidth: implicitWidth
|
|
||||||
text: i18nc("checkbox label", "Use theme's default window border size")
|
|
||||||
checked: kcm.settings.borderSizeAuto
|
|
||||||
onToggled: {
|
|
||||||
kcm.settings.borderSizeAuto = checked;
|
|
||||||
borderSizeComboBox.autoBorderUpdate()
|
|
||||||
}
|
|
||||||
|
|
||||||
KCM.SettingStateBinding {
|
|
||||||
configObject: kcm.settings
|
|
||||||
settingName: "borderSizeAuto"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Controls.ComboBox {
|
Controls.ComboBox {
|
||||||
id: borderSizeComboBox
|
id: borderSizeComboBox
|
||||||
model: kcm.borderSizesModel
|
model: kcm.borderSizesModel
|
||||||
currentIndex: kcm.borderSize
|
currentIndex: kcm.borderIndex
|
||||||
onActivated: {
|
onActivated: {
|
||||||
kcm.borderSize = currentIndex
|
kcm.borderIndex = currentIndex
|
||||||
}
|
|
||||||
|
|
||||||
KCM.SettingStateBinding {
|
|
||||||
configObject: kcm.settings
|
|
||||||
settingName: "borderSize"
|
|
||||||
extraEnabledConditions: !borderSizeAutoCheckbox.checked
|
|
||||||
}
|
|
||||||
|
|
||||||
function autoBorderUpdate() {
|
|
||||||
if (borderSizeAutoCheckbox.checked) {
|
|
||||||
kcm.borderSize = kcm.recommendedBorderSize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: kcm
|
|
||||||
function onThemeChanged() {
|
|
||||||
borderSizeComboBox.autoBorderUpdate()
|
|
||||||
}
|
}
|
||||||
|
KCM.SettingHighlighter {
|
||||||
|
highlight: kcm.borderIndex != 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
|
|
Loading…
Reference in a new issue