mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
improve tag completion
allow to select item from tooltip by mouse and insert it to text edtior
This commit is contained in:
parent
87406f70c4
commit
c3c46ff1b1
@ -33,6 +33,22 @@ Item {
|
||||
|
||||
QtControls.ToolTip {
|
||||
id: tooltip
|
||||
|
||||
property string substring
|
||||
property var tags: []
|
||||
text: tags.join('\n')
|
||||
|
||||
bottomPadding: 0
|
||||
topPadding: 0
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
var tagHeight = tooltip.height / tooltip.tags.length
|
||||
var pos = Math.round(mouse.y / tagHeight, 0)
|
||||
appendTag(tooltip.tags[pos], tooltip.substring)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onTextChanged: {
|
||||
@ -42,19 +58,18 @@ Item {
|
||||
tooltip.visible = false
|
||||
return
|
||||
}
|
||||
var tags = backend.dictKeys(true, "^" + currentTag).join('\n')
|
||||
// exit if no suggestion found
|
||||
if (tags.length == 0) {
|
||||
tooltip.visible = false
|
||||
return
|
||||
}
|
||||
// update tooltip and show it
|
||||
tooltip.text = tags
|
||||
tooltip.substring = currentTag
|
||||
tooltip.tags = backend.dictKeys(true, "^" + tooltip.substring)
|
||||
changeTooltipPosition()
|
||||
tooltip.visible = true
|
||||
tooltip.visible = (tooltip.tags.length != 0)
|
||||
}
|
||||
}
|
||||
|
||||
function appendTag(tag, substring) {
|
||||
textArea.insert(textArea.cursorPosition, tag.substring(substring.length))
|
||||
}
|
||||
|
||||
function changeTooltipPosition() {
|
||||
tooltip.x = textArea. cursorRectangle.x
|
||||
tooltip.y = textArea. cursorRectangle.y
|
||||
|
@ -49,7 +49,7 @@ QtDialogs.Dialog {
|
||||
width: parent.width
|
||||
anchors.top: title.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
|
||||
QtControls.GroupBox {
|
||||
width: parent.width
|
||||
height: parent.height / 5
|
||||
@ -122,7 +122,7 @@ QtDialogs.Dialog {
|
||||
QtDialogs.FileDialog {
|
||||
id: logPath
|
||||
title: i18n("Open log file")
|
||||
onAccepted:
|
||||
onAccepted:
|
||||
logBody.text = awActions.getFileContent(logPath.fileUrl.toString().replace("file://", ""))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user