Commit 07f8349e authored by Andreas Traczyk's avatar Andreas Traczyk

wizard: save avatar after account creation

Change-Id: I00b34f9d94605651ffe1d99b214b70a47f6cf59b
parent 6c323c6e
......@@ -295,6 +295,9 @@ NewWizardWidget::slotRegisteredNameFound(const std::string& accountId,
const std::string& address,
const std::string& name)
{
Q_UNUSED(accountId);
Q_UNUSED(address);
using namespace lrc::api::account;
if (name.length() < 3) {
registrationStateOk_ = false;
......@@ -400,6 +403,9 @@ NewWizardWidget::createRingAccount(const QString &displayName,
LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), accountProperties);
emit NavigationRequested(ScreenEnum::CallScreen);
});
if (ui->setAvatarWidget->hasAvatar()) {
LRCInstance::setCurrAccAvatar(ui->setAvatarWidget->getAvatarPixmap());
}
QObject::disconnect(*connection);
if (connection) {
delete connection;
......
......@@ -33,7 +33,8 @@
PhotoboothWidget::PhotoboothWidget(QWidget *parent) :
QWidget(parent),
fileName_(""),
ui(new Ui::PhotoboothWidget)
ui(new Ui::PhotoboothWidget),
hasAvatar_(false)
{
ui->setupUi(this);
ui->videoFeed->setIsFullPreview(true);
......@@ -64,6 +65,7 @@ PhotoboothWidget::~PhotoboothWidget()
void PhotoboothWidget::startBooth()
{
hasAvatar_ = false;
ui->videoFeed->setResetPreview(true);
Video::PreviewManager::instance().stopPreview();
Video::PreviewManager::instance().startPreview();
......@@ -97,9 +99,9 @@ PhotoboothWidget::on_importButton_clicked()
Video::PreviewManager::instance().stopPreview();
auto image = QImage(fileName_);
auto avatar = image.scaled(100, 100, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
auto avatarPixmap = QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width()));
LRCInstance::setCurrAccAvatar(avatarPixmap);
ui->avatarLabel->setPixmap(avatarPixmap);
avatarPixmap_ = QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width()));
ui->avatarLabel->setPixmap(avatarPixmap_);
hasAvatar_ = true;
stopBooth();
}
......@@ -122,14 +124,26 @@ PhotoboothWidget::on_takePhotoButton_clicked()
flashAnimation_->start(QPropertyAnimation::KeepWhenStopped);
QtConcurrent::run(
[=] {
[this] {
Video::PreviewManager::instance().stopPreview();
auto photo = ui->videoFeed->takePhoto();
auto avatar = photo.scaled(100, 100, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
auto avatarPixmap = QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width()));
LRCInstance::setCurrAccAvatar(avatarPixmap);
ui->avatarLabel->setPixmap(avatarPixmap);
avatarPixmap_ = QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width()));
ui->avatarLabel->setPixmap(avatarPixmap_);
hasAvatar_ = true;
stopBooth();
});
}
}
const QPixmap&
PhotoboothWidget::getAvatarPixmap()
{
return avatarPixmap_;
}
bool
PhotoboothWidget::hasAvatar()
{
return hasAvatar_;
}
\ No newline at end of file
......@@ -36,6 +36,8 @@ public:
~PhotoboothWidget();
void startBooth();
void stopBooth();
const QPixmap& getAvatarPixmap();
bool hasAvatar();
private slots:
void on_importButton_clicked();
......@@ -47,6 +49,8 @@ private:
QLabel* flashOverlay_;
QPropertyAnimation *flashAnimation_;
QPixmap avatarPixmap_;
bool hasAvatar_;
bool takePhotoState_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment