Changeset View
Changeset View
Standalone View
Standalone View
applets/digital-clock/package/contents/ui/configAppearance.qml
Show All 15 Lines | |||||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. | ||
18 | * | 18 | * | ||
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | import QtQuick 2.0 | 23 | import QtQuick 2.0 | ||
24 | import QtQuick.Controls 1.0 as QtControls | 24 | import QtQuick.Controls 2.3 as QtControls | ||
25 | import QtQuick.Layouts 1.0 as QtLayouts | 25 | import QtQuick.Layouts 1.0 as QtLayouts | ||
26 | import org.kde.plasma.calendar 2.0 as PlasmaCalendar | 26 | import org.kde.plasma.calendar 2.0 as PlasmaCalendar | ||
27 | import org.kde.kirigami 2.5 as Kirigami | ||||
27 | 28 | | |||
28 | Item { | 29 | QtLayouts.ColumnLayout { | ||
29 | id: appearancePage | 30 | id: appearancePage | ||
30 | width: childrenRect.width | 31 | width: childrenRect.width | ||
31 | height: childrenRect.height | 32 | height: childrenRect.height | ||
32 | 33 | | |||
33 | signal configurationChanged | 34 | signal configurationChanged | ||
34 | 35 | | |||
35 | property string cfg_fontFamily | 36 | property string cfg_fontFamily | ||
36 | property alias cfg_boldText: boldCheckBox.checked | 37 | property alias cfg_boldText: boldCheckBox.checked | ||
37 | property string cfg_timeFormat: "" | 38 | property string cfg_timeFormat: "" | ||
38 | property alias cfg_italicText: italicCheckBox.checked | 39 | property alias cfg_italicText: italicCheckBox.checked | ||
39 | 40 | | |||
40 | property alias cfg_showLocalTimezone: showLocalTimezone.checked | 41 | property alias cfg_showLocalTimezone: showLocalTimezone.checked | ||
41 | property alias cfg_displayTimezoneAsCode: timezoneCodeRadio.checked | 42 | property alias cfg_displayTimezoneAsCode: timezoneCodeRadio.checked | ||
42 | property alias cfg_showSeconds: showSeconds.checked | 43 | property alias cfg_showSeconds: showSeconds.checked | ||
43 | 44 | | |||
44 | property alias cfg_showDate: showDate.checked | 45 | property alias cfg_showDate: showDate.checked | ||
45 | property string cfg_dateFormat: "shortDate" | 46 | property string cfg_dateFormat: "shortDate" | ||
46 | property alias cfg_use24hFormat: use24hFormat.checkedState | 47 | property alias cfg_use24hFormat: use24hFormat.checked | ||
47 | 48 | | |||
48 | onCfg_fontFamilyChanged: { | 49 | onCfg_fontFamilyChanged: { | ||
49 | // HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined | 50 | // HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined | ||
50 | if (cfg_fontFamily) { | 51 | if (cfg_fontFamily) { | ||
51 | for (var i = 0, j = fontsModel.count; i < j; ++i) { | 52 | for (var i = 0, j = fontsModel.count; i < j; ++i) { | ||
52 | if (fontsModel.get(i).value == cfg_fontFamily) { | 53 | if (fontsModel.get(i).value == cfg_fontFamily) { | ||
53 | fontFamilyComboBox.currentIndex = i | 54 | fontFamilyComboBox.currentIndex = i | ||
54 | break | 55 | break | ||
Show All 12 Lines | 63 | Component.onCompleted: { | |||
67 | var foundIndex = 0 | 68 | var foundIndex = 0 | ||
68 | for (var i = 0, j = fonts.length; i < j; ++i) { | 69 | for (var i = 0, j = fonts.length; i < j; ++i) { | ||
69 | arr.push({text: fonts[i], value: fonts[i]}) | 70 | arr.push({text: fonts[i], value: fonts[i]}) | ||
70 | } | 71 | } | ||
71 | append(arr) | 72 | append(arr) | ||
72 | } | 73 | } | ||
73 | } | 74 | } | ||
74 | 75 | | |||
75 | QtLayouts.ColumnLayout { | 76 | Kirigami.FormLayout { | ||
76 | anchors.left: parent.left | | |||
77 | | ||||
78 | QtControls.GroupBox { | | |||
79 | QtLayouts.Layout.fillWidth: true | 77 | QtLayouts.Layout.fillWidth: true | ||
80 | title: i18n("Information") | | |||
81 | flat: true | | |||
82 | 78 | | |||
83 | QtLayouts.ColumnLayout { | | |||
84 | QtControls.CheckBox { | 79 | QtControls.CheckBox { | ||
85 | id: showDate | 80 | id: showDate | ||
81 | Kirigami.FormData.label: i18n("Information:") | ||||
86 | text: i18n("Show date") | 82 | text: i18n("Show date") | ||
87 | } | 83 | } | ||
88 | 84 | | |||
89 | QtControls.CheckBox { | 85 | QtControls.CheckBox { | ||
90 | id: showSeconds | 86 | id: showSeconds | ||
91 | text: i18n("Show seconds") | 87 | text: i18n("Show seconds") | ||
92 | } | 88 | } | ||
93 | 89 | | |||
94 | QtControls.CheckBox { | 90 | QtControls.CheckBox { | ||
95 | id: use24hFormat | 91 | id: use24hFormat | ||
96 | text: i18nc("Checkbox label; means 24h clock format, without am/pm", "Use 24-hour Clock") | 92 | text: i18nc("Checkbox label; means 24h clock format, without am/pm", "Use 24-hour Clock") | ||
97 | } | 93 | } | ||
98 | 94 | | |||
99 | QtControls.CheckBox { | 95 | QtControls.CheckBox { | ||
100 | id: showLocalTimezone | 96 | id: showLocalTimezone | ||
101 | text: i18n("Show local time zone") | 97 | text: i18n("Show local time zone") | ||
102 | } | 98 | } | ||
103 | 99 | | |||
104 | QtControls.Label { | | |||
105 | text: i18n("Display time zone as:") | | |||
106 | } | | |||
107 | | ||||
108 | QtControls.GroupBox { | | |||
109 | QtLayouts.Layout.fillWidth: true | | |||
110 | flat: true | | |||
111 | QtLayouts.ColumnLayout { | 100 | QtLayouts.ColumnLayout { | ||
112 | 101 | Kirigami.FormData.label: i18n("Display time zone as:") | |||
113 | QtControls.ExclusiveGroup { id: timezoneDisplayType } | 102 | Kirigami.FormData.buddyFor: timezoneCityRadio | ||
114 | 103 | | |||
115 | QtControls.RadioButton { | 104 | QtControls.RadioButton { | ||
116 | id: timezoneCityRadio | 105 | id: timezoneCityRadio | ||
117 | text: i18n("Time zone city") | 106 | text: i18n("Time zone city") | ||
118 | exclusiveGroup: timezoneDisplayType | | |||
119 | } | 107 | } | ||
120 | 108 | | |||
121 | QtControls.RadioButton { | 109 | QtControls.RadioButton { | ||
122 | id: timezoneCodeRadio | 110 | id: timezoneCodeRadio | ||
123 | text: i18n("Time zone code") | 111 | text: i18n("Time zone code") | ||
124 | exclusiveGroup: timezoneDisplayType | | |||
125 | } | | |||
126 | } | 112 | } | ||
127 | } | 113 | } | ||
128 | 114 | | |||
129 | QtLayouts.RowLayout { | 115 | Item { | ||
130 | QtControls.Label { | 116 | Kirigami.FormData.isSection: true | ||
131 | text: i18n("Date format:") | | |||
132 | } | 117 | } | ||
133 | 118 | | |||
134 | QtControls.ComboBox { | 119 | QtControls.ComboBox { | ||
135 | id: dateFormat | 120 | id: dateFormat | ||
121 | Kirigami.FormData.label: i18n("Date format:") | ||||
136 | enabled: showDate.checked | 122 | enabled: showDate.checked | ||
137 | textRole: "label" | 123 | textRole: "label" | ||
138 | model: [ | 124 | model: [ | ||
139 | { | 125 | { | ||
140 | 'label': i18n("Long Date"), | 126 | 'label': i18n("Long Date"), | ||
141 | 'name': "longDate" | 127 | 'name': "longDate" | ||
142 | }, | 128 | }, | ||
143 | { | 129 | { | ||
Show All 10 Lines | |||||
154 | Component.onCompleted: { | 140 | Component.onCompleted: { | ||
155 | for (var i = 0; i < model.length; i++) { | 141 | for (var i = 0; i < model.length; i++) { | ||
156 | if (model[i]["name"] == plasmoid.configuration.dateFormat) { | 142 | if (model[i]["name"] == plasmoid.configuration.dateFormat) { | ||
157 | dateFormat.currentIndex = i; | 143 | dateFormat.currentIndex = i; | ||
158 | } | 144 | } | ||
159 | } | 145 | } | ||
160 | } | 146 | } | ||
161 | } | 147 | } | ||
162 | } | 148 | | ||
163 | } | 149 | Item { | ||
150 | Kirigami.FormData.isSection: true | ||||
164 | } | 151 | } | ||
165 | 152 | | |||
166 | QtLayouts.RowLayout { | 153 | QtLayouts.RowLayout { | ||
167 | QtLayouts.Layout.fillWidth: true | 154 | QtLayouts.Layout.fillWidth: true | ||
168 | 155 | | |||
169 | QtControls.Label { | 156 | Kirigami.FormData.label: i18n("Font style:") | ||
170 | text: i18n("Font style:") | | |||
171 | } | | |||
172 | 157 | | |||
173 | QtControls.ComboBox { | 158 | QtControls.ComboBox { | ||
174 | id: fontFamilyComboBox | 159 | id: fontFamilyComboBox | ||
175 | QtLayouts.Layout.fillWidth: true | 160 | QtLayouts.Layout.fillWidth: true | ||
161 | currentIndex: 0 | ||||
176 | // ComboBox's sizing is just utterly broken | 162 | // ComboBox's sizing is just utterly broken | ||
177 | QtLayouts.Layout.minimumWidth: units.gridUnit * 10 | 163 | QtLayouts.Layout.minimumWidth: units.gridUnit * 10 | ||
178 | model: fontsModel | 164 | model: fontsModel | ||
179 | // doesn't autodeduce from model because we manually populate it | 165 | // doesn't autodeduce from model because we manually populate it | ||
180 | textRole: "text" | 166 | textRole: "text" | ||
181 | 167 | | |||
182 | onCurrentIndexChanged: { | 168 | onCurrentIndexChanged: { | ||
183 | var current = model.get(currentIndex) | 169 | var current = model.get(currentIndex) | ||
184 | if (current) { | 170 | if (current) { | ||
185 | cfg_fontFamily = current.value | 171 | cfg_fontFamily = current.value | ||
186 | appearancePage.configurationChanged() | 172 | appearancePage.configurationChanged() | ||
187 | } | 173 | } | ||
188 | } | 174 | } | ||
189 | } | 175 | } | ||
190 | 176 | | |||
191 | QtControls.Button { | 177 | QtControls.Button { | ||
192 | id: boldCheckBox | 178 | id: boldCheckBox | ||
193 | tooltip: i18n("Bold text") | 179 | QtControls.ToolTip { | ||
194 | iconName: "format-text-bold" | 180 | text: i18n("Bold text") | ||
181 | } | ||||
182 | icon.name: "format-text-bold" | ||||
195 | checkable: true | 183 | checkable: true | ||
196 | Accessible.name: tooltip | 184 | Accessible.name: tooltip | ||
197 | } | 185 | } | ||
198 | 186 | | |||
199 | QtControls.Button { | 187 | QtControls.Button { | ||
200 | id: italicCheckBox | 188 | id: italicCheckBox | ||
201 | tooltip: i18n("Italic text") | 189 | QtControls.ToolTip { | ||
202 | iconName: "format-text-italic" | 190 | text: i18n("Italic text") | ||
191 | } | ||||
192 | icon.name: "format-text-italic" | ||||
203 | checkable: true | 193 | checkable: true | ||
204 | Accessible.name: tooltip | 194 | Accessible.name: tooltip | ||
205 | } | 195 | } | ||
206 | } | 196 | } | ||
207 | } | 197 | } | ||
198 | Item { | ||||
199 | QtLayouts.Layout.fillHeight: true | ||||
200 | } | ||||
208 | 201 | | |||
209 | Component.onCompleted: { | 202 | Component.onCompleted: { | ||
210 | if (plasmoid.configuration.displayTimezoneAsCode) { | 203 | if (plasmoid.configuration.displayTimezoneAsCode) { | ||
211 | timezoneCodeRadio.checked = true; | 204 | timezoneCodeRadio.checked = true; | ||
212 | } else { | 205 | } else { | ||
213 | timezoneCityRadio.checked = true; | 206 | timezoneCityRadio.checked = true; | ||
214 | } | 207 | } | ||
215 | } | 208 | } | ||
216 | } | 209 | } |