Warning, /plasma/plasma-sdk/lookandfeelexplorer/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.0
0008 import QtQuick.Controls 2.15 as QQC2
0009 import QtQuick.Layouts 1.1
0010 
0011 import org.kde.draganddrop 2.0 as DragAndDrop
0012 import org.kde.kirigami 2.3 as Kirigami
0013 
0014 Kirigami.AbstractApplicationWindow {
0015     id: root
0016     width: Kirigami.Units.gridUnit * 50
0017     height: Kirigami.Units.gridUnit * 26
0018     visible: true
0019 
0020     Component.onCompleted: {
0021         for (var i = 0; i < lnfLogic.lnfList.count; ++i) {
0022             if (commandlineTheme == lnfLogic.lnfList.get(i).packageNameRole) {
0023                 themeSelector.currentIndex = i;
0024                 break;
0025             }
0026         }
0027     }
0028 
0029     globalDrawer: Kirigami.GlobalDrawer {
0030         title: i18n("Look And Feel")
0031         titleIcon: "preferences-desktop-theme"
0032         modal: true;
0033         collapsible: false;
0034         collapsed: false;
0035         topContent: QQC2.ComboBox {
0036             id: themeSelector
0037             Layout.fillWidth: true
0038             model: lnfLogic.lnfList
0039             textRole: "displayRole"
0040             onCurrentIndexChanged: {
0041                 lnfLogic.theme = lnfLogic.lnfList.get(currentIndex).packageNameRole;
0042             }
0043         }
0044         actions: [
0045             Kirigami.Action {
0046                 text: i18n("New Themeā€¦")
0047                 icon.name: "document-new"
0048                 onTriggered: {
0049                     if (!root.metadataEditor) {
0050                         root.metadataEditor = metadataEditorComponent.createObject(root);
0051                     }
0052                     root.metadataEditor.pluginName = "";
0053                     root.metadataEditor.name = "";
0054                     root.metadataEditor.comment = "";
0055                     root.metadataEditor.author = "";
0056                     root.metadataEditor.email = "";
0057                     root.metadataEditor.license = "LGPL 2.1+";
0058                     root.metadataEditor.website = "";
0059                     root.metadataEditor.open();
0060                 }
0061             },
0062             Kirigami.Action {
0063                 text: i18n("Open Theme Folder")
0064                 icon.name: "document-open-folder"
0065                 onTriggered: Qt.openUrlExternally(lnfLogic.themeFolder);
0066             }
0067         ]
0068     }
0069 
0070     property QtObject metadataEditor
0071     Component {
0072         id: metadataEditorComponent
0073         MetadataEditor {}
0074     }
0075 
0076     SystemPalette {
0077         id: palette
0078     }
0079 
0080     RowLayout {
0081         anchors {
0082             fill: parent
0083             margins: Kirigami.Units.largeSpacing
0084         }
0085         Layout.alignment: Qt.AlignHCenter
0086         ColumnLayout {
0087             Layout.alignment: Qt.AlignHCenter
0088             Layout.fillWidth: true
0089             Kirigami.FormLayout {
0090                 enabled: lnfLogic.isWritable
0091                 QQC2.Label {
0092                     text: i18n("Plugin name:") + lnfLogic.theme
0093                 }
0094                 FormField {
0095                     label: i18n("Name:")
0096                     key: "name"
0097                 }
0098                 FormField {
0099                     label: i18n("Comment:")
0100                     key: "comment"
0101                 }
0102                 FormField {
0103                     label: i18n("Author:")
0104                     key: "author"
0105                 }
0106                 FormField {
0107                     label: i18n("Email:")
0108                     key: "email"
0109                 }
0110                 FormField {
0111                     label: i18n("Version:")
0112                     key: "version"
0113                 }
0114                 FormField {
0115                     label: i18n("Website:")
0116                     key: "website"
0117                 }
0118                 FormField {
0119                     label: i18n("License:")
0120                     key: "license"
0121                 }
0122                 QQC2.Button {
0123                     text: i18n("Layout from current Plasma setup")
0124                     onClicked: lnfLogic.performLayoutDump = true
0125                     Layout.fillWidth: true
0126                 }
0127                 QQC2.Button {
0128                     text: i18n("Defaults from current setup")
0129                     onClicked: lnfLogic.performDefaultsDump = true
0130                     Layout.fillWidth: true
0131                 }
0132             }
0133         }
0134         Connections {
0135             target: lnfLogic
0136             function onThumbnailPathChanged() {
0137                 thumbnail.source = ""
0138                 thumbnail.source = lnfLogic.thumbnailPath
0139             }
0140             function onMessageRequested(level, message) {
0141                 root.showPassiveNotification(message);
0142             }
0143         }
0144         Rectangle {
0145             width: 250
0146             height: 250
0147             QQC2.Label {
0148                 anchors.centerIn: parent
0149                 text: i18n("Click to open an image")
0150                 visible: thumbnail.source == ""
0151             }
0152             Image {
0153                 id: thumbnail
0154                 anchors.fill: parent
0155                 fillMode: Image.PreserveAspectFit
0156 
0157                 cache: false
0158                 DragAndDrop.DropArea {
0159                     id: dropArea
0160                     anchors.fill: parent
0161                     onDrop: event => {
0162                         if (event.mimeData.urls[0]) {
0163                             lnfLogic.processThumbnail(event.mimeData.urls[0]);
0164                         }
0165                         event.accept(Qt.CopyAction);
0166                         thumbnail.sourceChanged(thumbnail.source);
0167                     }
0168                 }
0169                 MouseArea {
0170                     anchors.fill:parent
0171                     onClicked: {
0172                         lnfLogic.processThumbnail(lnfLogic.openFile());
0173                         thumbnail.sourceChanged(thumbnail.source);
0174                     }
0175                 }
0176             }
0177         }
0178     }
0179     QQC2.Button {
0180         anchors {
0181             right: parent.right
0182             bottom: parent.bottom
0183             margins: Kirigami.Units.largeSpacing
0184         }
0185         text: i18n("Save")
0186         enabled: lnfLogic.needsSave
0187         onClicked: lnfLogic.save()
0188     }
0189 }