Make buttons toggleable by single clicking

This commit is contained in:
xypwn
2020-04-04 14:07:16 +02:00
parent 5340635389
commit 7ade16be8b
20 changed files with 80 additions and 65 deletions

View File

@@ -5,6 +5,7 @@
#include "../Scene.h"
#include "../Logic.h"
#include "../Connector.h"
#include "ToggleButton.h"
#include "LightBulb.h"

View File

@@ -27,7 +27,7 @@ QPainterPath ToggleButton::symbolPainterPath(QRect limits)
return QPainterPath();
}
void ToggleButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void ToggleButton::partClickedEvent()
{
m_toggleState = !m_toggleState;
if(m_toggleState)
@@ -41,5 +41,4 @@ void ToggleButton::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
m_brushColorSelected = Qt::GlobalColor::red;
}
update();
Part::mouseDoubleClickEvent(event);
}

View File

@@ -14,9 +14,7 @@ public:
QPainterPath symbolPainterPath(QRect limits) override;
private:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
QPointF m_dragBeginPos;
void partClickedEvent() override;
bool m_toggleState = false;
};