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);
|
||||
connect(curve, &VSimpleCurve::Selected, this, &VToolRotation::ObjectSelected);
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
|
||||
connect(curve, &VSimpleCurve::Delete, this, &VToolRotation::DeleteFromLabel);
|
||||
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
|
||||
rObjects.insert(id, curve);
|
||||
return curve;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
signals:
|
||||
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||
void Delete();
|
||||
|
||||
public slots:
|
||||
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <QDebug>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QKeyEvent>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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));
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
this->setAcceptHoverEvents(true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -155,6 +157,20 @@ void VSimpleCurve::contextMenuEvent(QGraphicsSceneContextMenuEvent *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()
|
||||
{
|
||||
|
|
|
@ -57,19 +57,19 @@ signals:
|
|||
*/
|
||||
void Choosed(quint32 id);
|
||||
void Selected(bool selected, quint32 id);
|
||||
void Delete();
|
||||
|
||||
public slots:
|
||||
void CurveChoosed();
|
||||
void CurveSelected(bool selected);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverEnterEvent ( 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 void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VSimpleCurve)
|
||||
|
|
|
@ -64,7 +64,6 @@ signals:
|
|||
*/
|
||||
void Choosed(quint32 id);
|
||||
void Selected(bool selected, quint32 id);
|
||||
void Delete();
|
||||
void NameChangedPosition(const QPointF &pos, quint32 id);
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in New Issue
Block a user