Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/potd/contents/ui/config.qml
Show All 12 Lines | |||||
13 | * | 13 | * | ||
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.5 | 20 | import QtQuick 2.5 | ||
21 | import QtQuick.Controls 1.4 as QQC1 | 21 | import QtQuick.Controls 2.8 as QQC2 | ||
22 | import org.kde.kquickcontrols 2.0 as KQuickControls | 22 | import org.kde.kquickcontrols 2.0 as KQC2 | ||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | 23 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
24 | import org.kde.kirigami 2.5 as Kirigami | 24 | import org.kde.kirigami 2.5 as Kirigami | ||
25 | 25 | | |||
26 | Kirigami.FormLayout { | 26 | Kirigami.FormLayout { | ||
27 | id: root | 27 | id: root | ||
28 | twinFormLayouts: parentLayout | 28 | twinFormLayouts: parentLayout | ||
29 | anchors.left: parent.left | | |||
30 | anchors.right: parent.right | | |||
31 | 29 | | |||
32 | property string cfg_Provider | 30 | property string cfg_Provider | ||
33 | property string cfg_Category | 31 | property string cfg_Category | ||
34 | property int cfg_FillMode | 32 | property int cfg_FillMode | ||
35 | property alias cfg_Color: colorButton.color | 33 | property alias cfg_Color: colorButton.color | ||
36 | property alias formLayout: root | 34 | property alias formLayout: root | ||
37 | 35 | | |||
38 | ListModel { | 36 | ListModel { | ||
Show All 22 Lines | 58 | Component.onCompleted: { | |||
61 | populateProviders() | 59 | populateProviders() | ||
62 | for (var i = 0; i < providerModel.count; i++) { | 60 | for (var i = 0; i < providerModel.count; i++) { | ||
63 | if (providerModel.get(i)["id"] == wallpaper.configuration.Provider) { | 61 | if (providerModel.get(i)["id"] == wallpaper.configuration.Provider) { | ||
64 | providerComboBox.currentIndex = i; | 62 | providerComboBox.currentIndex = i; | ||
65 | break; | 63 | break; | ||
66 | } | 64 | } | ||
67 | } | 65 | } | ||
68 | } | 66 | } | ||
69 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | 67 | | ||
70 | QQC1.ComboBox { | 68 | QQC2.ComboBox { | ||
71 | id: providerComboBox | 69 | id: providerComboBox | ||
72 | TextMetrics { | | |||
73 | id: providerTextMetrics | | |||
74 | text: providerComboBox.currentText | | |||
75 | } | | |||
76 | implicitWidth: Math.max(providerTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken | | |||
77 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Provider:") | 70 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Provider:") | ||
78 | model: providerModel | 71 | model: providerModel | ||
79 | textRole: "name" | 72 | textRole: "name" | ||
80 | onCurrentIndexChanged: { | 73 | onCurrentIndexChanged: { | ||
81 | cfg_Provider = providerModel.get(currentIndex)["id"] | 74 | cfg_Provider = providerModel.get(currentIndex)["id"] | ||
82 | } | 75 | } | ||
83 | } | 76 | } | ||
84 | 77 | | |||
85 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | 78 | QQC2.ComboBox { | ||
86 | QQC1.ComboBox { | | |||
87 | id: categoryComboBox | 79 | id: categoryComboBox | ||
88 | visible: cfg_Provider === 'unsplash' | 80 | visible: cfg_Provider === 'unsplash' | ||
89 | TextMetrics { | | |||
90 | id: categoryTextMetrics | | |||
91 | text: categoryComboBox.currentText | | |||
92 | } | | |||
93 | implicitWidth: Math.max(providerTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken | | |||
94 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Category:") | 81 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Category:") | ||
95 | model: [ | 82 | model: [ | ||
96 | { | 83 | { | ||
97 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "All"), | 84 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "All"), | ||
98 | 'value': '1065976' | 85 | 'value': '1065976' | ||
99 | }, | 86 | }, | ||
100 | { | 87 | { | ||
101 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "1080p"), | 88 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "1080p"), | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 192 | Component.onCompleted: { | |||
206 | for (var i = 0; i < model.length; i++) { | 193 | for (var i = 0; i < model.length; i++) { | ||
207 | if (model[i]["value"] == wallpaper.configuration.Category) { | 194 | if (model[i]["value"] == wallpaper.configuration.Category) { | ||
208 | categoryComboBox.currentIndex = i; | 195 | categoryComboBox.currentIndex = i; | ||
209 | } | 196 | } | ||
210 | } | 197 | } | ||
211 | } | 198 | } | ||
212 | } | 199 | } | ||
213 | 200 | | |||
214 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | 201 | QQC2.ComboBox { | ||
215 | QQC1.ComboBox { | | |||
216 | id: resizeComboBox | 202 | id: resizeComboBox | ||
217 | TextMetrics { | | |||
218 | id: resizeTextMetrics | | |||
219 | text: resizeComboBox.currentText | | |||
220 | } | | |||
221 | implicitWidth: Math.max(resizeTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken | | |||
222 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") | 203 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") | ||
223 | model: [ | 204 | model: [ | ||
224 | { | 205 | { | ||
225 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled and Cropped"), | 206 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled and Cropped"), | ||
226 | 'fillMode': Image.PreserveAspectCrop | 207 | 'fillMode': Image.PreserveAspectCrop | ||
227 | }, | 208 | }, | ||
228 | { | 209 | { | ||
229 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled"), | 210 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled"), | ||
Show All 22 Lines | 232 | for (var i = 0; i < model.length; i++) { | |||
252 | if (model[i]["fillMode"] == wallpaper.configuration.FillMode) { | 233 | if (model[i]["fillMode"] == wallpaper.configuration.FillMode) { | ||
253 | resizeComboBox.currentIndex = i; | 234 | resizeComboBox.currentIndex = i; | ||
254 | var tl = model[i]["label"].length; | 235 | var tl = model[i]["label"].length; | ||
255 | } | 236 | } | ||
256 | } | 237 | } | ||
257 | } | 238 | } | ||
258 | } | 239 | } | ||
259 | 240 | | |||
260 | KQuickControls.ColorButton { | 241 | KQC2.ColorButton { | ||
261 | id: colorButton | 242 | id: colorButton | ||
262 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") | 243 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") | ||
263 | dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") | 244 | dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") | ||
264 | } | 245 | } | ||
265 | } | 246 | } |