Skip to content
Snippets Groups Projects
Commit 26c922da authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

wizard: fix profile page avatar previews

Replaces live updates to the avatar preview when editing the alias
field on the profile page during account creation.

Gitlab: #466
Change-Id: I93dd4611949ab0e76f9cea78f9d7aaa1949daa13
parent 34f8d019
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ public:
Q_INVOKABLE bool isPreviewing();
Q_INVOKABLE void setCurrAccDisplayName(const QString& text);
Q_INVOKABLE void setCurrentAccountAvatarFile(const QString& source);
Q_INVOKABLE void setCurrentAccountAvatarBase64(const QString& source);
Q_INVOKABLE void setCurrentAccountAvatarBase64(const QString& source = {});
Q_SIGNALS:
// Trigger other components to reconnect account related signals.
......
......@@ -22,6 +22,7 @@ import QtQuick.Controls 2.14
import net.jami.Adapters 1.0
import net.jami.Constants 1.0
import net.jami.Helpers 1.0
import net.jami.Models 1.0
Item {
......
......@@ -35,6 +35,8 @@ ColumnLayout {
property int size: 224
signal avatarSet
function startBooth() {
AccountAdapter.startPreviewing(false)
mode = PhotoboothView.Mode.Previewing
......@@ -72,6 +74,7 @@ ColumnLayout {
onAccepted: {
var filePath = UtilsAdapter.getAbsPath(file)
AccountAdapter.setCurrentAccountAvatarFile(filePath)
avatarSet()
}
}
......@@ -165,6 +168,7 @@ ColumnLayout {
flashAnimation.start()
AccountAdapter.setCurrentAccountAvatarBase64(
preview.takePhoto(size))
avatarSet()
stopBooth()
return
}
......
......@@ -460,7 +460,7 @@ MainApplication::initQmlLayer()
QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, pluginAdapter, "PluginAdapter");
auto avatarRegistry = new AvatarRegistry(lrcInstance_.data(), this);
QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, avatarRegistry, "AvatarRegistry");
QML_REGISTERSINGLETONTYPE_POBJECT(NS_HELPERS, avatarRegistry, "AvatarRegistry");
// TODO: remove these
QML_REGISTERSINGLETONTYPE_CUSTOM(NS_MODELS, AVModel, &lrcInstance_->avModel())
......
......@@ -20,7 +20,9 @@ import QtQuick 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls 2.14
import net.jami.Adapters 1.0
import net.jami.Constants 1.0
import net.jami.Helpers 1.0
import "../../commoncomponents"
......@@ -34,6 +36,7 @@ Rectangle {
property alias displayName: aliasEdit.text
property bool isRdv: false
property alias avatarBooth: setAvatarWidget
property bool avatarSet
signal leavePage
signal saveProfile
......@@ -42,6 +45,7 @@ Rectangle {
createdAccountId = "dummy"
clearAllTextFields()
saveProfileBtn.spinnerTriggered = true
avatarSet = false
}
function clearAllTextFields() {
......@@ -99,6 +103,7 @@ Rectangle {
Layout.fillHeight: true
imageId: createdAccountId
onAvatarSet: root.avatarSet = true
size: 200
}
......@@ -106,7 +111,7 @@ Rectangle {
MaterialLineEdit {
id: aliasEdit
property string lastInitialCharacter: ""
property string lastFirstChar
Layout.preferredHeight: fieldLayoutHeight
Layout.preferredWidth: fieldLayoutWidth
......@@ -122,18 +127,14 @@ Rectangle {
fieldLayoutWidth: saveProfileBtn.width
onTextEdited: {
if (!(setAvatarWidget.avatarSet)) {
if (text.length === 0) {
setAvatarWidget.setAvatarImage(AvatarImage.AvatarMode.FromAccount,
createdAccountId)
return
}
if (text.length == 1 && text.charAt(0) !== lastInitialCharacter) {
lastInitialCharacter = text.charAt(0)
setAvatarWidget.setAvatarImage(AvatarImage.AvatarMode.FromTemporaryName,
text)
}
if (root.avatarSet)
return
if (text.length === 0) {
lastFirstChar = ""
AccountAdapter.setCurrAccDisplayName(lastFirstChar)
} else if (text.length == 1 && text.charAt(0) !== lastFirstChar) {
lastFirstChar = text.charAt(0)
AccountAdapter.setCurrAccDisplayName(lastFirstChar)
}
}
}
......@@ -164,7 +165,9 @@ Rectangle {
outlined: true
onClicked: {
leavePage()
AccountAdapter.setCurrentAccountAvatarBase64()
aliasEdit.clear()
saveProfile()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment