From 30ac2c75709a5f81bb5d69a9c395c45476117cb3 Mon Sep 17 00:00:00 2001 From: Olivier SOLDANO Date: Fri, 4 Aug 2017 09:14:47 -0400 Subject: [PATCH] replace photoboothdialog code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit photoboothwidget was created to integrate the dialog inside the account creation wizard. the widget is now reused as the core of the photobooth dialog used in the profile configuration. Change-Id: I794d7964195bc468452f2f1e63fe1b157baaab97 Reviewed-by: Anthony Léonard --- configurationwidget.cpp | 2 +- photoboothdialog.cpp | 48 ++++--------------------- photoboothdialog.h | 12 ++----- photoboothdialog.ui | 79 +++++++++-------------------------------- 4 files changed, 26 insertions(+), 115 deletions(-) diff --git a/configurationwidget.cpp b/configurationwidget.cpp index 745dab3..4a9e1e6 100644 --- a/configurationwidget.cpp +++ b/configurationwidget.cpp @@ -432,7 +432,7 @@ ConfigurationWidget::on_avatarButton_clicked() PhotoBoothDialog dlg; dlg.exec(); if (dlg.result() == QDialog::Accepted) { - auto image = QImage(dlg.fileName_); + auto image = QImage(dlg.getOutputFileName()); auto avatar = image.scaled(100, 100, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); ProfileModel::instance().selectedProfile()->person()->setPhoto(avatar); ProfileModel::instance().selectedProfile()->save(); diff --git a/photoboothdialog.cpp b/photoboothdialog.cpp index 6a804f3..5ea8091 100644 --- a/photoboothdialog.cpp +++ b/photoboothdialog.cpp @@ -26,54 +26,18 @@ PhotoBoothDialog::PhotoBoothDialog(QWidget* parent) : QDialog(parent), - fileName_(QStandardPaths::standardLocations(QStandardPaths::TempLocation).first() - + QStringLiteral("profile.png")), ui(new Ui::PhotoBoothDialog) { ui->setupUi(this); - - Qt::WindowFlags flags = windowFlags(); - flags = flags & (~Qt::WindowContextHelpButtonHint); - setWindowFlags(flags); - - ui->videoFeed->setIsFullPreview(true); - ui->videoFeed->setPhotoMode(true); - Video::PreviewManager::instance().startPreview(); + setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); + connect(ui->Photobooth, &PhotoboothWidget::photoTaken, [this](QString fileName){ + fileName_ = fileName; + accept(); + } + ); } PhotoBoothDialog::~PhotoBoothDialog() { delete ui; } - -void -PhotoBoothDialog::closeEvent(QCloseEvent* event) -{ - Q_UNUSED(event) - Video::PreviewManager::instance().stopPreview(); -} - -void -PhotoBoothDialog::on_importButton_clicked() -{ - fileName_ = QFileDialog::getOpenFileName(this, tr("Choose File"), - "", - tr("Files (*)")); - if (fileName_.isEmpty()) - fileName_ = QStandardPaths::standardLocations( - QStandardPaths::TempLocation).first() - + QStringLiteral("profile.png"); - else { - Video::PreviewManager::instance().stopPreview(); - accept(); - } -} - -void -PhotoBoothDialog::on_takePhotoButton_clicked() -{ - auto photo = ui->videoFeed->takePhoto(); - Video::PreviewManager::instance().stopPreview(); - photo.save(fileName_); - accept(); -} diff --git a/photoboothdialog.h b/photoboothdialog.h index 9330f97..ac16f10 100644 --- a/photoboothdialog.h +++ b/photoboothdialog.h @@ -31,17 +31,9 @@ class PhotoBoothDialog : public QDialog public: explicit PhotoBoothDialog(QWidget* parent = 0); ~PhotoBoothDialog(); -public: - QString fileName_; - -protected: - void closeEvent(QCloseEvent* event); - -//UI SLOTS -private slots: - void on_importButton_clicked(); - void on_takePhotoButton_clicked(); + QString& getOutputFileName() { return fileName_;} private: Ui::PhotoBoothDialog* ui; + QString fileName_; }; diff --git a/photoboothdialog.ui b/photoboothdialog.ui index 8c98b55..748b015 100644 --- a/photoboothdialog.ui +++ b/photoboothdialog.ui @@ -13,77 +13,32 @@ Photobooth - + + + 0 + + + 0 + + + 0 + + + 0 + - - - - - - - 0 - 0 - - - - - 40 - 40 - - - - - - - - :/images/icons/ic_photo_camera_white_24dp_2x.png:/images/icons/ic_photo_camera_white_24dp_2x.png - - - - 36 - 36 - - - - - - - - - 0 - 0 - - - - or - - - - - - - - 90 - 30 - - - - Import - - + - VideoWidget + PhotoboothWidget QWidget -
videowidget.h
+
photoboothwidget.h
1
- - - + -- GitLab