| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef KSNIP_SNIPPINGAREARESIZER_H |
| 21 |
#define KSNIP_SNIPPINGAREARESIZER_H |
| 22 |
|
| 23 |
#include <QPainter> |
| 24 |
#include <QKeyEvent> |
| 25 |
#include <QCursor> |
| 26 |
#include <QVector> |
| 27 |
|
| 28 |
#include "src/common/helper/RectHelper.h" |
| 29 |
#include "src/backend/config/IConfig.h" |
| 30 |
|
| 31 |
class SnippingAreaResizer : public QObject |
| 32 |
{ |
| 33 |
Q_OBJECT |
| 34 |
public: |
| 35 |
explicit SnippingAreaResizer(const QSharedPointer<IConfig> &config, QObject *parent); |
| 36 |
~SnippingAreaResizer() override = default; |
| 37 |
void activate(const QRectF &rect, const QPointF &pos); |
| 38 |
void deactivate(); |
| 39 |
void paint(QPainter *painter); |
| 40 |
bool isActive() const; |
| 41 |
void handleMousePress(const QPointF &pos); |
| 42 |
void handleMouseRelease(); |
| 43 |
void handleMouseMove(const QPointF &pos); |
| 44 |
void handleKeyPress(QKeyEvent *event); |
| 45 |
void handleKeyRelease(QKeyEvent *event); |
| 46 |
|
| 47 |
signals: |
| 48 |
void rectChanged(const QRectF &rect); |
| 49 |
void cursorChanged(const QCursor &cursor); |
| 50 |
|
| 51 |
private: |
| 52 |
QRectF mCurrentRect; |
| 53 |
bool mIsActive; |
| 54 |
QPointF mGrabOffset; |
| 55 |
bool mIsGrabbed; |
| 56 |
int mGrabbedHandleIndex; |
| 57 |
QVector<QRectF> mHandles; |
| 58 |
QSharedPointer<IConfig> mConfig; |
| 59 |
QColor mColor; |
| 60 |
bool mControlPressed; |
| 61 |
bool mAltPressed; |
| 62 |
|
| 63 |
void updateHandlePositions(); |
| 64 |
void updateCurrentRect(const QPointF &point); |
| 65 |
void updateCursor(const QPointF &pos); |
| 66 |
void notifyRectChanged(); |
| 67 |
void arrowUpPressed(); |
| 68 |
void arrowDownPressed(); |
| 69 |
void arrowLeftPressed(); |
| 70 |
void arrowRightPressed(); |
| 71 |
void arrowKeyPressed(const QKeyEvent *event); |
| 72 |
}; |
| 73 |
|
| 74 |
#endif |