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