Warning, /plasma/plasma-workspace/kcms/desktoptheme/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2014 Marco Martin <mart@kde.org>
0003 SPDX-FileCopyrightText: 2016 David Rosca <nowrep@gmail.com>
0004 SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
0005 SPDX-FileCopyrightText: 2019 Kevin Ottens <kevin.ottens@enioka.com>
0006
0007 SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009
0010 import QtCore
0011 import QtQuick 2.1
0012 import QtQuick.Layouts 1.1
0013 import QtQuick.Dialogs 6.3
0014 import QtQuick.Controls 2.3 as QtControls
0015 import QtQml 2.15
0016
0017 import org.kde.kirigami 2.8 as Kirigami
0018 import org.kde.newstuff 1.81 as NewStuff
0019 import org.kde.kcmutils as KCM
0020 import org.kde.private.kcms.desktoptheme 1.0 as Private
0021
0022
0023 KCM.GridViewKCM {
0024 id: root
0025
0026 view.model: kcm.filteredModel
0027 view.currentIndex: kcm.filteredModel.selectedThemeIndex
0028
0029 Binding {
0030 target: kcm.filteredModel
0031 property: "query"
0032 value: searchField.text
0033 restoreMode: Binding.RestoreBinding
0034 }
0035
0036 Binding {
0037 target: kcm.filteredModel
0038 property: "filter"
0039 value: filterCombo.model[filterCombo.currentIndex].filter
0040 restoreMode: Binding.RestoreBinding
0041 }
0042
0043 KCM.SettingStateBinding {
0044 configObject: kcm.desktopThemeSettings
0045 settingName: "name"
0046 extraEnabledConditions: !kcm.downloadingFile
0047 }
0048
0049 DropArea {
0050 anchors.fill: parent
0051 onEntered: {
0052 if (!drag.hasUrls) {
0053 drag.accepted = false;
0054 }
0055 }
0056 onDropped: kcm.installThemeFromFile(drop.urls[0])
0057 }
0058 header: RowLayout {
0059 Layout.fillWidth: true
0060
0061 Kirigami.SearchField {
0062 id: searchField
0063 Layout.fillWidth: true
0064 }
0065 QtControls.ComboBox {
0066 id: filterCombo
0067 textRole: "text"
0068 model: [
0069 {text: i18n("All Themes"), filter: Private.FilterProxyModel.AllThemes},
0070 {text: i18n("Light Themes"), filter: Private.FilterProxyModel.LightThemes},
0071 {text: i18n("Dark Themes"), filter: Private.FilterProxyModel.DarkThemes},
0072 {text: i18n("Color scheme compatible"), filter: Private.FilterProxyModel.ThemesFollowingColors}
0073 ]
0074
0075 // HACK QQC2 doesn't support icons, so we just tamper with the desktop style ComboBox's background
0076 // and inject a nice little filter icon.
0077 Component.onCompleted: {
0078 if (!background || !background.hasOwnProperty("properties")) {
0079 // not a KQuickStyleItem
0080 return;
0081 }
0082
0083 var props = background.properties || {};
0084
0085 background.properties = Qt.binding(function() {
0086 var newProps = props;
0087 newProps.currentIcon = "view-filter";
0088 newProps.iconColor = Kirigami.Theme.textColor;
0089 return newProps;
0090 });
0091 }
0092 }
0093 }
0094
0095 actions: [
0096 Kirigami.Action {
0097 text: i18n("Install from File…")
0098 icon.name: "document-import"
0099 onTriggered: fileDialogLoader.active = true
0100 },
0101 NewStuff.Action {
0102 text: i18n("Get New…")
0103 configFile: "plasma-themes.knsrc"
0104 onEntryEvent: function (entry, event) {
0105 kcm.load();
0106 }
0107 }
0108 ]
0109
0110 view.delegate: KCM.GridDelegate {
0111 id: delegate
0112
0113 text: model.display
0114 subtitle: model.colorType == Private.ThemesModel.FollowsColorTheme
0115 && view.model.filter != Private.FilterProxyModel.ThemesFollowingColors ? i18n("Follows color scheme") : ""
0116 toolTip: model.description || model.display
0117
0118 opacity: model.pendingDeletion ? 0.3 : 1
0119 Behavior on opacity {
0120 NumberAnimation { duration: Kirigami.Units.longDuration }
0121 }
0122
0123 thumbnailAvailable: true
0124 thumbnail: ThemePreview {
0125 id: preview
0126 anchors.fill: parent
0127 themeName: model.pluginName
0128 }
0129
0130 actions: [
0131 Kirigami.Action {
0132 icon.name: "document-edit"
0133 tooltip: i18n("Edit Theme…")
0134 enabled: !model.pendingDeletion
0135 visible: kcm.canEditThemes
0136 onTriggered: kcm.editTheme(model.pluginName)
0137 },
0138 Kirigami.Action {
0139 icon.name: "edit-delete"
0140 tooltip: i18n("Remove Theme")
0141 enabled: model.isLocal
0142 visible: !model.pendingDeletion
0143 onTriggered: model.pendingDeletion = true;
0144 },
0145 Kirigami.Action {
0146 icon.name: "edit-undo"
0147 tooltip: i18n("Restore Theme")
0148 visible: model.pendingDeletion
0149 onTriggered: model.pendingDeletion = false;
0150 }
0151 ]
0152
0153 onClicked: {
0154 kcm.desktopThemeSettings.name = model.pluginName;
0155 view.forceActiveFocus();
0156 }
0157 onDoubleClicked: {
0158 kcm.save();
0159 }
0160 }
0161
0162 footer: ColumnLayout {
0163 Kirigami.InlineMessage {
0164 id: infoLabel
0165 Layout.fillWidth: true
0166
0167 showCloseButton: true
0168
0169 Connections {
0170 target: kcm
0171 function onShowSuccessMessage(message) {
0172 infoLabel.type = Kirigami.MessageType.Positive;
0173 infoLabel.text = message;
0174 infoLabel.visible = true;
0175 }
0176 function onShowErrorMessage(message) {
0177 infoLabel.type = Kirigami.MessageType.Error;
0178 infoLabel.text = message;
0179 infoLabel.visible = true;
0180 }
0181 }
0182 }
0183 }
0184
0185 Loader {
0186 id: fileDialogLoader
0187 active: false
0188 sourceComponent: FileDialog {
0189 title: i18n("Open Theme")
0190 currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
0191 nameFilters: [ i18n("Theme Files (*.zip *.tar.gz *.tar.bz2)") ]
0192 Component.onCompleted: open()
0193 onAccepted: {
0194 kcm.installThemeFromFile(selectedFile)
0195 fileDialogLoader.active = false
0196 }
0197 onRejected: {
0198 fileDialogLoader.active = false
0199 }
0200 }
0201 }
0202 }