Commit aa070ca5 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add methods for better re-usability

parent baa73639
......@@ -39,8 +39,7 @@ SpecularDataCanvas::SpecularDataCanvas(QWidget* parent)
m_plot_canvas->setStatusLabelEnabled(true);
connect(m_plot_canvas->customPlot(), &QCustomPlot::mousePress, this,
&SpecularDataCanvas::onMousePress, Qt::UniqueConnection);
enableDeprecatedOnMousePress(true); // true for legacy reasons
}
void SpecularDataCanvas::setItem(SessionItem* intensityItem)
......@@ -64,6 +63,21 @@ QList<QAction*> SpecularDataCanvas::actionList()
return QList<QAction*>() << m_reset_view_action << m_save_plot_action;
}
QCustomPlot* SpecularDataCanvas::customPlot()
{
return m_plot_canvas->customPlot();
}
void SpecularDataCanvas::enableDeprecatedOnMousePress(bool b)
{
if (b)
connect(m_plot_canvas->customPlot(), &QCustomPlot::mousePress, this,
&SpecularDataCanvas::onMousePress, Qt::UniqueConnection);
else
disconnect(m_plot_canvas->customPlot(), &QCustomPlot::mousePress, this,
&SpecularDataCanvas::onMousePress);
}
void SpecularDataCanvas::onResetViewAction()
{
specularDataItem()->resetView();
......
......@@ -20,6 +20,7 @@
class SpecularDataItem;
class SpecularPlotCanvas;
class QCustomPlot;
class SpecularDataCanvas : public SessionItemWidget {
Q_OBJECT
......@@ -32,6 +33,15 @@ public:
QSize minimumSizeHint() const override;
QList<QAction*> actionList() override;
QCustomPlot* customPlot();
//! Enable or disable the onMousePress() handler.
//! For legacy reasons the onMousePress handler is enabled.
//! It is deprecated because of:
//! * mousepress is the wrong event to listen to for opening a context menu
//! * disables possibility to get context menu events for specific parts of the plot (e.g.
//! context menu for axis configuration)
void enableDeprecatedOnMousePress(bool b);
public slots:
void onResetViewAction();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment