diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-02-21 04:06:49 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-02-21 04:07:13 +0100 |
commit | 609cd82dc047c600f04569a12431d0a3273fc056 (patch) | |
tree | c45ffc4915c0b747a60fa649dedfbfadf31ef83f /resources/qml/QuickSwitcher.qml | |
parent | Add sender names to state events (#948) (diff) | |
download | nheko-609cd82dc047c600f04569a12431d0a3273fc056.tar.xz |
Fix forward completer
Diffstat (limited to '')
-rw-r--r-- | resources/qml/QuickSwitcher.qml | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index 3b8ceb15..103f7584 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -3,8 +3,9 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.9 -import QtQuick.Controls 2.3 +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 import im.nheko 1.0 Popup { @@ -14,62 +15,60 @@ Popup { background: null width: Math.min(Math.max(Math.round(parent.width / 2),450),parent.width) // limiting width to parent.width/2 can be a bit narrow - x: Math.round(parent.width / 2 - width / 2) - y: Math.round(parent.height / 4 - height / 2) + x: Math.round(parent.width / 2 - contentWidth / 2) + y: Math.round(parent.height / 4) modal: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside parent: Overlay.overlay palette: Nheko.colors onOpened: { - completerPopup.open(); roomTextInput.forceActiveFocus(); } - onClosed: { - completerPopup.close(); - } - - MatrixTextField { - id: roomTextInput + Column{ anchors.fill: parent - font.pixelSize: Math.ceil(quickSwitcher.textHeight * 0.6) - color: Nheko.colors.text - onTextEdited: { - completerPopup.completer.searchString = text; - } - Keys.onPressed: { - if ((event.key == Qt.Key_Up || event.key == Qt.Key_Backtab) && completerPopup.opened) { - event.accepted = true; - completerPopup.up(); - } else if ((event.key == Qt.Key_Down || event.key == Qt.Key_Tab) && completerPopup.opened) { - event.accepted = true; - if (event.key == Qt.Key_Tab && (event.modifiers & Qt.ShiftModifier)) + spacing: 1 + + MatrixTextField { + id: roomTextInput + + width: parent.width + font.pixelSize: Math.ceil(quickSwitcher.textHeight * 0.6) + color: Nheko.colors.text + onTextEdited: { + completerPopup.completer.searchString = text; + } + Keys.onPressed: { + if (event.key == Qt.Key_Up || event.key == Qt.Key_Backtab) { + event.accepted = true; + completerPopup.up(); + } else if (event.key == Qt.Key_Down || event.key == Qt.Key_Tab) { + event.accepted = true; + if (event.key == Qt.Key_Tab && (event.modifiers & Qt.ShiftModifier)) completerPopup.up(); - else + else completerPopup.down(); - } else if (event.matches(StandardKey.InsertParagraphSeparator)) { - completerPopup.finishCompletion(); - event.accepted = true; + } else if (event.matches(StandardKey.InsertParagraphSeparator)) { + completerPopup.finishCompletion(); + event.accepted = true; + } } } - } - Completer { - id: completerPopup + Completer { + id: completerPopup - x: roomTextInput.x - y: roomTextInput.y + quickSwitcher.textHeight - visible: roomTextInput.length > 0 - width: parent.width - completerName: "room" - bottomToTop: false - fullWidth: true - avatarHeight: quickSwitcher.textHeight - avatarWidth: quickSwitcher.textHeight - centerRowContent: false - rowMargin: Math.round(quickSwitcher.textMargin / 2) - rowSpacing: quickSwitcher.textMargin - closePolicy: Popup.NoAutoClose + visible: roomTextInput.text.length > 0 + width: parent.width + completerName: "room" + bottomToTop: false + fullWidth: true + avatarHeight: quickSwitcher.textHeight + avatarWidth: quickSwitcher.textHeight + centerRowContent: false + rowMargin: Math.round(quickSwitcher.textMargin / 2) + rowSpacing: quickSwitcher.textMargin + } } Connections { @@ -80,7 +79,7 @@ Popup { function onCountChanged() { if (completerPopup.count > 0 && (completerPopup.currentIndex < 0 || completerPopup.currentIndex >= completerPopup.count)) - completerPopup.currentIndex = 0; + completerPopup.currentIndex = 0; } |