mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-20 07:14:13 +02:00
avoid that another action triggers while aborting operation
This commit is contained in:
@@ -801,6 +801,11 @@ void Diagram::clearEventInterface()
|
||||
}
|
||||
}
|
||||
|
||||
bool Diagram::eventInterfaceIsRunning() const
|
||||
{
|
||||
return m_event_interface && m_event_interface->isRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Diagram::conductorsAutonumName
|
||||
@return the name of autonum to use.
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ class Diagram : public QGraphicsScene
|
||||
// methods related to graphics items addition/removal on the diagram
|
||||
virtual void addItem (QGraphicsItem *item);
|
||||
virtual void removeItem (QGraphicsItem *item);
|
||||
bool hasEventInterface() const { return m_event_interface != nullptr; }
|
||||
bool eventInterfaceIsRunning() const;
|
||||
|
||||
// methods related to graphics options
|
||||
ExportProperties applyProperties(const ExportProperties &);
|
||||
|
||||
@@ -87,12 +87,14 @@ DiagramEventAddPaste::DiagramEventAddPaste(Diagram *diagram, const QPointF &star
|
||||
*/
|
||||
DiagramEventAddPaste::~DiagramEventAddPaste()
|
||||
{
|
||||
if (!m_finished) {
|
||||
if (!m_finished && m_diagram) {
|
||||
removeItems();
|
||||
m_finished = true;
|
||||
m_running = false;
|
||||
}
|
||||
if (m_status_bar) m_status_bar->clearMessage();
|
||||
if (m_status_bar) {
|
||||
m_status_bar->clearMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,13 +166,13 @@ void DiagramEventAddPaste::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (!m_running) return;
|
||||
|
||||
event->setAccepted(true);
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
moveTo(event->scenePos());
|
||||
commit();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
cancel();
|
||||
}
|
||||
event->setAccepted(true);
|
||||
}
|
||||
|
||||
void DiagramEventAddPaste::keyPressEvent(QKeyEvent *event)
|
||||
@@ -179,15 +181,15 @@ void DiagramEventAddPaste::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Escape:
|
||||
cancel();
|
||||
event->setAccepted(true);
|
||||
cancel();
|
||||
break;
|
||||
//Return and Enter drop the paste where it stands, so the whole
|
||||
//operation can be completed without a mouse.
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
commit();
|
||||
event->setAccepted(true);
|
||||
commit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -733,7 +733,7 @@ void DiagramView::keyPressEvent(QKeyEvent *e)
|
||||
//way off the canvas for someone working without a mouse.
|
||||
//Escape steps back out: first it drops the selection, then it
|
||||
//hands focus to the next widget.
|
||||
if (m_diagram && m_diagram->hasEventInterface()) {
|
||||
if (m_diagram && m_diagram->eventInterfaceIsRunning()) {
|
||||
QGraphicsView::keyPressEvent(e); // let the active tool see it
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user