[applet/{analog,digital}-clock] Merge roots of full representations with MouseArea

wilder-5.26
ivan tkachenko 4 years ago
parent 335ee5baf3
commit 55532aad73
No known key found for this signature in database
GPG Key ID: AF72731B7C654CB3
  1. 13
      applets/analog-clock/contents/ui/analogclock.qml
  2. 70
      applets/digital-clock/package/contents/ui/DigitalClock.qml

@ -67,20 +67,15 @@ Item {
dataSource.onDataChanged.connect(dateTimeChanged); dataSource.onDataChanged.connect(dateTimeChanged);
} }
Plasmoid.compactRepresentation: Item { Plasmoid.compactRepresentation: MouseArea {
id: representation id: representation
Layout.minimumWidth: Plasmoid.formFactor !== PlasmaCore.Types.Vertical ? representation.height : PlasmaCore.Units.gridUnit Layout.minimumWidth: Plasmoid.formFactor !== PlasmaCore.Types.Vertical ? representation.height : PlasmaCore.Units.gridUnit
Layout.minimumHeight: Plasmoid.formFactor === PlasmaCore.Types.Vertical ? representation.width : PlasmaCore.Units.gridUnit Layout.minimumHeight: Plasmoid.formFactor === PlasmaCore.Types.Vertical ? representation.width : PlasmaCore.Units.gridUnit
MouseArea { property bool wasExpanded
anchors.fill: parent
property bool wasExpanded
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
}
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
PlasmaCore.Svg { PlasmaCore.Svg {
id: clockSvg id: clockSvg

@ -14,7 +14,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as Components // Date label height breaks on vertical panel with PC3 version import org.kde.plasma.components 2.0 as Components // Date label height breaks on vertical panel with PC3 version
import org.kde.plasma.private.digitalclock 1.0 import org.kde.plasma.private.digitalclock 1.0
Item { MouseArea {
id: main id: main
property string timeFormat property string timeFormat
@ -61,6 +61,9 @@ Item {
} }
} }
property bool wasExpanded
property int wheelDelta: 0
onDateFormatChanged: { onDateFormatChanged: {
setupLabels(); setupLabels();
} }
@ -433,46 +436,39 @@ Item {
} }
] ]
MouseArea { onPressed: wasExpanded = Plasmoid.expanded
anchors.fill: parent onClicked: Plasmoid.expanded = !wasExpanded
onWheel: {
property bool wasExpanded if (!Plasmoid.configuration.wheelChangesTimezone) {
property int wheelDelta: 0 return;
}
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
onWheel: {
if (!Plasmoid.configuration.wheelChangesTimezone) {
return;
}
var delta = wheel.angleDelta.y || wheel.angleDelta.x var delta = wheel.angleDelta.y || wheel.angleDelta.x
var newIndex = main.tzIndex; var newIndex = main.tzIndex;
wheelDelta += delta; wheelDelta += delta;
// magic number 120 for common "one click" // magic number 120 for common "one click"
// See: https://doc.qt.io/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop // See: https://doc.qt.io/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
while (wheelDelta >= 120) { while (wheelDelta >= 120) {
wheelDelta -= 120; wheelDelta -= 120;
newIndex--; newIndex--;
} }
while (wheelDelta <= -120) { while (wheelDelta <= -120) {
wheelDelta += 120; wheelDelta += 120;
newIndex++; newIndex++;
} }
if (newIndex >= Plasmoid.configuration.selectedTimeZones.length) { if (newIndex >= Plasmoid.configuration.selectedTimeZones.length) {
newIndex = 0; newIndex = 0;
} else if (newIndex < 0) { } else if (newIndex < 0) {
newIndex = Plasmoid.configuration.selectedTimeZones.length - 1; newIndex = Plasmoid.configuration.selectedTimeZones.length - 1;
} }
if (newIndex !== main.tzIndex) { if (newIndex !== main.tzIndex) {
Plasmoid.configuration.lastSelectedTimezone = Plasmoid.configuration.selectedTimeZones[newIndex]; Plasmoid.configuration.lastSelectedTimezone = Plasmoid.configuration.selectedTimeZones[newIndex];
main.tzIndex = newIndex; main.tzIndex = newIndex;
dataSource.dataChanged(); dataSource.dataChanged();
setupLabels(); setupLabels();
}
} }
} }

Loading…
Cancel
Save