Warning, /plasma/plasma-workspace/kcms/style/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 import QtQuick 2.6
0008 import QtQuick.Layouts 1.1
0009 import org.kde.kirigami 2.5 as Kirigami
0010 import org.kde.kcmutils as KCM
0011 import org.kde.private.kcms.style 1.0 as Private
0012 
0013 KCM.GridViewKCM {
0014     id: root
0015 
0016     view.model: kcm.model
0017     view.currentIndex: kcm.model.selectedStyleIndex
0018 
0019     KCM.SettingStateBinding {
0020         configObject: kcm.styleSettings
0021         settingName: "widgetStyle"
0022     }
0023 
0024     function openGtkStyleSettings() {
0025         kcm.push("GtkStylePage.qml");
0026     }
0027 
0028     Component.onCompleted: {
0029         // The widget thumbnails are a bit more elaborate and need more room, especially when translated
0030         view.implicitCellWidth = Kirigami.Units.gridUnit * 21;
0031         view.implicitCellHeight = Kirigami.Units.gridUnit * 15;
0032     }
0033 
0034     // putting the InlineMessage as header item causes it to show up initially despite visible false
0035     header: ColumnLayout {
0036         Kirigami.InlineMessage {
0037             id: infoLabel
0038             Layout.fillWidth: true
0039 
0040             showCloseButton: true
0041             visible: false
0042 
0043             Connections {
0044                 target: kcm
0045                 function onShowErrorMessage(message) {
0046                     infoLabel.type = Kirigami.MessageType.Error;
0047                     infoLabel.text = message;
0048                     infoLabel.visible = true;
0049                 }
0050             }
0051         }
0052     }
0053 
0054     actions: [
0055         Kirigami.Action {
0056             id: effectSettingsButton
0057             text: i18n("Configure Icons and Toolbars")
0058             icon.name: "configure-toolbars" // proper icon?
0059             checkable: true
0060             checked: effectSettingsPopupLoader.popupOpen
0061             onTriggered: {
0062                 if (effectSettingsPopupLoader.popupOpen) {
0063                     effectSettingsPopupLoader.item.close()
0064                     // We don't set the Loader to inactive here since that would
0065                     // happen before the popup has closed; instead we use a
0066                     // Connections object in the Loader itself to handle it
0067                 } else {
0068                     effectSettingsPopupLoader.active = true;
0069                     effectSettingsPopupLoader.item.open();
0070                 }
0071             }
0072         },
0073         Kirigami.Action {
0074             visible: kcm.gtkConfigKdedModuleLoaded
0075             text: i18n("Configure GNOME/GTK Application Style…")
0076             icon.name: "configure"
0077             onTriggered: root.openGtkStyleSettings()
0078         }
0079     ]
0080 
0081     view.delegate: KCM.GridDelegate {
0082         id: delegate
0083 
0084         text: model.display
0085         toolTip: model.description
0086 
0087         thumbnailAvailable: thumbnailItem.valid
0088         thumbnail: Private.PreviewItem {
0089             id: thumbnailItem
0090             anchors.fill: parent
0091 
0092             smooth: false
0093             styleName: model.styleName
0094 
0095             Connections {
0096                 target: kcm
0097                 function onStyleReconfigured(message) {
0098                     if (styleName === model.styleName) {
0099                         thumbnailItem.reload();
0100                     }
0101                 }
0102             }
0103         }
0104 
0105         actions: [
0106             Kirigami.Action {
0107                 icon.name: "document-edit"
0108                 tooltip: i18n("Configure Style…")
0109                 enabled: model.configurable
0110                 onTriggered: kcm.configure(model.display, model.styleName, delegate)
0111             }
0112         ]
0113         onClicked: {
0114             kcm.model.selectedStyle = model.styleName;
0115             view.forceActiveFocus();
0116         }
0117         onDoubleClicked: {
0118             kcm.save();
0119         }
0120     }
0121 
0122     Loader {
0123         id: effectSettingsPopupLoader
0124 
0125         readonly property bool popupOpen: Boolean(effectSettingsPopupLoader.item?.opened)
0126 
0127         active: false
0128         sourceComponent: EffectSettingsPopup {
0129             parent: root
0130         }
0131 
0132         Connections {
0133             enabled: effectSettingsPopupLoader.active
0134             target: effectSettingsPopupLoader.item
0135             function onClosed() {
0136                 effectSettingsPopupLoader.active = false;
0137             }
0138         }
0139     }
0140 }