2017-04-23 15:05:48 +02:00
|
|
|
#ifndef CROPSCENE_HPP
|
|
|
|
#define CROPSCENE_HPP
|
|
|
|
|
2017-05-05 23:59:39 +02:00
|
|
|
#include <QFont>
|
2017-04-23 15:05:48 +02:00
|
|
|
#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-05-02 19:49:33 +02:00
|
|
|
#include <QMenu>
|
2017-07-24 20:17:10 +02:00
|
|
|
#include <QMenuBar>
|
2017-05-02 19:49:33 +02:00
|
|
|
#include <functional>
|
2017-07-09 21:04:21 +02:00
|
|
|
#include <screenshotutil.hpp>
|
2017-04-29 17:35:42 +02:00
|
|
|
class CropScene;
|
|
|
|
|
|
|
|
#include <cropeditor/drawing/drawitem.hpp>
|
|
|
|
|
2017-05-05 23:59:39 +02:00
|
|
|
class CropScene : public QGraphicsScene {
|
2017-05-09 17:26:00 +02:00
|
|
|
Q_OBJECT
|
2017-06-14 23:34:58 +02:00
|
|
|
public:
|
2017-07-02 20:51:15 +02:00
|
|
|
CropScene(QObject *parent, QPixmap pixmap);
|
2017-05-09 17:26:00 +02:00
|
|
|
~CropScene();
|
|
|
|
QPen &pen();
|
|
|
|
QBrush &brush();
|
|
|
|
QFont &font();
|
|
|
|
void setDrawingSelection(QString name, std::function<DrawItem *()> drawAction);
|
2017-07-02 20:51:15 +02:00
|
|
|
QPixmap pixmap() {
|
2017-05-09 17:26:00 +02:00
|
|
|
return _pixmap;
|
|
|
|
}
|
2017-06-26 15:43:12 +02:00
|
|
|
QGraphicsPolygonItem *polyItm() {
|
|
|
|
return polyItem;
|
|
|
|
}
|
|
|
|
QGraphicsRectItem *selRect() {
|
|
|
|
return rect;
|
|
|
|
}
|
2017-07-12 00:59:38 +02:00
|
|
|
QGraphicsItem *whichItem(QPointF scenePos);
|
2017-06-29 19:09:39 +02:00
|
|
|
void hide();
|
|
|
|
void show();
|
|
|
|
void setVisible(bool visible);
|
2017-07-08 21:40:09 +02:00
|
|
|
QPointF cursorPosition() {
|
|
|
|
return cursorPos;
|
|
|
|
}
|
2017-05-09 17:26:00 +02:00
|
|
|
|
2017-06-14 23:34:58 +02:00
|
|
|
public slots:
|
2017-05-09 17:26:00 +02:00
|
|
|
void fontAsk();
|
|
|
|
|
2017-06-14 23:34:58 +02:00
|
|
|
signals:
|
2017-05-09 17:26:00 +02:00
|
|
|
void closedWithRect(QRect rect);
|
|
|
|
|
2017-06-14 23:34:58 +02:00
|
|
|
protected:
|
2017-05-09 17:26:00 +02:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override;
|
2017-06-28 22:26:18 +02:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *e) override;
|
2017-06-27 00:27:04 +02:00
|
|
|
void wheelEvent(QGraphicsSceneWheelEvent *event) override; // WHEEEEEEL
|
2017-05-09 17:26:00 +02:00
|
|
|
void keyReleaseEvent(QKeyEvent *e) override;
|
|
|
|
|
2017-07-25 01:16:56 +02:00
|
|
|
private slots:
|
|
|
|
void done(bool notEsc = true);
|
|
|
|
|
2017-06-14 23:34:58 +02:00
|
|
|
private:
|
2017-07-08 21:40:09 +02:00
|
|
|
void updateMag();
|
2017-06-27 00:27:04 +02:00
|
|
|
void initMagnifierGrid();
|
2017-07-25 01:16:56 +02:00
|
|
|
void addDrawingAction(QMenuBar *menu, QString name, QString icon, std::function<DrawItem *()> item);
|
2017-06-29 19:09:39 +02:00
|
|
|
bool fullscreen;
|
2017-07-08 21:40:09 +02:00
|
|
|
QPointF cursorPos;
|
2017-05-09 17:26:00 +02:00
|
|
|
std::function<DrawItem *()> drawingSelectionMaker;
|
|
|
|
QFlags<Qt::MouseButton> prevButtons;
|
2017-07-02 20:51:15 +02:00
|
|
|
QPixmap _pixmap;
|
2017-05-09 17:26:00 +02:00
|
|
|
QGraphicsRectItem *rect = nullptr;
|
2017-06-27 00:02:27 +02:00
|
|
|
QGraphicsPixmapItem *magnifier = nullptr;
|
|
|
|
QGraphicsRectItem *magnifierBox = nullptr;
|
|
|
|
QGraphicsTextItem *magnifierHint = nullptr;
|
|
|
|
QGraphicsRectItem *magnifierHintBox = nullptr;
|
2017-05-09 17:26:00 +02:00
|
|
|
QPointF initPos;
|
|
|
|
QPen _pen;
|
|
|
|
QBrush _brush;
|
|
|
|
QFont _font;
|
|
|
|
QGraphicsPolygonItem *polyItem = nullptr;
|
|
|
|
DrawItem *drawingSelection = nullptr;
|
2017-07-24 20:17:10 +02:00
|
|
|
QMenuBar *menu = nullptr;
|
|
|
|
QGraphicsProxyWidget *proxyMenu = nullptr;
|
2017-05-09 17:26:00 +02:00
|
|
|
QString drawingName = "None";
|
|
|
|
QAction *display;
|
2017-06-27 00:02:27 +02:00
|
|
|
QList<QGraphicsRectItem *> gridRectsX;
|
|
|
|
QList<QGraphicsRectItem *> gridRectsY;
|
2017-07-08 21:40:09 +02:00
|
|
|
QGraphicsPolygonItem *cursorItem = nullptr;
|
2017-07-29 23:58:09 +02:00
|
|
|
QGraphicsPixmapItem *hint
|
|
|
|
= new QGraphicsPixmapItem(screenshotutil::renderText(tr( //
|
|
|
|
"Press F1 to toggle this hint\n"
|
|
|
|
"\tHold Shift to slow the cursor down\n"
|
|
|
|
"\tCtrl+Drag a thing to move it around\n"
|
|
|
|
"\tAlt+Click a drawing to remove it\n"
|
|
|
|
"\tPress Return/Enter to finish\n"
|
|
|
|
"\tPress ESC to cancel\n"
|
|
|
|
"\tUse the menu bar to draw\n"
|
|
|
|
"\tNOTE: You must select 'Crop' before closing the editor\n"
|
|
|
|
"\tIf you do not it will not close."),
|
|
|
|
5,
|
|
|
|
QColor(0, 0, 0, 125),
|
|
|
|
Qt::white));
|
2017-04-23 15:05:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CROPSCENE_HPP
|