Debian Codegraph @

src/gui/snippingArea/SnippingAreaSelector.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_SNIPPINGAREASELECTOR_H
21 #define KSNIP_SNIPPINGAREASELECTOR_H
22
23 #include <QPainter>
24 #include <QKeyEvent>
25
26 #include "SnippingAreaAdorner.h"
27 #include "src/backend/config/Config.h"
28 #include "src/widgets/CustomCursor.h"
29
30 class SnippingAreaSelector : public QObject
31 {
32 Q_OBJECT
33 public:
34 explicit SnippingAreaSelector(const QSharedPointer<IConfig> &config, QObject *parent);
35 ~SnippingAreaSelector() override = default;
36 void activate(const QRectF &snippingAreaGeometry, const QPointF &pos);
37 void deactivate();
38 void paint(QPainter *painter);
39 bool isActive() const;
40 void handleMousePress(const QPointF &pos);
41 void handleMouseRelease();
42 void handleMouseMove(const QPointF &pos);
43 void handleKeyPress(QKeyEvent *event);
44 void setBackgroundImage(const QPixmap *background);
45
46 signals:
47 void rectChanged(const QRectF &rect);
48 void cursorChanged(const QCursor &cursor);
49
50 private:
51 QRectF mCurrentRect;
52 bool mIsActive;
53 QSharedPointer<IConfig> mConfig;
54 SnippingAreaAdorner mAdorner;
55 QPointF mMouseDownPos;
56 bool mIsMouseDown;
57 QRectF mSnippingAreaGeometry;
58 QColor mAdornerColor;
59 QColor mCursorColor;
60 QCursor mMouseCursor;
61
62 void setupAdorner();
63 void setIsMouseDown(bool isMouseDown);
64 void updateCurrentRect(const QRectF &rect, const QPointF &pos);
65 void updateAdorner(const QPointF &pos);
66 };
67
68
69 #endif //KSNIP_SNIPPINGAREASELECTOR_H