mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 14:55:43 +02:00
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
This commit is contained in:
parent
34f8d019e0
commit
26c922da4d
5 changed files with 24 additions and 16 deletions
|
@ -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
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
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 {
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
var filePath = UtilsAdapter.getAbsPath(file)
|
var filePath = UtilsAdapter.getAbsPath(file)
|
||||||
AccountAdapter.setCurrentAccountAvatarFile(filePath)
|
AccountAdapter.setCurrentAccountAvatarFile(filePath)
|
||||||
|
avatarSet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()
|
||||||
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
|
||||||
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 {
|
||||||
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 {
|
||||||
createdAccountId = "dummy"
|
createdAccountId = "dummy"
|
||||||
clearAllTextFields()
|
clearAllTextFields()
|
||||||
saveProfileBtn.spinnerTriggered = true
|
saveProfileBtn.spinnerTriggered = true
|
||||||
|
avatarSet = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAllTextFields() {
|
function clearAllTextFields() {
|
||||||
|
@ -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 {
|
||||||
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 {
|
||||||
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 {
|
||||||
outlined: true
|
outlined: true
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
leavePage()
|
AccountAdapter.setCurrentAccountAvatarBase64()
|
||||||
|
aliasEdit.clear()
|
||||||
|
saveProfile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue