Improve drawing experiance
This commit is contained in:
parent
99f9171951
commit
49d556569f
@ -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());
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ class LineItem : public DrawItem
|
||||
|
||||
private:
|
||||
QPainterPath *path = nullptr;
|
||||
QGraphicsPathItem *pathItem = nullptr;
|
||||
};
|
||||
|
||||
#endif // LINEITEM_HPP
|
||||
|
6
main.cpp
6
main.cpp
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user