Commit a699acd3 authored by Nate Graham's avatar Nate Graham
Browse files

[applets/digital clock] Restore scroll-to-change-displayed-timezone

After the rest of the UI changes made to the applet and the time zone
config page, I don't think users will be confused by the differences
between the timezone displayed in the clock, and the systemwide local
timezone anymore. Therefore, it should be safe enough to bring back the
wheely time feature.

BUG: 431977
parent 22e02fbb
......@@ -48,6 +48,10 @@
<entry name="lastSelectedTimezone" type="String">
<label>When multiple time zones are configured, this is the one shown on widget restore. Typically the system's current timezone.</label>
<default>Local</default>
</entry>
<entry name="wheelChangesTimezone" type="Bool">
<label>Whether the mouse wheel switches between the timezones configured in selectedTimeZones.</label>
<default>false</default>
</entry>
<entry name="displayTimezoneAsCode" type="Bool">
<label>Whether the timezone is displayed as a code i.e. "GMT" or full text i.e. "London".</label>
......
......@@ -423,7 +423,44 @@ Item {
MouseArea {
anchors.fill: parent
property int wheelDelta: 0
onClicked: plasmoid.expanded = !plasmoid.expanded
onWheel: {
if (!plasmoid.configuration.wheelChangesTimezone) {
return;
}
var delta = wheel.angleDelta.y || wheel.angleDelta.x
var newIndex = main.tzIndex;
wheelDelta += delta;
// magic number 120 for common "one click"
// See: https://doc.qt.io/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
while (wheelDelta >= 120) {
wheelDelta -= 120;
newIndex--;
}
while (wheelDelta <= -120) {
wheelDelta += 120;
newIndex++;
}
if (newIndex >= plasmoid.configuration.selectedTimeZones.length) {
newIndex = 0;
} else if (newIndex < 0) {
newIndex = plasmoid.configuration.selectedTimeZones.length - 1;
}
if (newIndex !== main.tzIndex) {
plasmoid.configuration.lastSelectedTimezone = plasmoid.configuration.selectedTimeZones[newIndex];
main.tzIndex = newIndex;
dataSource.dataChanged();
setupLabels();
}
}
}
/*
......
......@@ -32,6 +32,8 @@ ColumnLayout {
id: timeZonesPage
property alias cfg_selectedTimeZones: timeZones.selectedTimeZones
property alias cfg_wheelChangesTimezone: enableWheelCheckBox.checked
TimeZoneModel {
......@@ -47,7 +49,7 @@ ColumnLayout {
QQC2.ScrollView {
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 19
Layout.preferredHeight: Kirigami.Units.gridUnit * 16
Component.onCompleted: background.visible = true // enable border
ListView {
......@@ -143,10 +145,20 @@ ColumnLayout {
onClicked: timezoneSheet.open()
}
QQC2.CheckBox {
id: enableWheelCheckBox
configuredTimezoneList.count > 1
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.largeSpacing * 2
text: i18n("Switch displayed time zone by scrolling over clock applet")
}
QQC2.Label {
visible: configuredTimezoneList.count > 1
Layout.fillWidth: true
Layout.margins: Kirigami.Units.largeSpacing * 2
Layout.topMargin: Kirigami.Units.largeSpacing * 2
Layout.leftMargin: Kirigami.Units.largeSpacing * 2
Layout.rightMargin: Kirigami.Units.largeSpacing * 2
text: i18n("Note that using a different time zone for the clock does not change the systemwide local time zone. When you travel, switch the local time zone instead.")
wrapMode: Text.Wrap
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment