A keyboard input focus for class VSimpleCurve.
--HG-- branch : develop
This commit is contained in:
parent
e4ee400903
commit
58ed043b1b
|
@ -953,6 +953,7 @@ VSimpleCurve *VToolRotation::InitCurve(quint32 id, VContainer *data, GOType curv
|
||||||
curve->SetType(curveType);
|
curve->SetType(curveType);
|
||||||
connect(curve, &VSimpleCurve::Selected, this, &VToolRotation::ObjectSelected);
|
connect(curve, &VSimpleCurve::Selected, this, &VToolRotation::ObjectSelected);
|
||||||
connect(curve, &VSimpleCurve::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
|
connect(curve, &VSimpleCurve::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
|
||||||
|
connect(curve, &VSimpleCurve::Delete, this, &VToolRotation::DeleteFromLabel);
|
||||||
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
|
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
|
||||||
rObjects.insert(id, curve);
|
rObjects.insert(id, curve);
|
||||||
return curve;
|
return curve;
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
|
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||||
|
void Delete();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
|
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
||||||
|
@ -44,6 +45,7 @@ VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternU
|
||||||
this->setBrush(QBrush(Qt::NoBrush));
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -155,6 +157,20 @@ void VSimpleCurve::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
emit ShowContextMenu(event);
|
emit ShowContextMenu(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::keyReleaseEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Delete:
|
||||||
|
emit Delete();
|
||||||
|
return; //Leave this method immediately after call!!!
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
QGraphicsPathItem::keyReleaseEvent ( event );
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimpleCurve::ShowPath()
|
void VSimpleCurve::ShowPath()
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,6 @@ signals:
|
||||||
*/
|
*/
|
||||||
void Choosed(quint32 id);
|
void Choosed(quint32 id);
|
||||||
void Selected(bool selected, quint32 id);
|
void Selected(bool selected, quint32 id);
|
||||||
void Delete();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void CurveChoosed();
|
void CurveChoosed();
|
||||||
|
@ -70,6 +69,7 @@ protected:
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VSimpleCurve)
|
Q_DISABLE_COPY(VSimpleCurve)
|
||||||
|
|
|
@ -64,7 +64,6 @@ signals:
|
||||||
*/
|
*/
|
||||||
void Choosed(quint32 id);
|
void Choosed(quint32 id);
|
||||||
void Selected(bool selected, quint32 id);
|
void Selected(bool selected, quint32 id);
|
||||||
void Delete();
|
|
||||||
void NameChangedPosition(const QPointF &pos, quint32 id);
|
void NameChangedPosition(const QPointF &pos, quint32 id);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user