aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop/modules/user/UserPage.qml51
1 files changed, 35 insertions, 16 deletions
diff --git a/desktop/modules/user/UserPage.qml b/desktop/modules/user/UserPage.qml
index fabb3e4..5e2e448 100644
--- a/desktop/modules/user/UserPage.qml
+++ b/desktop/modules/user/UserPage.qml
@@ -27,15 +27,25 @@ Column {
spacing: 14
// A new detail is one entry here and one case in userctl. Avatar is not
- // listed: it is the picture at the top, not a row.
+ // listed: it is the picture at the top, not a row. A "derived" field is
+ // read-only, computed by derived() from the draft, and never saved on
+ // its own: userctl writes it as part of the field it comes from.
readonly property var fields: [
{ key: "name", label: "Name", kind: "text" },
{ key: "email", label: "Email", kind: "text" },
{ key: "location", label: "Location", kind: "text" },
{ key: "language", label: "Language", kind: "locale" },
- { key: "signingkey", label: "Signing key", kind: "key" },
+ { key: "gitname", label: "Name", kind: "derived", section: "Git" },
+ { key: "gitemail", label: "Email", kind: "derived", section: "Git" },
+ { key: "signingkey", label: "Signing key", kind: "key", section: "Git" },
]
+ function derived(key) {
+ if (key === "gitname") return U.gitName(form.draft.name ?? "");
+ if (key === "gitemail") return form.draft.email ?? "";
+ return "";
+ }
+
readonly property string ctl: Qt.resolvedUrl("userctl").toString().replace(/^file:\/\//, "")
property var saved: ({})
property var draft: ({})
@@ -216,39 +226,56 @@ Column {
id: field
enabled: !form.busy
required property var modelData
+ required property int index
+ readonly property bool derived: modelData.kind === "derived"
width: form.width
spacing: 4
+ // A section's heading, above its first field.
+ Text {
+ visible: !!field.modelData.section
+ && form.fields[field.index - 1]?.section !== field.modelData.section
+ topPadding: 10
+ bottomPadding: 2
+ text: field.modelData.section ?? ""
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize; bold: true }
+ color: Theme.text
+ }
+
Text {
text: field.modelData.label
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
color: Theme.subtext
}
+ // Read-only fields are dimmer, but still selectable for copying.
Rectangle {
- visible: field.modelData.kind === "text"
+ visible: field.modelData.kind === "text" || field.derived
width: parent.width
height: 34
radius: 8
- color: Theme.surface
+ color: field.derived ? Qt.alpha(Theme.surface, 0.4) : Theme.surface
TextInput {
anchors { fill: parent; leftMargin: 10; rightMargin: 10 }
verticalAlignment: TextInput.AlignVCenter
clip: true
selectByMouse: true
- color: Theme.text
+ readOnly: field.derived
+ color: field.derived ? Theme.subtext : Theme.text
font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
- text: form.draft[field.modelData.key] ?? ""
+ text: field.derived ? form.derived(field.modelData.key)
+ : form.draft[field.modelData.key] ?? ""
onTextEdited: form.set(field.modelData.key, text)
}
}
ComboBox {
- visible: field.modelData.kind !== "text"
+ readonly property bool used: field.modelData.kind === "locale" || field.modelData.kind === "key"
+ visible: used
width: parent.width
textRole: "text"
valueRole: "value"
- model: field.modelData.kind === "text" ? [] : form.options(field.modelData.kind)
+ model: used ? form.options(field.modelData.kind) : []
// count is read so the index is recomputed once the list
// arrives, which is after the draft.
currentIndex: count >= 0 ? indexOfValue(form.draft[field.modelData.key] ?? "") : -1
@@ -283,14 +310,6 @@ Column {
}
}
- Text {
- width: parent.width
- text: "git: " + U.gitName(form.draft.name ?? "") + " <" + (form.draft.email ?? "") + ">"
- elide: Text.ElideRight
- font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
- color: Theme.overlay
- }
-
Button {
anchors.right: parent.right
text: form.busy ? "Saving…" : "Save"