diff --git a/src/cropeditor/cropscene.cpp b/src/cropeditor/cropscene.cpp index 4ed9a47..c1c7fa0 100644 --- a/src/cropeditor/cropscene.cpp +++ b/src/cropeditor/cropscene.cpp @@ -188,6 +188,10 @@ void CropScene::setHighlight(QColor highlight) { } void CropScene::setDrawingSelection(QString name, std::function drawAction) { + if (drawingSelection) { + delete drawingSelection; + drawingSelection = 0; + } this->setFocus(); drawingSelectionMaker = drawAction; drawingSelection = drawAction(); @@ -195,6 +199,11 @@ void CropScene::setDrawingSelection(QString name, std::function dr display->setText(drawingName); if (drawingSelection) if (!drawingSelection->init(this)) setDrawingSelection(tr("None"), [] { return nullptr; }); + menu->adjustSize(); + auto screen = QApplication::primaryScreen(); + int w = screen->geometry().width(); + proxyMenu->setPos(views()[0]->mapToScene( + QPoint(screen->geometry().x() + (w - proxyMenu->boundingRect().width()) / 2, screen->geometry().y() + 100))); } QGraphicsItem *CropScene::whichItem(QPointF scenePos) { @@ -287,7 +296,7 @@ void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { if (item) item->moveBy(delta.x(), delta.y()); return; } - if (buttons == Qt::LeftButton || (prevButtons == Qt::NoButton && prevButtons != buttons)) { + if (buttons == Qt::LeftButton) { if (drawingSelection) { drawingSelection->mouseDragEvent(e, this); } else { @@ -323,10 +332,7 @@ void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { drawingRect = false; if (drawingSelection) { drawingSelection->mouseDragEndEvent(e, this); - delete drawingSelection; - drawingSelection = drawingSelectionMaker(); - if (drawingSelection) - if (!drawingSelection->init(this)) setDrawingSelection(tr("None"), [] { return nullptr; }); + setDrawingSelection(drawingName, drawingSelectionMaker); } else if (settings::settings().value("quickMode", false).toBool()) done(true); prevButtons = Qt::NoButton; diff --git a/src/cropeditor/drawing/bluritem.cpp b/src/cropeditor/drawing/bluritem.cpp index 4a99e8c..753a02e 100644 --- a/src/cropeditor/drawing/bluritem.cpp +++ b/src/cropeditor/drawing/bluritem.cpp @@ -24,7 +24,9 @@ void BlurItem::mouseDragEvent(QGraphicsSceneMouseEvent *, CropScene *scene) { } else { QPointF p = scene->cursorPosition(); rect->setRect(QRect(qMin(pos.x(), p.x()), qMin(pos.y(), p.y()), qAbs(pos.x() - p.x()), qAbs(pos.y() - p.y()))); - pixmap->setPixmap(scene->pixmap().copy(rect->rect().toRect())); + auto area = rect->rect(); + if (area.width() > 1 && area.height() > 1 && area.top() > 1 && area.left() > 1) + pixmap->setPixmap(scene->pixmap().copy(rect->rect().toRect())); pixmap->setPos(rect->rect().topLeft()); } } diff --git a/src/cropeditor/drawing/bluritem.hpp b/src/cropeditor/drawing/bluritem.hpp index 4e9bbef..43e876b 100644 --- a/src/cropeditor/drawing/bluritem.hpp +++ b/src/cropeditor/drawing/bluritem.hpp @@ -11,7 +11,6 @@ public: return "Blur"; } ~BlurItem() { - return; } bool init(CropScene *) override; @@ -21,7 +20,7 @@ public: private: QGraphicsBlurEffect *effect; QPointF pos; - QGraphicsRectItem *rect; + QGraphicsRectItem *rect = 0; QGraphicsPixmapItem *pixmap; };