Fix some stuff that I can't remember..

... Because I've litelary been debugging this for months.
This commit is contained in:
ArsenArsen 2017-10-17 20:09:38 +02:00
parent 6d92fe11ed
commit 821d11efe0
No known key found for this signature in database
GPG Key ID: 683D2F43B0CA4BD2
3 changed files with 15 additions and 8 deletions

View File

@ -188,6 +188,10 @@ void CropScene::setHighlight(QColor highlight) {
}
void CropScene::setDrawingSelection(QString name, std::function<DrawItem *()> drawAction) {
if (drawingSelection) {
delete drawingSelection;
drawingSelection = 0;
}
this->setFocus();
drawingSelectionMaker = drawAction;
drawingSelection = drawAction();
@ -195,6 +199,11 @@ void CropScene::setDrawingSelection(QString name, std::function<DrawItem *()> 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;

View File

@ -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());
}
}

View File

@ -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;
};