mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +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 {
|
QtControls.ToolTip {
|
||||||
id: 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: {
|
onTextChanged: {
|
||||||
@ -42,19 +58,18 @@ Item {
|
|||||||
tooltip.visible = false
|
tooltip.visible = false
|
||||||
return
|
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
|
// update tooltip and show it
|
||||||
tooltip.text = tags
|
tooltip.substring = currentTag
|
||||||
|
tooltip.tags = backend.dictKeys(true, "^" + tooltip.substring)
|
||||||
changeTooltipPosition()
|
changeTooltipPosition()
|
||||||
tooltip.visible = true
|
tooltip.visible = (tooltip.tags.length != 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function appendTag(tag, substring) {
|
||||||
|
textArea.insert(textArea.cursorPosition, tag.substring(substring.length))
|
||||||
|
}
|
||||||
|
|
||||||
function changeTooltipPosition() {
|
function changeTooltipPosition() {
|
||||||
tooltip.x = textArea. cursorRectangle.x
|
tooltip.x = textArea. cursorRectangle.x
|
||||||
tooltip.y = textArea. cursorRectangle.y
|
tooltip.y = textArea. cursorRectangle.y
|
||||||
|
@ -49,7 +49,7 @@ QtDialogs.Dialog {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.top: title.bottom
|
anchors.top: title.bottom
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
QtControls.GroupBox {
|
QtControls.GroupBox {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height / 5
|
height: parent.height / 5
|
||||||
@ -122,7 +122,7 @@ QtDialogs.Dialog {
|
|||||||
QtDialogs.FileDialog {
|
QtDialogs.FileDialog {
|
||||||
id: logPath
|
id: logPath
|
||||||
title: i18n("Open log file")
|
title: i18n("Open log file")
|
||||||
onAccepted:
|
onAccepted:
|
||||||
logBody.text = awActions.getFileContent(logPath.fileUrl.toString().replace("file://", ""))
|
logBody.text = awActions.getFileContent(logPath.fileUrl.toString().replace("file://", ""))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user