Port accounts page to formcard
This commit is contained in:
@@ -8,113 +8,102 @@ import QtQuick.Window 2.15
|
|||||||
import Qt.labs.platform 1.1
|
import Qt.labs.platform 1.1
|
||||||
|
|
||||||
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.kirigamiaddons.labs.components 1.0 as KirigamiComponents
|
import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
|
||||||
|
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
import 'Dialog' as Dialog
|
import 'Dialog' as Dialog
|
||||||
|
|
||||||
Kirigami.ScrollablePage {
|
FormCard.FormCardPage {
|
||||||
id: page
|
id: root
|
||||||
|
|
||||||
title: i18n("Accounts")
|
title: i18n("Accounts")
|
||||||
topPadding: 0
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
|
|
||||||
ColumnLayout {
|
FormCard.FormHeader {
|
||||||
spacing: 0
|
title: i18n("Accounts")
|
||||||
MobileForm.FormHeader {
|
}
|
||||||
Layout.fillWidth: true
|
FormCard.FormCard {
|
||||||
title: i18n("Accounts")
|
Repeater {
|
||||||
}
|
model: AccountRegistry
|
||||||
MobileForm.FormCard {
|
delegate: FormCard.AbstractFormDelegate {
|
||||||
Layout.fillWidth: true
|
id: accountDelegate
|
||||||
contentItem: ColumnLayout {
|
required property NeoChatConnection connection
|
||||||
spacing: 0
|
Layout.fillWidth: true
|
||||||
Repeater {
|
onClicked: pageStack.layers.push("qrc:/AccountEditorPage.qml", {
|
||||||
model: AccountRegistry
|
connection: accountDelegate.connection
|
||||||
delegate: MobileForm.AbstractFormDelegate {
|
}, {
|
||||||
id: accountDelegate
|
title: i18n("Account editor")
|
||||||
required property NeoChatConnection connection
|
})
|
||||||
|
|
||||||
|
contentItem: RowLayout {
|
||||||
|
KirigamiComponents.Avatar {
|
||||||
|
name: accountDelegate.connection.localUser.displayName
|
||||||
|
source: accountDelegate.connection.localUser.avatarMediaId ? ("image://mxc/" + accountDelegate.connection.localUser.avatarMediaId) : ""
|
||||||
|
|
||||||
|
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.medium
|
||||||
|
implicitHeight: Kirigami.Units.iconSizes.medium
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
onClicked: pageStack.layers.push("qrc:/AccountEditorPage.qml", {
|
spacing: Kirigami.Units.smallSpacing
|
||||||
connection: accountDelegate.connection
|
|
||||||
}, {
|
|
||||||
title: i18n("Account editor")
|
|
||||||
})
|
|
||||||
|
|
||||||
contentItem: RowLayout {
|
QQC2.Label {
|
||||||
KirigamiComponents.Avatar {
|
Layout.fillWidth: true
|
||||||
name: accountDelegate.connection.localUser.displayName
|
text: accountDelegate.connection.localUser.displayName
|
||||||
source: accountDelegate.connection.localUser.avatarMediaId ? ("image://mxc/" + accountDelegate.connection.localUser.avatarMediaId) : ""
|
textFormat: Text.PlainText
|
||||||
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
maximumLineCount: 2
|
||||||
|
color: Kirigami.Theme.textColor
|
||||||
|
}
|
||||||
|
|
||||||
Layout.rightMargin: Kirigami.Units.largeSpacing
|
QQC2.Label {
|
||||||
implicitWidth: Kirigami.Units.iconSizes.medium
|
Layout.fillWidth: true
|
||||||
implicitHeight: Kirigami.Units.iconSizes.medium
|
text: accountDelegate.connection.localUserId
|
||||||
}
|
color: Kirigami.Theme.disabledTextColor
|
||||||
|
font: Kirigami.Theme.smallFont
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
QQC2.ToolButton {
|
||||||
Layout.fillWidth: true
|
text: i18n("Logout")
|
||||||
spacing: Kirigami.Units.smallSpacing
|
icon.name: "im-kick-user"
|
||||||
|
onClicked: confirmLogoutDialogComponent.createObject(applicationWindow().overlay).open()
|
||||||
|
}
|
||||||
|
|
||||||
QQC2.Label {
|
Component {
|
||||||
Layout.fillWidth: true
|
id: confirmLogoutDialogComponent
|
||||||
text: accountDelegate.connection.localUser.displayName
|
Dialog.ConfirmLogout {
|
||||||
textFormat: Text.PlainText
|
connection: model.connection
|
||||||
elide: Text.ElideRight
|
onAccepted: {
|
||||||
wrapMode: Text.Wrap
|
if (Controller.accountCount === 1) {
|
||||||
maximumLineCount: 2
|
root.Window.window.close()
|
||||||
color: Kirigami.Theme.textColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: accountDelegate.connection.localUserId
|
|
||||||
color: Kirigami.Theme.disabledTextColor
|
|
||||||
font: Kirigami.Theme.smallFont
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QQC2.ToolButton {
|
|
||||||
text: i18n("Logout")
|
|
||||||
icon.name: "im-kick-user"
|
|
||||||
onClicked: confirmLogoutDialogComponent.createObject(applicationWindow().overlay).open()
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: confirmLogoutDialogComponent
|
|
||||||
Dialog.ConfirmLogout {
|
|
||||||
connection: model.connection
|
|
||||||
onAccepted: {
|
|
||||||
if (Controller.accountCount === 1) {
|
|
||||||
page.Window.window.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MobileForm.FormArrow {
|
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
|
||||||
direction: MobileForm.FormArrow.Right
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
MobileForm.FormDelegateSeparator { below: addAccountDelegate }
|
|
||||||
|
|
||||||
MobileForm.FormButtonDelegate {
|
FormCard.FormArrow {
|
||||||
id: addAccountDelegate
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||||
text: i18n("Add Account")
|
direction: FormCard.FormArrow.Right
|
||||||
icon.name: "list-add"
|
}
|
||||||
onClicked: pageStack.layers.push("qrc:/WelcomePage.qml")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FormCard.FormDelegateSeparator { below: addAccountDelegate }
|
||||||
|
|
||||||
|
FormCard.FormButtonDelegate {
|
||||||
|
id: addAccountDelegate
|
||||||
|
text: i18n("Add Account")
|
||||||
|
icon.name: "list-add"
|
||||||
|
onClicked: pageStack.layers.push("qrc:/WelcomePage.qml")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
property Connections connections: Connections {
|
||||||
target: Controller
|
target: Controller
|
||||||
function onConnectionAdded() {
|
function onConnectionAdded() {
|
||||||
if (pageStack.layers.depth > 2) {
|
if (pageStack.layers.depth > 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user