Debian Codegraph @

src/gui/operations/SaveOperation.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
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> &notificationService,
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> &notificationService,
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 //KSNIP_SAVEOPERATION_H