Verified Commit 55532aad authored by ivan tkachenko's avatar ivan tkachenko
Browse files

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

parent 335ee5ba
......@@ -67,20 +67,15 @@ Item {
dataSource.onDataChanged.connect(dateTimeChanged);
}
Plasmoid.compactRepresentation: Item {
Plasmoid.compactRepresentation: MouseArea {
id: representation
Layout.minimumWidth: Plasmoid.formFactor !== PlasmaCore.Types.Vertical ? representation.height : PlasmaCore.Units.gridUnit
Layout.minimumHeight: Plasmoid.formFactor === PlasmaCore.Types.Vertical ? representation.width : PlasmaCore.Units.gridUnit
MouseArea {
anchors.fill: parent
property bool wasExpanded
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
}
property bool wasExpanded
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
PlasmaCore.Svg {
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.private.digitalclock 1.0
Item {
MouseArea {
id: main
property string timeFormat
......@@ -61,6 +61,9 @@ Item {
}
}
property bool wasExpanded
property int wheelDelta: 0
onDateFormatChanged: {
setupLabels();
}
......@@ -433,46 +436,39 @@ Item {
}
]
MouseArea {
anchors.fill: parent
property bool wasExpanded
property int wheelDelta: 0
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
onWheel: {
if (!Plasmoid.configuration.wheelChangesTimezone) {
return;
}
onPressed: wasExpanded = Plasmoid.expanded
onClicked: Plasmoid.expanded = !wasExpanded
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++;
}
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 >= 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;
if (newIndex !== main.tzIndex) {
Plasmoid.configuration.lastSelectedTimezone = Plasmoid.configuration.selectedTimeZones[newIndex];
main.tzIndex = newIndex;
dataSource.dataChanged();
setupLabels();
}
dataSource.dataChanged();
setupLabels();
}
}
......
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