Port DevicesPage to FormCard

This commit is contained in:
Tobias Fella
2023-09-01 16:56:43 +02:00
parent d9dc5f48bc
commit ddd690f6d5
3 changed files with 57 additions and 70 deletions

View File

@@ -7,11 +7,11 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.19 as Kirigami 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 import org.kde.neochat 1.0
MobileForm.AbstractFormDelegate { FormCard.AbstractFormDelegate {
id: deviceDelegate id: deviceDelegate
required property string id required property string id
@@ -21,8 +21,6 @@ MobileForm.AbstractFormDelegate {
property bool editDeviceName: false property bool editDeviceName: false
property bool showVerifyButton property bool showVerifyButton
Layout.fillWidth: true
onClicked: deviceDelegate.editDeviceName = true onClicked: deviceDelegate.editDeviceName = true
contentItem: RowLayout { contentItem: RowLayout {

View File

@@ -6,7 +6,7 @@ import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.19 as Kirigami 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 import org.kde.neochat 1.0
@@ -18,38 +18,32 @@ ColumnLayout {
required property bool showVerifyButton required property bool showVerifyButton
visible: deviceRepeater.count > 0 visible: deviceRepeater.count > 0
MobileForm.FormHeader {
FormCard.FormHeader {
title: root.title title: root.title
Layout.fillWidth: true
} }
MobileForm.FormCard { FormCard.FormCard {
id: devicesCard 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 { delegate: DeviceDelegate {
spacing: 0 showVerifyButton: root.showVerifyButton
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
}
} }
} }
} }
} }

View File

@@ -7,64 +7,59 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.19 as Kirigami 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 import org.kde.neochat 1.0
Kirigami.ScrollablePage { FormCard.FormCardPage {
id: root id: root
title: i18n("Devices") title: i18n("Devices")
required property NeoChatConnection connection required property NeoChatConnection connection
leftPadding: 0 property DevicesModel devicesModel: DevicesModel {
rightPadding: 0
DevicesModel {
id: devicesModel id: devicesModel
connection: root.connection connection: root.connection
} }
ColumnLayout { DevicesCard {
DevicesCard { title: i18n("This Device")
title: i18n("This Device") type: DevicesModel.This
type: DevicesModel.This showVerifyButton: false
showVerifyButton: false }
} DevicesCard {
DevicesCard { title: i18n("Verified Devices")
title: i18n("Verified Devices") type: DevicesModel.Verified
type: DevicesModel.Verified showVerifyButton: true
showVerifyButton: true }
} DevicesCard {
DevicesCard { title: i18n("Unverified Devices")
title: i18n("Unverified Devices") type: DevicesModel.Unverified
type: DevicesModel.Unverified showVerifyButton: true
showVerifyButton: true }
} DevicesCard {
DevicesCard { title: i18n("Devices without Encryption Support")
title: i18n("Devices without Encryption Support") type: DevicesModel.Unencrypted
type: DevicesModel.Unencrypted showVerifyButton: false
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
}
} }
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 id: passwordSheet
property string deviceId property string deviceId