Commit e8b9956b authored by Nicolas Fella's avatar Nicolas Fella

[kcm] Port to ScrollViewKCM

Use ScrollViewKCM + ListView instead of Repeater + ColumnLayout + Frame.

This makes for a more standard appearance and behaviour.
parent ec9746ca
...@@ -14,7 +14,7 @@ import org.kde.kcm 1.2 ...@@ -14,7 +14,7 @@ import org.kde.kcm 1.2
import org.kde.kaccounts 1.2 as KAccounts import org.kde.kaccounts 1.2 as KAccounts
SimpleKCM { ScrollViewKCM {
id: component; id: component;
title: i18n("Account Details") title: i18n("Account Details")
...@@ -42,41 +42,44 @@ SimpleKCM { ...@@ -42,41 +42,44 @@ SimpleKCM {
KAccounts.AccountServiceToggleJob { } KAccounts.AccountServiceToggleJob { }
} }
header: RowLayout { header: ColumnLayout {
Layout.fillWidth: true RowLayout {
Layout.margins: Kirigami.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing
Kirigami.Icon {
source: model.accountIconName
Layout.preferredWidth: Kirigami.Units.iconSizes.large
Layout.preferredHeight: Kirigami.Units.iconSizes.large
}
Controls.Label {
Layout.fillWidth: true Layout.fillWidth: true
text: { Layout.margins: Kirigami.Units.smallSpacing
if (model.accountDisplayName.length > 0 && model.accountProviderName.length > 0) { spacing: Kirigami.Units.smallSpacing
return i18n("%1 (%2)", model.accountDisplayName, model.accountProviderName) Kirigami.Icon {
} else if (model.accountDisplayName.length > 0) { source: model.accountIconName
return model.accountDisplayName Layout.preferredWidth: Kirigami.Units.iconSizes.large
} else { Layout.preferredHeight: Kirigami.Units.iconSizes.large
return i18n("%1 account", model.accountProviderName) }
Controls.Label {
Layout.fillWidth: true
text: {
if (model.accountDisplayName.length > 0 && model.accountProviderName.length > 0) {
return i18n("%1 (%2)", model.accountDisplayName, model.accountProviderName)
} else if (model.accountDisplayName.length > 0) {
return model.accountDisplayName
} else {
return i18n("%1 account", model.accountProviderName)
}
} }
} }
} Controls.ToolButton {
Controls.ToolButton { icon.name: "edit-entry"
icon.name: "edit-entry" Layout.preferredHeight: Kirigami.Units.iconSizes.large
display: Controls.AbstractButton.IconOnly Layout.preferredWidth: Kirigami.Units.iconSizes.large
Layout.preferredHeight: Kirigami.Units.iconSizes.large onClicked: accountRenamer.open();
Layout.preferredWidth: Kirigami.Units.iconSizes.large Controls.ToolTip {
onClicked: accountRenamer.open(); text: i18nc("Button which spawns a dialog allowing the user to change the displayed account's human-readable name", "Change Account Display Name")
Controls.ToolTip { }
visible: parent.hovered && !parent.pressed
text: i18nc("Button which spawns a dialog allowing the user to change the displayed account's human-readable name", "Change Account Display Name")
delay: Kirigami.Units.toolTipDelay
timeout: 5000
y: parent.height
} }
} }
Kirigami.Heading {
leftPadding: Kirigami.Units.smallSpacing
visible: servicesList.count > 0
level: 3
text: i18nc("Heading for a list of services available with this account", "Use This Account For")
}
} }
footer: RowLayout { footer: RowLayout {
...@@ -88,16 +91,11 @@ SimpleKCM { ...@@ -88,16 +91,11 @@ SimpleKCM {
} }
} }
Controls.Frame { view: ListView {
Layout.fillWidth: true id: servicesList
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.Button clip: true
color: Kirigami.Theme.backgroundColor
border {
width: 1
color: Qt.tint(Kirigami.Theme.textColor, Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.8))
}
}
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
...@@ -111,46 +109,33 @@ SimpleKCM { ...@@ -111,46 +109,33 @@ SimpleKCM {
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: i18nc("A text shown when an account has no configurable services", "There are no configurable services available for this account. You can still change its display name by clicking the edit icon above.") text: i18nc("A text shown when an account has no configurable services", "There are no configurable services available for this account. You can still change its display name by clicking the edit icon above.")
} }
Kirigami.Heading { }
delegate: ColumnLayout {
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.smallSpacing
spacing: 0
Controls.CheckBox {
id: serviceCheck
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.smallSpacing checked: model.enabled
visible: servicesList.count > 0 text: model.displayName
level: 3 Binding {
text: i18nc("Heading for a list of services available with this account", "Use This Account For") target: serviceCheck
} property: "checked"
Repeater { value: model.enabled
id: servicesList }
delegate: ColumnLayout { onClicked: {
Layout.fillWidth: true var job = serviceToggleJob.createObject(component, { "accountId": servicesList.model.accountId, "serviceId": model.name, "serviceEnabled": !model.enabled })
Layout.leftMargin: Kirigami.Units.smallSpacing job.start()
spacing: 0
Controls.CheckBox {
id: serviceCheck
Layout.fillWidth: true
checked: model.enabled
text: model.displayName
Binding {
target: serviceCheck
property: "checked"
value: model.enabled
}
onClicked: {
var job = serviceToggleJob.createObject(component, { "accountId": servicesList.model.accountId, "serviceId": model.name, "serviceEnabled": !model.enabled })
job.start()
}
}
Controls.Label {
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing * 2
visible: text.length > 0
text: model.description
wrapMode: Text.Wrap
}
} }
} }
Item { Controls.Label {
Layout.fillWidth: true Layout.fillWidth: true
height: Kirigami.Units.smallSpacing Layout.leftMargin: Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing * 2
visible: text.length > 0
text: model.description
wrapMode: Text.Wrap
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment