Verified Commit 9da987da authored by ivan tkachenko's avatar ivan tkachenko
Browse files

[desktoppackage] Add tooltips to SliderHandles on a panel's Ruler

This should make life easier for users who want to know what a control
is doing before clicking it.
parent abd6e467
......@@ -17,6 +17,9 @@ 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")
imagePath: "widgets/containment-controls"
state: "BottomEdge"
implicitWidth: offsetHandle.width + rightMinimumLengthHandle.width
......@@ -63,6 +66,7 @@ PlasmaCore.FrameSvgItem {
SliderHandle {
id: offsetHandle
graphicElementName: "offsetslider"
description: i18n("Drag to change position on this screen edge")
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
......@@ -112,6 +116,7 @@ PlasmaCore.FrameSvgItem {
SliderHandle {
id: rightMinimumLengthHandle
description: root.minimumText
alignment: panel.alignment | Qt.AlignLeft
visible: panel.alignment !== Qt.AlignRight
offset: panel.offset
......@@ -127,6 +132,7 @@ PlasmaCore.FrameSvgItem {
SliderHandle {
id: rightMaximumLengthHandle
description: root.maximumText
alignment: panel.alignment | Qt.AlignLeft
visible: panel.alignment !== Qt.AlignRight
offset: panel.offset
......@@ -139,8 +145,10 @@ PlasmaCore.FrameSvgItem {
panel.alignment === Qt.AlignCenter ? Math.min(dialogRootSize - size/2, dialogRootSize + offset * 2 - size/2) : dialogRootSize - size/2
}
}
SliderHandle {
id: leftMinimumLengthHandle
description: root.minimumText
alignment: panel.alignment | Qt.AlignRight
visible: panel.alignment !== Qt.AlignLeft
offset: panel.offset
......@@ -152,8 +160,10 @@ PlasmaCore.FrameSvgItem {
panel.alignment === Qt.AlignCenter ? Math.max(-size/2, offset*2 - size/2) : -size/2
}
}
SliderHandle {
id: leftMaximumLengthHandle
description: root.maximumText
alignment: panel.alignment | Qt.AlignRight
visible: panel.alignment !== Qt.AlignLeft
offset: panel.offset
......
......@@ -4,8 +4,10 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.0
import QtQuick 2.15
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.configuration 2.0
......@@ -41,6 +43,9 @@ PlasmaCore.SvgItem {
property int minimumPosition
property int maximumPosition
// Handle name displayed as a tooltip.
property string description
function syncPos() {
if (dialogRoot.vertical) {
if (alignment === Qt.AlignRight) {
......@@ -85,7 +90,13 @@ PlasmaCore.SvgItem {
}
}
PlasmaComponents3.ToolTip {
text: root.description
visible: root.description !== "" && area.containsMouse && !area.containsPress
}
MouseArea {
id: area
drag {
target: parent
axis: (dialogRoot.vertical) ? Drag.YAxis : Drag.XAxis
......@@ -101,8 +112,12 @@ PlasmaCore.SvgItem {
topMargin: (dialogRoot.vertical) ? -PlasmaCore.Units.gridUnit : 0
bottomMargin: (dialogRoot.vertical) ? -PlasmaCore.Units.gridUnit : 0
}
hoverEnabled: true
cursorShape: dialogRoot.vertical ? Qt.SizeVerCursor : Qt.SizeHorCursor
onPositionChanged: {
if (!drag.active) {
return;
}
if (dialogRoot.vertical) {
if (root.alignment === Qt.AlignRight) {
root.value = root.parent.height - (parent.y + offset + root.height/2)
......
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