diff --git a/containment/package/contents/ui/editmode/HeaderSettings.qml b/containment/package/contents/ui/editmode/HeaderSettings.qml index 3af919bfb..4576a9973 100644 --- a/containment/package/contents/ui/editmode/HeaderSettings.qml +++ b/containment/package/contents/ui/editmode/HeaderSettings.qml @@ -33,8 +33,11 @@ Item { width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parent.width : parent.height height: thickness + readonly property bool containsMouse: rearrangeBtn.containsMouse readonly property int thickness: rearrangeBtn.implicitHeight + readonly property string tooltip: rearrangeBtn.tooltip + rotation: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { return 0; diff --git a/containment/package/contents/ui/editmode/SettingsOverlay.qml b/containment/package/contents/ui/editmode/SettingsOverlay.qml index b3b299bfb..29ad78997 100644 --- a/containment/package/contents/ui/editmode/SettingsOverlay.qml +++ b/containment/package/contents/ui/editmode/SettingsOverlay.qml @@ -33,6 +33,7 @@ import "../../code/ColorizerTools.js" as ColorizerTools Item{ id: settingsRoot + readonly property bool containsMouse: headerSettings.containsMouse || ruler.containsMouse || tooltipMouseArea.containsMouse readonly property int thickness: ruler.thickness + headerSettings.thickness + spacing * 3 readonly property int spacing: 5 @@ -44,6 +45,8 @@ Item{ } } + property string tooltip: "" + readonly property real textColorBrightness: ColorizerTools.colorBrightness(textColor) readonly property bool textColorIsDark: textColorBrightness < 127.5 readonly property color textColor: { @@ -54,7 +57,6 @@ Item{ } } - layer.enabled: true layer.effect: DropShadow{ radius: settingsRoot.textShadow @@ -72,4 +74,61 @@ Item{ thicknessMargin: headerSettings.thickness + spacing thickMargin: spacing } + + //! Tooltip + onContainsMouseChanged: { + if (containsMouse) { + hideTooltipTimer.stop(); + tooltip.visible = true; + } else { + hideTooltipTimer.restart(); + } + } + + Binding{ + target: settingsRoot + property: "tooltip" + value: { + if (ruler.containsMouse) { + return ruler.tooltip; + } else if (headerSettings.containsMouse) { + return headerSettings.tooltip; + } + } + } + + Timer { + id: hideTooltipTimer + interval: units.longDuration * 2 + onTriggered: { + if (!settingsRoot.containsMouse) { + tooltip.visible = false; + } + } + } + + PlasmaCore.Dialog { + id: tooltip + visualParent: settingsOverlay + + type: PlasmaCore.Dialog.Dock + flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.BypassWindowManagerHint | Qt.ToolTip + location: plasmoid.location + + mainItem: MouseArea { + id: tooltipMouseArea + width: label.width + (2 * units.smallSpacing) + height: label.height + hoverEnabled: true + + PlasmaComponents.Label { + id: label + anchors.centerIn: parent + textFormat: Text.PlainText + maximumLineCount: 1 + text: settingsRoot.tooltip + } + } + } + } diff --git a/containment/package/contents/ui/editmode/controls/Button.qml b/containment/package/contents/ui/editmode/controls/Button.qml index 89342371f..9e5d4b26b 100644 --- a/containment/package/contents/ui/editmode/controls/Button.qml +++ b/containment/package/contents/ui/editmode/controls/Button.qml @@ -39,6 +39,7 @@ Item{ property string text: "Default Text" property string tooltip: "" + readonly property bool containsMouse: buttonMouseArea.containsMouse readonly property int implicitHeight: visibleButton.height readonly property color appliedTextColor: checked ? checkedTextColor : textColor @@ -95,50 +96,6 @@ Item{ anchors.fill: visibleButton hoverEnabled: true - onEntered: { - tooltip.visible = true; - } - - onExited: { - hideTooltipTimer.restart(); - } - onClicked: button.pressed(); } - - Timer { - id: hideTooltipTimer - interval: units.longDuration * 2 - onTriggered: { - if (!tooltipMouseArea.containsMouse && !buttonMouseArea.containsMouse) { - tooltip.visible = false; - } - } - } - - PlasmaCore.Dialog { - id: tooltip - visualParent: button - - type: PlasmaCore.Dialog.Dock - flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.BypassWindowManagerHint | Qt.ToolTip - location: plasmoid.location - - mainItem: MouseArea { - id: tooltipMouseArea - width: label.width + (2 * units.smallSpacing) - height: label.height - hoverEnabled: true - onEntered: hideTooltipTimer.stop(); - onExited: hideTooltipTimer.restart(); - - PlasmaComponents.Label { - id: label - anchors.centerIn: parent - textFormat: Text.PlainText - maximumLineCount: 1 - text: button.tooltip - } - } - } } diff --git a/containment/package/contents/ui/editmode/maxlength/RulerMouseArea.qml b/containment/package/contents/ui/editmode/maxlength/RulerMouseArea.qml index f1215c182..3174dc832 100644 --- a/containment/package/contents/ui/editmode/maxlength/RulerMouseArea.qml +++ b/containment/package/contents/ui/editmode/maxlength/RulerMouseArea.qml @@ -31,14 +31,6 @@ MouseArea{ hoverEnabled: root.editMode cursorShape: root.isHorizontal ? Qt.SizeHorCursor : Qt.SizeVerCursor - onEntered: { - tooltip.visible = true; - } - - onExited: { - hideTooltipTimer.restart(); - } - onVisibleChanged: { if (!visible) { tooltip.visible = false; @@ -90,40 +82,4 @@ MouseArea{ } } } - - Timer { - id: hideTooltipTimer - interval: units.longDuration * 2 - onTriggered: { - if (!tooltipMouseArea.containsMouse && !rulerMouseArea.containsMouse) { - tooltip.visible = false; - } - } - } - - PlasmaCore.Dialog { - id: tooltip - visualParent: settingsOverlay - - type: PlasmaCore.Dialog.Dock - flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.BypassWindowManagerHint | Qt.ToolTip - location: plasmoid.location - - mainItem: MouseArea { - id: tooltipMouseArea - width: label.width + (2 * units.smallSpacing) - height: label.height - hoverEnabled: true - onEntered: hideTooltipTimer.stop(); - onExited: hideTooltipTimer.restart(); - - PlasmaComponents.Label { - id: label - anchors.centerIn: parent - textFormat: Text.PlainText - maximumLineCount: 1 - text: ruler.tooltip - } - } - } }