Warning, /plasma/plasma-sdk/themeexplorer/package/contents/ui/MetadataEditor.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.3 0008 import QtQuick.Layouts 1.1 0009 import QtQuick.Controls 2.15 0010 import QtQuick.Dialogs 0011 0012 Dialog { 0013 id: dialog 0014 property alias name: nameField.text 0015 property alias author: authorField.text 0016 property alias email: emailField.text 0017 property alias license: licenseField.editText 0018 property alias website: websiteField.text 0019 property bool newTheme: false 0020 0021 property bool canEdit: false 0022 0023 title: newTheme ? i18n("New Theme") : i18n("Edit Theme") 0024 0025 onVisibleChanged: { 0026 nameField.focus = true 0027 } 0028 0029 //all this reimplementing shouldn't be necessary, 0030 //but unfortunately native standard buttons management 0031 //is completely broken 0032 contentItem: Rectangle { 0033 implicitWidth: layout.Layout.minimumWidth + units.smallSpacing*2 0034 implicitHeight: layout.Layout.minimumHeight + units.smallSpacing*2 0035 0036 Keys.onPressed: { 0037 if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) { 0038 dialog.accept(); 0039 } else if (event.key == Qt.Key_Escape) { 0040 dialog.reject(); 0041 } 0042 } 0043 0044 SystemPalette { 0045 id: palette 0046 } 0047 color: palette.window 0048 0049 ColumnLayout { 0050 id: layout 0051 anchors { 0052 fill: parent 0053 margins: units.smallSpacing 0054 } 0055 Label { 0056 id: errorMessage 0057 text: "" 0058 property string defaultMEssage: newTheme ? "" : i18n("Warning: don't change author or license for themes you don't own") 0059 wrapMode: Text.WordWrap 0060 Layout.fillWidth: true 0061 } 0062 GridLayout { 0063 Layout.fillWidth: true 0064 columns: 2 0065 columnSpacing: units.smallSpacing 0066 0067 FormLabel { 0068 visible: newTheme 0069 text: i18n("Theme Name:") 0070 buddy: nameField 0071 } 0072 TextField { 0073 id: nameField 0074 visible: newTheme 0075 Layout.fillWidth: true 0076 onTextChanged: { 0077 if (!newTheme) { 0078 errorMessage.text = errorMessage.defaultMEssage; 0079 dialog.canEdit = true; 0080 return; 0081 } 0082 for (var i = 0; i < themeModel.themeList.count; ++i) { 0083 if (nameField.text == themeModel.themeList.get(i).packageNameRole) { 0084 dialog.canEdit = false; 0085 errorMessage.text = i18n("This theme name already exists"); 0086 return; 0087 } 0088 } 0089 errorMessage.text = ""; 0090 dialog.canEdit = true; 0091 } 0092 } 0093 FormLabel { 0094 text: i18n("Author:") 0095 buddy: authorField 0096 } 0097 TextField { 0098 id: authorField 0099 Layout.fillWidth: true 0100 } 0101 FormLabel { 0102 text: i18n("Email:") 0103 buddy: emailField 0104 } 0105 TextField { 0106 id: emailField 0107 Layout.fillWidth: true 0108 } 0109 FormLabel { 0110 text: i18n("License:") 0111 buddy: licenseField 0112 } 0113 ComboBox { 0114 id: licenseField 0115 Layout.fillWidth: true 0116 editable: true 0117 editText: "LGPL 2.1+" 0118 model: ["LGPL 2.1+", "GPL 2+", "GPL 3+", "LGPL 3+", "BSD"] 0119 } 0120 FormLabel { 0121 text: i18n("Website:") 0122 buddy: websiteField 0123 } 0124 TextField { 0125 id: websiteField 0126 Layout.fillWidth: true 0127 } 0128 } 0129 Item { 0130 Layout.fillHeight: true 0131 } 0132 DialogButtonBox { 0133 Layout.alignment: Qt.AlignRight 0134 Button { 0135 DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole 0136 text: i18n("OK") 0137 onClicked: dialog.accept() 0138 enabled: canEdit && nameField.text && authorField.text && emailField.text && websiteField.text 0139 } 0140 Button { 0141 DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole 0142 text: i18n("Cancel") 0143 onClicked: dialog.reject() 0144 } 0145 } 0146 } 0147 } 0148 0149 onAccepted: { 0150 if (newTheme) { 0151 themeModel.createNewTheme(nameField.text, authorField.text, emailField.text, licenseField.editText, websiteField.text); 0152 for (var i = 0; i < themeModel.themeList.count; ++i) { 0153 if (nameField.text == themeModel.themeList.get(i).packageNameRole) { 0154 themeSelector.currentIndex = i; 0155 break; 0156 } 0157 } 0158 } else { 0159 themeModel.editThemeMetaData(nameField.text, authorField.text, emailField.text, licenseField.editText, websiteField.text); 0160 } 0161 } 0162 }