Warning, /plasma/plasma-sdk/themeexplorer/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.5 0008 import QtQuick.Controls 2.15 0009 import QtQuick.Layouts 1.1 0010 0011 import org.kde.plasma.core as PlasmaCore 0012 import org.kde.kirigami 2.20 as Kirigami 0013 import org.kde.kitemmodels as KItemModels 0014 0015 Kirigami.AbstractApplicationWindow { 0016 id: root 0017 width: Kirigami.Units.gridUnit * 50 0018 height: Kirigami.Units.gridUnit * 35 0019 visible: true 0020 property int iconSize: iconSizeSlider.value 0021 property alias showMargins: showMarginsCheckBox.checked 0022 0023 Shortcut { 0024 sequence: StandardKey.Quit 0025 onActivated: Qt.quit() 0026 } 0027 0028 header: ToolBar { 0029 RowLayout { 0030 anchors.fill: parent 0031 ToolButton { 0032 ToolTip.text: i18n("New Theme…") 0033 icon.name: "document-new" 0034 onClicked: { 0035 if (!root.metadataEditor) { 0036 root.metadataEditor = metadataEditorComponent.createObject(root); 0037 } 0038 root.metadataEditor.newTheme = true; 0039 root.metadataEditor.name = ""; 0040 root.metadataEditor.author = ""; 0041 root.metadataEditor.email = ""; 0042 root.metadataEditor.license = "LGPL 2.1+"; 0043 root.metadataEditor.website = ""; 0044 root.metadataEditor.open(); 0045 } 0046 } 0047 Label { 0048 text: i18n("Theme:") 0049 } 0050 ComboBox { 0051 id: themeSelector 0052 //FIXME: why crashes? 0053 //model: 3//themeModel.themeList 0054 textRole: "display" 0055 onCurrentIndexChanged: { 0056 themeModel.theme = themeModel.themeList.get(currentIndex).packageNameRole; 0057 } 0058 } 0059 ToolButton { 0060 ToolTip.text: i18n("Open Folder") 0061 icon.name: "document-open-folder" 0062 onClicked: Qt.openUrlExternally(themeModel.themeFolder); 0063 } 0064 ToolButton { 0065 ToolTip.text: i18n("Edit Metadata…") 0066 icon.name: "configure" 0067 enabled: view.currentItem?.modelData.isWritable ?? false 0068 onClicked: { 0069 if (!root.metadataEditor) { 0070 root.metadataEditor = metadataEditorComponent.createObject(root); 0071 } 0072 root.metadataEditor.newTheme = false; 0073 root.metadataEditor.name = themeModel.theme; 0074 root.metadataEditor.author = themeModel.author; 0075 root.metadataEditor.email = themeModel.email; 0076 root.metadataEditor.license = themeModel.license; 0077 root.metadataEditor.website = themeModel.website; 0078 root.metadataEditor.open(); 0079 } 0080 } 0081 ToolButton { 0082 ToolTip.text: i18n("Edit Colors…") 0083 icon.name: "color" 0084 enabled: view.currentItem?.modelData.isWritable ?? false 0085 onClicked: { 0086 if (!root.colorEditor) { 0087 root.colorEditor = colorEditorComponent.createObject(root); 0088 } 0089 0090 root.colorEditor.open(); 0091 } 0092 } 0093 Item { 0094 Layout.fillWidth: true 0095 Layout.fillHeight: true 0096 } 0097 ToolButton { 0098 ToolTip.text: i18n("Help") 0099 icon.name: "help-contents" 0100 onClicked: Qt.openUrlExternally("https://techbase.kde.org/Development/Tutorials/Plasma5/ThemeDetails"); 0101 } 0102 TextField { 0103 placeholderText: i18n("Search…") 0104 onTextChanged: searchModel.filterRegularExpression = RegExp(".*" + text + ".*") 0105 } 0106 } 0107 } 0108 0109 property QtObject metadataEditor 0110 Component { 0111 id: metadataEditorComponent 0112 MetadataEditor {} 0113 } 0114 property QtObject colorEditor 0115 Component { 0116 id: colorEditorComponent 0117 ColorEditor {} 0118 } 0119 0120 Timer { 0121 running: true 0122 interval: 200 0123 onTriggered: { 0124 themeSelector.model = themeModel.themeList 0125 for (var i = 0; i < themeModel.themeList.count; ++i) { 0126 if (commandlineTheme == themeModel.themeList.get(i).packageNameRole) { 0127 themeSelector.currentIndex = i; 0128 break; 0129 } 0130 } 0131 //NOTE:assigning this in a second moment solves a crash in some versions of Qt 5.8 0132 searchModel.sourceModel= themeModel 0133 } 0134 } 0135 SystemPalette { 0136 id: palette 0137 } 0138 0139 Rectangle { 0140 anchors.fill: scrollView 0141 Kirigami.Theme.colorSet: Kirigami.Theme.View 0142 color: Kirigami.Theme.backgroundColor 0143 } 0144 ScrollView { 0145 id: scrollView 0146 anchors { 0147 top: parent.top 0148 bottom: parent.bottom 0149 left: parent.left 0150 right: sidebar.left 0151 } 0152 GridView { 0153 id: view 0154 anchors.fill: parent 0155 model: KItemModels.KSortFilterProxyModel { 0156 id: searchModel 0157 filterRoleName: "imagePath" 0158 } 0159 cellWidth: root.iconSize 0160 cellHeight: cellWidth 0161 highlightMoveDuration: 0 0162 0163 highlight: Rectangle { 0164 radius: 3 0165 color: palette.highlight 0166 } 0167 delegate: Item { 0168 width: view.cellWidth 0169 height: view.cellHeight 0170 property QtObject modelData: model 0171 MouseArea { 0172 z: 2 0173 anchors.fill: parent 0174 onClicked: { 0175 view.currentIndex = index; 0176 } 0177 } 0178 Loader { 0179 z: -1 0180 anchors.fill: parent 0181 source: Qt.resolvedUrl("delegates/" + model.delegate + ".qml") 0182 } 0183 Rectangle { 0184 anchors { 0185 right: parent.right 0186 bottom: parent.bottom 0187 margins: Kirigami.Units.gridUnit 0188 } 0189 width: Kirigami.Units.gridUnit 0190 height: Kirigami.Units.gridUnit 0191 radius: Kirigami.Units.gridUnit 0192 opacity: 0.5 0193 color: model.usesFallback ? "red" : "green" 0194 } 0195 } 0196 } 0197 } 0198 Item { 0199 id: sidebar 0200 anchors { 0201 top: parent.top 0202 bottom: parent.bottom 0203 right: parent.right 0204 } 0205 width: root.width / 3 0206 Rectangle { 0207 width: 1 0208 anchors { 0209 top: parent.top 0210 bottom: parent.bottom 0211 } 0212 color: palette.highlight 0213 } 0214 ColumnLayout { 0215 anchors { 0216 fill: parent 0217 margins: Kirigami.Units.gridUnit 0218 } 0219 Label { 0220 Layout.fillWidth: true 0221 visible: !view.currentItem?.modelData.isWritable ?? false 0222 text: i18n("This is a readonly, system wide installed theme") 0223 wrapMode: Text.WordWrap 0224 } 0225 Label { 0226 Layout.fillWidth: true 0227 text: i18n("Preview:") 0228 } 0229 Loader { 0230 id: extendedLoader 0231 property QtObject model: view.currentItem?.modelData ?? null 0232 Layout.fillWidth: true 0233 Layout.minimumHeight: width 0234 source: model ? Qt.resolvedUrl("delegates/" + model.delegate + ".qml") : "" 0235 } 0236 Item { 0237 Layout.fillWidth: true 0238 Layout.fillHeight: true 0239 } 0240 Label { 0241 Layout.fillWidth: true 0242 text: i18n("Image path: %1", view.currentItem?.modelData.imagePath ?? i18n("None")) 0243 wrapMode: Text.WordWrap 0244 } 0245 Label { 0246 Layout.fillWidth: true 0247 text: i18n("Description: %1", view.currentItem?.modelData.description ?? "") 0248 wrapMode: Text.WordWrap 0249 } 0250 Label { 0251 Layout.fillWidth: true 0252 text: view.currentItem && view.currentItem.modelData.usesFallback ? i18n("Missing from this theme") : i18n("Present in this theme") 0253 wrapMode: Text.WordWrap 0254 } 0255 CheckBox { 0256 id: showMarginsCheckBox 0257 text: i18n("Show Margins") 0258 } 0259 Button { 0260 text: view.currentItem && view.currentItem.modelData.usesFallback ? i18n("Create with Editor…") : i18n("Open In Editor…") 0261 enabled: view.currentItem?.modelData.isWritable ?? false 0262 Layout.alignment: Qt.AlignHCenter 0263 onClicked: { 0264 print(view.currentItem.modelData.svgAbsolutePath) 0265 themeModel.editElement(view.currentItem.modelData.imagePath) 0266 //Qt.openUrlExternally(view.currentItem.modelData.svgAbsolutePath) 0267 } 0268 } 0269 Slider { 0270 id: iconSizeSlider 0271 Layout.fillWidth: true 0272 value: Kirigami.Units.gridUnit * 12 0273 from: Kirigami.Units.gridUnit * 5 0274 to: Kirigami.Units.gridUnit * 20 0275 } 0276 } 0277 } 0278 }