diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index f77f50e9..ec5030e7 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -52,7 +52,11 @@ Popup { onCompleterNameChanged: { if (completerName) { - completer = TimelineManager.timeline.input.completerFor(completerName); + if (completerName == "user") { + completer = TimelineManager.completerFor(completerName, TimelineManager.timeline.roomId()); + } else { + completer = TimelineManager.completerFor(completerName); + } completer.setSearchString(""); } else { completer = undefined; diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml new file mode 100644 index 00000000..317c96b3 --- /dev/null +++ b/resources/qml/QuickSwitcher.qml @@ -0,0 +1,38 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import im.nheko 1.0 + +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 + + onTextEdited: { + completerPopup.completer.setSearchString(text) + } + } + + Completer { + id: completerPopup + + x: roomTextInput.x + 100 + y: roomTextInput.y - 20 + completerName: "room" + bottomToTop: true + } + + onOpened: { + completerPopup.open() + } +} \ No newline at end of file diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 7db9d041..f575e133 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -68,6 +68,22 @@ Page { } + Component { + id: quickSwitcherComponent + + QuickSwitcher { + id: quickSwitcher + } + } + + Shortcut { + sequence: "Ctrl+L" + onActivated: { + var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); + quickSwitch.open(); + } + } + Menu { id: messageContextMenu diff --git a/resources/res.qrc b/resources/res.qrc index 12d098c0..d30d6e18 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -139,6 +139,7 @@ qml/StatusIndicator.qml qml/TimelineRow.qml qml/TopBar.qml + qml/QuickSwitcher.qml qml/TypingIndicator.qml qml/RoomSettings.qml qml/emoji/EmojiButton.qml diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index f2e6d571..dc041cb9 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -11,13 +11,16 @@ #include "BlurhashProvider.h" #include "ChatPage.h" #include "ColorImageProvider.h" +#include "CompletionProxyModel.h" #include "DelegateChooser.h" #include "DeviceVerificationFlow.h" #include "Logging.h" #include "MainWindow.h" #include "MatrixClient.h" #include "MxcImageProvider.h" +#include "RoomsModel.h" #include "UserSettingsPage.h" +#include "UsersModel.h" #include "dialogs/ImageOverlay.h" #include "emoji/EmojiModel.h" #include "emoji/Provider.h" @@ -552,3 +555,25 @@ TimelineViewManager::focusMessageInput() { emit focusInput(); } + +QObject * +TimelineViewManager::completerFor(QString completerName, QString roomId) +{ + if (completerName == "user") { + auto userModel = new UsersModel(roomId.toStdString()); + auto proxy = new CompletionProxyModel(userModel); + userModel->setParent(proxy); + return proxy; + } else if (completerName == "emoji") { + auto emojiModel = new emoji::EmojiModel(); + auto proxy = new CompletionProxyModel(emojiModel); + emojiModel->setParent(proxy); + return proxy; + } else if (completerName == "room") { + auto roomModel = new RoomsModel(true); + auto proxy = new CompletionProxyModel(roomModel); + roomModel->setParent(proxy); + return proxy; + } + return nullptr; +} \ No newline at end of file diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 61fce574..d6383806 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -138,6 +138,7 @@ public slots: } void backToRooms() { emit showRoomList(); } + QObject *completerFor(QString completerName, QString roomId = ""); private: #ifdef USE_QUICK_VIEW