| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef KSNIP_ABSTRACTSNIPPINGAREA_H |
| 21 |
#define KSNIP_ABSTRACTSNIPPINGAREA_H |
| 22 |
|
| 23 |
#include <QWidget> |
| 24 |
#include <QMouseEvent> |
| 25 |
#include <QApplication> |
| 26 |
#include <QTimer> |
| 27 |
|
| 28 |
#include "SnippingAreaAdorner.h" |
| 29 |
#include "SnippingAreaResizer.h" |
| 30 |
#include "SnippingAreaSelector.h" |
| 31 |
#include "SnippingAreaSelectorInfoText.h" |
| 32 |
#include "SnippingAreaResizerInfoText.h" |
| 33 |
#include "src/common/helper/MathHelper.h" |
| 34 |
#include "src/backend/config/IConfig.h" |
| 35 |
|
| 36 |
class AbstractSnippingArea : public QWidget |
| 37 |
{ |
| 38 |
Q_OBJECT |
| 39 |
public: |
| 40 |
explicit AbstractSnippingArea(const QSharedPointer<IConfig> &config); |
| 41 |
~AbstractSnippingArea() override; |
| 42 |
void showWithoutBackground(); |
| 43 |
void showWithBackground(const QPixmap& background); |
| 44 |
virtual QRect selectedRectArea() const = 0; |
| 45 |
virtual QPixmap background() const; |
| 46 |
bool closeSnippingArea(); |
| 47 |
|
| 48 |
signals: |
| 49 |
void finished(); |
| 50 |
void canceled(); |
| 51 |
|
| 52 |
protected: |
| 53 |
QRegion mClippingRegion; |
| 54 |
|
| 55 |
void mousePressEvent(QMouseEvent *event) override; |
| 56 |
void mouseReleaseEvent(QMouseEvent *event) override; |
| 57 |
void mouseMoveEvent(QMouseEvent *event) override; |
| 58 |
void mouseDoubleClickEvent(QMouseEvent *event) override; |
| 59 |
void keyPressEvent(QKeyEvent *event) override; |
| 60 |
void keyReleaseEvent(QKeyEvent *event) override; |
| 61 |
void paintEvent(QPaintEvent *event) override; |
| 62 |
virtual bool isBackgroundTransparent() const; |
| 63 |
virtual void setFullScreen() = 0; |
| 64 |
virtual QSizeF getSize() const = 0; |
| 65 |
virtual QPoint getGlobalCursorPosition() const; |
| 66 |
virtual void grabKeyboardFocus(); |
| 67 |
virtual QPointF getPosition() const; |
| 68 |
virtual QRectF getGeometry() const; |
| 69 |
virtual void showSnippingArea(); |
| 70 |
QRect getCaptureArea() const; |
| 71 |
QRect getGlobalCaptureArea() const; |
| 72 |
|
| 73 |
private: |
| 74 |
QRect mCaptureArea; |
| 75 |
QSharedPointer<IConfig> mConfig; |
| 76 |
QPixmap *mBackground; |
| 77 |
SnippingAreaResizer *mResizer; |
| 78 |
SnippingAreaSelector *mSelector; |
| 79 |
SnippingAreaSelectorInfoText *mSelectorInfoText; |
| 80 |
SnippingAreaResizerInfoText *mResizerInfoText; |
| 81 |
bool mIsSwitchPressed; |
| 82 |
QTimer *mTimer; |
| 83 |
int mUnselectedRegionAlpha; |
| 84 |
QPointF mPosition; |
| 85 |
|
| 86 |
void setBackgroundImage(const QPixmap &background); |
| 87 |
void clearBackgroundImage(); |
| 88 |
void finishSelection(); |
| 89 |
|
| 90 |
private slots: |
| 91 |
void updateCapturedArea(const QRectF &rect); |
| 92 |
void updateCursor(const QCursor &cursor); |
| 93 |
void switchToResizer(const QPointF &pos); |
| 94 |
void cancelSelection(); |
| 95 |
bool isResizerSwitchRequired() const; |
| 96 |
void startTimeout(); |
| 97 |
void stopTimeout(); |
| 98 |
void updatePosition(); |
| 99 |
}; |
| 100 |
|
| 101 |
#endif |