mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
add room alias delegate, fix some quickswitcher ui problems
This commit is contained in:
parent
32d419d14f
commit
0922a8e4c7
4 changed files with 46 additions and 8 deletions
|
@ -11,6 +11,7 @@ Popup {
|
||||||
property string completerName
|
property string completerName
|
||||||
property var completer
|
property var completer
|
||||||
property bool bottomToTop: true
|
property bool bottomToTop: true
|
||||||
|
property bool fullWidth: false
|
||||||
property alias count: listView.count
|
property alias count: listView.count
|
||||||
|
|
||||||
signal completionClicked(string completion)
|
signal completionClicked(string completion)
|
||||||
|
@ -75,14 +76,14 @@ Popup {
|
||||||
id: listView
|
id: listView
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
implicitWidth: contentItem.childrenRect.width
|
implicitWidth: fullWidth ? parent.width : contentItem.childrenRect.width
|
||||||
model: completer
|
model: completer
|
||||||
verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom
|
verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom
|
||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
color: model.index == popup.currentIndex ? colors.highlight : colors.base
|
color: model.index == popup.currentIndex ? colors.highlight : colors.base
|
||||||
height: chooser.childrenRect.height + 4
|
height: chooser.childrenRect.height + 4
|
||||||
implicitWidth: chooser.childrenRect.width + 4
|
implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
@ -161,6 +162,30 @@ Popup {
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: "room"
|
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 {
|
RowLayout {
|
||||||
id: del
|
id: del
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ Rectangle {
|
||||||
messageInput.openCompleter(cursorPosition, "emoji");
|
messageInput.openCompleter(cursorPosition, "emoji");
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_NumberSign) {
|
} else if (event.key == Qt.Key_NumberSign) {
|
||||||
messageInput.openCompleter(cursorPosition, "room");
|
messageInput.openCompleter(cursorPosition, "roomAliases");
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
||||||
completerTriggeredAt = -1;
|
completerTriggeredAt = -1;
|
||||||
|
|
|
@ -6,17 +6,16 @@ Popup {
|
||||||
x: parent.width / 2 - width / 2
|
x: parent.width / 2 - width / 2
|
||||||
y: parent.height / 4 - height / 2
|
y: parent.height / 4 - height / 2
|
||||||
width: parent.width / 2
|
width: parent.width / 2
|
||||||
height: 100
|
|
||||||
modal: true
|
modal: true
|
||||||
focus: true
|
|
||||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||||
parent: Overlay.overlay
|
parent: Overlay.overlay
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: roomTextInput
|
id: roomTextInput
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
focus: true
|
focus: true
|
||||||
|
anchors.fill: parent
|
||||||
|
color: colors.text
|
||||||
|
|
||||||
onTextEdited: {
|
onTextEdited: {
|
||||||
completerPopup.completer.setSearchString(text)
|
completerPopup.completer.setSearchString(text)
|
||||||
|
@ -26,13 +25,22 @@ Popup {
|
||||||
Completer {
|
Completer {
|
||||||
id: completerPopup
|
id: completerPopup
|
||||||
|
|
||||||
x: roomTextInput.x + 100
|
x: roomTextInput.x
|
||||||
y: roomTextInput.y - 20
|
y: roomTextInput.y + parent.height
|
||||||
|
width: parent.width
|
||||||
completerName: "room"
|
completerName: "room"
|
||||||
bottomToTop: true
|
bottomToTop: true
|
||||||
|
fullWidth: true
|
||||||
|
|
||||||
|
closePolicy: Popup.NoAutoClose
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
completerPopup.open()
|
completerPopup.open()
|
||||||
|
roomTextInput.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
|
onClosed: {
|
||||||
|
completerPopup.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -570,6 +570,11 @@ TimelineViewManager::completerFor(QString completerName, QString roomId)
|
||||||
emojiModel->setParent(proxy);
|
emojiModel->setParent(proxy);
|
||||||
return proxy;
|
return proxy;
|
||||||
} else if (completerName == "room") {
|
} 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 roomModel = new RoomsModel(true);
|
||||||
auto proxy = new CompletionProxyModel(roomModel);
|
auto proxy = new CompletionProxyModel(roomModel);
|
||||||
roomModel->setParent(proxy);
|
roomModel->setParent(proxy);
|
||||||
|
|
Loading…
Reference in a new issue