diff --git a/src/commoncomponents/AvatarImage.qml b/src/commoncomponents/AvatarImage.qml index d59177bb774f3b4970131cd04f7f5dc3f1db4339..61b68a74a01e79163235d6ef9538be4a3db88324 100644 --- a/src/commoncomponents/AvatarImage.qml +++ b/src/commoncomponents/AvatarImage.qml @@ -65,6 +65,7 @@ Item { property alias presenceStatus: presenceIndicator.status property bool showPresenceIndicator: true property int unreadMessagesCount: 0 + property bool enableAnimation: true signal imageIsReady @@ -97,8 +98,13 @@ Item { onStatusChanged: { if (status === Image.Ready) { - rootImageOverlay.state = "" - rootImageOverlay.state = "rootImageLoading" + if (enableAnimation) { + rootImageOverlay.state = "" + rootImageOverlay.state = "rootImageLoading" + } else { + rootImageOverlay.source = rootImage.source + root.imageIsReady() + } } } @@ -122,6 +128,8 @@ Item { fillMode: Image.PreserveAspectFit + opacity: enableAnimation ? 1 : 0 + onOpacityChanged: { if (opacity === 0) source = rootImage.source @@ -140,7 +148,11 @@ Item { } transitions: Transition { - NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad; duration: 400} + NumberAnimation { + properties: "opacity" + easing.type: Easing.InOutQuad + duration: 400 + } } } } diff --git a/src/commoncomponents/PhotoboothView.qml b/src/commoncomponents/PhotoboothView.qml index dec922ad6911aeb17c5a7ad7a6a782e2e8dfabce..f88ff3ea425b0e33d5db0c1e7ab4fe5ca1b1bb89 100644 --- a/src/commoncomponents/PhotoboothView.qml +++ b/src/commoncomponents/PhotoboothView.qml @@ -28,10 +28,11 @@ ColumnLayout { buttonsRowLayout.height + JamiTheme.preferredMarginSize / 2 - function initUI() { + function initUI(useDefaultAvatar = true) { photoState = PhotoboothView.PhotoState.Default avatarSet = false - setAvatarImage(AvatarImage.Mode.Default, "") + if (useDefaultAvatar) + setAvatarImage(AvatarImage.Mode.Default, "") } function startBooth(force = false) { @@ -49,6 +50,11 @@ ColumnLayout { function setAvatarImage(mode = AvatarImage.Mode.FromAccount, imageId = AccountAdapter.currentAccountId){ + if (mode !== AvatarImage.Mode.FromUrl) + avatarImg.enableAnimation = true + else + avatarImg.enableAnimation = false + avatarImg.mode = mode if (mode === AvatarImage.Mode.Default) { @@ -109,7 +115,7 @@ ColumnLayout { id: avatarLabelBackground anchors.fill: parent - color: "grey" + color: "white" radius: height / 2 AvatarImage { @@ -135,14 +141,44 @@ ColumnLayout { } onImageIsReady: { - // Once image is loaded (updated), save to boothImg - avatarImg.grabToImage(function(result) { - if (mode !== AvatarImage.Mode.Default) - boothImg = result.image + if (mode === AvatarImage.Mode.FromUrl) + photoState = PhotoboothView.PhotoState.Taken - if (saveToConfig) - SettingsAdapter.setCurrAccAvatar(result.image) - }) + if (photoState === PhotoboothView.PhotoState.Taken) { + avatarImg.state = "" + avatarImg.state = "flashIn" + } else { + // Once image is loaded (updated), save to boothImg (choose from file) + avatarImg.grabToImage(function(result) { + if (mode !== AvatarImage.Mode.Default) + boothImg = result.image + + if (saveToConfig) + SettingsAdapter.setCurrAccAvatar(result.image) + }) + } + } + + onOpacityChanged: { + if (avatarImg.state === "flashIn" && opacity === 0) + avatarImg.state = "flashOut" + } + + states: [ + State { + name: "flashIn" + PropertyChanges { target: avatarImg; opacity: 0} + }, State { + name: "flashOut" + PropertyChanges { target: avatarImg; opacity: 1} + }] + + transitions: Transition { + NumberAnimation { + properties: "opacity" + easing.type: Easing.Linear + duration: 100 + } } } } @@ -172,22 +208,6 @@ ColumnLayout { } } } - - Label { - id: flashOverlay - - anchors.fill: previewWidget - visible: false - color: JamiTheme.whiteColor - - OpacityAnimator on opacity { - id: flashAnimation - - from: 1 - to: 0 - duration: 600 - } - } } RowLayout { @@ -235,15 +255,14 @@ ColumnLayout { startBooth() return } else { - // show flash overlay - flashOverlay.visible = true - flashAnimation.restart() - previewWidget.grabToImage(function(result) { + boothImg = result.image + + if (saveToConfig) + SettingsAdapter.setCurrAccAvatar(result.image) setAvatarImage(AvatarImage.Mode.FromUrl, result.url) - photoState = PhotoboothView.PhotoState.Taken avatarSet = true stopBooth() }) diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index 578eec29c7170ffc6dec5025a46504c2f7a97280..8b74653d29f33396c7f3324271fd2948e3b1ba49 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -53,9 +53,6 @@ Rectangle { pageIdCurrentAccountSettings.connectCurrentAccount() settingsViewRect.stopPreviewing() selectedMenu = sel - if(pageIdCurrentAccountSettings.isPhotoBoothOpened()) { - settingsViewRect.setAvatar() - } pageIdCurrentAccountSettings.updateAccountInfoDisplayed() break case SettingsView.General: @@ -123,7 +120,6 @@ Rectangle { signal stopPreviewing signal stopBooth - signal setAvatar property bool isSIP: { switch (profileType) { diff --git a/src/settingsview/components/AccountProfile.qml b/src/settingsview/components/AccountProfile.qml index 068fa04e769451e93b94e73cf45b14f5874a196c..070b5170243108d82d2e0f842283e7507ff2763e 100644 --- a/src/settingsview/components/AccountProfile.qml +++ b/src/settingsview/components/AccountProfile.qml @@ -38,21 +38,14 @@ ColumnLayout { function onStopBooth() { stopBooth() } - - function onSetAvatar() { - setAvatar() - } } function updateAccountInfo() { displayNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias() } - function isPhotoBoothOpened() { - return currentAccountAvatar.takePhotoState - } - - function setAvatar() { + function initPhotoBooth() { + currentAccountAvatar.initUI(false) currentAccountAvatar.setAvatarImage() } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index f522cd761d1c07c3a31eadc54559250844a5d89f..317bf8164ad5aece0e99aa2ab0b043dce4aabeef 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -43,12 +43,8 @@ Rectangle { signal navigateToNewWizardView signal advancedSettingsToggled(bool settingsVisible) - function isPhotoBoothOpened() { - return accountProfile.isPhotoBoothOpened() - } - function updateAccountInfoDisplayed() { - accountProfile.setAvatar() + accountProfile.initPhotoBooth() accountEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled() accountProfile.updateAccountInfo()