From 0f215827524bdaa024e7a6f2ec05fec44c8c5d23 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Sun, 3 Mar 2019 20:07:06 +0800 Subject: [PATCH] Join room from search bar. --- imports/Spectral/Panel/RoomListPanel.qml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/imports/Spectral/Panel/RoomListPanel.qml b/imports/Spectral/Panel/RoomListPanel.qml index 4dc084f..2cf0025 100644 --- a/imports/Spectral/Panel/RoomListPanel.qml +++ b/imports/Spectral/Panel/RoomListPanel.qml @@ -627,6 +627,8 @@ Item { AutoTextField { readonly property bool active: text + readonly property bool isRoom: text.match(/#.*:.*\..*/g) || text.match(/!.*:.*\..*/g) + readonly property bool isUser: text.match(/@.*:.*\..*/g) Layout.fillWidth: true Layout.fillHeight: true @@ -641,6 +643,26 @@ Item { background: Item {} } + ItemDelegate { + Layout.preferredWidth: height + Layout.fillHeight: true + + visible: searchField.isRoom || searchField.isUser + + contentItem: MaterialIcon { icon: "\ue145" } + + onClicked: { + if (searchField.isRoom) { + controller.joinRoom(controller.connection, searchField.text) + return + } + if (searchField.isUser) { + controller.createDirectChat(controller.connection, searchField.text) + return + } + } + } + Avatar { Layout.preferredWidth: height Layout.fillHeight: true