From 6a4f292ae29fbf2bc45df9fa76372c01cda394ba Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Mon, 12 Apr 2021 10:35:44 +0100 Subject: [PATCH] Use customContextMenu for changing the display type --- app/widget/slider/rationalslider.cpp | 1 + app/widget/slider/sliderbase.h | 2 ++ app/widget/slider/sliderlabel.cpp | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/widget/slider/rationalslider.cpp b/app/widget/slider/rationalslider.cpp index 87073187d..cebb193c1 100644 --- a/app/widget/slider/rationalslider.cpp +++ b/app/widget/slider/rationalslider.cpp @@ -32,6 +32,7 @@ RationalSlider::RationalSlider(QWidget *parent) : connect(this, SIGNAL(ValueChanged(QVariant)), this, SLOT(ConvertValue(QVariant))); connect(this, &SliderBase::changeRationalDisplayType, this, &RationalSlider::changeDisplayType); connect(Core::instance(), &Core::TimecodeDisplayChanged, this, &RationalSlider::ChangeTimecodeDisplayType); + connect(SliderBase::label(), &SliderLabel::customContextMenuRequested, this, &RationalSlider::changeDisplayType); SetDisplayType(display_type_); diff --git a/app/widget/slider/sliderbase.h b/app/widget/slider/sliderbase.h index c28fc48a7..e3475efdf 100644 --- a/app/widget/slider/sliderbase.h +++ b/app/widget/slider/sliderbase.h @@ -85,6 +85,8 @@ protected: void UpdateLabel(const QVariant& v); + QLabel* label() { return label_; } + virtual double AdjustDragDistanceInternal(const double& start, const double& drag); virtual QString ValueToString(const QVariant &v) = 0; diff --git a/app/widget/slider/sliderlabel.cpp b/app/widget/slider/sliderlabel.cpp index 276a2bc75..fbccd3c53 100644 --- a/app/widget/slider/sliderlabel.cpp +++ b/app/widget/slider/sliderlabel.cpp @@ -47,6 +47,9 @@ SliderLabel::SliderLabel(QWidget *parent) : // Allow users to tab to this widget setFocusPolicy(Qt::TabFocus); + + // Add ccustom context menu + setContextMenuPolicy(Qt::CustomContextMenu); } void SliderLabel::mousePressEvent(QMouseEvent *e) @@ -57,8 +60,6 @@ void SliderLabel::mousePressEvent(QMouseEvent *e) } else { emit LabelPressed(); } - } else if (e->button() == Qt::RightButton) { - emit ChangeSliderType(); } }