Debian Codegraph @

src/gui/captureHandler/MultiCaptureHandler.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_MULTICAPTUREHANDLER_H
21 #define KSNIP_MULTICAPTUREHANDLER_H
22
23 #include "src/gui/captureHandler/ICaptureHandler.h"
24 #include "src/gui/captureHandler/ICaptureTabStateHandler.h"
25 #include "src/gui/captureHandler/TabContextMenuAction.h"
26 #include "src/gui/operations/CanDiscardOperation.h"
27 #include "src/gui/operations/SaveOperation.h"
28 #include "src/gui/operations/RenameOperation.h"
29 #include "src/gui/operations/DeleteImageOperation.h"
30 #include "src/gui/INotificationService.h"
31 #include "src/gui/clipboard/IClipboard.h"
32 #include "src/gui/desktopService/IDesktopService.h"
33 #include "src/gui/imageAnnotator/IImageAnnotator.h"
34 #include "src/common/provider/NewCaptureNameProvider.h"
35 #include "src/common/provider/PathFromCaptureProvider.h"
36 #include "src/common/loader/IIconLoader.h"
37 #include "src/dependencyInjector/DependencyInjector.h"
38
39 class MultiCaptureHandler : public ICaptureHandler
40 {
41 Q_OBJECT
42 public:
43 explicit MultiCaptureHandler(
44 IImageAnnotator *imageAnnotator,
45 const QSharedPointer<INotificationService> &notificationService,
46 const QSharedPointer<ICaptureTabStateHandler> &captureTabStateHandler,
47 const QSharedPointer<IConfig> &config,
48 const QSharedPointer<IClipboard> &clipboard,
49 const QSharedPointer<IDesktopService> &desktopService,
50 const QSharedPointer<IFileService> &fileService,
51 const QSharedPointer<IMessageBoxService> &messageBoxService,
52 const QSharedPointer<IRecentImageService> &recentImageService,
53 const QSharedPointer<IImageSaver> &imageSaver,
54 const QSharedPointer<ISavePathProvider> &savePathProvider,
55 const QSharedPointer<IIconLoader> &iconLoader,
56 const QSharedPointer<IFileDialogService> &fileDialogService,
57 QWidget *parent);
58 ~MultiCaptureHandler() override = default;
59 bool canClose() override;
60 bool canTakeNew() override;
61 bool isSaved() const override;
62 QString path() const override;
63 bool isPathValid() const override;
64 void saveAs() override;
65 void save() override;
66 void saveAll() override;
67 void rename() override;
68 void copy() override;
69 void copyPath() override;
70 void openDirectory() override;
71 void removeImage() override;
72 void load(const CaptureDto &capture) override;
73 QImage image() const override;
74 void insertImageItem(const QPointF &pos, const QPixmap &pixmap) override;
75 void addListener(ICaptureChangeListener *captureChangeListener) override;
76
77 private:
78 IImageAnnotator *mImageAnnotator;
79 QSharedPointer<ICaptureTabStateHandler> mTabStateHandler;
80 QSharedPointer<INotificationService> mNotificationService;
81 QWidget *mParent;
82 ICaptureChangeListener *mCaptureChangeListener;
83 NewCaptureNameProvider mNewCaptureNameProvider;
84 PathFromCaptureProvider mPathFromCaptureProvider;
85 QSharedPointer<IConfig> mConfig;
86 QSharedPointer<IClipboard> mClipboard;
87 QSharedPointer<IDesktopService> mDesktopService;
88 QSharedPointer<IMessageBoxService> mMessageBoxService;
89 QSharedPointer<IFileService> mFileService;
90 QSharedPointer<IRecentImageService> mRecentImageService;
91 QSharedPointer<IImageSaver> mImageSaver;
92 QSharedPointer<ISavePathProvider> mSavePathProvider;
93 QSharedPointer<IFileDialogService> mFileDialogService;
94 TabContextMenuAction *mSaveContextMenuAction;
95 TabContextMenuAction *mSaveAsContextMenuAction;
96 TabContextMenuAction *mSaveAllContextMenuAction;
97 TabContextMenuAction *mRenameContextMenuAction;
98 TabContextMenuAction *mOpenDirectoryContextMenuAction;
99 TabContextMenuAction *mCopyPathToClipboardContextMenuAction;
100 TabContextMenuAction *mCopyToClipboardContextMenuAction;
101 TabContextMenuAction *mDeleteImageContextMenuAction;
102 QAction *mContextMenuSeparatorAction;
103
104 bool discardChanges(int index);
105 void removeTab(int currentTabIndex);
106 void saveAt(int index, bool isInstant);
107 void addTabContextMenuActions(const QSharedPointer<IIconLoader> &iconLoader);
108
109 private slots:
110 void tabCloseRequested(int index);
111 void captureChanged();
112 void captureEmpty();
113 void annotatorConfigChanged();
114 void saveAsTab(int index);
115 void renameTab(int index);
116 void saveTab(int index);
117 void saveAllTabs();
118 void openDirectoryTab(int index);
119 void updateContextMenuActions(int index);
120 void copyToClipboardTab(int index);
121 void copyPathToClipboardTab(int index);
122 void deleteImageTab(int index);
123 };
124
125 #endif //KSNIP_MULTICAPTUREHANDLER_H