mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Light change in user interface
When mouse over a element, coonductor, text, the graphic symbol draw his bounding box. and draw a tooltip with his name For conductor the conductor size change. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3490 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
6f23bea143
commit
e2f6e232ee
@ -44,6 +44,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
|||||||
QGraphicsPathItem(0, parent_diagram),
|
QGraphicsPathItem(0, parent_diagram),
|
||||||
terminal1(p1),
|
terminal1(p1),
|
||||||
terminal2(p2),
|
terminal2(p2),
|
||||||
|
bMouseOver(false),
|
||||||
destroyed_(false),
|
destroyed_(false),
|
||||||
text_item(0),
|
text_item(0),
|
||||||
segments(NULL),
|
segments(NULL),
|
||||||
@ -444,6 +445,10 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if mouse over conductor change size
|
||||||
|
if ( bMouseOver ) conductor_pen.setWidthF(3.0);
|
||||||
|
else conductor_pen.setWidthF(1.0);
|
||||||
|
|
||||||
// affectation du QPen et de la QBrush modifies au QPainter
|
// affectation du QPen et de la QBrush modifies au QPainter
|
||||||
qp -> setBrush(conductor_brush);
|
qp -> setBrush(conductor_brush);
|
||||||
QPen final_conductor_pen = conductor_pen;
|
QPen final_conductor_pen = conductor_pen;
|
||||||
@ -687,9 +692,8 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
segments_squares_scale_ = 2.0;
|
segments_squares_scale_ = 2.0;
|
||||||
if (isSelected()) {
|
bMouseOver = true;
|
||||||
update();
|
update();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -699,9 +703,8 @@ void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
|||||||
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
segments_squares_scale_ = 1.0;
|
segments_squares_scale_ = 1.0;
|
||||||
if (isSelected()) {
|
update();
|
||||||
update();
|
bMouseOver = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,6 +130,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|
||||||
|
bool bMouseOver;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Functional properties
|
/// Functional properties
|
||||||
ConductorProperties properties_;
|
ConductorProperties properties_;
|
||||||
|
@ -30,7 +30,9 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren
|
|||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
rotate_by_user_(false)
|
rotate_by_user_(false)
|
||||||
{}
|
{
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@ -201,3 +203,40 @@ void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element
|
||||||
|
change bMouseOver to true (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
bMouseOver = true;
|
||||||
|
QString str_ToolTip = toPlainText();
|
||||||
|
setToolTip( str_ToolTip );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element leave the position
|
||||||
|
change bMouseOver to false(used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
//qDebug() << "Leave mouse over";
|
||||||
|
bMouseOver = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do nothing default function .
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void ConductorTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
QGraphicsTextItem::hoverMoveEvent(e);
|
||||||
|
}
|
||||||
|
@ -57,6 +57,11 @@ class ConductorTextItem : public DiagramTextItem {
|
|||||||
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
|
||||||
QGraphicsTextItem(parent, parent_diagram),
|
QGraphicsTextItem(parent, parent_diagram),
|
||||||
|
bMouseOver(false),
|
||||||
previous_text_(),
|
previous_text_(),
|
||||||
rotation_angle_(0.0),
|
rotation_angle_(0.0),
|
||||||
m_first_move (true)
|
m_first_move (true)
|
||||||
{
|
{
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,10 +45,12 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram)
|
|||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
|
||||||
QGraphicsTextItem(text, parent, parent_diagram),
|
QGraphicsTextItem(text, parent, parent_diagram),
|
||||||
|
bMouseOver(false),
|
||||||
previous_text_(text),
|
previous_text_(text),
|
||||||
rotation_angle_(0.0)
|
rotation_angle_(0.0)
|
||||||
{
|
{
|
||||||
build();
|
build();
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@ -211,6 +215,24 @@ void DiagramTextItem::setFontSize(int &s) {
|
|||||||
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
QGraphicsTextItem::paint(painter, option, widget);
|
QGraphicsTextItem::paint(painter, option, widget);
|
||||||
|
|
||||||
|
if ( bMouseOver ) {
|
||||||
|
painter -> save();
|
||||||
|
// Annulation des renderhints
|
||||||
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
// Dessin du cadre de selection en gris
|
||||||
|
QPen t;
|
||||||
|
t.setColor(Qt::gray);
|
||||||
|
t.setStyle(Qt::DashDotLine);
|
||||||
|
painter -> setPen(t);
|
||||||
|
// Le dessin se fait a partir du rectangle delimitant
|
||||||
|
//painter -> drawRoundRect(boundingRect().adjusted(1, 1, -1, -1), 10, 10);
|
||||||
|
painter -> drawRoundRect(boundingRect().adjusted(0, 0, 0, 0), 10, 10);
|
||||||
|
painter -> restore();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -366,3 +388,39 @@ void DiagramTextItem::edit() {
|
|||||||
editor->show();
|
editor->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element
|
||||||
|
change bMouseOver to true (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void DiagramTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
bMouseOver = true;
|
||||||
|
QString str_ToolTip = toPlainText();
|
||||||
|
setToolTip( str_ToolTip );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element leave the position
|
||||||
|
change bMouseOver to false (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void DiagramTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
//qDebug() << "Leave mouse over";
|
||||||
|
bMouseOver = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do nothing default function .
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void DiagramTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
QGraphicsTextItem::hoverMoveEvent(e);
|
||||||
|
}
|
||||||
|
@ -76,8 +76,13 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event);
|
||||||
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
|
||||||
virtual void applyRotation(const qreal &);
|
virtual void applyRotation(const qreal &);
|
||||||
|
|
||||||
|
bool bMouseOver;
|
||||||
signals:
|
signals:
|
||||||
/// signal emitted when the text field loses focus
|
/// signal emitted when the text field loses focus
|
||||||
void lostFocus();
|
void lostFocus();
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
||||||
QetGraphicsItem(parent),
|
QetGraphicsItem(parent),
|
||||||
internal_connections_(false),
|
internal_connections_(false),
|
||||||
must_highlight_(false)
|
must_highlight_(false),
|
||||||
|
bMouseOver(false)
|
||||||
{
|
{
|
||||||
Q_UNUSED(scene);
|
Q_UNUSED(scene);
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
|||||||
uuid_ = QUuid::createUuid();
|
uuid_ = QUuid::createUuid();
|
||||||
setZValue(10);
|
setZValue(10);
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,6 +107,8 @@ void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
|
|
||||||
// Dessin du cadre de selection si necessaire
|
// Dessin du cadre de selection si necessaire
|
||||||
if (isSelected()) drawSelection(painter, options);
|
if (isSelected()) drawSelection(painter, options);
|
||||||
|
|
||||||
|
if ( bMouseOver ) drawSelection(painter, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -540,3 +543,39 @@ bool comparPos(const Element *elmt1, const Element *elmt2) {
|
|||||||
return elmt1->y() <= elmt2->pos().y();
|
return elmt1->y() <= elmt2->pos().y();
|
||||||
return elmt1->pos().x() <= elmt2->pos().x();
|
return elmt1->pos().x() <= elmt2->pos().x();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element
|
||||||
|
change bMouseOver to true (used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void Element::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
|
||||||
|
bMouseOver = true;
|
||||||
|
QString str_ToolTip = name();
|
||||||
|
setToolTip( str_ToolTip );
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
When mouse over element leave the position
|
||||||
|
change bMouseOver to false(used in paint() function )
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
//qDebug() << "Leave mouse over";
|
||||||
|
bMouseOver = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do nothing default function .
|
||||||
|
@param e QGraphicsSceneHoverEvent
|
||||||
|
*/
|
||||||
|
void Element::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
QGraphicsItem::hoverMoveEvent(e);
|
||||||
|
}
|
||||||
|
@ -186,6 +186,14 @@ class Element : public QetGraphicsItem {
|
|||||||
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void updatePixmap();
|
void updatePixmap();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
|
||||||
|
|
||||||
|
bool bMouseOver;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool comparPos(const Element * elmt1, const Element * elmt2);
|
bool comparPos(const Element * elmt1, const Element * elmt2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user