Debian Codegraph @

src/gui/captureHandler/SingleCaptureHandler.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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_SINGLECAPTUREHANDLER_H
21 #define KSNIP_SINGLECAPTUREHANDLER_H
22
23 #include "src/gui/captureHandler/ICaptureHandler.h"
24 #include "src/gui/operations/CanDiscardOperation.h"
25 #include "src/gui/operations/DeleteImageOperation.h"
26 #include "src/gui/operations/RenameOperation.h"
27 #include "src/gui/INotificationService.h"
28 #include "src/gui/clipboard/IClipboard.h"
29 #include "src/gui/desktopService/IDesktopService.h"
30 #include "src/gui/imageAnnotator/IImageAnnotator.h"
31 #include "src/common/provider/PathFromCaptureProvider.h"
32 #include "src/dependencyInjector/DependencyInjector.h"
33
34 class SingleCaptureHandler : public ICaptureHandler
35 {
36 Q_OBJECT
37 public:
38 explicit SingleCaptureHandler(
39 IImageAnnotator *imageAnnotator,
40 const QSharedPointer<INotificationService> &notificationService,
41 const QSharedPointer<IClipboard> &clipboard,
42 const QSharedPointer<IDesktopService> &desktopService,
43 const QSharedPointer<IFileService> &fileService,
44 const QSharedPointer<IMessageBoxService> &messageBoxService,
45 const QSharedPointer<IRecentImageService> &recentImageService,
46 const QSharedPointer<IImageSaver> &imageSaver,
47 const QSharedPointer<ISavePathProvider> &savePathProvider,
48 const QSharedPointer<IFileDialogService> &fileDialogService,
49 const QSharedPointer<IConfig> &config,
50 QWidget *parent);
51 ~SingleCaptureHandler() override = default;
52 bool canClose() override;
53 bool canTakeNew() override;
54 bool isSaved() const override;
55 QString path() const override;
56 bool isPathValid() const override;
57 void saveAs() override;
58 void save() override;
59 void saveAll() override;
60 void rename() override;
61 void copy() override;
62 void copyPath() override;
63 void openDirectory() override;
64 void removeImage() override;
65 void load(const CaptureDto &capture) override;
66 QImage image() const override;
67 void insertImageItem(const QPointF &pos, const QPixmap &pixmap) override;
68 void addListener(ICaptureChangeListener *captureChangeListener) override;
69
70 private:
71 IImageAnnotator *mImageAnnotator;
72 QSharedPointer<INotificationService> mNotificationService;
73 QSharedPointer<IClipboard> mClipboard;
74 QSharedPointer<IDesktopService> mDesktopService;
75 QSharedPointer<IFileService> mFileService;
76 QSharedPointer<IMessageBoxService> mMessageBoxService;
77 QSharedPointer<IRecentImageService> mRecentImageService;
78 QSharedPointer<IImageSaver> mImageSaver;
79 QSharedPointer<ISavePathProvider> mSavePathProvider;
80 QSharedPointer<IFileDialogService> mFileDialogService;
81 QSharedPointer<IConfig> mConfig;
82 QWidget *mParent;
83 ICaptureChangeListener *mCaptureChangeListener;
84 bool mIsSaved;
85 QString mPath;
86 PathFromCaptureProvider mPathFromCaptureProvider;
87
88 bool discardChanges();
89
90 private slots:
91 void captureChanged();
92 void captureEmpty();
93 void innerSave(bool isInstant);
94 void markUnsaved();
95 void reset();
96 };
97
98 #endif //KSNIP_SINGLECAPTUREHANDLER_H