mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-04 01:15:52 +00:00
better tooltip class
This commit is contained in:
@ -34,22 +34,20 @@ Item {
|
|||||||
}
|
}
|
||||||
textFormat: TextEdit.PlainText
|
textFormat: TextEdit.PlainText
|
||||||
|
|
||||||
QtControls.ToolTip {
|
Column {
|
||||||
id: tooltip
|
id: tooltip
|
||||||
|
|
||||||
property string substring
|
property string substring
|
||||||
property var tags: []
|
|
||||||
text: tags.join('\n')
|
|
||||||
|
|
||||||
bottomPadding: 0
|
|
||||||
topPadding: 0
|
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: tags
|
||||||
|
Text {
|
||||||
|
id: text
|
||||||
|
text: modelData
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: appendTag(text.text, tooltip.substring)
|
||||||
var tagHeight = tooltip.height / tooltip.tags.length
|
}
|
||||||
var pos = Math.round(mouse.y / tagHeight, 0)
|
|
||||||
appendTag(tooltip.tags[pos], tooltip.substring)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,9 +61,12 @@ Item {
|
|||||||
}
|
}
|
||||||
// update tooltip and show it
|
// update tooltip and show it
|
||||||
tooltip.substring = currentTag
|
tooltip.substring = currentTag
|
||||||
tooltip.tags = backend.dictKeys(true, "^" + tooltip.substring)
|
tags.model = backend.dictKeys(true, "^" + tooltip.substring)
|
||||||
changeTooltipPosition()
|
changeTooltipPosition()
|
||||||
tooltip.visible = (tooltip.tags.length != 0)
|
// show tooltip if found more than 1 or current text does not match
|
||||||
|
// tag found
|
||||||
|
tooltip.visible = ((tags.count > 1)
|
||||||
|
|| ((tags.count == 1) && (tags.model[0] != tooltip.substring)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +75,8 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changeTooltipPosition() {
|
function changeTooltipPosition() {
|
||||||
tooltip.x = textArea. cursorRectangle.x
|
tooltip.x = textArea.cursorRectangle.x
|
||||||
tooltip.y = textArea. cursorRectangle.y
|
tooltip.y = textArea.cursorRectangle.y
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastTag() {
|
function getLastTag() {
|
||||||
|
Reference in New Issue
Block a user