From b6674f74bf0ccf22706d545e591de817826573bb 2017-09-11 09:44:38 From: Alexandre Leroux Date: 2017-09-11 09:44:38 Subject: [PATCH] Calls 'close graph' action when selecting close item in overlay --- diff --git a/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp b/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp index 30cf109..0df228c 100644 --- a/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp +++ b/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp @@ -90,6 +90,15 @@ struct VisualizationGraphRenderingDelegate::VisualizationGraphRenderingDelegateP // Inits "close button" in plot overlay m_ClosePixmap->setLayer(OVERLAY_LAYER); initClosePixmapStyle(*m_ClosePixmap); + + // Connects pixmap selection to graph widget closing + QObject::connect(m_ClosePixmap, &QCPItemPixmap::selectionChanged, + [&graphWidget](bool selected) { + if (selected) { + graphWidget.close(); + } + }); + // Inits graph name in plot overlay m_TitleText->setLayer(OVERLAY_LAYER); m_TitleText->setText(graphWidget.name()); diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index 537ec36..d81ec54 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -59,7 +59,7 @@ VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget // Set qcpplot properties : // - Drag (on x-axis) and zoom are enabled // - Mouse wheel on qcpplot is intercepted to determine the zoom orientation - ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); + ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectItems); ui->widget->axisRect()->setRangeDrag(Qt::Horizontal); // The delegate must be initialized after the ui as it uses the plot