mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Mod code to drop 2 inden
- if (isReadOnly()) return; - if (dc.items(DiagramContent::All).isEmpty())
This commit is contained in:
@@ -341,14 +341,19 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isReadOnly())
|
if (isReadOnly()) return;
|
||||||
{
|
|
||||||
QPointF movement;
|
QPointF movement;
|
||||||
qreal top_position = 0;
|
qreal top_position = 0;
|
||||||
qreal left_position = 0;
|
qreal left_position = 0;
|
||||||
DiagramContent dc(this);
|
DiagramContent dc(this);
|
||||||
if (!dc.items(DiagramContent::All).isEmpty())
|
if (dc.items(DiagramContent::All).isEmpty())
|
||||||
{
|
{
|
||||||
|
event->ignore();
|
||||||
|
QGraphicsScene::keyPressEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma message("@TODO move code to new function")
|
#pragma message("@TODO move code to new function")
|
||||||
//Move item with the keyboard arrow
|
//Move item with the keyboard arrow
|
||||||
if(event->modifiers() == Qt::NoModifier)
|
if(event->modifiers() == Qt::NoModifier)
|
||||||
@@ -390,7 +395,6 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(event->modifiers() == Qt::AltModifier)
|
else if(event->modifiers() == Qt::AltModifier)
|
||||||
|
|
||||||
{
|
{
|
||||||
switch(event->key())
|
switch(event->key())
|
||||||
{
|
{
|
||||||
@@ -431,26 +435,39 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
else if(event->modifiers() == Qt::ControlModifier)
|
else if(event->modifiers() == Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
//Adjust the alignment of a texts group
|
//Adjust the alignment of a texts group
|
||||||
if(selectedItems().size() == 1 && selectedItems().first()->type() == QGraphicsItemGroup::Type)
|
if(selectedItems().size() == 1
|
||||||
|
&& selectedItems().first()->type()
|
||||||
|
== QGraphicsItemGroup::Type)
|
||||||
{
|
{
|
||||||
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(selectedItems().first()))
|
if(ElementTextItemGroup *etig =
|
||||||
|
dynamic_cast<ElementTextItemGroup *>
|
||||||
|
(selectedItems().first()))
|
||||||
{
|
{
|
||||||
if(event->key() == Qt::Key_Left && etig->alignment() != Qt::AlignLeft)
|
if(event->key() == Qt::Key_Left
|
||||||
undoStack().push(new AlignmentTextsGroupCommand(etig, Qt::AlignLeft));
|
&& etig->alignment() != Qt::AlignLeft)
|
||||||
|
undoStack().push(
|
||||||
|
new AlignmentTextsGroupCommand(
|
||||||
|
etig,
|
||||||
|
Qt::AlignLeft));
|
||||||
|
|
||||||
else if (event->key() == Qt::Key_Up && etig->alignment() != Qt::AlignVCenter)
|
else if (event->key() == Qt::Key_Up
|
||||||
undoStack().push(new AlignmentTextsGroupCommand(etig, Qt::AlignVCenter));
|
&& etig->alignment() != Qt::AlignVCenter)
|
||||||
|
undoStack().push(
|
||||||
|
new AlignmentTextsGroupCommand(
|
||||||
|
etig,
|
||||||
|
Qt::AlignVCenter));
|
||||||
|
|
||||||
else if (event->key() == Qt::Key_Right && etig->alignment() != Qt::AlignRight)
|
else if (event->key() == Qt::Key_Right
|
||||||
undoStack().push(new AlignmentTextsGroupCommand(etig, Qt::AlignRight));
|
&& etig->alignment() != Qt::AlignRight)
|
||||||
|
undoStack().push(
|
||||||
|
new AlignmentTextsGroupCommand(
|
||||||
|
etig,
|
||||||
|
Qt::AlignRight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
QGraphicsScene::keyPressEvent(event);
|
QGraphicsScene::keyPressEvent(event);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user