/******************************************************************************* * * * Société de Transports de Montréal. * * 2013 * * * * Projet Zones Tests * * * * * * * *******************************************************************************/ /* Description: Affiche un bitmap d'une prise verte lorsque la connexion est etablie ou rouge lorsque la connexion est rompue. */ /* ************************************************************************** */ /* Revision: ### 20131024 JFM Verision d'origine. ### YYYYMMDD Description du besoin ou du bug Description du changement. */ #include "EthConnWidget.h" #include CEthConnWidget::CEthConnWidget(QString Label,QGraphicsItem *Parent) { setParentItem(Parent); mLabel = new QGraphicsTextItem(this); mEthOnPixmap = new QGraphicsPixmapItem(this); mEthONImage.load("./Images/connexion_vert.png"); mEthOffPixmap = new QGraphicsPixmapItem(this); mEthOFFImage.load("./Images/connexion_rouge.png"); mLabel->setPlainText(Label); mLabel->adjustSize(); EthOFF(); resize(25,25); } void CEthConnWidget::resizeEvent(QGraphicsSceneResizeEvent *event) { Q_UNUSED(event) mEthOnPixmap->setPixmap(QPixmap().fromImage(mEthONImage).scaled(boundingRect().width(),boundingRect().height())); mEthOffPixmap->setPixmap(QPixmap().fromImage(mEthOFFImage).scaled(boundingRect().width(),boundingRect().height())); //mLabel->setPos((boundingRect().width()/2) - ((QFontMetrics(mLabel->font()).width(mLabel->toPlainText())/2)),boundingRect().height()-10); mLabel->setPos((boundingRect().width()/2) - (mLabel->boundingRect().width()/2),mEthOnPixmap->boundingRect().bottom()-9); } void CEthConnWidget::EthOFF() { mEthOnPixmap->hide(); mEthOffPixmap->show(); } void CEthConnWidget::EthON() { mEthOnPixmap->show(); mEthOffPixmap->hide(); } void CEthConnWidget::SetEth(bool ON) { if(ON == true) EthON(); else EthOFF(); }