From 0922a8e4c755dec9170820ae6263a1fc3122468c Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Mon, 22 Feb 2021 00:01:50 +0530 Subject: [PATCH] add room alias delegate, fix some quickswitcher ui problems --- resources/qml/Completer.qml | 29 ++++++++++++++++++++++++++-- resources/qml/MessageInput.qml | 2 +- resources/qml/QuickSwitcher.qml | 18 ++++++++++++----- src/timeline/TimelineViewManager.cpp | 5 +++++ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index ec5030e7..76e08e7e 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -11,6 +11,7 @@ Popup { property string completerName property var completer property bool bottomToTop: true + property bool fullWidth: false property alias count: listView.count signal completionClicked(string completion) @@ -75,14 +76,14 @@ Popup { id: listView anchors.fill: parent - implicitWidth: contentItem.childrenRect.width + implicitWidth: fullWidth ? parent.width : contentItem.childrenRect.width model: completer verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom delegate: Rectangle { color: model.index == popup.currentIndex ? colors.highlight : colors.base height: chooser.childrenRect.height + 4 - implicitWidth: chooser.childrenRect.width + 4 + implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4 MouseArea { id: mouseArea @@ -161,6 +162,30 @@ Popup { DelegateChoice { roleValue: "room" + RowLayout { + id: del + + anchors.centerIn: parent + + Avatar { + height: 24 + width: 24 + url: model.avatarUrl.replace("mxc://", "image://MxcImage/") + onClicked: popup.completionClicked(completer.completionAt(model.index)) + } + + Label { + text: model.roomName + color: model.index == popup.currentIndex ? colors.highlightedText : colors.text + } + + } + + } + + DelegateChoice { + roleValue: "roomAliases" + RowLayout { id: del diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index 7ecaf81a..e6b6762d 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -184,7 +184,7 @@ Rectangle { messageInput.openCompleter(cursorPosition, "emoji"); popup.open(); } else if (event.key == Qt.Key_NumberSign) { - messageInput.openCompleter(cursorPosition, "room"); + messageInput.openCompleter(cursorPosition, "roomAliases"); popup.open(); } else if (event.key == Qt.Key_Escape && popup.opened) { completerTriggeredAt = -1; diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 317c96b3..ca7a5eeb 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -6,17 +6,16 @@ Popup { x: parent.width / 2 - width / 2 y: parent.height / 4 - height / 2 width: parent.width / 2 - height: 100 modal: true - focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside parent: Overlay.overlay TextInput { id: roomTextInput - anchors.fill: parent focus: true + anchors.fill: parent + color: colors.text onTextEdited: { completerPopup.completer.setSearchString(text) @@ -26,13 +25,22 @@ Popup { Completer { id: completerPopup - x: roomTextInput.x + 100 - y: roomTextInput.y - 20 + x: roomTextInput.x + y: roomTextInput.y + parent.height + width: parent.width completerName: "room" bottomToTop: true + fullWidth: true + + closePolicy: Popup.NoAutoClose } onOpened: { completerPopup.open() + roomTextInput.forceActiveFocus() + } + + onClosed: { + completerPopup.close() } } \ No newline at end of file diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index dc041cb9..74d416bb 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -570,6 +570,11 @@ TimelineViewManager::completerFor(QString completerName, QString roomId) emojiModel->setParent(proxy); return proxy; } else if (completerName == "room") { + auto roomModel = new RoomsModel(false); + auto proxy = new CompletionProxyModel(roomModel); + roomModel->setParent(proxy); + return proxy; + } else if (completerName == "roomAliases") { auto roomModel = new RoomsModel(true); auto proxy = new CompletionProxyModel(roomModel); roomModel->setParent(proxy);