Changeset View
Changeset View
Standalone View
Standalone View
kcms/desktoptheme/package/contents/ui/main.qml
Show All 20 Lines | |||||
21 | 21 | | |||
22 | import QtQuick 2.1 | 22 | import QtQuick 2.1 | ||
23 | import QtQuick.Layouts 1.1 | 23 | import QtQuick.Layouts 1.1 | ||
24 | import QtQuick.Dialogs 1.0 | 24 | import QtQuick.Dialogs 1.0 | ||
25 | import QtQuick.Controls 2.3 as QtControls | 25 | import QtQuick.Controls 2.3 as QtControls | ||
26 | import org.kde.kirigami 2.4 as Kirigami | 26 | import org.kde.kirigami 2.4 as Kirigami | ||
27 | import org.kde.kconfig 1.0 // for KAuthorized | 27 | import org.kde.kconfig 1.0 // for KAuthorized | ||
28 | import org.kde.kcm 1.1 as KCM | 28 | import org.kde.kcm 1.1 as KCM | ||
29 | import org.kde.private.kcms.desktoptheme 1.0 as Private | ||||
30 | | ||||
29 | 31 | | |||
30 | KCM.GridViewKCM { | 32 | KCM.GridViewKCM { | ||
31 | KCM.ConfigModule.quickHelp: i18n("This module lets you choose the Plasma style.") | 33 | KCM.ConfigModule.quickHelp: i18n("This module lets you choose the Plasma style.") | ||
32 | 34 | | |||
33 | view.model: kcm.desktopThemeModel | 35 | view.model: kcm.filteredModel | ||
34 | view.currentIndex: kcm.pluginIndex(kcm.desktopThemeSettings.name) | 36 | view.currentIndex: kcm.filteredModel.selectedThemeIndex | ||
37 | | ||||
38 | Binding { | ||||
39 | target: kcm.filteredModel | ||||
40 | property: "query" | ||||
41 | value: searchField.text | ||||
42 | } | ||||
43 | | ||||
44 | Binding { | ||||
45 | target: kcm.filteredModel | ||||
46 | property: "filter" | ||||
47 | value: filterCombo.model[filterCombo.currentIndex].filter | ||||
48 | } | ||||
35 | 49 | | |||
36 | enabled: !kcm.downloadingFile && !kcm.desktopThemeSettings.isImmutable("name") | 50 | enabled: !kcm.downloadingFile && !kcm.desktopThemeSettings.isImmutable("name") | ||
37 | 51 | | |||
38 | DropArea { | 52 | DropArea { | ||
39 | anchors.fill: parent | 53 | anchors.fill: parent | ||
40 | onEntered: { | 54 | onEntered: { | ||
41 | if (!drag.hasUrls) { | 55 | if (!drag.hasUrls) { | ||
42 | drag.accepted = false; | 56 | drag.accepted = false; | ||
43 | } | 57 | } | ||
44 | } | 58 | } | ||
45 | onDropped: kcm.installThemeFromFile(drop.urls[0]) | 59 | onDropped: kcm.installThemeFromFile(drop.urls[0]) | ||
46 | } | 60 | } | ||
61 | header: RowLayout { | ||||
62 | Layout.fillWidth: true | ||||
63 | | ||||
64 | QtControls.TextField { | ||||
65 | id: searchField | ||||
66 | Layout.fillWidth: true | ||||
67 | placeholderText: i18n("Search...") | ||||
68 | leftPadding: LayoutMirroring.enabled ? clearButton.width : undefined | ||||
69 | rightPadding: LayoutMirroring.enabled ? undefined : clearButton.width | ||||
70 | // this could be useful as a component | ||||
71 | MouseArea { | ||||
72 | id: clearButton | ||||
73 | anchors { | ||||
74 | top: parent.top | ||||
75 | topMargin: parent.topPadding | ||||
76 | right: parent.right | ||||
77 | // the TextField's padding is taking into account the clear button's size | ||||
78 | // so we just use the opposite one for positioning the clear button | ||||
79 | rightMargin: LayoutMirroring.enabled ? parent.rightPadding: parent.leftPadding | ||||
80 | bottom: parent.bottom | ||||
81 | bottomMargin: parent.bottomPadding | ||||
82 | } | ||||
83 | width: height | ||||
84 | | ||||
85 | opacity: searchField.length > 0 ? 1 : 0 | ||||
86 | onClicked: searchField.clear() | ||||
87 | | ||||
88 | Kirigami.Icon { | ||||
89 | anchors.fill: parent | ||||
90 | active: parent.pressed | ||||
91 | source: "edit-clear-locationbar-" + (LayoutMirroring.enabled ? "ltr" : "rtl") | ||||
92 | } | ||||
93 | | ||||
94 | Behavior on opacity { | ||||
95 | NumberAnimation { duration: Kirigami.Units.longDuration } | ||||
96 | } | ||||
97 | } | ||||
98 | } | ||||
99 | QtControls.ComboBox { | ||||
100 | id: filterCombo | ||||
101 | textRole: "text" | ||||
102 | model: [ | ||||
103 | {text: i18n("All Themes"), filter: Private.FilterProxyModel.AllThemes}, | ||||
104 | {text: i18n("Light Themes"), filter: Private.FilterProxyModel.LightThemes}, | ||||
105 | {text: i18n("Dark Themes"), filter: Private.FilterProxyModel.DarkThemes}, | ||||
106 | {text: i18n("Color scheme compatible"), filter: Private.FilterProxyModel.ThemesFollowingColors} | ||||
ndavis: "Color scheme compatible" is a bit better because it won't get shortened and even if it does… | |||||
107 | ] | ||||
108 | | ||||
109 | // HACK QQC2 doesn't support icons, so we just tamper with the desktop style ComboBox's background | ||||
110 | // and inject a nice little filter icon. | ||||
111 | Component.onCompleted: { | ||||
112 | if (!background || !background.hasOwnProperty("properties")) { | ||||
113 | // not a KQuickStyleItem | ||||
114 | return; | ||||
115 | } | ||||
116 | | ||||
117 | var props = background.properties || {}; | ||||
118 | | ||||
119 | background.properties = Qt.binding(function() { | ||||
120 | var newProps = props; | ||||
121 | newProps.currentIcon = "view-filter"; | ||||
122 | newProps.iconColor = Kirigami.Theme.textColor; | ||||
123 | return newProps; | ||||
124 | }); | ||||
125 | } | ||||
126 | } | ||||
127 | } | ||||
47 | 128 | | |||
48 | view.delegate: KCM.GridDelegate { | 129 | view.delegate: KCM.GridDelegate { | ||
49 | id: delegate | 130 | id: delegate | ||
50 | 131 | | |||
51 | text: model.themeName | 132 | text: model.display | ||
52 | subtitle: model.followsSystemColors ? i18n("Follows color scheme") : undefined | 133 | subtitle: model.colorType == Private.ThemesModel.FollowsColorTheme | ||
53 | toolTip: model.description || model.themeName | 134 | && view.model.filter != Private.FilterProxyModel.ThemesFollowingColors ? i18n("Follows color scheme") : "" | ||
135 | toolTip: model.description || model.display | ||||
54 | 136 | | |||
55 | opacity: model.pendingDeletion ? 0.3 : 1 | 137 | opacity: model.pendingDeletion ? 0.3 : 1 | ||
56 | Behavior on opacity { | 138 | Behavior on opacity { | ||
57 | NumberAnimation { duration: Kirigami.Units.longDuration } | 139 | NumberAnimation { duration: Kirigami.Units.longDuration } | ||
58 | } | 140 | } | ||
59 | 141 | | |||
60 | thumbnailAvailable: true | 142 | thumbnailAvailable: true | ||
61 | thumbnail: ThemePreview { | 143 | thumbnail: ThemePreview { | ||
Show All 10 Lines | 150 | Kirigami.Action { | |||
72 | visible: kcm.canEditThemes | 154 | visible: kcm.canEditThemes | ||
73 | onTriggered: kcm.editTheme(model.pluginName) | 155 | onTriggered: kcm.editTheme(model.pluginName) | ||
74 | }, | 156 | }, | ||
75 | Kirigami.Action { | 157 | Kirigami.Action { | ||
76 | iconName: "edit-delete" | 158 | iconName: "edit-delete" | ||
77 | tooltip: i18n("Remove Theme") | 159 | tooltip: i18n("Remove Theme") | ||
78 | enabled: model.isLocal | 160 | enabled: model.isLocal | ||
79 | visible: !model.pendingDeletion | 161 | visible: !model.pendingDeletion | ||
80 | onTriggered: kcm.setPendingDeletion(model.index, true); | 162 | onTriggered: model.pendingDeletion = true; | ||
81 | }, | 163 | }, | ||
82 | Kirigami.Action { | 164 | Kirigami.Action { | ||
83 | iconName: "edit-undo" | 165 | iconName: "edit-undo" | ||
84 | tooltip: i18n("Restore Theme") | 166 | tooltip: i18n("Restore Theme") | ||
85 | visible: model.pendingDeletion | 167 | visible: model.pendingDeletion | ||
86 | onTriggered: kcm.setPendingDeletion(model.index, false); | 168 | onTriggered: model.pendingDeletion = false; | ||
87 | } | 169 | } | ||
88 | ] | 170 | ] | ||
89 | 171 | | |||
90 | onClicked: { | 172 | onClicked: { | ||
91 | kcm.desktopThemeSettings.name = model.pluginName; | 173 | kcm.desktopThemeSettings.name = model.pluginName; | ||
92 | view.forceActiveFocus(); | 174 | view.forceActiveFocus(); | ||
93 | } | 175 | } | ||
94 | } | 176 | } | ||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |
"Color scheme compatible" is a bit better because it won't get shortened and even if it does, it'll be easier to see what the filter does.