Fix a few small completer glitches

This commit is contained in:
Nicolas Werner 2022-03-01 01:59:06 +01:00
parent a307dc46cb
commit 23efa8f815
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
4 changed files with 21 additions and 12 deletions

View File

@ -77,11 +77,11 @@ Control {
} }
currentIndex = -1 currentIndex = -1
} }
padding: 0
leftInset: 1 bottomPadding: 1
bottomInset: 1 leftPadding: 1
topInset: 1 topPadding: 1
rightInset: 1 rightPadding: 1
contentItem: ListView { contentItem: ListView {
id: listView id: listView
@ -107,7 +107,6 @@ Control {
onContentYChanged: deadTimer.restart() onContentYChanged: deadTimer.restart()
reuseItems: true reuseItems: true
//anchors.fill: parent
implicitWidth: listView.contentItem.childrenRect.width implicitWidth: listView.contentItem.childrenRect.width
model: completer model: completer
verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom
@ -120,7 +119,7 @@ Control {
color: model.index == popup.currentIndex ? Nheko.colors.highlight : Nheko.colors.base color: model.index == popup.currentIndex ? Nheko.colors.highlight : Nheko.colors.base
height: chooser.child.implicitHeight + 2 * popup.rowMargin height: chooser.child.implicitHeight + 2 * popup.rowMargin
implicitWidth: fullWidth ? popup.implicitContentWidth : chooser.child.implicitWidth + 4 implicitWidth: fullWidth ? ListView.view.width : chooser.child.implicitWidth + 4
MouseArea { MouseArea {
id: mouseArea id: mouseArea

View File

@ -156,7 +156,7 @@ Rectangle {
onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text) onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text) onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
// Ensure that we get escape key press events first. // Ensure that we get escape key press events first.
Keys.onShortcutOverride: event.accepted = (popup.opened && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter)) Keys.onShortcutOverride: event.accepted = (popup.opened && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter || event.key === Qt.Key_Space))
Keys.onPressed: { Keys.onPressed: {
if (event.matches(StandardKey.Paste)) { if (event.matches(StandardKey.Paste)) {
room.input.paste(false); room.input.paste(false);
@ -166,7 +166,7 @@ Rectangle {
if (cursorPosition == completerTriggeredAt + 1) if (cursorPosition == completerTriggeredAt + 1)
popup.close(); popup.close();
if (popup.opened && popup.count <= 0) if (popup.opened && completer.count <= 0)
popup.close(); popup.close();
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_U) { } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_U) {
@ -190,6 +190,8 @@ Rectangle {
} else if (event.matches(StandardKey.SelectAll) && popup.opened) { } else if (event.matches(StandardKey.SelectAll) && popup.opened) {
completer.completerName = ""; completer.completerName = "";
popup.close(); popup.close();
} else if (event.matches(StandardKey.InsertLineSeparator)) {
if (popup.opened) popup.close();
} else if (event.matches(StandardKey.InsertParagraphSeparator)) { } else if (event.matches(StandardKey.InsertParagraphSeparator)) {
if (popup.opened) { if (popup.opened) {
var currentCompletion = completer.currentCompletion(); var currentCompletion = completer.currentCompletion();
@ -198,7 +200,7 @@ Rectangle {
if (currentCompletion) { if (currentCompletion) {
messageInput.insertCompletion(currentCompletion); messageInput.insertCompletion(currentCompletion);
event.accepted = true; event.accepted = true;
return ; return;
} }
} }
room.input.send(); room.input.send();
@ -304,12 +306,15 @@ Rectangle {
x: messageInput.positionToRectangle(messageInput.completerTriggeredAt).x x: messageInput.positionToRectangle(messageInput.completerTriggeredAt).x
y: messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height y: messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height
padding: 0
background: null background: null
padding: 0
Completer { Completer {
anchors.fill: parent anchors.fill: parent
id: completer id: completer
rowMargin: 2
rowSpacing: 0
} }
enter: Transition { enter: Transition {

View File

@ -24,6 +24,7 @@ Popup {
onOpened: { onOpened: {
roomTextInput.forceActiveFocus(); roomTextInput.forceActiveFocus();
} }
property int textMargin: Nheko.paddingSmall
Column{ Column{
anchors.fill: parent anchors.fill: parent

View File

@ -173,7 +173,7 @@ Pane {
onActivated: { onActivated: {
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); var quickSwitch = quickSwitcherComponent.createObject(timelineRoot);
quickSwitch.open(); quickSwitch.open();
destroyOnClose(quickSwitch); destroyOnClosed(quickSwitch);
} }
} }
@ -225,6 +225,10 @@ Pane {
obj.closing.connect(() => obj.destroy()); obj.closing.connect(() => obj.destroy());
} }
function destroyOnClosed(obj) {
obj.closed.connect(() => obj.destroy());
}
Connections { Connections {
function onOpenProfile(profile) { function onOpenProfile(profile) {
var userProfile = userProfileComponent.createObject(timelineRoot, { var userProfile = userProfileComponent.createObject(timelineRoot, {