@@ -43,6 +43,8 private: | |||||
43 | spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl; |
|
43 | spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl; | |
44 |
|
44 | |||
45 | private slots: |
|
45 | private slots: | |
|
46 | /// Slot called when right clicking on the graph (displays a menu) | |||
|
47 | void onGraphMenuRequested(const QPoint &pos) noexcept; | |||
46 |
|
48 | |||
47 | void onRangeChanged(const QCPRange &t1, const QCPRange &t2); |
|
49 | void onRangeChanged(const QCPRange &t1, const QCPRange &t2); | |
48 |
|
50 |
@@ -53,6 +53,11 VisualizationGraphWidget::VisualizationGraphWidget(const QString &name, QWidget | |||||
53 | connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>( |
|
53 | connect(ui->widget->xAxis, static_cast<void (QCPAxis::*)(const QCPRange &, const QCPRange &)>( | |
54 | &QCPAxis::rangeChanged), |
|
54 | &QCPAxis::rangeChanged), | |
55 | this, &VisualizationGraphWidget::onRangeChanged); |
|
55 | this, &VisualizationGraphWidget::onRangeChanged); | |
|
56 | ||||
|
57 | // Activates menu when right clicking on the graph | |||
|
58 | ui->widget->setContextMenuPolicy(Qt::CustomContextMenu); | |||
|
59 | connect(ui->widget, &QCustomPlot::customContextMenuRequested, this, | |||
|
60 | &VisualizationGraphWidget::onGraphMenuRequested); | |||
56 | } |
|
61 | } | |
57 |
|
62 | |||
58 |
|
63 | |||
@@ -96,6 +101,16 QString VisualizationGraphWidget::name() const | |||||
96 | return ui->graphNameLabel->text(); |
|
101 | return ui->graphNameLabel->text(); | |
97 | } |
|
102 | } | |
98 |
|
103 | |||
|
104 | void VisualizationGraphWidget::onGraphMenuRequested(const QPoint &pos) noexcept | |||
|
105 | { | |||
|
106 | QMenu graphMenu{}; | |||
|
107 | ||||
|
108 | ||||
|
109 | if (!graphMenu.isEmpty()) { | |||
|
110 | graphMenu.exec(mapToGlobal(pos)); | |||
|
111 | } | |||
|
112 | } | |||
|
113 | ||||
99 | void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2) |
|
114 | void VisualizationGraphWidget::onRangeChanged(const QCPRange &t1, const QCPRange &t2) | |
100 | { |
|
115 | { | |
101 |
|
116 |
General Comments 0
You need to be logged in to leave comments.
Login now