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.plasma.components 2.0 as PlasmaComponents | ||
29 | 29 | | |||
30 | Item { | 30 | Item { | ||
31 | id: timeZonesPage | 31 | id: timeZonesPage | ||
Show All 10 Lines | 41 | onSelectedTimeZonesChanged: { | |||
42 | if (selectedTimeZones.length === 0) { | 42 | if (selectedTimeZones.length === 0) { | ||
43 | messageWidget.visible = true; | 43 | messageWidget.visible = true; | ||
44 | 44 | | |||
45 | timeZones.selectLocalTimeZone(); | 45 | timeZones.selectLocalTimeZone(); | ||
46 | } | 46 | } | ||
47 | } | 47 | } | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | // This is just for getting the column width | | |||
51 | QtControls.CheckBox { | | |||
52 | id: checkbox | | |||
53 | visible: false | | |||
54 | } | | |||
55 | | ||||
56 | | ||||
57 | ColumnLayout { | 50 | ColumnLayout { | ||
58 | anchors.fill: parent | 51 | anchors.fill: parent | ||
59 | 52 | | |||
60 | Rectangle { | 53 | Rectangle { | ||
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 | |||||
61 | id: messageWidget | 54 | id: messageWidget | ||
62 | 55 | | |||
63 | anchors { | 56 | Layout.fillWidth: true | ||
64 | left: parent.left | 57 | Layout.margins: 1 | ||
65 | right: parent.right | | |||
66 | margins: 1 | | |||
67 | } | | |||
68 | 58 | | |||
69 | height: 0 | 59 | height: 0 | ||
70 | 60 | | |||
71 | //TODO: This is the actual color KMessageWidget uses as its base color but here it gives | 61 | //TODO: This is the actual color KMessageWidget uses as its base color but here it gives | ||
72 | // a different color, figure out why | 62 | // a different color, figure out why | ||
73 | //property color gradBaseColor: Qt.rgba(0.69, 0.5, 0, 1) | 63 | //property color gradBaseColor: Qt.rgba(0.69, 0.5, 0, 1) | ||
74 | gradient: Gradient { | 64 | gradient: Gradient { | ||
75 | GradientStop { position: 0.0; color: "#FFD86D" } //Qt.lighter(messageWidget.gradBaseColor, 1.1) | 65 | GradientStop { position: 0.0; color: "#FFD86D" } //Qt.lighter(messageWidget.gradBaseColor, 1.1) | ||
Show All 27 Lines | |||||
103 | RowLayout { | 93 | RowLayout { | ||
104 | anchors.fill: parent | 94 | anchors.fill: parent | ||
105 | anchors.margins: units.largeSpacing | 95 | anchors.margins: units.largeSpacing | ||
106 | anchors.leftMargin: units.smallSpacing | 96 | anchors.leftMargin: units.smallSpacing | ||
107 | anchors.rightMargin: units.smallSpacing | 97 | anchors.rightMargin: units.smallSpacing | ||
108 | spacing: units.smallSpacing | 98 | spacing: units.smallSpacing | ||
109 | 99 | | |||
110 | PlasmaCore.IconItem { | 100 | PlasmaCore.IconItem { | ||
111 | anchors.verticalCenter: parent.verticalCenter | 101 | Layout.alignment: Qt.AlignVCenter | ||
112 | height: units.iconSizes.smallMedium | 102 | height: units.iconSizes.smallMedium | ||
113 | width: height | 103 | width: height | ||
114 | source: "dialog-warning" | 104 | source: "dialog-warning" | ||
115 | } | 105 | } | ||
116 | 106 | | |||
117 | QtControls.Label { | 107 | Label { | ||
118 | id: messageWidgetLabel | 108 | id: messageWidgetLabel | ||
119 | anchors.verticalCenter: parent.verticalCenter | 109 | Layout.alignment: Qt.AlignVCenter | ||
120 | Layout.fillWidth: true | 110 | Layout.fillWidth: true | ||
121 | text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") | 111 | text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") | ||
122 | verticalAlignment: Text.AlignVCenter | 112 | verticalAlignment: Text.AlignVCenter | ||
123 | wrapMode: Text.WordWrap | 113 | wrapMode: Text.WordWrap | ||
124 | } | 114 | } | ||
125 | 115 | | |||
126 | PlasmaComponents.ToolButton { | 116 | PlasmaComponents.ToolButton { | ||
127 | anchors.verticalCenter: parent.verticalCenter | 117 | Layout.alignment: Qt.AlignVCenter | ||
128 | iconName: "dialog-close" | 118 | iconName: "dialog-close" | ||
129 | flat: true | 119 | flat: true | ||
130 | 120 | | |||
131 | onClicked: { | 121 | onClicked: { | ||
132 | messageWidget.visible = false; | 122 | messageWidget.visible = false; | ||
133 | } | 123 | } | ||
134 | } | 124 | } | ||
135 | } | 125 | } | ||
136 | } | 126 | } | ||
137 | 127 | | |||
138 | QtControls.TextField { | 128 | TextField { | ||
139 | id: filter | 129 | id: filter | ||
140 | Layout.fillWidth: true | 130 | Layout.fillWidth: true | ||
141 | placeholderText: i18n("Search Time Zones") | 131 | placeholderText: i18n("Search Time Zones") | ||
142 | } | 132 | } | ||
143 | 133 | | |||
144 | QtControls.TableView { | 134 | ScrollView { | ||
145 | id: timeZoneView | 135 | id: scroll | ||
146 | | ||||
147 | signal toggleCurrent | | |||
148 | | ||||
149 | Layout.fillWidth: true | 136 | Layout.fillWidth: true | ||
150 | Layout.fillHeight: true | 137 | Layout.fillHeight: true | ||
138 | Component.onCompleted: scroll.background.visible = true; | ||||
151 | 139 | | |||
152 | Keys.onSpacePressed: toggleCurrent() | 140 | ListView { | ||
141 | id: timeZoneView | ||||
142 | clip: true | ||||
143 | spacing: 5 | ||||
ngraham: `units.largeSpacing` is preferable to hardcoded spacing values | |||||
153 | 144 | | |||
154 | model: TimeZoneFilterProxy { | 145 | model: TimeZoneFilterProxy { | ||
155 | sourceModel: timeZones | 146 | sourceModel: timeZones | ||
156 | filterString: filter.text | 147 | filterString: filter.text | ||
157 | } | 148 | } | ||
158 | 149 | | |||
159 | QtControls.TableViewColumn { | 150 | delegate: CheckDelegate { | ||
160 | role: "checked" | 151 | id: checkbox | ||
161 | width: checkbox.width | 152 | width: parent.width | ||
162 | delegate: | 153 | 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 { | 154 | checked: model.checked | ||
164 | id: checkBox | 155 | onToggled: { | ||
165 | anchors.centerIn: parent | 156 | 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 | } | 157 | } | ||
190 | QtControls.TableViewColumn { | | |||
191 | role: "region" | | |||
192 | title: i18n("Region") | | |||
193 | } | 158 | } | ||
194 | QtControls.TableViewColumn { | | |||
195 | role: "comment" | | |||
196 | title: i18n("Comment") | | |||
197 | } | 159 | } | ||
198 | } | 160 | } | ||
199 | 161 | | |||
200 | RowLayout { | 162 | RowLayout { | ||
201 | Layout.fillWidth: true | 163 | Layout.fillWidth: true | ||
202 | QtControls.CheckBox { | 164 | CheckBox { | ||
203 | id: enableWheelCheckBox | 165 | id: enableWheelCheckBox | ||
204 | text: i18n("Switch time zone with mouse wheel") | 166 | text: i18n("Switch time zone with mouse wheel") | ||
205 | } | 167 | } | ||
206 | } | 168 | } | ||
207 | 169 | | |||
208 | } | 170 | } | ||
209 | } | 171 | } |
import QtQuick.Controls 2.5 as QQC2