2017-04-23 15:05:48 +02:00
|
|
|
#ifndef CROPSCENE_HPP
|
|
|
|
#define CROPSCENE_HPP
|
|
|
|
|
|
|
|
#include <QGraphicsRectItem>
|
|
|
|
#include <QGraphicsScene>
|
2017-04-29 12:08:02 +02:00
|
|
|
#include <QGraphicsSceneContextMenuEvent>
|
2017-04-23 15:05:48 +02:00
|
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
2017-04-29 17:35:42 +02:00
|
|
|
class CropScene;
|
|
|
|
|
|
|
|
#include <cropeditor/drawing/drawitem.hpp>
|
|
|
|
|
2017-04-23 15:05:48 +02:00
|
|
|
class CropScene : public QGraphicsScene
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-05-01 11:28:54 +02:00
|
|
|
CropScene(QObject *parent, QPixmap *pixmap);
|
2017-04-29 23:00:32 +02:00
|
|
|
QPen &pen();
|
|
|
|
QBrush &brush();
|
2017-04-29 17:35:42 +02:00
|
|
|
void setDrawingSelection(DrawItem *drawAction);
|
2017-05-01 11:28:54 +02:00
|
|
|
QPixmap *pixmap()
|
|
|
|
{
|
|
|
|
return _pixmap;
|
|
|
|
}
|
2017-04-29 17:35:42 +02:00
|
|
|
|
2017-04-23 15:05:48 +02:00
|
|
|
signals:
|
|
|
|
void closedWithRect(QRect rect);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override;
|
2017-04-29 12:08:02 +02:00
|
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *e) override;
|
2017-04-23 15:05:48 +02:00
|
|
|
|
|
|
|
void keyReleaseEvent(QKeyEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2017-04-29 17:35:42 +02:00
|
|
|
void addDrawingAction(QMenu &menu, DrawItem *item);
|
2017-04-23 15:05:48 +02:00
|
|
|
void done();
|
2017-05-01 11:28:54 +02:00
|
|
|
QPixmap *_pixmap;
|
2017-04-23 15:05:48 +02:00
|
|
|
QFlags<Qt::MouseButton> prevButtons;
|
|
|
|
QGraphicsRectItem *rect = nullptr;
|
|
|
|
QPointF initPos;
|
2017-04-29 17:35:42 +02:00
|
|
|
QPen _pen;
|
|
|
|
QBrush _brush;
|
2017-04-26 22:00:13 +02:00
|
|
|
QGraphicsPolygonItem *polyItem = nullptr;
|
2017-04-29 17:35:42 +02:00
|
|
|
DrawItem *drawingSelection = nullptr;
|
2017-04-23 15:05:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CROPSCENE_HPP
|