From f8d3e25f8ef280a731fb3c605115a4095627ae5c Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Sat, 22 Jul 2023 23:25:47 +0200 Subject: [PATCH] Move no connection info message to the top --- src/qml/Component/ChatBox/ChatBox.qml | 9 --------- src/qml/Page/RoomPage.qml | 27 +++++++++++++++++++++------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/qml/Component/ChatBox/ChatBox.qml b/src/qml/Component/ChatBox/ChatBox.qml index c2dc65ef4..d4c9a746e 100644 --- a/src/qml/Component/ChatBox/ChatBox.qml +++ b/src/qml/Component/ChatBox/ChatBox.qml @@ -56,15 +56,6 @@ ColumnLayout { Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.inherit: false - Kirigami.InlineMessage { - Layout.fillWidth: true - Layout.leftMargin: 1 // So we can see the border - Layout.rightMargin: 1 // So we can see the border - - text: i18n("NeoChat is offline. Please check your network connection.") - visible: !Controller.isOnline - } - Kirigami.Separator { Layout.fillWidth: true } diff --git a/src/qml/Page/RoomPage.qml b/src/qml/Page/RoomPage.qml index d9bba1f7f..45f5fa1fa 100644 --- a/src/qml/Page/RoomPage.qml +++ b/src/qml/Page/RoomPage.qml @@ -43,7 +43,22 @@ Kirigami.Page { } } + Connections { + target: Controller + function onIsOnlineChanged() { + if (true || !Controller.isOnline) { + banner.text = i18n("NeoChat is offline. Please check your network connection."); + banner.visible = true; + banner.type = Kirigami.MessageType.Error; + } else { + banner.visible = false; + } + } + } + header: KirigamiComponents.Banner { + id: banner + showCloseButton: true visible: false } @@ -162,16 +177,16 @@ Kirigami.Page { Connections { target: currentRoom function onShowMessage(messageType, message) { - root.header.text = message; - root.headertype = messageType === ActionsHandler.Error ? Kirigami.MessageType.Error : messageType === ActionsHandler.Positive ? Kirigami.MessageType.Positive : Kirigami.MessageType.Information; - root.header.visible = true; + banner.text = message; + banner.type = messageType === ActionsHandler.Error ? Kirigami.MessageType.Error : messageType === ActionsHandler.Positive ? Kirigami.MessageType.Positive : Kirigami.MessageType.Information; + banner.visible = true; } } function warning(title, message) { - root.header.text = `${title}
${message}`; - root.header.type = Kirigami.MessageType.Warning; - root.header.visible = true; + banner.text = `${title}
${message}`; + banner.type = Kirigami.MessageType.Warning; + banner.visible = true; } function showUserDetail(user) {