diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2023-02-23 21:57:53 -0500 |
---|---|---|
committer | Loren Burkholder <computersemiexpert@outlook.com> | 2023-02-28 20:10:25 -0500 |
commit | b6ef00b5ee14bd0adc85c3a98bb8a127f79932ea (patch) | |
tree | df09acee8f648cea85aa75bfcd43b6f247e8cc81 /resources/qml | |
parent | Enhance appearance of room ping warning (diff) | |
download | nheko-b6ef00b5ee14bd0adc85c3a98bb8a127f79932ea.tar.xz |
Show warning when invalid command is entered
Fixes #1363 Please note that this doesn't prompt when you try to send a message with a bad command.
Diffstat (limited to 'resources/qml')
-rw-r--r-- | resources/qml/MessageInput.qml | 2 | ||||
-rw-r--r-- | resources/qml/MessageInputWarning.qml (renamed from resources/qml/NotificationWarning.qml) | 12 | ||||
-rw-r--r-- | resources/qml/TimelineView.qml | 19 |
3 files changed, 29 insertions, 4 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index f31123e5..f6fe03c5 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -13,6 +13,8 @@ import im.nheko 1.0 Rectangle { id: inputBar + readonly property string text: messageInput.text + color: Nheko.colors.window Layout.fillWidth: true Layout.preferredHeight: row.implicitHeight diff --git a/resources/qml/NotificationWarning.qml b/resources/qml/MessageInputWarning.qml index 13d2cb23..c2db2daa 100644 --- a/resources/qml/NotificationWarning.qml +++ b/resources/qml/MessageInputWarning.qml @@ -8,14 +8,20 @@ import QtQuick.Layouts 1.2 import im.nheko 1.0 Item { - implicitHeight: warningRect.visible ? warningDisplay.implicitHeight + 2 * Nheko.paddingSmall : 0 + id: warningRoot + + required property string text + required property bool isVisible + + implicitHeight: isVisible ? warningDisplay.implicitHeight + 2 * Nheko.paddingSmall : 0 height: implicitHeight Layout.fillWidth: true + Layout.margins: isVisible ? Nheko.paddingSmall : 0 Rectangle { id: warningRect - visible: (room && room.permissions.canPingRoom() && room.input.containsAtRoom) + visible: warningRoot.isVisible // TODO: Qt.alpha() would make more sense but it wasn't working... color: Qt.rgba(Nheko.theme.error.r, Nheko.theme.error.g, Nheko.theme.error.b, 0.3) border.width: 1 @@ -31,7 +37,7 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.margins: Nheko.paddingSmall color: Nheko.colors.text - text: qsTr("You are about to notify the whole room") + text: warningRoot.text textFormat: Text.PlainText } diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index e836f60f..5c982270 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -153,13 +153,30 @@ Item { UploadBox { } - NotificationWarning { + MessageInputWarning { + text: qsTr("You are about to notify the whole room") + isVisible: (room && room.permissions.canPingRoom() && room.input.containsAtRoom) + } + + MessageInputWarning { + text: qsTr("The command /%1 is not recognized and will be sent as part of your message").arg(Nheko.getCommandFromText(input.text)) + isVisible: { + if (!input.text) + return false; + + let command = Nheko.getCommandFromText(input.text); + if (Nheko.isInvalidCommand(command) && ("/" + command !== input.text)) + return true; + else + return false; + } } ReplyPopup { } MessageInput { + id: input } } |