summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-03-13 23:45:05 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-13 23:45:05 +0100
commit7a356f3832c2c401d963cd8a654f62ab56a9288b (patch)
treed34e679a6a9f99e579124c55f5b74674c8c7a655 /resources
parentDisable bundled OpenSSL by default, even with hunter (diff)
parentchange allowed mistakes, fix minor style issues, remove old completer functio... (diff)
downloadnheko-7a356f3832c2c401d963cd8a654f62ab56a9288b.tar.xz
Merge branch 'quickswitcher_qml' of git://github.com/Jedi18/nheko into Jedi18-quickswitcher_qml
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/Completer.qml78
-rw-r--r--resources/qml/MatrixTextField.qml56
-rw-r--r--resources/qml/MessageInput.qml2
-rw-r--r--resources/qml/QuickSwitcher.qml97
-rw-r--r--resources/qml/TimelineView.qml16
-rw-r--r--resources/res.qrc2
6 files changed, 240 insertions, 11 deletions
diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml

index e1b5c129..6170045c 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml
@@ -15,9 +15,16 @@ Popup { property string completerName property var completer property bool bottomToTop: true + property bool fullWidth: false + 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) + signal completionSelected(string id) function up() { if (bottomToTop) @@ -54,9 +61,19 @@ Popup { return null; } + function finishCompletion() { + if(popup.completerName == "room") { + popup.completionSelected(listView.itemAtIndex(currentIndex).modelData.roomid) + } + } + 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; @@ -75,14 +92,17 @@ 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 + spacing: rowSpacing + pixelAligned: true delegate: Rectangle { color: model.index == popup.currentIndex ? colors.highlight : colors.base - height: chooser.childrenRect.height + 4 - implicitWidth: chooser.childrenRect.width + 4 + height: chooser.childrenRect.height + 2 * popup.rowMargin + implicitWidth: fullWidth ? popup.width : chooser.childrenRect.width + 4 + property variant modelData: model MouseArea { id: mouseArea @@ -90,7 +110,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 @@ -103,7 +128,8 @@ Popup { id: chooser roleValue: popup.completerName - anchors.centerIn: parent + anchors.fill: parent + anchors.margins: popup.rowMargin DelegateChoice { roleValue: "user" @@ -112,10 +138,11 @@ Popup { id: del anchors.centerIn: parent + spacing: rowSpacing 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)) @@ -142,6 +169,7 @@ Popup { id: del anchors.centerIn: parent + spacing: rowSpacing Label { text: model.unicode @@ -164,11 +192,41 @@ Popup { RowLayout { id: del + anchors.centerIn: centerRowContent ? parent : undefined + spacing: rowSpacing + + Avatar { + height: popup.avatarHeight + width: popup.avatarWidth + url: model.avatarUrl.replace("mxc://", "image://MxcImage/") + onClicked: { + popup.completionClicked(completer.completionAt(model.index)) + popup.completionSelected(model.roomid) + } + } + + Label { + text: model.roomName + font.pixelSize: popup.avatarHeight * 0.5 + color: model.index == popup.currentIndex ? colors.highlightedText : colors.text + } + + } + + } + + DelegateChoice { + roleValue: "roomAliases" + + RowLayout { + id: del + anchors.centerIn: parent + spacing: rowSpacing 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..9e8d286b --- /dev/null +++ b/resources/qml/MatrixTextField.qml
@@ -0,0 +1,56 @@ +import QtQuick 2.13 +import QtQuick.Layouts 1.13 +import QtQuick.Controls 2.13 + +TextField { + id: input + palette: colors + + background: Rectangle { + color: colors.base + } + + 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 + width: 0 + color: colors.text + + 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/MessageInput.qml b/resources/qml/MessageInput.qml
index 7b651bc0..faf0d442 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml
@@ -161,7 +161,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 new file mode 100644
index 00000000..29d9a9b2 --- /dev/null +++ b/resources/qml/QuickSwitcher.qml
@@ -0,0 +1,97 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import im.nheko 1.0 + +Popup { + id: quickSwitcher + + property int textHeight: 32 + property int textMargin: 8 + + x: parent.width / 2 - width / 2 + y: parent.height / 4 - height / 2 + width: parent.width / 2 + modal: true + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + parent: Overlay.overlay + palette: colors + + Overlay.modal: Rectangle { + color: "#aa1E1E1E" + } + + MatrixTextField { + id: roomTextInput + + anchors.fill: parent + font.pixelSize: quickSwitcher.textHeight * 0.6 + padding: textMargin + color: colors.text + + 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(); + } else if (event.matches(StandardKey.InsertParagraphSeparator)) { + completerPopup.finishCompletion() + event.accepted = true; + } + } + } + + Completer { + id: completerPopup + + x: roomTextInput.x + y: roomTextInput.y + roomTextInput.height + textMargin + width: parent.width + completerName: "room" + bottomToTop: false + fullWidth: true + avatarHeight: textHeight + avatarWidth: textHeight + centerRowContent: false + rowMargin: 8 + rowSpacing: 6 + + closePolicy: Popup.NoAutoClose + } + + onOpened: { + completerPopup.open() + delay(200, function() { + roomTextInput.forceActiveFocus() + }) + } + + onClosed: { + completerPopup.close() + } + + Connections { + onCompletionSelected: { + TimelineManager.setHistoryView(id) + TimelineManager.highlightRoom(id) + quickSwitcher.close() + } + 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/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 0a823329..20251bc0 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml
@@ -72,6 +72,22 @@ Page { } + Component { + id: quickSwitcherComponent + + QuickSwitcher { + } + } + + Shortcut { + sequence: "Ctrl+K" + onActivated: { + var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); + TimelineManager.focusTimeline() + quickSwitch.open(); + } + } + Menu { id: messageContextMenu diff --git a/resources/res.qrc b/resources/res.qrc
index e629a871..328f65ca 100644 --- a/resources/res.qrc +++ b/resources/res.qrc
@@ -129,6 +129,7 @@ <file>qml/EncryptionIndicator.qml</file> <file>qml/ImageButton.qml</file> <file>qml/MatrixText.qml</file> + <file>qml/MatrixTextField.qml</file> <file>qml/ToggleButton.qml</file> <file>qml/MessageInput.qml</file> <file>qml/MessageView.qml</file> @@ -140,6 +141,7 @@ <file>qml/StatusIndicator.qml</file> <file>qml/TimelineRow.qml</file> <file>qml/TopBar.qml</file> + <file>qml/QuickSwitcher.qml</file> <file>qml/TypingIndicator.qml</file> <file>qml/RoomSettings.qml</file> <file>qml/emoji/EmojiButton.qml</file>