From 32d419d14f19436c2c8352de06b5c6051e8cc0ab Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Sun, 21 Feb 2021 23:10:21 +0530 Subject: [PATCH 01/17] add quick switcher qml file and moved completerFor from inputbar to timeline view class --- resources/qml/Completer.qml | 6 ++++- resources/qml/QuickSwitcher.qml | 38 ++++++++++++++++++++++++++++ resources/qml/TimelineView.qml | 16 ++++++++++++ resources/res.qrc | 1 + src/timeline/TimelineViewManager.cpp | 25 ++++++++++++++++++ src/timeline/TimelineViewManager.h | 1 + 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 resources/qml/QuickSwitcher.qml 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 From 0922a8e4c755dec9170820ae6263a1fc3122468c Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Mon, 22 Feb 2021 00:01:50 +0530 Subject: [PATCH 02/17] add room alias delegate, fix some quickswitcher ui problems --- resources/qml/Completer.qml | 29 ++++++++++++++++++++++++++-- resources/qml/MessageInput.qml | 2 +- resources/qml/QuickSwitcher.qml | 18 ++++++++++++----- src/timeline/TimelineViewManager.cpp | 5 +++++ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index ec5030e7..76e08e7e 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -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 diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index 7ecaf81a..e6b6762d 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -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; diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 317c96b3..ca7a5eeb 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -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() } } \ No newline at end of file diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index dc041cb9..74d416bb 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -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); From 3f4ad1dd8b506462cc463b67a23adf0c7fce88aa Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Mon, 22 Feb 2021 23:08:42 +0530 Subject: [PATCH 03/17] selecting room in quickswitcher now works, added completionSelected signal --- resources/qml/Completer.qml | 13 +++++++++++-- resources/qml/QuickSwitcher.qml | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 76e08e7e..a4f81e6e 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -15,6 +15,7 @@ Popup { property alias count: listView.count signal completionClicked(string completion) + signal completionSelected(string id) function up() { if (bottomToTop) @@ -91,7 +92,12 @@ Popup { anchors.fill: parent hoverEnabled: true onPositionChanged: popup.currentIndex = model.index - onClicked: popup.completionClicked(completer.completionAt(model.index)) + onClicked: { + popup.completionClicked(completer.completionAt(model.index)) + if(popup.completerName == "room") { + popup.completionSelected(model.roomid) + } + } Ripple { rippleTarget: mouseArea @@ -171,7 +177,10 @@ Popup { height: 24 width: 24 url: model.avatarUrl.replace("mxc://", "image://MxcImage/") - onClicked: popup.completionClicked(completer.completionAt(model.index)) + onClicked: { + popup.completionClicked(completer.completionAt(model.index)) + popup.completionSelected(model.roomid) + } } Label { diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index ca7a5eeb..b94fc0e2 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.3 import im.nheko 1.0 Popup { + id: quickSwitcher x: parent.width / 2 - width / 2 y: parent.height / 4 - height / 2 width: parent.width / 2 @@ -20,6 +21,16 @@ Popup { onTextEdited: { completerPopup.completer.setSearchString(text) } + + 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(); + } + } } Completer { @@ -43,4 +54,12 @@ Popup { onClosed: { completerPopup.close() } + + Connections { + onCompletionSelected: { + TimelineManager.setHistoryView(id) + quickSwitcher.close() + } + target: completerPopup + } } \ No newline at end of file From b1dec6f6acec929495f66ef7d0fcb3cac9ee25e3 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Tue, 23 Feb 2021 00:18:31 +0530 Subject: [PATCH 04/17] enter key now works, fix room highlighting and add overlay --- resources/qml/Completer.qml | 7 +++++++ resources/qml/QuickSwitcher.qml | 9 +++++++++ resources/qml/TimelineView.qml | 1 - src/ChatPage.cpp | 6 ++++++ src/ChatPage.h | 1 + src/timeline/TimelineViewManager.cpp | 6 ++++++ src/timeline/TimelineViewManager.h | 1 + 7 files changed, 30 insertions(+), 1 deletion(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index a4f81e6e..cef19fbf 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -52,6 +52,12 @@ Popup { return null; } + function finishCompletion() { + if(popup.completerName == "room") { + popup.completionSelected(listView.itemAtIndex(currentIndex).modelData.roomid) + } + } + onCompleterNameChanged: { if (completerName) { if (completerName == "user") { @@ -85,6 +91,7 @@ Popup { color: model.index == popup.currentIndex ? colors.highlight : colors.base height: chooser.childrenRect.height + 4 implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4 + property variant modelData: model MouseArea { id: mouseArea diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index b94fc0e2..609c443f 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -11,6 +11,10 @@ Popup { closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside parent: Overlay.overlay + Overlay.modal: Rectangle { + color: "#aa1E1E1E" + } + TextInput { id: roomTextInput @@ -29,6 +33,9 @@ Popup { } else if (event.key == Qt.Key_Down && completerPopup.opened) { event.accepted = true; completerPopup.down(); + } else if (event.matches(StandardKey.InsertParagraphSeparator)) { + completerPopup.finishCompletion() + event.accepted = true; } } } @@ -57,7 +64,9 @@ Popup { Connections { onCompletionSelected: { + console.log(id) TimelineManager.setHistoryView(id) + TimelineManager.highlightRoom(id) quickSwitcher.close() } target: completerPopup diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index f575e133..8c84c145 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -72,7 +72,6 @@ Page { id: quickSwitcherComponent QuickSwitcher { - id: quickSwitcher } } diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 9c814bd1..b862e129 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -1429,3 +1429,9 @@ ChatPage::handleMatrixUri(const QUrl &uri) { handleMatrixUri(uri.toString(QUrl::ComponentFormattingOption::FullyEncoded).toUtf8()); } + +void +ChatPage::highlightRoom(const QString &room_id) +{ + room_list_->highlightSelectedRoom(room_id); +} \ No newline at end of file diff --git a/src/ChatPage.h b/src/ChatPage.h index 917bd785..47acd807 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -116,6 +116,7 @@ public slots: void startChat(QString userid); void leaveRoom(const QString &room_id); void createRoom(const mtx::requests::CreateRoom &req); + void highlightRoom(const QString &room_id); void joinRoom(const QString &room); void joinRoomVia(const std::string &room_id, const std::vector &via); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 74d416bb..49072ef4 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -333,6 +333,12 @@ TimelineViewManager::setHistoryView(const QString &room_id) } } +void +TimelineViewManager::highlightRoom(const QString &room_id) +{ + ChatPage::instance()->highlightRoom(room_id); +} + QString TimelineViewManager::escapeEmoji(QString str) const { diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index d6383806..dfc2e386 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -100,6 +100,7 @@ public slots: } void setHistoryView(const QString &room_id); + void highlightRoom(const QString &room_id); TimelineModel *getHistoryView(const QString &room_id) { auto room = models.find(room_id); From ee232c5c60740921f7f3a72a97e46b2523882441 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Tue, 23 Feb 2021 00:46:40 +0530 Subject: [PATCH 05/17] fix timeline focus --- resources/qml/TimelineView.qml | 1 + src/timeline/TimelineViewManager.cpp | 6 ++++++ src/timeline/TimelineViewManager.h | 1 + 3 files changed, 8 insertions(+) diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 8c84c145..02032393 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -79,6 +79,7 @@ Page { sequence: "Ctrl+L" onActivated: { var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); + TimelineManager.focusTimeline() quickSwitch.open(); } } diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 49072ef4..7d74496d 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -587,4 +587,10 @@ TimelineViewManager::completerFor(QString completerName, QString roomId) return proxy; } return nullptr; +} + +void +TimelineViewManager::focusTimeline() +{ + getWidget()->setFocus(); } \ No newline at end of file diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index dfc2e386..f1c360ef 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -101,6 +101,7 @@ public slots: void setHistoryView(const QString &room_id); void highlightRoom(const QString &room_id); + void focusTimeline(); TimelineModel *getHistoryView(const QString &room_id) { auto room = models.find(room_id); From 97c25056192b08b55d845f0fead92491171987eb Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Tue, 23 Feb 2021 21:36:21 +0530 Subject: [PATCH 06/17] add matrix text field --- resources/qml/Completer.qml | 14 +++++---- resources/qml/MatrixTextField.qml | 51 +++++++++++++++++++++++++++++++ resources/qml/QuickSwitcher.qml | 32 ++++++++++++++----- resources/res.qrc | 1 + 4 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 resources/qml/MatrixTextField.qml diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index cef19fbf..9fad7156 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -12,6 +12,8 @@ Popup { property var completer property bool bottomToTop: true property bool fullWidth: false + property int avatarHeight: 24 + property int avatarWidth: 24 property alias count: listView.count signal completionClicked(string completion) @@ -128,8 +130,8 @@ Popup { anchors.centerIn: parent Avatar { - height: 24 - width: 24 + height: popup.avatarHeight + width: popup.avatarWidth displayName: model.displayName url: model.avatarUrl.replace("mxc://", "image://MxcImage/") onClicked: popup.completionClicked(completer.completionAt(model.index)) @@ -181,8 +183,8 @@ Popup { anchors.centerIn: parent Avatar { - height: 24 - width: 24 + height: popup.avatarHeight + width: popup.avatarWidth url: model.avatarUrl.replace("mxc://", "image://MxcImage/") onClicked: { popup.completionClicked(completer.completionAt(model.index)) @@ -208,8 +210,8 @@ Popup { anchors.centerIn: parent Avatar { - height: 24 - width: 24 + height: popup.avatarHeight + width: popup.avatarWidth url: model.avatarUrl.replace("mxc://", "image://MxcImage/") onClicked: popup.completionClicked(completer.completionAt(model.index)) } diff --git a/resources/qml/MatrixTextField.qml b/resources/qml/MatrixTextField.qml new file mode 100644 index 00000000..2852044b --- /dev/null +++ b/resources/qml/MatrixTextField.qml @@ -0,0 +1,51 @@ +import QtQuick 2.13 +import QtQuick.Layouts 1.13 +import QtQuick.Controls 2.13 + +TextInput { + id: input + + Rectangle { + id: blueBar + + anchors.top: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + + color: "blue" + height: 1 + width: parent.width + + Rectangle { + id: blackBar + + anchors.verticalCenter: blueBar.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + + height: parent.height+1 + width: 0 + color: "#000000" + + states: State { + name: "focused"; when: input.activeFocus == true + PropertyChanges { + target: blackBar + width: blueBar.width + } + } + + transitions: Transition { + from: "" + to: "focused" + reversible: true + + NumberAnimation { + target: blackBar + properties: "width" + duration: 500 + easing.type: Easing.InOutQuad + alwaysRunToEnd: true + } + } + } + } +} \ No newline at end of file diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 609c443f..2d2ae5cf 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -4,9 +4,13 @@ import im.nheko 1.0 Popup { id: quickSwitcher + + property int textWidth: 48 + x: parent.width / 2 - width / 2 y: parent.height / 4 - height / 2 width: parent.width / 2 + height: textWidth modal: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside parent: Overlay.overlay @@ -15,12 +19,11 @@ Popup { color: "#aa1E1E1E" } - TextInput { + MatrixTextField { id: roomTextInput - focus: true anchors.fill: parent - color: colors.text + font.pixelSize: quickSwitcher.textWidth - 12 onTextEdited: { completerPopup.completer.setSearchString(text) @@ -43,19 +46,23 @@ Popup { Completer { id: completerPopup - x: roomTextInput.x - y: roomTextInput.y + parent.height - width: parent.width + x: roomTextInput.x - 5 + y: roomTextInput.y + roomTextInput.height + 5 + width: parent.width + 10 completerName: "room" bottomToTop: true fullWidth: true + avatarHeight: textWidth + avatarWidth: textWidth closePolicy: Popup.NoAutoClose } onOpened: { completerPopup.open() - roomTextInput.forceActiveFocus() + delay(200, function() { + roomTextInput.forceActiveFocus() + }) } onClosed: { @@ -71,4 +78,15 @@ Popup { } target: completerPopup } + + Timer { + id: timer + } + + function delay(delayTime, cb) { + timer.interval = delayTime; + timer.repeat = false; + timer.triggered.connect(cb); + timer.start(); + } } \ No newline at end of file diff --git a/resources/res.qrc b/resources/res.qrc index d30d6e18..7d6b3a6d 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -128,6 +128,7 @@ qml/EncryptionIndicator.qml qml/ImageButton.qml qml/MatrixText.qml + qml/MatrixTextField.qml qml/ToggleButton.qml qml/MessageInput.qml qml/MessageView.qml From ebb35e5cb131d012862be05db5d5c8e95f21ad0d Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Tue, 23 Feb 2021 22:07:45 +0530 Subject: [PATCH 07/17] fix matrixtextfield color and quickswitcher font size --- resources/qml/MatrixTextField.qml | 4 ++-- resources/qml/QuickSwitcher.qml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/qml/MatrixTextField.qml b/resources/qml/MatrixTextField.qml index 2852044b..037a0b71 100644 --- a/resources/qml/MatrixTextField.qml +++ b/resources/qml/MatrixTextField.qml @@ -11,7 +11,7 @@ TextInput { anchors.top: parent.bottom anchors.horizontalCenter: parent.horizontalCenter - color: "blue" + color: colors.highlight height: 1 width: parent.width @@ -23,7 +23,7 @@ TextInput { height: parent.height+1 width: 0 - color: "#000000" + color: colors.text states: State { name: "focused"; when: input.activeFocus == true diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 2d2ae5cf..b772983a 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -10,10 +10,10 @@ Popup { x: parent.width / 2 - width / 2 y: parent.height / 4 - height / 2 width: parent.width / 2 - height: textWidth modal: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside parent: Overlay.overlay + palette: colors Overlay.modal: Rectangle { color: "#aa1E1E1E" @@ -23,7 +23,8 @@ Popup { id: roomTextInput anchors.fill: parent - font.pixelSize: quickSwitcher.textWidth - 12 + font.pixelSize: quickSwitcher.textWidth - 24 + color: colors.text onTextEdited: { completerPopup.completer.setSearchString(text) From 096f37df1f81ca988a6a2aed7589ca5e15ee45d3 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Wed, 24 Feb 2021 13:38:01 +0530 Subject: [PATCH 08/17] fix row content centering --- resources/qml/Completer.qml | 15 ++++++++++----- resources/qml/QuickSwitcher.qml | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 9fad7156..ee25bb3f 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -12,6 +12,7 @@ Popup { property var completer property bool bottomToTop: true property bool fullWidth: false + property bool centerRowContent: true property int avatarHeight: 24 property int avatarWidth: 24 property alias count: listView.count @@ -119,7 +120,11 @@ Popup { id: chooser roleValue: popup.completerName - anchors.centerIn: parent + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: centerRowContent ? parent : null + anchors.centerIn: centerRowContent ? parent : null DelegateChoice { roleValue: "user" @@ -127,7 +132,7 @@ Popup { RowLayout { id: del - anchors.centerIn: parent + anchors.centerIn: centerRowContent ? parent : null Avatar { height: popup.avatarHeight @@ -157,7 +162,7 @@ Popup { RowLayout { id: del - anchors.centerIn: parent + anchors.centerIn: centerRowContent ? parent : null Label { text: model.unicode @@ -180,7 +185,7 @@ Popup { RowLayout { id: del - anchors.centerIn: parent + anchors.centerIn: centerRowContent ? parent : null Avatar { height: popup.avatarHeight @@ -207,7 +212,7 @@ Popup { RowLayout { id: del - anchors.centerIn: parent + anchors.centerIn: centerRowContent ? parent : null Avatar { height: popup.avatarHeight diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index b772983a..eceffbde 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -55,6 +55,7 @@ Popup { fullWidth: true avatarHeight: textWidth avatarWidth: textWidth + centerRowContent: false closePolicy: Popup.NoAutoClose } From 0ce7f78446df0baf1a8872e05bd68742a26edb8c Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Wed, 24 Feb 2021 19:32:13 +0530 Subject: [PATCH 09/17] added margins and ui changes for quickswitcher and completer --- resources/qml/Completer.qml | 24 ++++++++++++++---------- resources/qml/QuickSwitcher.qml | 6 +++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index ee25bb3f..3abf8f38 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -15,6 +15,8 @@ Popup { property bool centerRowContent: true property int avatarHeight: 24 property int avatarWidth: 24 + property int rowMargin: 0 + property int rowSpacing: 5 property alias count: listView.count signal completionClicked(string completion) @@ -89,10 +91,11 @@ Popup { implicitWidth: fullWidth ? parent.width : contentItem.childrenRect.width model: completer verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom + spacing: rowSpacing delegate: Rectangle { color: model.index == popup.currentIndex ? colors.highlight : colors.base - height: chooser.childrenRect.height + 4 + height: chooser.childrenRect.height + 2 * popup.rowMargin implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4 property variant modelData: model @@ -120,11 +123,8 @@ Popup { id: chooser roleValue: popup.completerName - anchors.left: parent.left - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: centerRowContent ? parent : null - anchors.centerIn: centerRowContent ? parent : null + anchors.fill: parent + anchors.margins: popup.rowMargin DelegateChoice { roleValue: "user" @@ -132,7 +132,8 @@ Popup { RowLayout { id: del - anchors.centerIn: centerRowContent ? parent : null + anchors.centerIn: parent + spacing: rowSpacing Avatar { height: popup.avatarHeight @@ -162,7 +163,8 @@ Popup { RowLayout { id: del - anchors.centerIn: centerRowContent ? parent : null + anchors.centerIn: parent + spacing: rowSpacing Label { text: model.unicode @@ -185,7 +187,8 @@ Popup { RowLayout { id: del - anchors.centerIn: centerRowContent ? parent : null + anchors.centerIn: centerRowContent ? parent : undefined + spacing: rowSpacing Avatar { height: popup.avatarHeight @@ -212,7 +215,8 @@ Popup { RowLayout { id: del - anchors.centerIn: centerRowContent ? parent : null + anchors.centerIn: parent + spacing: rowSpacing Avatar { height: popup.avatarHeight diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index eceffbde..51924c5f 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -6,6 +6,7 @@ Popup { id: quickSwitcher property int textWidth: 48 + property int textMargin: 8 x: parent.width / 2 - width / 2 y: parent.height / 4 - height / 2 @@ -23,7 +24,8 @@ Popup { id: roomTextInput anchors.fill: parent - font.pixelSize: quickSwitcher.textWidth - 24 + font.pixelSize: quickSwitcher.textWidth - 18 + padding: textMargin color: colors.text onTextEdited: { @@ -56,6 +58,8 @@ Popup { avatarHeight: textWidth avatarWidth: textWidth centerRowContent: false + rowMargin: 8 + rowSpacing: 6 closePolicy: Popup.NoAutoClose } From 68c999e5f46d8107cb14cd947098e45869c44c91 Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Wed, 24 Feb 2021 19:50:36 +0530 Subject: [PATCH 10/17] remove old quick switcher --- CMakeLists.txt | 2 - resources/qml/TimelineView.qml | 2 +- src/ChatPage.cpp | 13 --- src/ChatPage.h | 2 - src/MainWindow.cpp | 6 -- src/QuickSwitcher.cpp | 141 --------------------------------- src/QuickSwitcher.h | 77 ------------------ 7 files changed, 1 insertion(+), 242 deletions(-) delete mode 100644 src/QuickSwitcher.cpp delete mode 100644 src/QuickSwitcher.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 05e54380..17b4ab2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -315,7 +315,6 @@ set(SRC_FILES src/MatrixClient.cpp src/MxcImageProvider.cpp src/Olm.cpp - src/QuickSwitcher.cpp src/RegisterPage.cpp src/RoomInfoListItem.cpp src/RoomList.cpp @@ -527,7 +526,6 @@ qt5_wrap_cpp(MOC_HEADERS src/LoginPage.h src/MainWindow.h src/MxcImageProvider.h - src/QuickSwitcher.h src/RegisterPage.h src/RoomInfoListItem.h src/RoomList.h diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 02032393..4415037c 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -76,7 +76,7 @@ Page { } Shortcut { - sequence: "Ctrl+L" + sequence: "Ctrl+K" onActivated: { var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); TimelineManager.focusTimeline() diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index b862e129..dbd93d1f 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -35,7 +35,6 @@ #include "MainWindow.h" #include "MatrixClient.h" #include "Olm.h" -#include "QuickSwitcher.h" #include "RoomList.h" #include "SideBarActions.h" #include "Splitter.h" @@ -598,18 +597,6 @@ ChatPage::loadStateFromCache() emit trySyncCb(); } -void -ChatPage::showQuickSwitcher() -{ - auto dialog = new QuickSwitcher(this); - - connect(dialog, &QuickSwitcher::roomSelected, room_list_, &RoomList::highlightSelectedRoom); - connect( - dialog, &QuickSwitcher::closing, this, []() { MainWindow::instance()->hideOverlay(); }); - - MainWindow::instance()->showTransparentOverlayModal(dialog); -} - void ChatPage::removeRoom(const QString &room_id) { diff --git a/src/ChatPage.h b/src/ChatPage.h index 47acd807..316ca9ae 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -43,7 +43,6 @@ #include "notifications/Manager.h" class OverlayModal; -class QuickSwitcher; class RoomList; class SideBarActions; class Splitter; @@ -84,7 +83,6 @@ public: // Initialize all the components of the UI. void bootstrap(QString userid, QString homeserver, QString token); - void showQuickSwitcher(); QString currentRoom() const { return current_room_; } static ChatPage *instance() { return instance_; } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index ae532ef3..3555c363 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -147,12 +147,6 @@ MainWindow::MainWindow(QWidget *parent) QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this); connect(quitShortcut, &QShortcut::activated, this, QApplication::quit); - QShortcut *quickSwitchShortcut = new QShortcut(QKeySequence("Ctrl+K"), this); - connect(quickSwitchShortcut, &QShortcut::activated, this, [this]() { - if (chat_page_->isVisible() && !hasActiveDialogs()) - chat_page_->showQuickSwitcher(); - }); - trayIcon_->setVisible(userSettings_->tray()); if (hasActiveUser()) { diff --git a/src/QuickSwitcher.cpp b/src/QuickSwitcher.cpp deleted file mode 100644 index 046c774d..00000000 --- a/src/QuickSwitcher.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * nheko Copyright (C) 2017 Konstantinos Sideris - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -#include "Cache.h" -#include "QuickSwitcher.h" -#include "popups/SuggestionsPopup.h" - -Q_DECLARE_METATYPE(std::vector) - -RoomSearchInput::RoomSearchInput(QWidget *parent) - : TextField(parent) -{} - -void -RoomSearchInput::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Tab: - case Qt::Key_Down: { - emit selectNextCompletion(); - event->accept(); - break; - } - case Qt::Key_Backtab: - case Qt::Key_Up: { - emit selectPreviousCompletion(); - event->accept(); - break; - } - default: - TextField::keyPressEvent(event); - } -} - -void -RoomSearchInput::hideEvent(QHideEvent *event) -{ - emit hiding(); - TextField::hideEvent(event); -} - -QuickSwitcher::QuickSwitcher(QWidget *parent) - : QWidget(parent) -{ - qRegisterMetaType>(); - setMaximumWidth(450); - - QFont font; - font.setPointSizeF(font.pointSizeF() * 1.5); - - roomSearch_ = new RoomSearchInput(this); - roomSearch_->setFont(font); - roomSearch_->setPlaceholderText(tr("Search for a room...")); - - topLayout_ = new QVBoxLayout(this); - topLayout_->addWidget(roomSearch_); - - connect(this, - &QuickSwitcher::queryResults, - this, - [this](const std::vector &rooms) { - auto pos = mapToGlobal(roomSearch_->geometry().bottomLeft()); - - popup_.setFixedWidth(width()); - popup_.addRooms(rooms); - popup_.move(pos.x() - topLayout_->margin(), pos.y() + topLayout_->margin()); - popup_.show(); - }); - - connect(roomSearch_, &QLineEdit::textEdited, this, [this](const QString &query) { - if (query.isEmpty()) { - popup_.hide(); - return; - } - - QtConcurrent::run([this, query = query.toLower()]() { - try { - emit queryResults(cache::searchRooms(query.toStdString())); - } catch (const lmdb::error &e) { - qWarning() << "room search failed:" << e.what(); - } - }); - }); - - connect(roomSearch_, - &RoomSearchInput::selectNextCompletion, - &popup_, - &SuggestionsPopup::selectNextSuggestion); - connect(roomSearch_, - &RoomSearchInput::selectPreviousCompletion, - &popup_, - &SuggestionsPopup::selectPreviousSuggestion); - connect(&popup_, &SuggestionsPopup::itemSelected, this, [this](const QString &room_id) { - reset(); - emit roomSelected(room_id); - }); - connect(roomSearch_, &RoomSearchInput::hiding, this, [this]() { popup_.hide(); }); - connect(roomSearch_, &QLineEdit::returnPressed, this, [this]() { - reset(); - popup_.selectHoveredSuggestion(); - }); -} - -void -QuickSwitcher::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} - -void -QuickSwitcher::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Escape) { - event->accept(); - reset(); - } -} diff --git a/src/QuickSwitcher.h b/src/QuickSwitcher.h deleted file mode 100644 index 5bc31650..00000000 --- a/src/QuickSwitcher.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * nheko Copyright (C) 2017 Konstantinos Sideris - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include -#include -#include -#include - -#include "popups/SuggestionsPopup.h" -#include "ui/TextField.h" - -class RoomSearchInput : public TextField -{ - Q_OBJECT -public: - explicit RoomSearchInput(QWidget *parent = nullptr); - -signals: - void selectNextCompletion(); - void selectPreviousCompletion(); - void hiding(); - -protected: - void keyPressEvent(QKeyEvent *event) override; - void hideEvent(QHideEvent *event) override; - bool focusNextPrevChild(bool) override { return false; }; -}; - -class QuickSwitcher : public QWidget -{ - Q_OBJECT - -public: - QuickSwitcher(QWidget *parent = nullptr); - -signals: - void closing(); - void roomSelected(const QString &roomid); - void queryResults(const std::vector &rooms); - -protected: - void keyPressEvent(QKeyEvent *event) override; - void showEvent(QShowEvent *) override { roomSearch_->setFocus(); } - void paintEvent(QPaintEvent *event) override; - -private: - void reset() - { - emit closing(); - roomSearch_->clear(); - } - - // Current highlighted selection from the completer. - int selection_ = -1; - - QVBoxLayout *topLayout_; - RoomSearchInput *roomSearch_; - - //! Autocomplete popup box with the room suggestions. - SuggestionsPopup popup_; -}; From 1f8a3ae1e8dc3f079591ae2474663c0b1e2d4d2b Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Fri, 26 Feb 2021 11:39:51 +0530 Subject: [PATCH 11/17] changed bottomToTop to true and renamed textWidth to textHeight --- resources/qml/QuickSwitcher.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 51924c5f..ab037d4e 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -5,7 +5,7 @@ import im.nheko 1.0 Popup { id: quickSwitcher - property int textWidth: 48 + property int textHeight: 48 property int textMargin: 8 x: parent.width / 2 - width / 2 @@ -24,7 +24,7 @@ Popup { id: roomTextInput anchors.fill: parent - font.pixelSize: quickSwitcher.textWidth - 18 + font.pixelSize: quickSwitcher.textHeight * 0.6 padding: textMargin color: colors.text @@ -53,10 +53,10 @@ Popup { y: roomTextInput.y + roomTextInput.height + 5 width: parent.width + 10 completerName: "room" - bottomToTop: true + bottomToTop: false fullWidth: true - avatarHeight: textWidth - avatarWidth: textWidth + avatarHeight: textHeight + avatarWidth: textHeight centerRowContent: false rowMargin: 8 rowSpacing: 6 From 8870455f9dd6463f9b8ef04516d69efef3c6287d Mon Sep 17 00:00:00 2001 From: Jedi18 Date: Sun, 7 Mar 2021 00:18:24 +0530 Subject: [PATCH 12/17] change allowed mistakes, fix minor style issues, remove old completer function from inputbar --- resources/qml/Completer.qml | 2 ++ resources/qml/MatrixTextField.qml | 7 ++++- resources/qml/QuickSwitcher.qml | 9 +++--- src/CompletionProxyModel.cpp | 7 +++-- src/CompletionProxyModel.h | 42 +++++++++++++++++----------- src/timeline/InputBar.cpp | 22 --------------- src/timeline/InputBar.h | 2 -- src/timeline/TimelineViewManager.cpp | 2 +- 8 files changed, 43 insertions(+), 50 deletions(-) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 3abf8f38..4a692c55 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -92,6 +92,7 @@ Popup { model: completer verticalLayoutDirection: popup.bottomToTop ? ListView.BottomToTop : ListView.TopToBottom spacing: rowSpacing + pixelAligned: true delegate: Rectangle { color: model.index == popup.currentIndex ? colors.highlight : colors.base @@ -202,6 +203,7 @@ Popup { Label { text: model.roomName + font.pixelSize: popup.avatarHeight * 0.5 color: model.index == popup.currentIndex ? colors.highlightedText : colors.text } diff --git a/resources/qml/MatrixTextField.qml b/resources/qml/MatrixTextField.qml index 037a0b71..9e8d286b 100644 --- a/resources/qml/MatrixTextField.qml +++ b/resources/qml/MatrixTextField.qml @@ -2,8 +2,13 @@ import QtQuick 2.13 import QtQuick.Layouts 1.13 import QtQuick.Controls 2.13 -TextInput { +TextField { id: input + palette: colors + + background: Rectangle { + color: colors.base + } Rectangle { id: blueBar diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index ab037d4e..29d9a9b2 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -5,7 +5,7 @@ import im.nheko 1.0 Popup { id: quickSwitcher - property int textHeight: 48 + property int textHeight: 32 property int textMargin: 8 x: parent.width / 2 - width / 2 @@ -49,9 +49,9 @@ Popup { Completer { id: completerPopup - x: roomTextInput.x - 5 - y: roomTextInput.y + roomTextInput.height + 5 - width: parent.width + 10 + x: roomTextInput.x + y: roomTextInput.y + roomTextInput.height + textMargin + width: parent.width completerName: "room" bottomToTop: false fullWidth: true @@ -77,7 +77,6 @@ Popup { Connections { onCompletionSelected: { - console.log(id) TimelineManager.setHistoryView(id) TimelineManager.highlightRoom(id) quickSwitcher.close() diff --git a/src/CompletionProxyModel.cpp b/src/CompletionProxyModel.cpp index fa5b3c2d..35b8d0a9 100644 --- a/src/CompletionProxyModel.cpp +++ b/src/CompletionProxyModel.cpp @@ -6,8 +6,11 @@ #include "Logging.h" #include "Utils.h" -CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, QObject *parent) +CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, + int max_mistakes, + QObject *parent) : QAbstractProxyModel(parent) + , maxMistakes_(max_mistakes) { setSourceModel(model); QRegularExpression splitPoints("\\s+|-"); @@ -59,7 +62,7 @@ CompletionProxyModel::invalidate() { auto key = searchString.toUcs4(); beginResetModel(); - mapping = trie_.search(key, 7); + mapping = trie_.search(key, 7, maxMistakes_); endResetModel(); std::string temp; diff --git a/src/CompletionProxyModel.h b/src/CompletionProxyModel.h index 1517505f..fc419702 100644 --- a/src/CompletionProxyModel.h +++ b/src/CompletionProxyModel.h @@ -54,19 +54,19 @@ struct trie } std::vector search(const QVector &keys, //< TODO(Nico): replace this with a span - size_t limit, - size_t max_distance = 2) const + size_t result_count_limit, + size_t max_edit_distance = 2) const { std::vector ret; - if (!limit) + if (!result_count_limit) return ret; if (keys.isEmpty()) - return valuesAndSubvalues(limit); + return valuesAndSubvalues(result_count_limit); - auto append = [&ret, limit](std::vector &&in) { + auto append = [&ret, result_count_limit](std::vector &&in) { for (auto &&v : in) { - if (ret.size() >= limit) + if (ret.size() >= result_count_limit) return; if (std::find(ret.begin(), ret.end(), v) == ret.end()) { @@ -76,11 +76,12 @@ struct trie }; if (auto e = this->next.find(keys[0]); e != this->next.end()) { - append(e->second.search(keys.mid(1), limit, max_distance)); + append( + e->second.search(keys.mid(1), result_count_limit, max_edit_distance)); } - if (max_distance && ret.size() < limit) { - max_distance -= 1; + if (max_edit_distance && ret.size() < result_count_limit) { + max_edit_distance -= 1; // swap chars case if (keys.size() >= 2) { @@ -95,27 +96,31 @@ struct trie } if (t) { - append(t->search( - keys.mid(2), (limit - ret.size()) * 2, max_distance)); + append(t->search(keys.mid(2), + (result_count_limit - ret.size()) * 2, + max_edit_distance)); } } // delete character case - append(this->search(keys.mid(1), (limit - ret.size()) * 2, max_distance)); + append(this->search( + keys.mid(1), (result_count_limit - ret.size()) * 2, max_edit_distance)); // substitute and insert cases for (const auto &[k, t] : this->next) { - if (k == keys[0] || ret.size() >= limit) + if (k == keys[0] || ret.size() >= result_count_limit) break; // substitute - append(t.search(keys.mid(1), limit - ret.size(), max_distance)); + append(t.search( + keys.mid(1), result_count_limit - ret.size(), max_edit_distance)); - if (ret.size() >= limit) + if (ret.size() >= result_count_limit) break; // insert - append(t.search(keys, limit - ret.size(), max_distance)); + append(t.search( + keys, result_count_limit - ret.size(), max_edit_distance)); } } @@ -128,7 +133,9 @@ class CompletionProxyModel : public QAbstractProxyModel Q_OBJECT public: - CompletionProxyModel(QAbstractItemModel *model, QObject *parent = nullptr); + CompletionProxyModel(QAbstractItemModel *model, + int max_mistakes = 2, + QObject *parent = nullptr); void invalidate(); @@ -156,4 +163,5 @@ private: QString searchString; trie trie_; std::vector mapping; + int maxMistakes_; }; diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 5ef38ac7..ab0fc3d7 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -174,28 +174,6 @@ InputBar::nextText() return text(); } -QObject * -InputBar::completerFor(QString completerName) -{ - if (completerName == "user") { - auto userModel = new UsersModel(room->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; -} - void InputBar::send() { diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 696a0dd9..678d953d 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -51,8 +51,6 @@ public slots: bool uploading() const { return uploading_; } void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED); - QObject *completerFor(QString completerName); - private slots: void startTyping(); void stopTyping(); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 7d74496d..04af7060 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -577,7 +577,7 @@ TimelineViewManager::completerFor(QString completerName, QString roomId) return proxy; } else if (completerName == "room") { auto roomModel = new RoomsModel(false); - auto proxy = new CompletionProxyModel(roomModel); + auto proxy = new CompletionProxyModel(roomModel, 4); roomModel->setParent(proxy); return proxy; } else if (completerName == "roomAliases") { From b82c11bd791d5cb4d3ddb9b01305e215d6385cff Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 13 Mar 2021 23:52:46 +0100 Subject: [PATCH 13/17] Fix text corruption from unrounded pixel height --- resources/qml/QuickSwitcher.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 29d9a9b2..88903163 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -24,7 +24,7 @@ Popup { id: roomTextInput anchors.fill: parent - font.pixelSize: quickSwitcher.textHeight * 0.6 + font.pixelSize: Math.ceil(quickSwitcher.textHeight * 0.6) padding: textMargin color: colors.text @@ -94,4 +94,4 @@ Popup { timer.triggered.connect(cb); timer.start(); } -} \ No newline at end of file +} From 1961312b1508070be0d2a3c6e67a1a3eb24c83d5 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 14 Mar 2021 01:24:26 +0100 Subject: [PATCH 14/17] Improve sorting and sizing of completions a bit --- resources/qml/Avatar.qml | 1 - resources/qml/Completer.qml | 27 ++++--- resources/qml/EncryptionIndicator.qml | 1 - resources/qml/ImageButton.qml | 1 - resources/qml/MatrixText.qml | 1 - resources/qml/MatrixTextField.qml | 36 +++++---- resources/qml/MessageInput.qml | 1 - resources/qml/MessageView.qml | 1 - resources/qml/NhekoBusyIndicator.qml | 1 - resources/qml/PrivacyScreen.qml | 1 - resources/qml/QuickSwitcher.qml | 76 ++++++++++--------- resources/qml/Reactions.qml | 1 - resources/qml/ReplyPopup.qml | 1 - resources/qml/RoomSettings.qml | 1 - resources/qml/ScrollHelper.qml | 2 - resources/qml/StatusIndicator.qml | 1 - resources/qml/TimelineRow.qml | 1 - resources/qml/TimelineView.qml | 4 +- resources/qml/ToggleButton.qml | 1 - resources/qml/TopBar.qml | 1 - resources/qml/TypingIndicator.qml | 1 - resources/qml/UserProfile.qml | 1 - resources/qml/delegates/FileMessage.qml | 1 - resources/qml/delegates/ImageMessage.qml | 1 - resources/qml/delegates/MessageDelegate.qml | 1 - resources/qml/delegates/NoticeMessage.qml | 1 - resources/qml/delegates/Pill.qml | 1 - resources/qml/delegates/Placeholder.qml | 1 - .../qml/delegates/PlayableMediaMessage.qml | 1 - resources/qml/delegates/Reply.qml | 1 - resources/qml/delegates/TextMessage.qml | 1 - .../AwaitingVerificationConfirmation.qml | 1 - .../DeviceVerification.qml | 1 - .../device-verification/DigitVerification.qml | 1 - .../qml/device-verification/EmojiElement.qml | 1 - .../device-verification/EmojiVerification.qml | 1 - resources/qml/device-verification/Failed.qml | 1 - .../NewVerificationRequest.qml | 1 - resources/qml/device-verification/Success.qml | 1 - resources/qml/device-verification/Waiting.qml | 1 - resources/qml/emoji/EmojiButton.qml | 1 - resources/qml/emoji/EmojiPicker.qml | 1 - resources/qml/ui/Ripple.qml | 1 - resources/qml/voip/ActiveCallBar.qml | 1 - resources/qml/voip/CallDevices.qml | 1 - resources/qml/voip/CallInvite.qml | 1 - resources/qml/voip/CallInviteBar.qml | 1 - resources/qml/voip/DeviceError.qml | 1 - resources/qml/voip/PlaceCall.qml | 1 - resources/qml/voip/ScreenShare.qml | 1 - resources/qml/voip/VideoCall.qml | 1 - src/CompletionProxyModel.cpp | 19 ++++- src/CompletionProxyModel.h | 6 +- 53 files changed, 95 insertions(+), 121 deletions(-) diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml index 07e68e10..f53dfe3a 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./ui" diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 6170045c..3b79a50d 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./ui" @@ -62,18 +61,17 @@ Popup { } function finishCompletion() { - if(popup.completerName == "room") { - popup.completionSelected(listView.itemAtIndex(currentIndex).modelData.roomid) - } + if (popup.completerName == "room") + popup.completionSelected(listView.itemAtIndex(currentIndex).modelData.roomid); + } onCompleterNameChanged: { if (completerName) { - if (completerName == "user") { + if (completerName == "user") completer = TimelineManager.completerFor(completerName, TimelineManager.timeline.roomId()); - } else { + else completer = TimelineManager.completerFor(completerName); - } completer.setSearchString(""); } else { completer = undefined; @@ -99,10 +97,11 @@ Popup { pixelAligned: true delegate: Rectangle { + property variant modelData: model + color: model.index == popup.currentIndex ? colors.highlight : colors.base height: chooser.childrenRect.height + 2 * popup.rowMargin implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4 - property variant modelData: model MouseArea { id: mouseArea @@ -111,10 +110,10 @@ Popup { hoverEnabled: true onPositionChanged: popup.currentIndex = model.index onClicked: { - popup.completionClicked(completer.completionAt(model.index)) - if(popup.completerName == "room") { - popup.completionSelected(model.roomid) - } + popup.completionClicked(completer.completionAt(model.index)); + if (popup.completerName == "room") + popup.completionSelected(model.roomid); + } Ripple { @@ -200,8 +199,8 @@ Popup { width: popup.avatarWidth url: model.avatarUrl.replace("mxc://", "image://MxcImage/") onClicked: { - popup.completionClicked(completer.completionAt(model.index)) - popup.completionSelected(model.roomid) + popup.completionClicked(completer.completionAt(model.index)); + popup.completionSelected(model.roomid); } } diff --git a/resources/qml/EncryptionIndicator.qml b/resources/qml/EncryptionIndicator.qml index 58805f48..5fcc0ada 100644 --- a/resources/qml/EncryptionIndicator.qml +++ b/resources/qml/EncryptionIndicator.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index 76cc0b42..f25705f0 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./ui" diff --git a/resources/qml/MatrixText.qml b/resources/qml/MatrixText.qml index dfe7122d..073956f4 100644 --- a/resources/qml/MatrixText.qml +++ b/resources/qml/MatrixText.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/MatrixTextField.qml b/resources/qml/MatrixTextField.qml index 9e8d286b..9762817c 100644 --- a/resources/qml/MatrixTextField.qml +++ b/resources/qml/MatrixTextField.qml @@ -1,56 +1,62 @@ import QtQuick 2.13 -import QtQuick.Layouts 1.13 import QtQuick.Controls 2.13 +import QtQuick.Layouts 1.13 TextField { id: input - palette: colors - background: Rectangle { - color: colors.base - } + palette: colors Rectangle { id: blueBar anchors.top: parent.bottom anchors.horizontalCenter: parent.horizontalCenter - color: colors.highlight height: 1 width: parent.width - + Rectangle { id: blackBar anchors.verticalCenter: blueBar.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - - height: parent.height+1 + height: parent.height + 1 width: 0 color: colors.text - + states: State { - name: "focused"; when: input.activeFocus == true + name: "focused" + when: input.activeFocus == true + PropertyChanges { target: blackBar width: blueBar.width } + } - + transitions: Transition { from: "" to: "focused" reversible: true - NumberAnimation { + NumberAnimation { target: blackBar properties: "width" duration: 500 easing.type: Easing.InOutQuad - alwaysRunToEnd: true + alwaysRunToEnd: true } + } + } + } -} \ No newline at end of file + + background: Rectangle { + color: colors.base + } + +} diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index faf0d442..29657c85 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./voip" diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 1bc10b60..baf6b800 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates" diff --git a/resources/qml/NhekoBusyIndicator.qml b/resources/qml/NhekoBusyIndicator.qml index 917e11dc..e45d71ec 100644 --- a/resources/qml/NhekoBusyIndicator.qml +++ b/resources/qml/NhekoBusyIndicator.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/PrivacyScreen.qml b/resources/qml/PrivacyScreen.qml index ca73cfd7..bd146dac 100644 --- a/resources/qml/PrivacyScreen.qml +++ b/resources/qml/PrivacyScreen.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtGraphicalEffects 1.0 diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 88903163..ac896c56 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -5,19 +5,31 @@ import im.nheko 1.0 Popup { id: quickSwitcher - property int textHeight: 32 - property int textMargin: 8 + property int textHeight: Math.round(Qt.application.font.pixelSize * 2.4) + property int textMargin: Math.round(textHeight / 8) - x: parent.width / 2 - width / 2 - y: parent.height / 4 - height / 2 - width: parent.width / 2 + function delay(delayTime, cb) { + timer.interval = delayTime; + timer.repeat = false; + timer.triggered.connect(cb); + timer.start(); + } + + width: Math.round(parent.width / 2) + x: Math.round(parent.width / 2 - width / 2) + y: Math.round(parent.height / 4 - height / 2) modal: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside parent: Overlay.overlay palette: colors - - Overlay.modal: Rectangle { - color: "#aa1E1E1E" + onOpened: { + completerPopup.open(); + delay(200, function() { + roomTextInput.forceActiveFocus(); + }); + } + onClosed: { + completerPopup.close(); } MatrixTextField { @@ -27,11 +39,9 @@ Popup { font.pixelSize: Math.ceil(quickSwitcher.textHeight * 0.6) padding: textMargin color: colors.text - onTextEdited: { - completerPopup.completer.setSearchString(text) + completerPopup.completer.searchString = text; } - Keys.onPressed: { if (event.key == Qt.Key_Up && completerPopup.opened) { event.accepted = true; @@ -40,7 +50,7 @@ Popup { event.accepted = true; completerPopup.down(); } else if (event.matches(StandardKey.InsertParagraphSeparator)) { - completerPopup.finishCompletion() + completerPopup.finishCompletion(); event.accepted = true; } } @@ -50,36 +60,30 @@ Popup { id: completerPopup x: roomTextInput.x - y: roomTextInput.y + roomTextInput.height + textMargin + y: roomTextInput.y + quickSwitcher.textHeight + quickSwitcher.textMargin + visible: roomTextInput.length > 0 width: parent.width completerName: "room" bottomToTop: false fullWidth: true - avatarHeight: textHeight - avatarWidth: textHeight + avatarHeight: quickSwitcher.textHeight + avatarWidth: quickSwitcher.textHeight centerRowContent: false - rowMargin: 8 - rowSpacing: 6 - + rowMargin: Math.round(quickSwitcher.textMargin / 2) + rowSpacing: quickSwitcher.textMargin closePolicy: Popup.NoAutoClose } - onOpened: { - completerPopup.open() - delay(200, function() { - roomTextInput.forceActiveFocus() - }) - } - - onClosed: { - completerPopup.close() - } - Connections { onCompletionSelected: { - TimelineManager.setHistoryView(id) - TimelineManager.highlightRoom(id) - quickSwitcher.close() + TimelineManager.setHistoryView(id); + TimelineManager.highlightRoom(id); + quickSwitcher.close(); + } + onCountChanged: { + if (completerPopup.count > 0 && (completerPopup.currentIndex < 0 || completerPopup.currentIndex >= completerPopup.count)) + completerPopup.currentIndex = 0; + } target: completerPopup } @@ -88,10 +92,8 @@ Popup { id: timer } - function delay(delayTime, cb) { - timer.interval = delayTime; - timer.repeat = false; - timer.triggered.connect(cb); - timer.start(); + Overlay.modal: Rectangle { + color: "#aa1E1E1E" } + } diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index f53c89ad..335d5b29 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.6 diff --git a/resources/qml/ReplyPopup.qml b/resources/qml/ReplyPopup.qml index 37b6f6cc..eb70585e 100644 --- a/resources/qml/ReplyPopup.qml +++ b/resources/qml/ReplyPopup.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates/" diff --git a/resources/qml/RoomSettings.qml b/resources/qml/RoomSettings.qml index 2117e513..ed1a5bd9 100644 --- a/resources/qml/RoomSettings.qml +++ b/resources/qml/RoomSettings.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import Qt.labs.platform 1.1 as Platform diff --git a/resources/qml/ScrollHelper.qml b/resources/qml/ScrollHelper.qml index 2dd56f27..2d315a6d 100644 --- a/resources/qml/ScrollHelper.qml +++ b/resources/qml/ScrollHelper.qml @@ -1,9 +1,7 @@ // Copyright (C) 2016 Michael Bohlender, // Copyright (C) 2017 Christian Mollekopf, // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later - /* * Shamelessly stolen from: * https://cgit.kde.org/kube.git/tree/framework/qml/ScrollHelper.qml diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index 3d2d8278..f2b6c12d 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 0f815f6f..8e479d58 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates" diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 20251bc0..49221014 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates" @@ -77,13 +76,14 @@ Page { QuickSwitcher { } + } Shortcut { sequence: "Ctrl+K" onActivated: { var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); - TimelineManager.focusTimeline() + TimelineManager.focusTimeline(); quickSwitch.open(); } } diff --git a/resources/qml/ToggleButton.qml b/resources/qml/ToggleButton.qml index bd82e4f9..3791a5b4 100644 --- a/resources/qml/ToggleButton.qml +++ b/resources/qml/ToggleButton.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index 444a4572..e158a8ba 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/TypingIndicator.qml b/resources/qml/TypingIndicator.qml index ffe88fb6..2e36e8ad 100644 --- a/resources/qml/TypingIndicator.qml +++ b/resources/qml/TypingIndicator.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml index dbf13796..05d2a391 100644 --- a/resources/qml/UserProfile.qml +++ b/resources/qml/UserProfile.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "./device-verification" diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 293b7a78..e73d6a50 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 0521258e..829d29ed 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 211e03a6..dcf6eb3b 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.6 diff --git a/resources/qml/delegates/NoticeMessage.qml b/resources/qml/delegates/NoticeMessage.qml index 4f8fbfd2..6c604c5e 100644 --- a/resources/qml/delegates/NoticeMessage.qml +++ b/resources/qml/delegates/NoticeMessage.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later TextMessage { diff --git a/resources/qml/delegates/Pill.qml b/resources/qml/delegates/Pill.qml index a3fa0d9e..8efa491c 100644 --- a/resources/qml/delegates/Pill.qml +++ b/resources/qml/delegates/Pill.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/delegates/Placeholder.qml b/resources/qml/delegates/Placeholder.qml index addbc7e7..50486439 100644 --- a/resources/qml/delegates/Placeholder.qml +++ b/resources/qml/delegates/Placeholder.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import ".." diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index f871e492..7d00de21 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtMultimedia 5.6 diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index 6763b71b..728e9739 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml index 1624d95c..ec0866ad 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import ".." diff --git a/resources/qml/device-verification/AwaitingVerificationConfirmation.qml b/resources/qml/device-verification/AwaitingVerificationConfirmation.qml index ae62c334..8d57c8d6 100644 --- a/resources/qml/device-verification/AwaitingVerificationConfirmation.qml +++ b/resources/qml/device-verification/AwaitingVerificationConfirmation.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/DeviceVerification.qml b/resources/qml/device-verification/DeviceVerification.qml index fee0284a..cb3cd8ab 100644 --- a/resources/qml/device-verification/DeviceVerification.qml +++ b/resources/qml/device-verification/DeviceVerification.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.10 diff --git a/resources/qml/device-verification/DigitVerification.qml b/resources/qml/device-verification/DigitVerification.qml index a387756d..cf5f75ed 100644 --- a/resources/qml/device-verification/DigitVerification.qml +++ b/resources/qml/device-verification/DigitVerification.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/EmojiElement.qml b/resources/qml/device-verification/EmojiElement.qml index f5c87a56..1b1ecbcf 100644 --- a/resources/qml/device-verification/EmojiElement.qml +++ b/resources/qml/device-verification/EmojiElement.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/EmojiVerification.qml b/resources/qml/device-verification/EmojiVerification.qml index be9e3938..e179b0ed 100644 --- a/resources/qml/device-verification/EmojiVerification.qml +++ b/resources/qml/device-verification/EmojiVerification.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/Failed.qml b/resources/qml/device-verification/Failed.qml index 5c71b02e..bc7dd5fc 100644 --- a/resources/qml/device-verification/Failed.qml +++ b/resources/qml/device-verification/Failed.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/NewVerificationRequest.qml b/resources/qml/device-verification/NewVerificationRequest.qml index e8589cf7..7af19b42 100644 --- a/resources/qml/device-verification/NewVerificationRequest.qml +++ b/resources/qml/device-verification/NewVerificationRequest.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/Success.qml b/resources/qml/device-verification/Success.qml index f2657b12..a454d56e 100644 --- a/resources/qml/device-verification/Success.qml +++ b/resources/qml/device-verification/Success.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/Waiting.qml b/resources/qml/device-verification/Waiting.qml index 3bfa153d..c8dc2a77 100644 --- a/resources/qml/device-verification/Waiting.qml +++ b/resources/qml/device-verification/Waiting.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/emoji/EmojiButton.qml b/resources/qml/emoji/EmojiButton.qml index cec51d75..71f8bc01 100644 --- a/resources/qml/emoji/EmojiButton.qml +++ b/resources/qml/emoji/EmojiButton.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/emoji/EmojiPicker.qml b/resources/qml/emoji/EmojiPicker.qml index 2db9dc07..ed8fdec4 100644 --- a/resources/qml/emoji/EmojiPicker.qml +++ b/resources/qml/emoji/EmojiPicker.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/ui/Ripple.qml b/resources/qml/ui/Ripple.qml index b240f421..7a8688f5 100644 --- a/resources/qml/ui/Ripple.qml +++ b/resources/qml/ui/Ripple.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtGraphicalEffects 1.0 diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 68d3bc4a..c8bd6037 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/CallDevices.qml b/resources/qml/voip/CallDevices.qml index 11644797..02340b4b 100644 --- a/resources/qml/voip/CallDevices.qml +++ b/resources/qml/voip/CallDevices.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/voip/CallInvite.qml b/resources/qml/voip/CallInvite.qml index 15d987e7..ed706f12 100644 --- a/resources/qml/voip/CallInvite.qml +++ b/resources/qml/voip/CallInvite.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index fe3f791f..c8474264 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/DeviceError.qml b/resources/qml/voip/DeviceError.qml index 05cfd409..a1ec7f12 100644 --- a/resources/qml/voip/DeviceError.qml +++ b/resources/qml/voip/DeviceError.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index c9aa8ea1..f340bb4e 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/ScreenShare.qml b/resources/qml/voip/ScreenShare.qml index af473c04..908500ee 100644 --- a/resources/qml/voip/ScreenShare.qml +++ b/resources/qml/voip/ScreenShare.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/VideoCall.qml b/resources/qml/voip/VideoCall.qml index 23651033..8dd5fb90 100644 --- a/resources/qml/voip/VideoCall.qml +++ b/resources/qml/voip/VideoCall.qml @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors -// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/src/CompletionProxyModel.cpp b/src/CompletionProxyModel.cpp index a6759978..45b44fca 100644 --- a/src/CompletionProxyModel.cpp +++ b/src/CompletionProxyModel.cpp @@ -19,6 +19,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, setSourceModel(model); QRegularExpression splitPoints("\\s+|-"); + // insert all the full texts for (int i = 0; i < sourceModel()->rowCount(); i++) { if (i < 7) mapping.push_back(i); @@ -29,6 +30,19 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, .toLower(); trie_.insert(string1.toUcs4(), i); + auto string2 = sourceModel() + ->data(sourceModel()->index(i, 0), CompletionModel::SearchRole2) + .toString() + .toLower(); + } + + // insert the partial matches + for (int i = 0; i < sourceModel()->rowCount(); i++) { + auto string1 = sourceModel() + ->data(sourceModel()->index(i, 0), CompletionModel::SearchRole) + .toString() + .toLower(); + for (const auto &e : string1.split(splitPoints)) { if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14 trie_.insert(e.toUcs4(), i); @@ -40,7 +54,6 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, .toLower(); if (!string2.isEmpty()) { - trie_.insert(string2.toUcs4(), i); for (const auto &e : string2.split(splitPoints)) { if (!e.isEmpty()) // NOTE(Nico): Use Qt::SkipEmptyParts in Qt 5.14 trie_.insert(e.toUcs4(), i); @@ -55,7 +68,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, [this](QString s) { s.remove(":"); s.remove("@"); - searchString = s.toLower(); + searchString_ = s.toLower(); invalidate(); }, Qt::QueuedConnection); @@ -64,7 +77,7 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, void CompletionProxyModel::invalidate() { - auto key = searchString.toUcs4(); + auto key = searchString_.toUcs4(); beginResetModel(); mapping = trie_.search(key, 7, maxMistakes_); endResetModel(); diff --git a/src/CompletionProxyModel.h b/src/CompletionProxyModel.h index 214845b7..5d3ae152 100644 --- a/src/CompletionProxyModel.h +++ b/src/CompletionProxyModel.h @@ -135,7 +135,8 @@ struct trie class CompletionProxyModel : public QAbstractProxyModel { Q_OBJECT - + Q_PROPERTY( + QString searchString READ searchString WRITE setSearchString NOTIFY newSearchString) public: CompletionProxyModel(QAbstractItemModel *model, int max_mistakes = 2, @@ -159,12 +160,13 @@ public slots: QVariant completionAt(int i) const; void setSearchString(QString s); + QString searchString() const { return searchString_; } signals: void newSearchString(QString); private: - QString searchString; + QString searchString_; trie trie_; std::vector mapping; int maxMistakes_; From 8ebb55623e2c70df8b26f8b5db8b004b3cea77f3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 14 Mar 2021 02:42:41 +0100 Subject: [PATCH 15/17] Remove background of quick switcher popup --- resources/qml/QuickSwitcher.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index ac896c56..1e5bb883 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -15,6 +15,7 @@ Popup { timer.start(); } + background: null width: Math.round(parent.width / 2) x: Math.round(parent.width / 2 - width / 2) y: Math.round(parent.height / 4 - height / 2) From 05c636a8d49ab245f39a0d5ddaf5604962bb283b Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 14 Mar 2021 02:45:20 +0100 Subject: [PATCH 16/17] Fix qml license headers again --- resources/qml/Avatar.qml | 1 + resources/qml/Completer.qml | 1 + resources/qml/EncryptionIndicator.qml | 1 + resources/qml/ImageButton.qml | 1 + resources/qml/MatrixText.qml | 1 + resources/qml/MatrixTextField.qml | 4 ++++ resources/qml/MessageInput.qml | 1 + resources/qml/MessageView.qml | 1 + resources/qml/NhekoBusyIndicator.qml | 1 + resources/qml/PrivacyScreen.qml | 1 + resources/qml/QuickSwitcher.qml | 4 ++++ resources/qml/Reactions.qml | 1 + resources/qml/ReplyPopup.qml | 1 + resources/qml/RoomSettings.qml | 1 + resources/qml/ScrollHelper.qml | 2 ++ resources/qml/StatusIndicator.qml | 1 + resources/qml/TimelineRow.qml | 1 + resources/qml/TimelineView.qml | 1 + resources/qml/ToggleButton.qml | 1 + resources/qml/TopBar.qml | 1 + resources/qml/TypingIndicator.qml | 1 + resources/qml/UserProfile.qml | 1 + resources/qml/delegates/FileMessage.qml | 1 + resources/qml/delegates/ImageMessage.qml | 1 + resources/qml/delegates/MessageDelegate.qml | 1 + resources/qml/delegates/NoticeMessage.qml | 1 + resources/qml/delegates/Pill.qml | 1 + resources/qml/delegates/Placeholder.qml | 1 + resources/qml/delegates/PlayableMediaMessage.qml | 1 + resources/qml/delegates/Reply.qml | 1 + resources/qml/delegates/TextMessage.qml | 1 + .../device-verification/AwaitingVerificationConfirmation.qml | 1 + resources/qml/device-verification/DeviceVerification.qml | 1 + resources/qml/device-verification/DigitVerification.qml | 1 + resources/qml/device-verification/EmojiElement.qml | 1 + resources/qml/device-verification/EmojiVerification.qml | 1 + resources/qml/device-verification/Failed.qml | 1 + resources/qml/device-verification/NewVerificationRequest.qml | 1 + resources/qml/device-verification/Success.qml | 1 + resources/qml/device-verification/Waiting.qml | 1 + resources/qml/emoji/EmojiButton.qml | 1 + resources/qml/emoji/EmojiPicker.qml | 1 + resources/qml/ui/Ripple.qml | 1 + resources/qml/voip/ActiveCallBar.qml | 1 + resources/qml/voip/CallDevices.qml | 1 + resources/qml/voip/CallInvite.qml | 1 + resources/qml/voip/CallInviteBar.qml | 1 + resources/qml/voip/DeviceError.qml | 1 + resources/qml/voip/PlaceCall.qml | 1 + resources/qml/voip/ScreenShare.qml | 1 + resources/qml/voip/VideoCall.qml | 1 + 51 files changed, 58 insertions(+) diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml index f53dfe3a..07e68e10 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./ui" diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 3b79a50d..176898ca 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./ui" diff --git a/resources/qml/EncryptionIndicator.qml b/resources/qml/EncryptionIndicator.qml index 5fcc0ada..58805f48 100644 --- a/resources/qml/EncryptionIndicator.qml +++ b/resources/qml/EncryptionIndicator.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml index f25705f0..76cc0b42 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./ui" diff --git a/resources/qml/MatrixText.qml b/resources/qml/MatrixText.qml index 073956f4..dfe7122d 100644 --- a/resources/qml/MatrixText.qml +++ b/resources/qml/MatrixText.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/MatrixTextField.qml b/resources/qml/MatrixTextField.qml index 9762817c..db2c907b 100644 --- a/resources/qml/MatrixTextField.qml +++ b/resources/qml/MatrixTextField.qml @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2021 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index 29657c85..faf0d442 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./voip" diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index baf6b800..1bc10b60 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates" diff --git a/resources/qml/NhekoBusyIndicator.qml b/resources/qml/NhekoBusyIndicator.qml index e45d71ec..917e11dc 100644 --- a/resources/qml/NhekoBusyIndicator.qml +++ b/resources/qml/NhekoBusyIndicator.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/PrivacyScreen.qml b/resources/qml/PrivacyScreen.qml index bd146dac..ca73cfd7 100644 --- a/resources/qml/PrivacyScreen.qml +++ b/resources/qml/PrivacyScreen.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtGraphicalEffects 1.0 diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 1e5bb883..8730f101 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2021 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + import QtQuick 2.9 import QtQuick.Controls 2.3 import im.nheko 1.0 diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index 335d5b29..f53c89ad 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.6 diff --git a/resources/qml/ReplyPopup.qml b/resources/qml/ReplyPopup.qml index eb70585e..37b6f6cc 100644 --- a/resources/qml/ReplyPopup.qml +++ b/resources/qml/ReplyPopup.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates/" diff --git a/resources/qml/RoomSettings.qml b/resources/qml/RoomSettings.qml index ed1a5bd9..2117e513 100644 --- a/resources/qml/RoomSettings.qml +++ b/resources/qml/RoomSettings.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import Qt.labs.platform 1.1 as Platform diff --git a/resources/qml/ScrollHelper.qml b/resources/qml/ScrollHelper.qml index 2d315a6d..2dd56f27 100644 --- a/resources/qml/ScrollHelper.qml +++ b/resources/qml/ScrollHelper.qml @@ -1,7 +1,9 @@ // Copyright (C) 2016 Michael Bohlender, // Copyright (C) 2017 Christian Mollekopf, // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later + /* * Shamelessly stolen from: * https://cgit.kde.org/kube.git/tree/framework/qml/ScrollHelper.qml diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index f2b6c12d..3d2d8278 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 8e479d58..0f815f6f 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates" diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 49221014..8b98e113 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./delegates" diff --git a/resources/qml/ToggleButton.qml b/resources/qml/ToggleButton.qml index 3791a5b4..bd82e4f9 100644 --- a/resources/qml/ToggleButton.qml +++ b/resources/qml/ToggleButton.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index e158a8ba..444a4572 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/TypingIndicator.qml b/resources/qml/TypingIndicator.qml index 2e36e8ad..ffe88fb6 100644 --- a/resources/qml/TypingIndicator.qml +++ b/resources/qml/TypingIndicator.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml index 05d2a391..dbf13796 100644 --- a/resources/qml/UserProfile.qml +++ b/resources/qml/UserProfile.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "./device-verification" diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index e73d6a50..293b7a78 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 829d29ed..0521258e 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index dcf6eb3b..211e03a6 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.6 diff --git a/resources/qml/delegates/NoticeMessage.qml b/resources/qml/delegates/NoticeMessage.qml index 6c604c5e..4f8fbfd2 100644 --- a/resources/qml/delegates/NoticeMessage.qml +++ b/resources/qml/delegates/NoticeMessage.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later TextMessage { diff --git a/resources/qml/delegates/Pill.qml b/resources/qml/delegates/Pill.qml index 8efa491c..a3fa0d9e 100644 --- a/resources/qml/delegates/Pill.qml +++ b/resources/qml/delegates/Pill.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.5 diff --git a/resources/qml/delegates/Placeholder.qml b/resources/qml/delegates/Placeholder.qml index 50486439..addbc7e7 100644 --- a/resources/qml/delegates/Placeholder.qml +++ b/resources/qml/delegates/Placeholder.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import ".." diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 7d00de21..f871e492 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtMultimedia 5.6 diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml index 728e9739..6763b71b 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.12 diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml index ec0866ad..1624d95c 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import ".." diff --git a/resources/qml/device-verification/AwaitingVerificationConfirmation.qml b/resources/qml/device-verification/AwaitingVerificationConfirmation.qml index 8d57c8d6..ae62c334 100644 --- a/resources/qml/device-verification/AwaitingVerificationConfirmation.qml +++ b/resources/qml/device-verification/AwaitingVerificationConfirmation.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/DeviceVerification.qml b/resources/qml/device-verification/DeviceVerification.qml index cb3cd8ab..fee0284a 100644 --- a/resources/qml/device-verification/DeviceVerification.qml +++ b/resources/qml/device-verification/DeviceVerification.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.10 diff --git a/resources/qml/device-verification/DigitVerification.qml b/resources/qml/device-verification/DigitVerification.qml index cf5f75ed..a387756d 100644 --- a/resources/qml/device-verification/DigitVerification.qml +++ b/resources/qml/device-verification/DigitVerification.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/EmojiElement.qml b/resources/qml/device-verification/EmojiElement.qml index 1b1ecbcf..f5c87a56 100644 --- a/resources/qml/device-verification/EmojiElement.qml +++ b/resources/qml/device-verification/EmojiElement.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/EmojiVerification.qml b/resources/qml/device-verification/EmojiVerification.qml index e179b0ed..be9e3938 100644 --- a/resources/qml/device-verification/EmojiVerification.qml +++ b/resources/qml/device-verification/EmojiVerification.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/Failed.qml b/resources/qml/device-verification/Failed.qml index bc7dd5fc..5c71b02e 100644 --- a/resources/qml/device-verification/Failed.qml +++ b/resources/qml/device-verification/Failed.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/NewVerificationRequest.qml b/resources/qml/device-verification/NewVerificationRequest.qml index 7af19b42..e8589cf7 100644 --- a/resources/qml/device-verification/NewVerificationRequest.qml +++ b/resources/qml/device-verification/NewVerificationRequest.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/Success.qml b/resources/qml/device-verification/Success.qml index a454d56e..f2657b12 100644 --- a/resources/qml/device-verification/Success.qml +++ b/resources/qml/device-verification/Success.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/device-verification/Waiting.qml b/resources/qml/device-verification/Waiting.qml index c8dc2a77..3bfa153d 100644 --- a/resources/qml/device-verification/Waiting.qml +++ b/resources/qml/device-verification/Waiting.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.3 diff --git a/resources/qml/emoji/EmojiButton.qml b/resources/qml/emoji/EmojiButton.qml index 71f8bc01..cec51d75 100644 --- a/resources/qml/emoji/EmojiButton.qml +++ b/resources/qml/emoji/EmojiButton.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/emoji/EmojiPicker.qml b/resources/qml/emoji/EmojiPicker.qml index ed8fdec4..2db9dc07 100644 --- a/resources/qml/emoji/EmojiPicker.qml +++ b/resources/qml/emoji/EmojiPicker.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/ui/Ripple.qml b/resources/qml/ui/Ripple.qml index 7a8688f5..b240f421 100644 --- a/resources/qml/ui/Ripple.qml +++ b/resources/qml/ui/Ripple.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtGraphicalEffects 1.0 diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index c8bd6037..68d3bc4a 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/CallDevices.qml b/resources/qml/voip/CallDevices.qml index 02340b4b..11644797 100644 --- a/resources/qml/voip/CallDevices.qml +++ b/resources/qml/voip/CallDevices.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/voip/CallInvite.qml b/resources/qml/voip/CallInvite.qml index ed706f12..15d987e7 100644 --- a/resources/qml/voip/CallInvite.qml +++ b/resources/qml/voip/CallInvite.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index c8474264..fe3f791f 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/DeviceError.qml b/resources/qml/voip/DeviceError.qml index a1ec7f12..05cfd409 100644 --- a/resources/qml/voip/DeviceError.qml +++ b/resources/qml/voip/DeviceError.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index f340bb4e..c9aa8ea1 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/ScreenShare.qml b/resources/qml/voip/ScreenShare.qml index 908500ee..af473c04 100644 --- a/resources/qml/voip/ScreenShare.qml +++ b/resources/qml/voip/ScreenShare.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import "../" diff --git a/resources/qml/voip/VideoCall.qml b/resources/qml/voip/VideoCall.qml index 8dd5fb90..23651033 100644 --- a/resources/qml/voip/VideoCall.qml +++ b/resources/qml/voip/VideoCall.qml @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: 2021 Nheko Contributors +// // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick 2.9 From eb9603f4c0a6d43c6e107a42e229991c10234091 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 14 Mar 2021 02:50:44 +0100 Subject: [PATCH 17/17] Fix room completions not showing label avatars When no image is set for a room, the room didn't have the first character in the avatar, when opening any completer, that showed it. --- resources/qml/Completer.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 176898ca..d648553f 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -198,6 +198,7 @@ Popup { Avatar { height: popup.avatarHeight width: popup.avatarWidth + displayName: model.roomName url: model.avatarUrl.replace("mxc://", "image://MxcImage/") onClicked: { popup.completionClicked(completer.completionAt(model.index)); @@ -227,6 +228,7 @@ Popup { Avatar { height: popup.avatarHeight width: popup.avatarWidth + displayName: model.roomName url: model.avatarUrl.replace("mxc://", "image://MxcImage/") onClicked: popup.completionClicked(completer.completionAt(model.index)) }