Changeset View
Changeset View
Standalone View
Standalone View
applets/digital-clock/package/contents/ui/configTimeZones.qml
Show All 13 Lines | |||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.0 | ||
22 | import QtQuick.Controls 1.2 as QtControls | 22 | import QtQuick.Controls 2.8 | ||
ngraham: `import QtQuick.Controls 2.5 as QQC2` | |||||
23 | import QtQuick.Layouts 1.0 | 23 | import QtQuick.Layouts 1.0 | ||
Next plasma release can only depend on Qt 5.12 Please can you change accordingly davidedmundson: Next plasma release can only depend on Qt 5.12
Please can you change accordingly | |||||
24 | import QtQuick.Dialogs 1.1 | 24 | import QtQuick.Dialogs 1.1 | ||
25 | 25 | | |||
26 | import org.kde.plasma.private.digitalclock 1.0 | 26 | import org.kde.plasma.private.digitalclock 1.0 | ||
27 | import org.kde.plasma.core 2.0 as PlasmaCore | 27 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
28 | import org.kde.plasma.components 2.0 as PlasmaComponents | 28 | import org.kde.kirigami 2.5 as Kirigami | ||
29 | 29 | | |||
30 | Item { | 30 | Item { | ||
31 | id: timeZonesPage | 31 | id: timeZonesPage | ||
32 | width: parent.width | | |||
33 | height: parent.height | | |||
34 | 32 | | |||
35 | property alias cfg_selectedTimeZones: timeZones.selectedTimeZones | 33 | property alias cfg_selectedTimeZones: timeZones.selectedTimeZones | ||
36 | property alias cfg_wheelChangesTimezone: enableWheelCheckBox.checked | 34 | property alias cfg_wheelChangesTimezone: enableWheelCheckBox.checked | ||
37 | 35 | | |||
36 | ColumnLayout { | ||||
37 | anchors.fill: parent | ||||
38 | | ||||
38 | TimeZoneModel { | 39 | TimeZoneModel { | ||
While you're doing some porting, this entire thing can be replaced with a Kirigami.InlineMessage which will drastically reduce the amount of code here, and you can also remove the PlasmaComponents import (PlasmaCore is still needed for units, unless you want to also port things to use Kirigami.Units instead) ngraham: While you're doing some porting, this entire thing can be replaced with a `Kirigami. | |||||
You can take my changes from D24853 kmaterka: You can take my changes from D24853 | |||||
39 | id: timeZones | 40 | id: timeZones | ||
40 | 41 | | |||
41 | onSelectedTimeZonesChanged: { | 42 | onSelectedTimeZonesChanged: { | ||
42 | if (selectedTimeZones.length === 0) { | 43 | if (selectedTimeZones.length === 0) { | ||
43 | messageWidget.visible = true; | 44 | messageWidget.visible = true; | ||
44 | 45 | | |||
45 | timeZones.selectLocalTimeZone(); | 46 | timeZones.selectLocalTimeZone(); | ||
46 | } | 47 | } | ||
47 | } | 48 | } | ||
48 | } | 49 | } | ||
49 | 50 | | |||
50 | // This is just for getting the column width | 51 | Kirigami.InlineMessage { | ||
51 | QtControls.CheckBox { | | |||
52 | id: checkbox | | |||
53 | visible: false | | |||
54 | } | | |||
55 | | ||||
56 | | ||||
57 | ColumnLayout { | | |||
58 | anchors.fill: parent | | |||
59 | | ||||
60 | Rectangle { | | |||
61 | id: messageWidget | 52 | id: messageWidget | ||
62 | | ||||
63 | anchors { | | |||
64 | left: parent.left | | |||
65 | right: parent.right | | |||
66 | margins: 1 | | |||
67 | } | | |||
68 | | ||||
69 | height: 0 | | |||
70 | | ||||
71 | //TODO: This is the actual color KMessageWidget uses as its base color but here it gives | | |||
72 | // a different color, figure out why | | |||
73 | //property color gradBaseColor: Qt.rgba(0.69, 0.5, 0, 1) | | |||
74 | gradient: Gradient { | | |||
75 | GradientStop { position: 0.0; color: "#FFD86D" } //Qt.lighter(messageWidget.gradBaseColor, 1.1) | | |||
76 | GradientStop { position: 0.1; color: "#EAC360" } // messageWidget.gradBaseColor | | |||
77 | GradientStop { position: 1.0; color: "#CAB064" } //Qt.darker(messageWidget.gradBaseColor, 1.1) | | |||
78 | } | | |||
79 | | ||||
80 | radius: 5 | | |||
81 | border.width: 1 | | |||
82 | border.color: "#79735B" | | |||
83 | | ||||
84 | visible: false | | |||
85 | | ||||
86 | Behavior on visible { | | |||
87 | ParallelAnimation { | | |||
88 | PropertyAnimation { | | |||
89 | target: messageWidget | | |||
90 | property: "opacity" | | |||
91 | to: messageWidget.visible ? 0 : 1.0 | | |||
92 | easing.type: Easing.Linear | | |||
93 | } | | |||
94 | PropertyAnimation { | | |||
95 | target: messageWidget | | |||
96 | property: "Layout.minimumHeight" | | |||
97 | to: messageWidget.visible ? 0 : messageWidgetLabel.height + (2 *units.largeSpacing) | | |||
98 | easing.type: Easing.Linear | | |||
99 | } | | |||
100 | } | | |||
101 | } | | |||
102 | | ||||
103 | RowLayout { | | |||
104 | anchors.fill: parent | | |||
105 | anchors.margins: units.largeSpacing | | |||
106 | anchors.leftMargin: units.smallSpacing | | |||
107 | anchors.rightMargin: units.smallSpacing | | |||
108 | spacing: units.smallSpacing | | |||
109 | | ||||
110 | PlasmaCore.IconItem { | | |||
111 | anchors.verticalCenter: parent.verticalCenter | | |||
112 | height: units.iconSizes.smallMedium | | |||
113 | width: height | | |||
114 | source: "dialog-warning" | | |||
115 | } | | |||
116 | | ||||
117 | QtControls.Label { | | |||
118 | id: messageWidgetLabel | | |||
119 | anchors.verticalCenter: parent.verticalCenter | | |||
120 | Layout.fillWidth: true | 53 | Layout.fillWidth: true | ||
54 | Layout.margins: Kirigami.Units.smallSpacing | ||||
55 | type: Kirigami.MessageType.Warning | ||||
121 | text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") | 56 | text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") | ||
122 | verticalAlignment: Text.AlignVCenter | 57 | showCloseButton: true | ||
123 | wrapMode: Text.WordWrap | | |||
124 | } | 58 | } | ||
125 | 59 | | |||
126 | PlasmaComponents.ToolButton { | 60 | TextField { | ||
127 | anchors.verticalCenter: parent.verticalCenter | | |||
128 | iconName: "dialog-close" | | |||
129 | flat: true | | |||
130 | | ||||
131 | onClicked: { | | |||
132 | messageWidget.visible = false; | | |||
133 | } | | |||
134 | } | | |||
135 | } | | |||
136 | } | | |||
137 | | ||||
138 | QtControls.TextField { | | |||
139 | id: filter | 61 | id: filter | ||
140 | Layout.fillWidth: true | 62 | Layout.fillWidth: true | ||
141 | placeholderText: i18n("Search Time Zones") | 63 | placeholderText: i18n("Search Time Zones") | ||
142 | } | 64 | } | ||
143 | 65 | | |||
144 | QtControls.TableView { | 66 | ScrollView { | ||
145 | id: timeZoneView | 67 | id: scroll | ||
146 | | ||||
147 | signal toggleCurrent | | |||
148 | | ||||
149 | Layout.fillWidth: true | 68 | Layout.fillWidth: true | ||
150 | Layout.fillHeight: true | 69 | Layout.fillHeight: true | ||
151 | 70 | | |||
152 | Keys.onSpacePressed: toggleCurrent() | 71 | ListView { | ||
72 | id: timeZoneView | ||||
73 | spacing: 5 | ||||
ngraham: `units.largeSpacing` is preferable to hardcoded spacing values | |||||
153 | 74 | | |||
154 | model: TimeZoneFilterProxy { | 75 | model: TimeZoneFilterProxy { | ||
155 | sourceModel: timeZones | 76 | sourceModel: timeZones | ||
156 | filterString: filter.text | 77 | filterString: filter.text | ||
157 | } | 78 | } | ||
158 | 79 | | |||
159 | QtControls.TableViewColumn { | 80 | delegate: CheckDelegate { | ||
160 | role: "checked" | 81 | id: checkbox | ||
161 | width: checkbox.width | 82 | width: parent.width | ||
162 | delegate: | 83 | text: !city || city.indexOf("UTC") === 0 ? comment : comment ? i18n("%1, %2 (%3)", city, region, comment) : i18n("%1, %2", city, region) | ||
This is pretty hard to follow. I would recommend expanding it to a conventional if/else block for clarity. ngraham: This is pretty hard to follow. I would recommend expanding it to a conventional if/else block… | |||||
163 | QtControls.CheckBox { | 84 | checked: model.checked | ||
164 | id: checkBox | 85 | onToggled: { | ||
165 | anchors.centerIn: parent | 86 | model.checked = checkbox.checked | ||
166 | checked: styleData.value | | |||
167 | activeFocusOnTab: false // only let the TableView as a whole get focus | | |||
168 | onClicked: { | | |||
169 | //needed for model's setData to be called | | |||
170 | model.checked = checked; | | |||
171 | } | | |||
172 | | ||||
173 | Connections { | | |||
174 | target: timeZoneView | | |||
175 | onToggleCurrent: { | | |||
176 | if (styleData.row === timeZoneView.currentRow) { | | |||
177 | model.checked = !checkBox.checked | | |||
178 | } | | |||
179 | } | | |||
180 | } | | |||
181 | } | | |||
182 | | ||||
183 | resizable: false | | |||
184 | movable: false | | |||
185 | } | | |||
186 | QtControls.TableViewColumn { | | |||
187 | role: "city" | | |||
188 | title: i18n("City") | | |||
189 | } | 87 | } | ||
190 | QtControls.TableViewColumn { | | |||
191 | role: "region" | | |||
192 | title: i18n("Region") | | |||
193 | } | 88 | } | ||
194 | QtControls.TableViewColumn { | | |||
195 | role: "comment" | | |||
196 | title: i18n("Comment") | | |||
197 | } | 89 | } | ||
198 | } | 90 | } | ||
199 | 91 | | |||
200 | RowLayout { | 92 | RowLayout { | ||
201 | Layout.fillWidth: true | 93 | Layout.fillWidth: true | ||
202 | QtControls.CheckBox { | 94 | CheckBox { | ||
203 | id: enableWheelCheckBox | 95 | id: enableWheelCheckBox | ||
204 | text: i18n("Switch time zone with mouse wheel") | 96 | text: i18n("Switch time zone with mouse wheel") | ||
205 | } | 97 | } | ||
206 | } | 98 | } | ||
207 | | ||||
208 | } | 99 | } | ||
209 | } | 100 | } |
import QtQuick.Controls 2.5 as QQC2