Commit 3245c6bc authored by Filip Fila's avatar Filip Fila 🌆
Browse files

[Plasma Style KCM] Add a color-wheel sign denoting the theme supports the system color scheme

Summary:
The discoverability of the system color scheme awareness feature of some Plasma themes right now is very poor.

In addition to that the previews for Breeze and Breeze Light look identical when using the default color scheme.

To fix this we add a little color wheel icon in the top right corner of the theme preview that only shows up if the theme supports this.

Credits go to @broulik for most of the code, I just positioned the icon.

BUG: 364953

Test Plan:
Depends on: D25999

{F7818015}

Doesn't get messed up with scaling either.

Reviewers: #plasma, #vdg, ngraham

Reviewed By: #vdg, ngraham

Subscribers: ngraham, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25785
parent 3044e078
......@@ -68,6 +68,7 @@ KCMDesktopTheme::KCMDesktopTheme(QObject *parent, const QVariantList &args)
roles[PluginNameRole] = QByteArrayLiteral("pluginName");
roles[ThemeNameRole] = QByteArrayLiteral("themeName");
roles[DescriptionRole] = QByteArrayLiteral("description");
roles[FollowsSystemColorsRole] = QByteArrayLiteral("followsSystemColors");
roles[IsLocalRole] = QByteArrayLiteral("isLocal");
roles[PendingDeletionRole] = QByteArrayLiteral("pendingDeletion");
m_model->setItemRoleNames(roles);
......@@ -258,6 +259,8 @@ void KCMDesktopTheme::load()
name = packageName;
}
const bool isLocal = QFileInfo(theme).isWritable();
// Plasma Theme creates a KColorScheme out of the "color" file and falls back to system colors if there is none
const bool followsSystemColors = !QFileInfo::exists(themeRoot + QLatin1String("/colors"));
if (m_model->findItems(packageName).isEmpty()) {
QStandardItem *item = new QStandardItem;
......@@ -265,6 +268,7 @@ void KCMDesktopTheme::load()
item->setData(packageName, PluginNameRole);
item->setData(name, ThemeNameRole);
item->setData(df.readComment(), DescriptionRole);
item->setData(followsSystemColors, FollowsSystemColorsRole);
item->setData(isLocal, IsLocalRole);
item->setData(false, PendingDeletionRole);
m_model->appendRow(item);
......
......@@ -55,6 +55,7 @@ public:
PluginNameRole = Qt::UserRole + 1,
ThemeNameRole,
DescriptionRole,
FollowsSystemColorsRole,
IsLocalRole,
PendingDeletionRole
};
......
......@@ -17,6 +17,7 @@
*/
import QtQuick 2.4
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.5 as QQC2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.4 as Kirigami
import org.kde.plasma.components 2.0 as PlasmaComponents
......@@ -52,6 +53,7 @@ Item {
RowLayout {
id: contents
spacing: 0
anchors {
fill: parent
topMargin: background.generalMargin
......@@ -84,16 +86,13 @@ Item {
}
}
Item {
Layout.fillWidth: true
}
// Analog clock
Item {
id: clock
Layout.fillHeight: true
Layout.fillWidth: true
Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter
property int hours: 9
property int minutes: 5
......@@ -177,6 +176,13 @@ Item {
height: naturalSize.height * clock.svgScale
}
}
Kirigami.Icon {
visible: model.followsSystemColors
source: "color-profile"
width: Kirigami.Units.iconSizes.smallMedium
height: width
Layout.alignment: Qt.AlignRight && Qt.AlignTop
}
}
Component.onCompleted: {
......
......@@ -49,6 +49,7 @@ KCM.GridViewKCM {
id: delegate
text: model.themeName
subtitle: model.followsSystemColors ? i18n("Follows color scheme") : undefined
toolTip: model.description || model.themeName
opacity: model.pendingDeletion ? 0.3 : 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment