From 23efa8f8153922e559931591d5ce517430681555 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 1 Mar 2022 01:59:06 +0100 Subject: [PATCH] Fix a few small completer glitches --- resources/qml/Completer.qml | 13 ++++++------- resources/qml/MessageInput.qml | 13 +++++++++---- resources/qml/QuickSwitcher.qml | 1 + resources/qml/Root.qml | 6 +++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 3acc91cc..a16ffa65 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -77,11 +77,11 @@ Control { } currentIndex = -1 } - padding: 0 - leftInset: 1 - bottomInset: 1 - topInset: 1 - rightInset: 1 + + bottomPadding: 1 + leftPadding: 1 + topPadding: 1 + rightPadding: 1 contentItem: ListView { id: listView @@ -107,7 +107,6 @@ Control { onContentYChanged: deadTimer.restart() reuseItems: true - //anchors.fill: parent implicitWidth: listView.contentItem.childrenRect.width model: completer verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom @@ -120,7 +119,7 @@ Control { color: model.index == popup.currentIndex ? Nheko.colors.highlight : Nheko.colors.base 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 { id: mouseArea diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index dd888ab1..1fdff8ed 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -156,7 +156,7 @@ Rectangle { onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text) onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text) // 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: { if (event.matches(StandardKey.Paste)) { room.input.paste(false); @@ -166,7 +166,7 @@ Rectangle { if (cursorPosition == completerTriggeredAt + 1) popup.close(); - if (popup.opened && popup.count <= 0) + if (popup.opened && completer.count <= 0) popup.close(); } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_U) { @@ -190,6 +190,8 @@ Rectangle { } else if (event.matches(StandardKey.SelectAll) && popup.opened) { completer.completerName = ""; popup.close(); + } else if (event.matches(StandardKey.InsertLineSeparator)) { + if (popup.opened) popup.close(); } else if (event.matches(StandardKey.InsertParagraphSeparator)) { if (popup.opened) { var currentCompletion = completer.currentCompletion(); @@ -198,7 +200,7 @@ Rectangle { if (currentCompletion) { messageInput.insertCompletion(currentCompletion); event.accepted = true; - return ; + return; } } room.input.send(); @@ -304,12 +306,15 @@ Rectangle { x: messageInput.positionToRectangle(messageInput.completerTriggeredAt).x y: messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height - padding: 0 + background: null + padding: 0 Completer { anchors.fill: parent id: completer + rowMargin: 2 + rowSpacing: 0 } enter: Transition { diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 103f7584..ac5d3aea 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -24,6 +24,7 @@ Popup { onOpened: { roomTextInput.forceActiveFocus(); } + property int textMargin: Nheko.paddingSmall Column{ anchors.fill: parent diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index 33ffee3d..14e6770b 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -173,7 +173,7 @@ Pane { onActivated: { var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); quickSwitch.open(); - destroyOnClose(quickSwitch); + destroyOnClosed(quickSwitch); } } @@ -225,6 +225,10 @@ Pane { obj.closing.connect(() => obj.destroy()); } + function destroyOnClosed(obj) { + obj.closed.connect(() => obj.destroy()); + } + Connections { function onOpenProfile(profile) { var userProfile = userProfileComponent.createObject(timelineRoot, {