| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef KSNIP_SAVEOPERATION_H |
| 21 |
#define KSNIP_SAVEOPERATION_H |
| 22 |
|
| 23 |
#include <QCoreApplication> |
| 24 |
|
| 25 |
#include "NotifyOperation.h" |
| 26 |
#include "src/common/dtos/SaveResultDto.h" |
| 27 |
#include "src/common/adapter/fileDialog/IFileDialogService.h" |
| 28 |
#include "src/common/helper/FileDialogFilterHelper.h" |
| 29 |
#include "src/backend/recentImages/IRecentImageService.h" |
| 30 |
#include "src/backend/config/IConfig.h" |
| 31 |
#include "src/backend/saver/ISavePathProvider.h" |
| 32 |
#include "src/backend/saver/IImageSaver.h" |
| 33 |
#include "src/gui/INotificationService.h" |
| 34 |
|
| 35 |
class SaveOperation : public QObject |
| 36 |
{ |
| 37 |
Q_OBJECT |
| 38 |
public: |
| 39 |
SaveOperation( |
| 40 |
QImage image, |
| 41 |
bool isInstantSave, |
| 42 |
const QSharedPointer<INotificationService> ¬ificationService, |
| 43 |
const QSharedPointer<IRecentImageService> &recentImageService, |
| 44 |
const QSharedPointer<IImageSaver> &imageSaver, |
| 45 |
const QSharedPointer<ISavePathProvider> &savePathProvider, |
| 46 |
const QSharedPointer<IFileDialogService> &fileDialogService, |
| 47 |
const QSharedPointer<IConfig> &config, |
| 48 |
QWidget *parent); |
| 49 |
SaveOperation( |
| 50 |
const QImage &image, |
| 51 |
bool isInstantSave, |
| 52 |
const QString &pathToImageSource, |
| 53 |
const QSharedPointer<INotificationService> ¬ificationService, |
| 54 |
const QSharedPointer<IRecentImageService> &recentImageService, |
| 55 |
const QSharedPointer<IImageSaver> &imageSaver, |
| 56 |
const QSharedPointer<ISavePathProvider> &savePathProvider, |
| 57 |
const QSharedPointer<IFileDialogService> &fileDialogService, |
| 58 |
const QSharedPointer<IConfig> &config, |
| 59 |
QWidget *parent); |
| 60 |
~SaveOperation() override = default; |
| 61 |
SaveResultDto execute(); |
| 62 |
|
| 63 |
private: |
| 64 |
QWidget* mParent; |
| 65 |
QImage mImage; |
| 66 |
QString mPathToImageSource; |
| 67 |
bool mIsInstantSave; |
| 68 |
QSharedPointer<IImageSaver> mImageSaver; |
| 69 |
QSharedPointer<ISavePathProvider> mSavePathProvider; |
| 70 |
QSharedPointer<INotificationService> mNotificationService; |
| 71 |
QSharedPointer<IRecentImageService> mRecentImageService; |
| 72 |
QSharedPointer<IFileDialogService> mFileDialogService; |
| 73 |
QSharedPointer<IConfig> mConfig; |
| 74 |
|
| 75 |
void notify(const QString &title, const QString &message, const QString &path, NotificationTypes notificationType) const; |
| 76 |
SaveResultDto save(const QString &path); |
| 77 |
QString getSavePath() const; |
| 78 |
void updateSaveDirectoryIfRequired(const QString &path, const SaveResultDto &saveResult) const; |
| 79 |
}; |
| 80 |
|
| 81 |
#endif |