Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/potd/contents/ui/config.qml
Show All 24 Lines | |||||
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 | 29 | anchors.left: parent.left | ||
30 | anchors.right: parent.right | 30 | anchors.right: parent.right | ||
31 | 31 | | |||
32 | property string cfg_Provider | 32 | property string cfg_Provider | ||
33 | property string cfg_Category | ||||
33 | property int cfg_FillMode | 34 | property int cfg_FillMode | ||
34 | property alias cfg_Color: colorButton.color | 35 | property alias cfg_Color: colorButton.color | ||
35 | property alias formLayout: root | 36 | property alias formLayout: root | ||
36 | 37 | | |||
37 | ListModel { | 38 | ListModel { | ||
38 | id: providerModel | 39 | id: providerModel | ||
39 | } | 40 | } | ||
40 | 41 | | |||
Show All 37 Lines | 70 | QQC1.ComboBox { | |||
78 | textRole: "name" | 79 | textRole: "name" | ||
79 | onCurrentIndexChanged: { | 80 | onCurrentIndexChanged: { | ||
80 | cfg_Provider = providerModel.get(currentIndex)["id"] | 81 | cfg_Provider = providerModel.get(currentIndex)["id"] | ||
81 | } | 82 | } | ||
82 | } | 83 | } | ||
83 | 84 | | |||
84 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | 85 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | ||
85 | QQC1.ComboBox { | 86 | QQC1.ComboBox { | ||
87 | id: categoryComboBox | ||||
88 | 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:") | ||||
95 | model: [ | ||||
96 | { | ||||
97 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "All"), | ||||
98 | 'value': '1065976' | ||||
99 | }, | ||||
100 | ] | ||||
101 | | ||||
102 | textRole: "label" | ||||
103 | onCurrentIndexChanged: { | ||||
104 | cfg_Category = model[currentIndex]["value"] | ||||
105 | } | ||||
106 | Component.onCompleted: setMethod(); | ||||
107 | | ||||
108 | function setMethod() { | ||||
109 | for (var i = 0; i < model.length; i++) { | ||||
110 | if (model[i]["value"] == wallpaper.configuration.Category) { | ||||
111 | categoryComboBox.currentIndex = i; | ||||
112 | } | ||||
113 | } | ||||
114 | } | ||||
115 | } | ||||
116 | | ||||
117 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | ||||
118 | QQC1.ComboBox { | ||||
86 | id: resizeComboBox | 119 | id: resizeComboBox | ||
87 | TextMetrics { | 120 | TextMetrics { | ||
88 | id: resizeTextMetrics | 121 | id: resizeTextMetrics | ||
89 | text: resizeComboBox.currentText | 122 | text: resizeComboBox.currentText | ||
90 | } | 123 | } | ||
91 | implicitWidth: Math.max(resizeTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken | 124 | implicitWidth: Math.max(resizeTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken | ||
92 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") | 125 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") | ||
93 | model: [ | 126 | model: [ | ||
Show All 33 Lines | |||||
127 | } | 160 | } | ||
128 | } | 161 | } | ||
129 | 162 | | |||
130 | KQuickControls.ColorButton { | 163 | KQuickControls.ColorButton { | ||
131 | id: colorButton | 164 | id: colorButton | ||
132 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") | 165 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") | ||
133 | dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") | 166 | dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") | ||
134 | } | 167 | } | ||
135 | } | 168 | } | ||
ngraham: Since this is only used once, you don't need to make it a function; just put all of this stuff… | |||||
guoyunhe: Fixed. |
Since this is only used once, you don't need to make it a function; just put all of this stuff in the Component.onCompleted: directly