mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
element-editor: add rotation with smaller increments for "line", "polygon", "text" and "dynamic_text" with shortcut <Ctrl>+<Space>
This commit is contained in:
@@ -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<PartLine*>(item);
|
||||
line->setRotation(-5);
|
||||
}
|
||||
else if (item->type() == PartPolygon::Type) {
|
||||
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
||||
poly->setRotation(-5);
|
||||
}
|
||||
else if (item->type() == PartText::Type) {
|
||||
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
||||
text->setRotation(-5);
|
||||
}
|
||||
else if (item->type() == PartDynamicTextField::Type) {
|
||||
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(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<PartLine*>(item);
|
||||
line->setRotation(+5);
|
||||
}
|
||||
else if (item->type() == PartPolygon::Type) {
|
||||
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
||||
poly->setRotation(+5);
|
||||
}
|
||||
else if (item->type() == PartText::Type) {
|
||||
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
||||
text->setRotation(+5);
|
||||
}
|
||||
else if (item->type() == PartDynamicTextField::Type) {
|
||||
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(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)
|
||||
{
|
||||
|
||||
@@ -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<QGraphicsItem*> m_items;
|
||||
|
||||
};
|
||||
|
||||
class MirrorElementsCommand : public ElementEditionCommand
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
<addaction name="m_edit_author_action"/>
|
||||
<addaction name="m_edit_element_properties_action"/>
|
||||
<addaction name="m_rotate_action"/>
|
||||
<addaction name="m_rotateFine_action"/>
|
||||
<addaction name="m_mirror_action"/>
|
||||
<addaction name="m_flip_action"/>
|
||||
</widget>
|
||||
@@ -495,6 +496,15 @@
|
||||
<string>Rotation</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_rotateFine_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
<normaloff>:/ico/16x16/orientations.png</normaloff>:/ico/16x16/orientations.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fine-Rotation</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_mirror_action">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qelectrotech.qrc">
|
||||
|
||||
Reference in New Issue
Block a user