Changeset View
Changeset View
Standalone View
Standalone View
lookandfeelexplorer/package/contents/ui/MetadataEditor.qml
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.3 | 20 | import QtQuick 2.3 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | import QtQuick.Controls 1.2 | 22 | import QtQuick.Controls 2.4 as QQC2 | ||
23 | import QtQuick.Controls 1.3 | ||||
23 | import QtQuick.Dialogs 1.2 | 24 | import QtQuick.Dialogs 1.2 | ||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.kirigami 2.3 as Kirigami | ||
25 | 26 | | |||
26 | Dialog { | 27 | QQC2.Dialog { | ||
27 | id: dialog | 28 | id: dialog | ||
28 | property alias pluginName: pluginNameField.text | 29 | property alias pluginName: pluginNameField.text | ||
29 | property alias name: nameField.text | 30 | property alias name: nameField.text | ||
30 | property alias comment: commentField.text | 31 | property alias comment: commentField.text | ||
31 | property alias author: authorField.text | 32 | property alias author: authorField.text | ||
32 | property alias email: emailField.text | 33 | property alias email: emailField.text | ||
33 | property alias license: licenseField.editText | 34 | property alias license: licenseField.editText | ||
34 | property alias website: websiteField.text | 35 | property alias website: websiteField.text | ||
35 | 36 | | |||
36 | property bool canEdit: false | 37 | property bool canEdit: false | ||
37 | 38 | | |||
38 | width: 500 | 39 | width: 500 | ||
40 | x: (parent.width - width) / 2 | ||||
41 | y: (parent.height - height) / 2 | ||||
39 | title: i18n("New Theme") | 42 | title: i18n("New Theme") | ||
40 | 43 | | |||
41 | onVisibleChanged: { | 44 | onVisibleChanged: { | ||
42 | nameField.focus = true | 45 | nameField.focus = true | ||
43 | } | 46 | } | ||
44 | 47 | | |||
45 | //all this reimplementing shouldn't be necessary, | | |||
46 | //but unfortunately native standard buttons management | | |||
47 | //is completely broken | | |||
48 | contentItem: Rectangle { | 48 | contentItem: Rectangle { | ||
49 | implicitWidth: layout.Layout.minimumWidth + units.smallSpacing*2 | | |||
50 | implicitHeight: layout.Layout.minimumHeight + units.smallSpacing*2 | | |||
51 | | ||||
52 | Keys.onPressed: { | | |||
53 | if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) { | | |||
54 | dialog.accept(); | | |||
55 | } else if (event.key == Qt.Key_Escape) { | | |||
56 | dialog.reject(); | | |||
57 | } | | |||
58 | } | | |||
59 | | ||||
60 | SystemPalette { | 49 | SystemPalette { | ||
61 | id: palette | 50 | id: palette | ||
62 | } | 51 | } | ||
63 | color: palette.window | 52 | color: palette.window | ||
64 | 53 | | |||
65 | ColumnLayout { | 54 | ColumnLayout { | ||
66 | id: layout | 55 | id: layout | ||
67 | anchors { | 56 | anchors { | ||
68 | fill: parent | 57 | fill: parent | ||
69 | margins: units.smallSpacing | 58 | margins: units.smallSpacing | ||
70 | } | 59 | } | ||
71 | Label { | 60 | Label { | ||
72 | id: errorMessage | 61 | id: errorMessage | ||
73 | text: "" | 62 | text: "" | ||
74 | wrapMode: Text.WordWrap | 63 | wrapMode: Text.WordWrap | ||
75 | Layout.fillWidth: true | 64 | Layout.fillWidth: true | ||
76 | } | 65 | } | ||
77 | GridLayout { | 66 | Kirigami.FormLayout { | ||
78 | Layout.fillWidth: true | 67 | Layout.fillWidth: true | ||
79 | columns: 2 | 68 | QQC2.TextField { | ||
80 | columnSpacing: units.smallSpacing | | |||
81 | | ||||
82 | FormLabel { | | |||
83 | text: i18n("Theme Plugin Name:") | | |||
84 | buddy: pluginNameField | | |||
85 | } | | |||
86 | TextField { | | |||
87 | id: pluginNameField | 69 | id: pluginNameField | ||
88 | Layout.fillWidth: true | 70 | Layout.fillWidth: true | ||
71 | Kirigami.FormData.label: i18n("Theme Plugin Name:") | ||||
89 | onTextChanged: { | 72 | onTextChanged: { | ||
90 | for (var i = 0; i < lnfLogic.lnfList.count; ++i) { | 73 | for (var i = 0; i < lnfLogic.lnfList.count; ++i) { | ||
91 | if (pluginNameField.text == lnfLogic.lnfList.get(i).packageNameRole) { | 74 | if (pluginNameField.text == lnfLogic.lnfList.get(i).packageNameRole) { | ||
92 | dialog.canEdit = false; | 75 | dialog.canEdit = false; | ||
93 | errorMessage.text = i18n("This theme plugin name already exists"); | 76 | errorMessage.text = i18n("This theme plugin name already exists"); | ||
94 | return; | 77 | return; | ||
95 | } | 78 | } | ||
96 | } | 79 | } | ||
97 | errorMessage.text = ""; | 80 | errorMessage.text = ""; | ||
98 | dialog.canEdit = true; | 81 | dialog.canEdit = true; | ||
99 | } | 82 | } | ||
100 | } | 83 | } | ||
101 | FormLabel { | 84 | QQC2.TextField { | ||
102 | text: i18n("Theme Name:") | 85 | id: "nameField" | ||
103 | buddy: nameField | 86 | Kirigami.FormData.label: i18n("Theme Name:") | ||
104 | } | 87 | } | ||
105 | TextField { | 88 | QQC2.TextField { | ||
106 | id: nameField | 89 | id: "commentField" | ||
107 | Layout.fillWidth: true | 90 | Kirigami.FormData.label: i18n("Comment:") | ||
108 | onTextChanged: { | 91 | } | ||
109 | for (var i = 0; i < lnfLogic.lnfList.count; ++i) { | 92 | QQC2.TextField { | ||
110 | if (nameField.text == lnfLogic.lnfList.get(i).displayRole) { | 93 | id: "authorField" | ||
111 | dialog.canEdit = false; | 94 | Kirigami.FormData.label: i18n("Author:") | ||
112 | errorMessage.text = i18n("This theme name already exists"); | 95 | } | ||
113 | return; | 96 | QQC2.TextField { | ||
114 | } | 97 | id: "emailField" | ||
115 | } | 98 | Kirigami.FormData.label: i18n("Email:") | ||
116 | errorMessage.text = ""; | 99 | } | ||
117 | dialog.canEdit = true; | 100 | QQC2.TextField { | ||
118 | } | 101 | id: "versionField" | ||
119 | } | 102 | Kirigami.FormData.label: i18n("Version:") | ||
120 | FormLabel { | 103 | } | ||
121 | text: i18n("Comment:") | 104 | QQC2.TextField { | ||
122 | buddy: commentField | 105 | id: "websiteField" | ||
123 | } | 106 | Kirigami.FormData.label: i18n("Website:") | ||
124 | TextField { | | |||
125 | id: commentField | | |||
126 | Layout.fillWidth: true | | |||
127 | } | | |||
128 | FormLabel { | | |||
129 | text: i18n("Author:") | | |||
130 | buddy: authorField | | |||
131 | } | | |||
132 | TextField { | | |||
133 | id: authorField | | |||
134 | Layout.fillWidth: true | | |||
135 | } | | |||
136 | FormLabel { | | |||
137 | text: i18n("Email:") | | |||
138 | buddy: emailField | | |||
139 | } | | |||
140 | TextField { | | |||
141 | id: emailField | | |||
142 | Layout.fillWidth: true | | |||
143 | } | | |||
144 | FormLabel { | | |||
145 | text: i18n("License:") | | |||
146 | buddy: licenseField | | |||
147 | } | 107 | } | ||
148 | ComboBox { | 108 | ComboBox { | ||
guoyunhe: This need to be changed to `QQC2.ComboBox` | |||||
I tried but I get Type QQC2.ComboBox unavailable 60: StylePrivate.PropertyWriter is not a type ognarb: I tried but I get
```
Type QQC2.ComboBox unavailable
60: StylePrivate.PropertyWriter is not a… | |||||
149 | id: licenseField | 109 | id: licenseField | ||
150 | Layout.fillWidth: true | 110 | Layout.fillWidth: true | ||
111 | Kirigami.FormData.label: i18n("License:") | ||||
151 | editable: true | 112 | editable: true | ||
152 | editText: "LGPL 2.1+" | 113 | editText: "LGPL 2.1+" | ||
153 | model: ["LGPL 2.1+", "GPL 2+", "GPL 3+", "LGPL 3+", "BSD"] | 114 | model: ["LGPL 2.1+", "GPL 2+", "GPL 3+", "LGPL 3+", "BSD"] | ||
154 | } | 115 | } | ||
155 | FormLabel { | | |||
156 | text: i18n("Website:") | | |||
157 | buddy: websiteField | | |||
158 | } | | |||
159 | TextField { | | |||
160 | id: websiteField | | |||
161 | Layout.fillWidth: true | | |||
162 | } | 116 | } | ||
163 | } | 117 | } | ||
164 | Item { | | |||
165 | Layout.fillHeight: true | | |||
166 | } | 118 | } | ||
167 | RowLayout { | 119 | | ||
168 | Layout.alignment: Qt.AlignRight | 120 | | ||
169 | Button { | 121 | footer: QQC2.DialogButtonBox { | ||
122 | QQC2.Button { | ||||
170 | text: i18n("OK") | 123 | text: i18n("OK ") | ||
171 | onClicked: dialog.accept() | | |||
172 | isDefault: true | | |||
173 | enabled: canEdit && nameField.text && authorField.text && emailField.text && websiteField.text | 124 | enabled: canEdit && nameField.text && authorField.text && emailField.text && websiteField.text | ||
125 | QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole | ||||
126 | onClicked: dialog.accept() | ||||
174 | } | 127 | } | ||
175 | Button { | 128 | QQC2.Button { | ||
176 | text: i18n("Cancel") | 129 | text: i18n("Cancel") | ||
130 | QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.DestructiveRole | ||||
177 | onClicked: dialog.reject() | 131 | onClicked: dialog.reject() | ||
178 | } | 132 | } | ||
179 | } | 133 | } | ||
180 | } | | |||
181 | } | | |||
182 | 134 | | |||
183 | onAccepted: { | 135 | onAccepted: { | ||
184 | lnfLogic.createNewTheme(pluginNameField.text, nameField.text, commentField.text, authorField.text, emailField.text, licenseField.editText, websiteField.text); | 136 | lnfLogic.createNewTheme(pluginNameField.text, nameField.text, commentField.text, authorField.text, emailField.text, licenseField.editText, websiteField.text); | ||
185 | for (var i = 0; i < lnfLogic.lnfList.count; ++i) { | 137 | for (var i = 0; i < lnfLogic.lnfList.count; ++i) { | ||
186 | if (nameField.text == lnfLogic.lnfList.get(i).packageNameRole) { | 138 | if (nameField.text == lnfLogic.lnfList.get(i).packageNameRole) { | ||
187 | themeSelector.currentIndex = i; | 139 | themeSelector.currentIndex = i; | ||
188 | break; | 140 | break; | ||
189 | } | 141 | } | ||
190 | } | 142 | } | ||
191 | } | 143 | } | ||
192 | } | 144 | } |
This need to be changed to QQC2.ComboBox