Make moving items possible

This commit is contained in:
ArsenArsen 2017-06-26 17:58:36 +02:00
parent 4b8b763024
commit 3bf1c9c4f7
2 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,6 @@
#include "cropscene.hpp" #include "cropscene.hpp"
#include <QColorDialog> #include <QColorDialog>
#include <QDebug>
#include <QFontDialog> #include <QFontDialog>
#include <QGraphicsPolygonItem> #include <QGraphicsPolygonItem>
#include <QGraphicsSceneContextMenuEvent> #include <QGraphicsSceneContextMenuEvent>
@ -103,6 +104,15 @@ void CropScene::fontAsk() {
void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
auto buttons = e->buttons(); auto buttons = e->buttons();
if (e->modifiers() & Qt::ControlModifier && buttons == Qt::LeftButton) {
QTransform stupidThing = views()[0]->transform();
auto item = itemAt(e->screenPos(), stupidThing);
if (item && item != polyItem && item != rect && item->zValue() != -1) {
QPointF delta = e->scenePos() - e->lastScenePos();
item->moveBy(delta.x(), delta.y());
}
return;
}
if (buttons == Qt::LeftButton || prevButtons == Qt::NoButton) { if (buttons == Qt::LeftButton || prevButtons == Qt::NoButton) {
if (drawingSelection) { if (drawingSelection) {
drawingSelection->mouseDragEvent(e, this); drawingSelection->mouseDragEvent(e, this);

View File

@ -30,12 +30,6 @@ RecordingFormats::RecordingFormats(formats::Recording f) {
iFormat = QImage::Format_RGB888; iFormat = QImage::Format_RGB888;
path = tmpDir.absoluteFilePath("res." + formats::recordingFormatName(f).toLower()); path = tmpDir.absoluteFilePath("res." + formats::recordingFormatName(f).toLower());
finalizer = [&] { finalizer = [&] {
qDebug() << "end";
try {
enc->end();
} catch (std::runtime_error e) {
qCritical() << "Encoder error: " << e.what();
}
delete enc; delete enc;
if (interrupt) { if (interrupt) {
tmpDir.removeRecursively(); tmpDir.removeRecursively();