diff --git a/ground/openpilotgcs/src/plugins/uploader/devicewidget.cpp b/ground/openpilotgcs/src/plugins/uploader/devicewidget.cpp index e3ca707b3..c22e548b0 100644 --- a/ground/openpilotgcs/src/plugins/uploader/devicewidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/devicewidget.cpp @@ -31,7 +31,6 @@ deviceWidget::deviceWidget(QWidget *parent) : { myDevice = new Ui_deviceWidget(); myDevice->setupUi(this); - devicePic = NULL; // Initialize pointer to null // Initialization of the Device icon display myDevice->verticalGroupBox_loaded->setVisible(false); @@ -54,18 +53,14 @@ void deviceWidget::showEvent(QShowEvent *event) Q_UNUSED(event) // Thit fitInView method should only be called now, once the // widget is shown, otherwise it cannot compute its values and - // the result is usually a ahrsbargraph that is way too small. - if (devicePic) - { - myDevice->gVDevice->fitInView(devicePic,Qt::KeepAspectRatio); - } + // the result is usually a ahrsbargraph that is way too small + myDevice->gVDevice->fitInView(devicePic.rect(),Qt::KeepAspectRatio); } void deviceWidget::resizeEvent(QResizeEvent* event) { Q_UNUSED(event); - if (devicePic) - myDevice->gVDevice->fitInView(devicePic, Qt::KeepAspectRatio); + myDevice->gVDevice->fitInView(devicePic.rect(), Qt::KeepAspectRatio); } @@ -92,31 +87,28 @@ void deviceWidget::populate() myDevice->lblDevName->setText(deviceDescriptorStruct::idToBoardName(id)); myDevice->lblHWRev->setText(QString(tr("HW Revision: "))+QString::number(id & 0x00FF, 16)); - devicePic = new QGraphicsSvgItem(); - devicePic->setSharedRenderer(new QSvgRenderer()); switch (id) { case 0x0101: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0101.svg")); - break; - case 0x0301: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0301.svg")); - break; - case 0x0401: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0401.svg")); - break; - case 0x0402: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0402.svg")); + devicePic.load("");//TODO break; case 0x0201: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0201.svg")); + devicePic.load("");//TODO + break; + case 0x0301: + devicePic.load("");//TODO + break; + case 0x0401: + devicePic.load(":/uploader/images/gcs-board-cc.png"); + break; + case 0x0402: + devicePic.load(":/uploader/images/gcs-board-cc3d.png"); break; default: break; } - devicePic->setElementId("device"); - myDevice->gVDevice->scene()->addItem(devicePic); - myDevice->gVDevice->setSceneRect(devicePic->boundingRect()); - myDevice->gVDevice->fitInView(devicePic,Qt::KeepAspectRatio); + myDevice->gVDevice->scene()->addPixmap(devicePic); + myDevice->gVDevice->setSceneRect(devicePic.rect()); + myDevice->gVDevice->fitInView(devicePic.rect(),Qt::KeepAspectRatio); bool r = m_dfu->devices[deviceID].Readable; bool w = m_dfu->devices[deviceID].Writable; diff --git a/ground/openpilotgcs/src/plugins/uploader/devicewidget.h b/ground/openpilotgcs/src/plugins/uploader/devicewidget.h index 202023d50..d2eab8e28 100644 --- a/ground/openpilotgcs/src/plugins/uploader/devicewidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/devicewidget.h @@ -64,7 +64,7 @@ private: DFUObject *m_dfu; QByteArray downloadedFirmware; QString filename; - QGraphicsSvgItem *devicePic; + QPixmap devicePic; QByteArray descriptionArray; void status(QString str, StatusIcon ic); bool populateBoardStructuredDescription(QByteArray arr); diff --git a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp index 4bf17e615..354cc0702 100644 --- a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.cpp @@ -32,15 +32,10 @@ runningDeviceWidget::runningDeviceWidget(QWidget *parent) : { myDevice = new Ui_runningDeviceWidget(); myDevice->setupUi(this); - devicePic = NULL; // Initialize pointer to null // Initialization of the Device icon display myDevice->devicePicture->setScene(new QGraphicsScene(this)); - /* - QPixmap pix = QPixmap(QString(":uploader/images/view-refresh.svg")); - myDevice->statusIcon->setPixmap(pix); - */ } @@ -50,15 +45,13 @@ void runningDeviceWidget::showEvent(QShowEvent *event) // Thit fitInView method should only be called now, once the // widget is shown, otherwise it cannot compute its values and // the result is usually a ahrsbargraph that is way too small. - if (devicePic) - myDevice->devicePicture->fitInView(devicePic,Qt::KeepAspectRatio); + myDevice->devicePicture->fitInView(devicePic.rect(),Qt::KeepAspectRatio); } void runningDeviceWidget::resizeEvent(QResizeEvent* event) { Q_UNUSED(event); - if (devicePic) - myDevice->devicePicture->fitInView(devicePic, Qt::KeepAspectRatio); + myDevice->devicePicture->fitInView(devicePic.rect(), Qt::KeepAspectRatio); } /** @@ -79,31 +72,29 @@ void runningDeviceWidget::populate() // DeviceID tells us what sort of HW we have detected: // display a nice icon: myDevice->devicePicture->scene()->clear(); - if (devicePic) - delete devicePic; - devicePic = new QGraphicsSvgItem(); - devicePic->setSharedRenderer(new QSvgRenderer()); switch (id) { case 0x0101: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0101.svg")); - break; - case 0x0301: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0301.svg")); - break; - case 0x0401: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0401.svg")); + devicePic.load("");//TODO break; case 0x0201: - devicePic->renderer()->load(QString(":/uploader/images/deviceID-0201.svg")); + devicePic.load("");//TODO + break; + case 0x0301: + devicePic.load("");//TODO + break; + case 0x0401: + devicePic.load(":/uploader/images/gcs-board-cc.png"); + break; + case 0x0402: + devicePic.load(":/uploader/images/gcs-board-cc3d.png"); break; default: break; } - devicePic->setElementId("device"); - myDevice->devicePicture->scene()->addItem(devicePic); - myDevice->devicePicture->setSceneRect(devicePic->boundingRect()); - myDevice->devicePicture->fitInView(devicePic,Qt::KeepAspectRatio); + myDevice->devicePicture->scene()->addPixmap(devicePic); + myDevice->devicePicture->setSceneRect(devicePic.rect()); + myDevice->devicePicture->fitInView(devicePic.rect(),Qt::KeepAspectRatio); QString serial = utilMngr->getBoardCPUSerial().toHex(); myDevice->CPUSerial->setText(serial); diff --git a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h index 05dd7f0dc..58e9583c1 100644 --- a/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/runningdevicewidget.h @@ -54,7 +54,7 @@ public: private: Ui_runningDeviceWidget *myDevice; int deviceID; - QGraphicsSvgItem *devicePic; + QPixmap devicePic; //void status(QString str, StatusIcon ic); diff --git a/ground/openpilotgcs/src/plugins/uploader/uploader.qrc b/ground/openpilotgcs/src/plugins/uploader/uploader.qrc index 083eab94d..5cec90aac 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploader.qrc +++ b/ground/openpilotgcs/src/plugins/uploader/uploader.qrc @@ -13,5 +13,7 @@ images/warning.svg images/error.svg images/deviceID-0402.svg + images/gcs-board-cc.png + images/gcs-board-cc3d.png