diff --git a/src/citra_qt/camera/still_image_camera.cpp b/src/citra_qt/camera/still_image_camera.cpp index b466d17df3..e02d0d0d32 100644 --- a/src/citra_qt/camera/still_image_camera.cpp +++ b/src/citra_qt/camera/still_image_camera.cpp @@ -13,6 +13,10 @@ namespace Camera { StillImageCamera::StillImageCamera(QImage image_, const Service::CAM::Flip& flip) : QtCameraInterface(flip), image(std::move(image_)) {} +StillImageCamera::~StillImageCamera() { + StillImageCameraFactory::last_path.clear(); +} + void StillImageCamera::StartCapture() {} void StillImageCamera::StopCapture() {} @@ -25,7 +29,12 @@ bool StillImageCamera::IsPreviewAvailable() { return !image.isNull(); } +std::string StillImageCameraFactory::last_path; + const std::string StillImageCameraFactory::GetFilePath() const { + if (!last_path.empty()) { + return last_path; + } QList types = QImageReader::supportedImageFormats(); QList temp_filters; for (QByteArray type : types) { @@ -33,8 +42,9 @@ const std::string StillImageCameraFactory::GetFilePath() const { } QString filter = QObject::tr("Supported image files (%1)").arg(temp_filters.join(" ")); - return QFileDialog::getOpenFileName(nullptr, QObject::tr("Open File"), ".", filter) - .toStdString(); + last_path = + QFileDialog::getOpenFileName(nullptr, QObject::tr("Open File"), ".", filter).toStdString(); + return last_path; } std::unique_ptr StillImageCameraFactory::Create(const std::string& config, diff --git a/src/citra_qt/camera/still_image_camera.h b/src/citra_qt/camera/still_image_camera.h index ccfc13211f..19ca044f03 100644 --- a/src/citra_qt/camera/still_image_camera.h +++ b/src/citra_qt/camera/still_image_camera.h @@ -15,6 +15,7 @@ namespace Camera { class StillImageCamera final : public QtCameraInterface { public: StillImageCamera(QImage image, const Service::CAM::Flip& flip); + ~StillImageCamera(); void StartCapture() override; void StopCapture() override; void SetFrameRate(Service::CAM::FrameRate frame_rate) override {} @@ -33,6 +34,12 @@ public: const Service::CAM::Flip& flip) override; Q_INVOKABLE const std::string GetFilePath() const; + +private: + /// Record the path chosen to avoid multiple prompt problem + static std::string last_path; + + friend class StillImageCamera; }; } // namespace Camera