Account page: spinners while profile is loading

This commit is contained in:
miruka 2020-06-25 09:59:40 -04:00
parent 470b0f0de2
commit d5ea248ba1
3 changed files with 38 additions and 10 deletions

View File

@ -1,16 +1,17 @@
# TODO
- room settings: make letter avatar respond to name change in real time
- sessions page size
- menu click-through padding to close it easily
- clear listview checked on message clear
- unregister popup/menu when destroyed without being closed
- flickshortcuts
- Account: wait until accountInfo available
- avatar upload/change component
- show scrollbars for a few secs if there's content to scroll on beginning
- can leave room with a reason?
- field/area focus line in popups weird
- use new nio `restore_login()`
- verify all popups and boxes work
## Refactoring

View File

@ -28,7 +28,7 @@ Item {
property int fileType: HFileDialogOpener.FileType.All
TapHandler { enabled: fill; onTapped: fileDialog.open() }
TapHandler { enabled: opener.enabled && fill; onTapped: fileDialog.open() }
FileDialog {
id: fileDialog

View File

@ -14,6 +14,7 @@ HFlickableColumnPage {
property string userId
readonly property QtObject account: ModelStore.get("accounts").find(userId)
readonly property bool ready: account && account.profile_updated >= new Date(1)
function takeFocus() {
@ -95,7 +96,7 @@ HFlickableColumnPage {
id: avatar
userId: page.userId
displayName: nameField.item.text
mxc: account.avatar_url
mxc: account ? account.avatar_url : ""
toolTipMxc: ""
sourceOverride: fileDialog.selectedFile || fileDialog.file
@ -105,13 +106,18 @@ HFlickableColumnPage {
Layout.preferredHeight: width
Rectangle {
anchors.fill: parent
z: 10
visible: opacity > 0
opacity: ! fileDialog.dialog.visible &&
((! avatar.mxc && ! avatar.changed) || avatar.hovered) ?
opacity:
! fileDialog.dialog.visible &&
(
(! avatar.mxc && ! avatar.changed) ||
avatar.hovered ||
! ready
) ?
1 : 0
anchors.fill: parent
color: utils.hsluv(
0, 0, 0, (! avatar.mxc && overlayHover.hovered) ? 0.8 : 0.7,
)
@ -123,16 +129,34 @@ HFlickableColumnPage {
MouseArea {
anchors.fill: parent
enabled: ready
acceptedButtons: Qt.NoButton
cursorShape:
overlayHover.hovered ?
Qt.PointingHandCursor : Qt.ArrowCursor
}
HLoader {
anchors.centerIn: parent
width: avatar.width / 3
height: width
source: "../../Base/HBusyIndicator.qml"
active: ! ready
opacity: active ? 1 : 0
visible: opacity > 0
Behavior on opacity { HNumberAnimation {} }
}
HColumnLayout {
anchors.centerIn: parent
spacing: currentSpacing
width: parent.width
opacity: ready ? 1 : 0
visible: opacity > 0
Behavior on opacity { HNumberAnimation {} }
HIcon {
svgName: "upload-avatar"
@ -165,9 +189,10 @@ HFlickableColumnPage {
HFileDialogOpener {
id: fileDialog
enabled: ready
fileType: HFileDialogOpener.FileType.Images
dialog.title: qsTr("Select profile picture for %1")
.arg(account.display_name)
.arg(account ? account.display_name : "")
}
}
@ -183,13 +208,15 @@ HFlickableColumnPage {
HLabeledItem {
id: nameField
loading: ! ready
label.text: qsTr("Display name:")
Layout.fillWidth: true
HTextField {
width: parent.width
defaultText: account.display_name
enabled: ready
defaultText: ready ? account.display_name : ""
maximumLength: 255
// TODO: Qt 5.14+: use a Binding enabled when text not empty
@ -239,7 +266,7 @@ HFlickableColumnPage {
defaultText: aliasField.currentAlias
placeholderText: qsTr("e.g. %1").arg((
nameField.item.text ||
account.display_name ||
(ready && account.display_name) ||
userId.substring(1)
)[0])
}