2021-02-21 18:40:21 +01:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
Popup {
|
2021-02-22 18:38:42 +01:00
|
|
|
id: quickSwitcher
|
2021-02-21 18:40:21 +01:00
|
|
|
x: parent.width / 2 - width / 2
|
|
|
|
y: parent.height / 4 - height / 2
|
|
|
|
width: parent.width / 2
|
|
|
|
modal: true
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
parent: Overlay.overlay
|
|
|
|
|
2021-02-22 19:48:31 +01:00
|
|
|
Overlay.modal: Rectangle {
|
|
|
|
color: "#aa1E1E1E"
|
|
|
|
}
|
|
|
|
|
2021-02-21 18:40:21 +01:00
|
|
|
TextInput {
|
|
|
|
id: roomTextInput
|
|
|
|
|
|
|
|
focus: true
|
2021-02-21 19:31:50 +01:00
|
|
|
anchors.fill: parent
|
|
|
|
color: colors.text
|
2021-02-21 18:40:21 +01:00
|
|
|
|
|
|
|
onTextEdited: {
|
|
|
|
completerPopup.completer.setSearchString(text)
|
|
|
|
}
|
2021-02-22 18:38:42 +01:00
|
|
|
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (event.key == Qt.Key_Up && completerPopup.opened) {
|
|
|
|
event.accepted = true;
|
|
|
|
completerPopup.up();
|
|
|
|
} else if (event.key == Qt.Key_Down && completerPopup.opened) {
|
|
|
|
event.accepted = true;
|
|
|
|
completerPopup.down();
|
2021-02-22 19:48:31 +01:00
|
|
|
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
|
|
|
completerPopup.finishCompletion()
|
|
|
|
event.accepted = true;
|
2021-02-22 18:38:42 +01:00
|
|
|
}
|
|
|
|
}
|
2021-02-21 18:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Completer {
|
|
|
|
id: completerPopup
|
|
|
|
|
2021-02-21 19:31:50 +01:00
|
|
|
x: roomTextInput.x
|
|
|
|
y: roomTextInput.y + parent.height
|
|
|
|
width: parent.width
|
2021-02-21 18:40:21 +01:00
|
|
|
completerName: "room"
|
|
|
|
bottomToTop: true
|
2021-02-21 19:31:50 +01:00
|
|
|
fullWidth: true
|
|
|
|
|
|
|
|
closePolicy: Popup.NoAutoClose
|
2021-02-21 18:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
completerPopup.open()
|
2021-02-21 19:31:50 +01:00
|
|
|
roomTextInput.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
completerPopup.close()
|
2021-02-21 18:40:21 +01:00
|
|
|
}
|
2021-02-22 18:38:42 +01:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
onCompletionSelected: {
|
2021-02-22 19:48:31 +01:00
|
|
|
console.log(id)
|
2021-02-22 18:38:42 +01:00
|
|
|
TimelineManager.setHistoryView(id)
|
2021-02-22 19:48:31 +01:00
|
|
|
TimelineManager.highlightRoom(id)
|
2021-02-22 18:38:42 +01:00
|
|
|
quickSwitcher.close()
|
|
|
|
}
|
|
|
|
target: completerPopup
|
|
|
|
}
|
2021-02-21 18:40:21 +01:00
|
|
|
}
|