| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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 |