add room alias delegate, fix some quickswitcher ui problems

This commit is contained in:
Jedi18 2021-02-22 00:01:50 +05:30
parent 32d419d14f
commit 0922a8e4c7
4 changed files with 46 additions and 8 deletions

View file

@ -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

View file

@ -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;

View file

@ -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()
}
}

View file

@ -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);