KShare/cropeditor/cropscene.hpp
ArsenArsen a2b973d34e This commit contains fixes and a broken attempt to make drawing.
Segfaults are real on this one. Basically, when I call this virtual method on a field which containts a pointer to a derived class from a pure virtual one the program segfaults. Please help.
2017-04-29 17:35:42 +02:00

47 lines
1.1 KiB
C++

#ifndef CROPSCENE_HPP
#define CROPSCENE_HPP
#include <QGraphicsRectItem>
#include <QGraphicsScene>
#include <QGraphicsSceneContextMenuEvent>
#include <QGraphicsSceneMouseEvent>
#include <QKeyEvent>
class CropScene;
#include <cropeditor/drawing/drawitem.hpp>
class CropScene : public QGraphicsScene
{
Q_OBJECT
public:
CropScene(QObject *parent);
QPen pen();
QBrush brush();
void setDrawingSelection(DrawItem *drawAction);
signals:
void closedWithRect(QRect rect);
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) override;
void contextMenuEvent(QGraphicsSceneContextMenuEvent *e) override;
void keyReleaseEvent(QKeyEvent *e) override;
private:
void addDrawingAction(QMenu &menu, DrawItem *item);
void done();
QFlags<Qt::MouseButton> prevButtons;
QGraphicsRectItem *rect = nullptr;
QPointF initPos;
QPen _pen;
QBrush _brush;
QGraphicsPolygonItem *polyItem = nullptr;
DrawItem *drawingSelection = nullptr;
};
#endif // CROPSCENE_HPP