Improve drawing experiance

This commit is contained in:
ArsenArsen 2017-04-29 23:20:08 +02:00
parent 99f9171951
commit 49d556569f
3 changed files with 13 additions and 5 deletions

View File

@ -9,15 +9,20 @@ LineItem::~LineItem()
delete path;
}
void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *)
void LineItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene)
{
if (path == nullptr)
{
path = new QPainterPath(e->scenePos());
pathItem = scene->addPath(*path, scene->pen(), scene->brush());
}
else
{
path->lineTo(e->scenePos());
pathItem->setPath(*path);
}
}
void LineItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *scene)
void LineItem::mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *)
{
scene->addPath(*path, scene->pen(), scene->brush());
}

View File

@ -18,6 +18,7 @@ class LineItem : public DrawItem
private:
QPainterPath *path = nullptr;
QGraphicsPathItem *pathItem = nullptr;
};
#endif // LINEITEM_HPP

View File

@ -1,7 +1,7 @@
#include "mainwindow.hpp"
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QTimer>
#include <QtGlobal>
#include <stdio.h>
@ -51,6 +51,8 @@ int main(int argc, char *argv[])
MainWindow w;
w.show();
if (parser.isSet(h)) w.hide();
QTimer::singleShot(0, [&] {
if (parser.isSet(h)) w.hide();
});
return a.exec();
}