mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-03 22:35:45 +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 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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue