use single tooltip for all settingsOverlay options

pull/5/head
Michail Vourlakos 6 years ago
parent e4254ed8c7
commit d45d28b1cc

@ -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;

@ -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
}
}
}
}

@ -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
}
}
}
}

@ -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
}
}
}
}

Loading…
Cancel
Save