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.Layouts 1.0 | 21 | import QtQuick.Controls 1.4 as QQC1 | ||
22 | import QtQuick.Controls 1.0 as QtControls1 | | |||
23 | import QtQuick.Controls 2.0 as QtControls | | |||
24 | import org.kde.kquickcontrols 2.0 as KQuickControls | 22 | import org.kde.kquickcontrols 2.0 as KQuickControls | ||
25 | 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 | ||||
26 | 25 | | |||
27 | ColumnLayout { | 26 | Kirigami.FormLayout { | ||
28 | id: root | 27 | id: root | ||
28 | twinFormLayouts: parentLayout | ||||
29 | anchors.left: parent.left | ||||
30 | anchors.right: parent.right | ||||
31 | | ||||
29 | property string cfg_Provider | 32 | property string cfg_Provider | ||
30 | property int cfg_FillMode | 33 | property int cfg_FillMode | ||
31 | property alias cfg_Color: colorButton.color | 34 | property alias cfg_Color: colorButton.color | ||
35 | property alias formLayout: root | ||||
36 | | ||||
32 | ListModel { | 37 | ListModel { | ||
33 | id: providerModel | 38 | id: providerModel | ||
34 | } | 39 | } | ||
35 | 40 | | |||
36 | function populateProviders() { | 41 | function populateProviders() { | ||
37 | providerModel.clear(); | 42 | providerModel.clear(); | ||
38 | var providers = engine.data["Providers"]; | 43 | var providers = engine.data["Providers"]; | ||
39 | if (providers) { | 44 | if (providers) { | ||
Show All 15 Lines | 59 | Component.onCompleted: { | |||
55 | populateProviders() | 60 | populateProviders() | ||
56 | for (var i = 0; i < providerModel.count; i++) { | 61 | for (var i = 0; i < providerModel.count; i++) { | ||
57 | if (providerModel.get(i)["id"] == wallpaper.configuration.Provider) { | 62 | if (providerModel.get(i)["id"] == wallpaper.configuration.Provider) { | ||
58 | providerComboBox.currentIndex = i; | 63 | providerComboBox.currentIndex = i; | ||
59 | break; | 64 | break; | ||
60 | } | 65 | } | ||
61 | } | 66 | } | ||
62 | } | 67 | } | ||
63 | | ||||
64 | Row { | | |||
65 | spacing: units.largeSpacing / 2 | | |||
66 | QtControls.Label { | | |||
67 | width: formAlignment - units.largeSpacing | | |||
68 | horizontalAlignment: Text.AlignRight | | |||
69 | anchors.verticalCenter: providerComboBox.verticalCenter | | |||
70 | text: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Providers:") | | |||
71 | } | | |||
72 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | 68 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | ||
73 | QtControls1.ComboBox { | 69 | QQC1.ComboBox { | ||
74 | id: providerComboBox | 70 | id: providerComboBox | ||
75 | property int textLength: 24 | 71 | TextMetrics { | ||
76 | width: theme.mSize(theme.defaultFont).width * textLength | 72 | id: providerTextMetrics | ||
73 | text: providerComboBox.currentText | ||||
74 | } | ||||
75 | implicitWidth: Math.max(providerTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken | ||||
76 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Providers:") | ||||
ngraham: This should not be plural and should probably say "Provider:" or maybe even "Source:". | |||||
77 | model: providerModel | 77 | model: providerModel | ||
78 | textRole: "name" | 78 | textRole: "name" | ||
79 | onCurrentIndexChanged: { | 79 | onCurrentIndexChanged: { | ||
80 | cfg_Provider = providerModel.get(currentIndex)["id"] | 80 | cfg_Provider = providerModel.get(currentIndex)["id"] | ||
81 | } | 81 | } | ||
82 | } | 82 | } | ||
83 | } | | |||
84 | 83 | | |||
85 | Row { | | |||
86 | //x: formAlignment - positionLabel.paintedWidth | | |||
87 | spacing: units.largeSpacing / 2 | | |||
88 | QtControls.Label { | | |||
89 | width: formAlignment - units.largeSpacing | | |||
90 | horizontalAlignment: Text.AlignRight | | |||
91 | anchors.verticalCenter: resizeComboBox.verticalCenter | | |||
92 | text: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") | | |||
93 | } | | |||
94 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | 84 | // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 | ||
95 | QtControls1.ComboBox { | 85 | QQC1.ComboBox { | ||
96 | id: resizeComboBox | 86 | id: resizeComboBox | ||
97 | property int textLength: 24 | 87 | TextMetrics { | ||
98 | width: theme.mSize(theme.defaultFont).width * textLength | 88 | id: resizeTextMetrics | ||
89 | text: resizeComboBox.currentText | ||||
90 | } | ||||
91 | 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:") | ||||
99 | model: [ | 93 | model: [ | ||
100 | { | 94 | { | ||
101 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled and Cropped"), | 95 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled and Cropped"), | ||
102 | 'fillMode': Image.PreserveAspectCrop | 96 | 'fillMode': Image.PreserveAspectCrop | ||
103 | }, | 97 | }, | ||
104 | { | 98 | { | ||
105 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled"), | 99 | 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled"), | ||
106 | 'fillMode': Image.Stretch | 100 | 'fillMode': Image.Stretch | ||
Show All 20 Lines | 120 | function setMethod() { | |||
127 | for (var i = 0; i < model.length; i++) { | 121 | for (var i = 0; i < model.length; i++) { | ||
128 | if (model[i]["fillMode"] == wallpaper.configuration.FillMode) { | 122 | if (model[i]["fillMode"] == wallpaper.configuration.FillMode) { | ||
129 | resizeComboBox.currentIndex = i; | 123 | resizeComboBox.currentIndex = i; | ||
130 | var tl = model[i]["label"].length; | 124 | var tl = model[i]["label"].length; | ||
131 | } | 125 | } | ||
132 | } | 126 | } | ||
133 | } | 127 | } | ||
134 | } | 128 | } | ||
135 | } | | |||
136 | 129 | | |||
137 | Row { | | |||
138 | id: colorRow | | |||
139 | spacing: units.largeSpacing / 2 | | |||
140 | QtControls.Label { | | |||
141 | width: formAlignment - units.largeSpacing | | |||
142 | horizontalAlignment: Text.AlignRight | | |||
143 | anchors.verticalCenter: colorButton.verticalCenter | | |||
144 | text: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") | | |||
145 | } | | |||
146 | KQuickControls.ColorButton { | 130 | KQuickControls.ColorButton { | ||
147 | id: colorButton | 131 | id: colorButton | ||
132 | Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") | ||||
148 | dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") | 133 | dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") | ||
149 | } | 134 | } | ||
150 | } | 135 | } | ||
151 | | ||||
152 | Item { // tighten layout | | |||
153 | Layout.fillHeight: true | | |||
154 | } | | |||
155 | } | |
This should not be plural and should probably say "Provider:" or maybe even "Source:".