added beta of hover texts
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import "../../../config"
|
||||
|
||||
PopupWindow {
|
||||
id: popup
|
||||
|
||||
property Item anchorItem
|
||||
property bool anchorHovered: false
|
||||
property int popupWidth: 300
|
||||
property int popupVerticalOffset: 0
|
||||
|
||||
default property alias content: contentColumn.data
|
||||
|
||||
visible: false
|
||||
color: "transparent"
|
||||
width: popupWidth
|
||||
height: background.height
|
||||
|
||||
onAnchorHoveredChanged: popup.updateVisibility()
|
||||
|
||||
function updateVisibility() {
|
||||
if (anchorHovered || mouseArea.containsMouse) {
|
||||
closeTimer.stop()
|
||||
visible = true
|
||||
} else {
|
||||
closeTimer.restart()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: closeTimer
|
||||
interval: 1
|
||||
onTriggered: {
|
||||
if (!anchorHovered && !mouseArea.containsMouse) {
|
||||
visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
anchor {
|
||||
item: anchorItem
|
||||
edges: Edges.Top | Edges.Left
|
||||
gravity: Edges.Bottom | Edges.Right
|
||||
adjustment: PopupAdjustment.FlipY | PopupAdjustment.SlideX
|
||||
onAnchoring: {
|
||||
anchor.rect.x = (anchorItem.width - popup.width) / 2
|
||||
anchor.rect.y = anchorItem.height + popupVerticalOffset
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onContainsMouseChanged: popup.updateVisibility()
|
||||
Rectangle {
|
||||
id: background
|
||||
width: parent.width
|
||||
height: contentColumn.implicitHeight + 2 * 12
|
||||
color: Qt.alpha(Colors.primaryContainer, 0.9)
|
||||
radius: 12
|
||||
border {
|
||||
color: Colors.primaryContainer_fg
|
||||
width: Config.border_width
|
||||
}
|
||||
|
||||
Column {
|
||||
id: contentColumn
|
||||
height: implicitHeight
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: 12
|
||||
}
|
||||
spacing: Config.small_spacing_fun(24)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user