From ddd690f6d5d5bddee9f4f7f50deb013eea9af946 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 1 Sep 2023 16:56:43 +0200 Subject: [PATCH] Port DevicesPage to FormCard --- src/qml/Settings/DeviceDelegate.qml | 6 +-- src/qml/Settings/DevicesCard.qml | 40 ++++++-------- src/qml/Settings/DevicesPage.qml | 81 ++++++++++++++--------------- 3 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/qml/Settings/DeviceDelegate.qml b/src/qml/Settings/DeviceDelegate.qml index 419d63f0f..8aab4672e 100644 --- a/src/qml/Settings/DeviceDelegate.qml +++ b/src/qml/Settings/DeviceDelegate.qml @@ -7,11 +7,11 @@ import QtQuick.Controls 2.15 as QQC2 import QtQuick.Layouts 1.15 import org.kde.kirigami 2.19 as Kirigami -import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm +import org.kde.kirigamiaddons.formcard 1.0 as FormCard import org.kde.neochat 1.0 -MobileForm.AbstractFormDelegate { +FormCard.AbstractFormDelegate { id: deviceDelegate required property string id @@ -21,8 +21,6 @@ MobileForm.AbstractFormDelegate { property bool editDeviceName: false property bool showVerifyButton - Layout.fillWidth: true - onClicked: deviceDelegate.editDeviceName = true contentItem: RowLayout { diff --git a/src/qml/Settings/DevicesCard.qml b/src/qml/Settings/DevicesCard.qml index aacba1f53..68cf5efd9 100644 --- a/src/qml/Settings/DevicesCard.qml +++ b/src/qml/Settings/DevicesCard.qml @@ -6,7 +6,7 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 import org.kde.kirigami 2.19 as Kirigami -import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm +import org.kde.kirigamiaddons.formcard 1.0 as FormCard import org.kde.neochat 1.0 @@ -18,38 +18,32 @@ ColumnLayout { required property bool showVerifyButton visible: deviceRepeater.count > 0 - MobileForm.FormHeader { + + FormCard.FormHeader { title: root.title - Layout.fillWidth: true } - MobileForm.FormCard { + FormCard.FormCard { id: devicesCard - Layout.fillWidth: true + Repeater { + id: deviceRepeater + model: DevicesProxyModel { + sourceModel: devicesModel + type: root.type + } + Kirigami.LoadingPlaceholder { + visible: deviceModel.count === 0 // We can assume 0 means loading since there is at least one device + anchors.centerIn: parent + } - contentItem: ColumnLayout { - spacing: 0 - - Repeater { - id: deviceRepeater - model: DevicesProxyModel { - sourceModel: devicesModel - type: root.type - } - - Kirigami.LoadingPlaceholder { - visible: deviceModel.count === 0 // We can assume 0 means loading since there is at least one device - anchors.centerIn: parent - } - - delegate: DeviceDelegate { - showVerifyButton: root.showVerifyButton - } + delegate: DeviceDelegate { + showVerifyButton: root.showVerifyButton } } } } + diff --git a/src/qml/Settings/DevicesPage.qml b/src/qml/Settings/DevicesPage.qml index d9ad558ac..e1a24cfb9 100644 --- a/src/qml/Settings/DevicesPage.qml +++ b/src/qml/Settings/DevicesPage.qml @@ -7,64 +7,59 @@ import QtQuick.Controls 2.15 as QQC2 import QtQuick.Layouts 1.15 import org.kde.kirigami 2.19 as Kirigami -import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm +import org.kde.kirigamiaddons.formcard 1.0 as FormCard import org.kde.neochat 1.0 -Kirigami.ScrollablePage { +FormCard.FormCardPage { id: root title: i18n("Devices") required property NeoChatConnection connection - leftPadding: 0 - rightPadding: 0 - - DevicesModel { + property DevicesModel devicesModel: DevicesModel { id: devicesModel connection: root.connection } - ColumnLayout { - DevicesCard { - title: i18n("This Device") - type: DevicesModel.This - showVerifyButton: false - } - DevicesCard { - title: i18n("Verified Devices") - type: DevicesModel.Verified - showVerifyButton: true - } - DevicesCard { - title: i18n("Unverified Devices") - type: DevicesModel.Unverified - showVerifyButton: true - } - DevicesCard { - title: i18n("Devices without Encryption Support") - type: DevicesModel.Unencrypted - showVerifyButton: false - } - - MobileForm.AbstractFormDelegate { - Layout.fillWidth: true - visible: Controller.activeConnection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device - contentItem: Kirigami.LoadingPlaceholder { } - } - - Kirigami.InlineMessage { - Layout.fillWidth: true - Layout.maximumWidth: Kirigami.Units.gridUnit * 30 - Layout.alignment: Qt.AlignHCenter - text: i18n("Please login to view the signed-in devices for your account.") - type: Kirigami.MessageType.Information - visible: !Controller.activeConnection - } + DevicesCard { + title: i18n("This Device") + type: DevicesModel.This + showVerifyButton: false + } + DevicesCard { + title: i18n("Verified Devices") + type: DevicesModel.Verified + showVerifyButton: true + } + DevicesCard { + title: i18n("Unverified Devices") + type: DevicesModel.Unverified + showVerifyButton: true + } + DevicesCard { + title: i18n("Devices without Encryption Support") + type: DevicesModel.Unencrypted + showVerifyButton: false } - Kirigami.OverlaySheet { + FormCard.AbstractFormDelegate { + Layout.fillWidth: true + visible: Controller.activeConnection && devicesModel.count === 0 // We can assume 0 means loading since there is at least one device + contentItem: Kirigami.LoadingPlaceholder { } + } + + Kirigami.InlineMessage { + Layout.fillWidth: true + Layout.maximumWidth: Kirigami.Units.gridUnit * 30 + Layout.alignment: Qt.AlignHCenter + text: i18n("Please login to view the signed-in devices for your account.") + type: Kirigami.MessageType.Information + visible: !Controller.activeConnection + } + + property Kirigami.OverlaySheet passwordSheet: Kirigami.OverlaySheet { id: passwordSheet property string deviceId