diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index 26eaf2f81..87d7cc706 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -607,6 +607,71 @@ void RotateElementsCommand::redo() } +RotateFineElementsCommand::RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent) : +ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent) +{ + m_items = scene->selectedItems(); +} + +/** + @brief RotateFineElementsCommand::undo +*/ +void RotateFineElementsCommand::undo() +{ + for (QGraphicsItem *item : m_items) + { + if (item->type() == PartLine::Type) { + PartLine* line = qgraphicsitem_cast(item); + line->setRotation(-5); + } + else if (item->type() == PartPolygon::Type) { + PartPolygon* poly = qgraphicsitem_cast(item); + poly->setRotation(-5); + } + else if (item->type() == PartText::Type) { + PartText* text = qgraphicsitem_cast(item); + text->setRotation(-5); + } + else if (item->type() == PartDynamicTextField::Type) { + PartDynamicTextField* dyntext = qgraphicsitem_cast(item); + dyntext->setRotation(-5); + } + else { + //item->setRotation(-5); + } + } +} + +/** + @brief RotateFineElementsCommand::redo +*/ +void RotateFineElementsCommand::redo() +{ + for (QGraphicsItem *item : m_items) + { + if (item->type() == PartLine::Type) { + PartLine* line = qgraphicsitem_cast(item); + line->setRotation(+5); + } + else if (item->type() == PartPolygon::Type) { + PartPolygon* poly = qgraphicsitem_cast(item); + poly->setRotation(+5); + } + else if (item->type() == PartText::Type) { + PartText* text = qgraphicsitem_cast(item); + text->setRotation(+5); + } + else if (item->type() == PartDynamicTextField::Type) { + PartDynamicTextField* dyntext = qgraphicsitem_cast(item); + dyntext->setRotation(+5); + } + else { + //item->setRotation(+5); + } + } +} + + MirrorElementsCommand::MirrorElementsCommand(ElementScene *scene, QUndoCommand *parent) : ElementEditionCommand(QObject::tr("Miroir de sélection", "undo caption"), scene, nullptr, parent) { diff --git a/sources/editor/editorcommands.h b/sources/editor/editorcommands.h index 23c6de8d0..7cb387804 100644 --- a/sources/editor/editorcommands.h +++ b/sources/editor/editorcommands.h @@ -265,6 +265,20 @@ private: }; +class RotateFineElementsCommand : public ElementEditionCommand +{ + +public: + RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr); + void undo() override; + void redo() override; + +private: + ElementScene *m_scene =nullptr; + QList m_items; + +}; + class MirrorElementsCommand : public ElementEditionCommand { public: diff --git a/sources/editor/ui/qetelementeditor.cpp b/sources/editor/ui/qetelementeditor.cpp index fc8a226d4..4b510af21 100644 --- a/sources/editor/ui/qetelementeditor.cpp +++ b/sources/editor/ui/qetelementeditor.cpp @@ -1002,6 +1002,10 @@ void QETElementEditor::setupActions() ui->m_rotate_action -> setShortcut(Qt::Key_Space); connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));}); + //Rotate Fine action = rotate with smaller inkrement + ui->m_rotateFine_action -> setShortcut(Qt::CTRL | Qt::Key_Space); + connect(ui->m_rotateFine_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateFineElementsCommand(this->elementScene()));}); + //Flip action ui->m_flip_action -> setShortcut(Qt::Key_F); connect(ui->m_flip_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new FlipElementsCommand(this->elementScene()));}); @@ -1076,6 +1080,7 @@ void QETElementEditor::updateAction() << ui->m_copy_action << ui->m_delete_action << ui->m_rotate_action + << ui->m_rotateFine_action << ui->m_flip_action << ui->m_mirror_action; auto items_selected = !m_read_only && m_elmt_scene->selectedItems().count(); diff --git a/sources/editor/ui/qetelementeditor.ui b/sources/editor/ui/qetelementeditor.ui index 9e9d761e7..90cf36118 100644 --- a/sources/editor/ui/qetelementeditor.ui +++ b/sources/editor/ui/qetelementeditor.ui @@ -77,6 +77,7 @@ + @@ -495,6 +496,15 @@ Rotation + + + + :/ico/16x16/orientations.png:/ico/16x16/orientations.png + + + Fine-Rotation + +