Verified Commit 085087f8 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

[desktoppackage] Add double-click-to-reset behavior to ruler handles

Toggles between panel's current length and the total available size
(usually screen).
parent 9e836642
Pipeline #207817 passed with stage
in 4 minutes and 57 seconds
......@@ -17,8 +17,8 @@ PlasmaCore.FrameSvgItem {
property alias minimumLength: rightMinimumLengthHandle.value
property alias maximumLength: rightMaximumLengthHandle.value
property string maximumText: dialogRoot.vertical ? i18n("Drag to change maximum height") : i18n("Drag to change maximum width")
property string minimumText: dialogRoot.vertical ? i18n("Drag to change minimum height") : i18n("Drag to change minimum width")
property string maximumText: (dialogRoot.vertical ? i18n("Drag to change maximum height.") : i18n("Drag to change maximum width.")) + "\n" + i18n("Double click to reset.")
property string minimumText: (dialogRoot.vertical ? i18n("Drag to change minimum height.") : i18n("Drag to change minimum width.")) + "\n" + i18n("Double click to reset.")
imagePath: "widgets/containment-controls"
state: "BottomEdge"
......@@ -49,6 +49,11 @@ PlasmaCore.FrameSvgItem {
leftMaximumLengthHandle.value = panel.maximumLength
}
function defaultPosition(value: int): int {
var dialogSize = dialogRoot.vertical ? dialogRoot.height : dialogRoot.width;
return (value === panel.length) ? dialogSize : panel.length;
}
PlasmaCore.Svg {
id: containmentControlsSvg
imagePath: "widgets/containment-controls"
......@@ -66,7 +71,7 @@ PlasmaCore.FrameSvgItem {
SliderHandle {
id: offsetHandle
graphicElementName: "offsetslider"
description: i18n("Drag to change position on this screen edge")
description: i18n("Drag to change position on this screen edge.\nDouble click to reset.")
onValueChanged: panel.offset = value
property int position: (dialogRoot.vertical) ? y : x
/* The maximum/minimumPosition values are needed to prevent the user from moving a panel with
......@@ -100,6 +105,9 @@ PlasmaCore.FrameSvgItem {
return dialogRootSize - panel.maximumLength / 2 - size / 2
}
}
function defaultPosition(): int {
return 0;
}
}
/* The maximumPosition value for the right handles and the minimumPosition value for the left handles are
......
......@@ -42,6 +42,11 @@ PlasmaCore.SvgItem {
//The maximum/minimum Position (X/Y) the silder can be moved to
property int minimumPosition
property int maximumPosition
//Provide default position for "reset" action.
function defaultPosition(): int {
var dialogSize = dialogRoot.vertical ? dialogRoot.height : dialogRoot.width;
return (value === panel.length) ? dialogSize : panel.length;
}
// Handle name displayed as a tooltip.
property string description
......@@ -162,6 +167,9 @@ PlasmaCore.SvgItem {
}
}
}
onDoubleClicked: {
root.value = root.defaultPosition();
}
}
states: [
......
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