Changeset View
Changeset View
Standalone View
Standalone View
kcms/translations/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2015 Marco Martin <mart@kde.org> | ||||
3 | * Copyright (C) 2018 Eike Hein <hein@kde.org> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Library General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2 of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This library is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | * Library General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Library General Public License | ||||
16 | * along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | * Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | import QtQuick 2.1 | ||||
22 | import QtQuick.Layouts 1.1 | ||||
23 | import QtQuick.Controls 2.3 as QtControls | ||||
24 | import org.kde.kirigami 2.4 as Kirigami | ||||
25 | import org.kde.plasma.core 2.1 as PlasmaCore | ||||
26 | import org.kde.kcm 1.2 | ||||
27 | | ||||
28 | ScrollViewKCM { | ||||
29 | id: root | ||||
30 | | ||||
31 | ConfigModule.quickHelp: i18n("Language") | ||||
32 | | ||||
33 | PlasmaCore.SortFilterModel { | ||||
34 | id: availableLanguagesModel | ||||
35 | | ||||
36 | sourceModel: kcm.translationsModel | ||||
37 | | ||||
38 | filterRole: "IsSelected" | ||||
39 | filterCallback: function(source_row, value) { return !value; } | ||||
40 | | ||||
41 | sortRole: "display" | ||||
42 | } | ||||
43 | | ||||
44 | Kirigami.OverlaySheet { | ||||
45 | id: addLanguagesSheet | ||||
46 | | ||||
47 | parent: root.parent | ||||
48 | | ||||
49 | topPadding: 0 | ||||
50 | leftPadding: 0 | ||||
51 | rightPadding: 0 | ||||
52 | bottomPadding: 0 | ||||
53 | | ||||
54 | header: Kirigami.Heading { text: i18nc("@title:window", "Add Languages") } | ||||
55 | | ||||
56 | property var selectedLanguages: [] | ||||
57 | | ||||
58 | onSheetOpenChanged: selectedLanguages = [] | ||||
59 | | ||||
60 | ListView { | ||||
aspotashev: Please add context:
```
i18nc("@title:window", "Add Languages")
``` | |||||
61 | implicitWidth: 18 * Kirigami.Units.gridUnit | ||||
62 | | ||||
63 | model: availableLanguagesModel | ||||
64 | | ||||
65 | delegate: Kirigami.BasicListItem { | ||||
66 | property string languageCode: model.LanguageCode | ||||
67 | | ||||
mart: same consideration for Layout.* in delegates | |||||
sorry, counter what i told you before, setting an explicit width: in lists in overlaysheets actually breaks them, https://imgur.com/a/CPMhtYX mart: sorry, counter what i told you before, setting an explicit width: in lists in overlaysheets… | |||||
68 | reserveSpaceForIcon: false | ||||
69 | | ||||
70 | label: model.display | ||||
71 | | ||||
72 | checkable: true | ||||
73 | onCheckedChanged: { | ||||
74 | if (checked) { | ||||
75 | addLanguagesSheet.selectedLanguages.push(index); | ||||
76 | | ||||
77 | // There's no property change notification for pushing to an array | ||||
78 | // in a var prop, so we can't bind selectedLanguages.length to | ||||
79 | // addLanguagesButton.enabled. | ||||
80 | addLanguagesButton.enabled = true; | ||||
81 | } else { | ||||
82 | addLanguagesSheet.selectedLanguages = addLanguagesSheet.selectedLanguages.filter(function(item) { return item !== index }); | ||||
83 | | ||||
84 | // There's no property change notification for pushing to an array | ||||
85 | // in a var prop, so we can't bind selectedLanguages.length to | ||||
86 | // addLanguagesButton.enabled. | ||||
87 | if (!addLanguagesSheet.selectedLanguages.length) { | ||||
88 | addLanguagesButton.enabled = false; | ||||
89 | } | ||||
90 | } | ||||
91 | } | ||||
92 | } | ||||
93 | } | ||||
94 | | ||||
95 | footer: RowLayout { | ||||
96 | QtControls.Button { | ||||
97 | id: addLanguagesButton | ||||
98 | | ||||
99 | Layout.alignment: Qt.AlignHCenter | ||||
100 | | ||||
101 | text: i18nc("@action:button", "Add") | ||||
102 | | ||||
103 | enabled: false | ||||
104 | | ||||
105 | onClicked: { | ||||
106 | var langs = []; | ||||
107 | addLanguagesSheet.selectedLanguages.sort().forEach(function(index) { | ||||
108 | langs.push(availableLanguagesModel.get(index).LanguageCode); | ||||
109 | }); | ||||
aspotashev: Please add context for translators:
```
i18nc("@action:button", "Add")
``` | |||||
110 | | ||||
111 | kcm.translationsModel.selectedLanguages = kcm.translationsModel.selectedLanguages.concat(langs); | ||||
112 | | ||||
113 | addLanguagesSheet.sheetOpen = false; | ||||
114 | } | ||||
115 | } | ||||
116 | } | ||||
117 | } | ||||
118 | | ||||
119 | header: ColumnLayout { | ||||
120 | id: messagesLayout | ||||
121 | | ||||
122 | spacing: Kirigami.Units.largeSpacing | ||||
123 | | ||||
124 | Kirigami.InlineMessage { | ||||
125 | Layout.fillWidth: true | ||||
126 | | ||||
127 | type: Kirigami.MessageType.Information | ||||
128 | | ||||
129 | text: i18nc("@info", "There are no languages available on this system.") | ||||
130 | | ||||
131 | visible: !availableLanguagesModel.count | ||||
132 | } | ||||
133 | | ||||
134 | Kirigami.InlineMessage { | ||||
135 | Layout.fillWidth: true | ||||
136 | | ||||
137 | type: kcm.everSaved ? Kirigami.MessageType.Positive : Kirigami.MessageType.Information | ||||
138 | | ||||
139 | text: (kcm.everSaved ? i18nc("@info", "Your changes will take effect the next time you log in.") | ||||
140 | : i18nc("@info", "There are currently no preferred languages configured.")) | ||||
141 | | ||||
142 | visible: !languagesList.count || kcm.everSaved | ||||
143 | } | ||||
144 | | ||||
145 | Kirigami.InlineMessage { | ||||
146 | Layout.fillWidth: true | ||||
Please add context: i18nc("@info", "There are no languages available on this system.") aspotashev: Please add context:
```
i18nc("@info", "There are no languages available on this system.")
``` | |||||
147 | | ||||
148 | type: Kirigami.MessageType.Error | ||||
149 | | ||||
150 | text: i18ncp("@info %2 is the language code", | ||||
151 | "The translation files for the language with the code '%2' could not be found. The language will be removed from your configuration. If you want to add it back, please install the localization files for it and add the language again.", | ||||
152 | "The translation files for the languages with the codes '%2' could not be found. These languages will be removed from your configuration. If you want to add them back, please install the localization files for it and the languages again.", | ||||
153 | kcm.translationsModel.missingLanguages.length, | ||||
154 | kcm.translationsModel.missingLanguages.join("', '")) | ||||
155 | | ||||
156 | visible: kcm.translationsModel.missingLanguages.length | ||||
157 | } | ||||
158 | | ||||
aspotashev: Please add context "@info" | |||||
159 | QtControls.Label { | ||||
160 | Layout.fillWidth: true | ||||
161 | | ||||
162 | visible: languagesList.count | ||||
163 | | ||||
164 | text: i18n("The language at the top of this list is is the one you want to see and use most often.") | ||||
165 | } | ||||
166 | } | ||||
167 | | ||||
168 | view: ListView { | ||||
169 | id: languagesList | ||||
170 | | ||||
171 | model: PlasmaCore.SortFilterModel { | ||||
aspotashev: Please add context "@info":
```
i18ncp("@info %2 is the language code",
``` | |||||
172 | sourceModel: kcm.translationsModel | ||||
173 | | ||||
174 | filterRole: "IsSelected" | ||||
175 | filterCallback: function(source_row, value) { return value; } | ||||
176 | | ||||
177 | sortRole: "SelectedPriority" | ||||
178 | } | ||||
179 | | ||||
180 | delegate: Kirigami.SwipeListItem { | ||||
181 | id: listItem | ||||
182 | | ||||
183 | width: ListView.view.width | ||||
184 | | ||||
185 | contentItem: RowLayout { | ||||
186 | width: implicitWidth | ||||
Layout.* attached properties are useless there, as items in a listview are not in a layout. width: languagesList.width mart: Layout.* attached properties are useless there, as items in a listview are not in a layout.
the… | |||||
187 | height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) | ||||
188 | | ||||
189 | anchors.verticalCenter: parent.verticalCenter | ||||
190 | | ||||
191 | Kirigami.Icon { | ||||
192 | visible: model.IsMissing | ||||
193 | | ||||
194 | Layout.alignment: Qt.AlignVCenter | ||||
195 | | ||||
196 | width: Kirigami.Units.iconSizes.smallMedium | ||||
197 | height: width | ||||
198 | | ||||
199 | source: "error" | ||||
200 | color: Kirigami.Theme.negativeTextColor | ||||
201 | } | ||||
202 | | ||||
203 | QtControls.Label { | ||||
204 | Layout.fillWidth: true | ||||
205 | | ||||
206 | Layout.alignment: Qt.AlignVCenter | ||||
207 | | ||||
208 | text: (index == 0) ? i18nc("@item:inlistbox 1 = Language name", "%1 (Default)", model.display) : model.display | ||||
209 | | ||||
210 | color: (model.IsMissing ? Kirigami.Theme.negativeTextColor | ||||
211 | : (listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) | ||||
212 | ? listItem.activeTextColor : listItem.textColor)) | ||||
213 | } | ||||
214 | } | ||||
215 | | ||||
216 | actions: [ | ||||
217 | Kirigami.Action { | ||||
218 | enabled: !model.IsMissing && index > 0 | ||||
219 | iconName: "go-top" | ||||
220 | tooltip: i18nc("@info:tooltip", "Promote to default") | ||||
221 | onTriggered: kcm.translationsModel.moveSelectedLanguage(index, 0) | ||||
222 | }, | ||||
223 | Kirigami.Action { | ||||
224 | enabled: !model.IsMissing && index > 0 | ||||
225 | iconName: "go-up" | ||||
226 | tooltip: i18nc("@info:tooltip", "Move up") | ||||
227 | onTriggered: kcm.translationsModel.moveSelectedLanguage(index, index - 1) | ||||
228 | }, | ||||
229 | Kirigami.Action { | ||||
230 | enabled: !model.IsMissing && index < (languagesList.count - 1) | ||||
231 | iconName: "go-down" | ||||
232 | tooltip: i18nc("@info:tooltip", "Move down") | ||||
233 | onTriggered: kcm.translationsModel.moveSelectedLanguage(index, index + 1) | ||||
234 | }, | ||||
235 | Kirigami.Action { | ||||
236 | enabled: !model.IsMissing | ||||
237 | iconName: "list-remove" | ||||
238 | tooltip: i18nc("@info:tooltip", "Remove") | ||||
239 | onTriggered: kcm.translationsModel.removeSelectedLanguage(model.LanguageCode) | ||||
240 | }] | ||||
241 | } | ||||
242 | } | ||||
243 | | ||||
244 | footer: RowLayout { | ||||
245 | id: footerLayout | ||||
246 | | ||||
247 | QtControls.Button { | ||||
248 | Layout.alignment: Qt.AlignRight | ||||
249 | | ||||
250 | enabled: availableLanguagesModel.count | ||||
251 | | ||||
252 | text: i18nc("@action:button", "Add languages...") | ||||
253 | | ||||
254 | onClicked: addLanguagesSheet.sheetOpen = !addLanguagesSheet.sheetOpen | ||||
255 | | ||||
256 | checkable: true | ||||
257 | checked: addLanguagesSheet.sheetOpen | ||||
258 | } | ||||
259 | } | ||||
260 | } | ||||
261 | | ||||
aspotashev: Please add context "@action:button" |
Please add context: