Debian Codegraph @

src/gui/dragAndDrop/DragAndDropProcessor.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_DRAGANDDROPPROCESSOR_H
21 #define KSNIP_DRAGANDDROPPROCESSOR_H
22
23 #include <QObject>
24 #include <QDragEnterEvent>
25 #include <QMimeData>
26 #include <QGraphicsSceneDragDropEvent>
27 #include <QDrag>
28 #include <QApplication>
29 #include <QPixmap>
30 #include <QList>
31 #include <QUrl>
32 #include <QDir>
33
34 #include "IDragContentProvider.h"
35 #include "src/common/helper/FileUrlHelper.h"
36 #include "src/common/helper/PathHelper.h"
37 #include "src/common/provider/ITempFileProvider.h"
38
39 class DragAndDropProcessor : public QObject
40 {
41 Q_OBJECT
42 public:
43 explicit DragAndDropProcessor(IDragContentProvider *dragContentProvider, const QSharedPointer<ITempFileProvider> &tempFileProvider);
44 ~DragAndDropProcessor() override = default;
45 bool eventFilter(QObject *object, QEvent *event) override;
46
47 signals:
48 void fileDropped(const QString &path);
49 void imageDropped(const QPixmap &pixmap);
50
51 private:
52 IDragContentProvider *mDragContentProvider;
53 QSharedPointer<ITempFileProvider> mTempFileProvider;
54 QPoint mDragStartPosition;
55
56 static bool handleDragEnter(QDragEnterEvent *event);
57 static bool handleDragEnter(QGraphicsSceneDragDropEvent *event);
58 bool handleDrop(QDropEvent *event);
59 bool handleDrop(QGraphicsSceneDragDropEvent *event);
60 bool handleDragStart(QMouseEvent *event);
61 bool handleDragMove(QMouseEvent *event);
62 static QStringList getUrlsFromMimeData(const QMimeData *mimeData);
63 static bool isDragStarting(const QMouseEvent *event);
64 bool isMinDragDistanceReached(const QMouseEvent *event) const;
65 void createDrag(const DragContent &dragContent);
66 QString getPathToDraggedImage(const DragContent &dragContent);
67 void processDroppedImagePaths(const QStringList &paths);
68 };
69
70 #endif //KSNIP_DRAGANDDROPPROCESSOR_H