From: Soeren Apel Date: Mon, 13 Jul 2020 12:01:12 +0000 (+0200) Subject: Fix #1567 by showing a custom text for the minimum range's value X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6275a6681d2f6fc4200c53a9e576cd0f0e07837f;p=pulseview.git Fix #1567 by showing a custom text for the minimum range's value --- diff --git a/pv/binding/device.cpp b/pv/binding/device.cpp index f84c1aae..084d4651 100644 --- a/pv/binding/device.cpp +++ b/pv/binding/device.cpp @@ -92,7 +92,9 @@ Device::Device(shared_ptr configurable) : break; case SR_CONF_LIMIT_FRAMES: - bind_int(name, "", "", pair(0, 1000000), get, set); + // Value 0 means that there is no limit + bind_int(name, "", "", pair(0, 1000000), get, set, + tr("No Limit")); break; case SR_CONF_PATTERN_MODE: @@ -182,13 +184,13 @@ void Device::bind_enum(const QString &name, const QString &desc, } void Device::bind_int(const QString &name, const QString &desc, QString suffix, - optional< pair > range, - Property::Getter getter, Property::Setter setter) + optional< pair > range, Property::Getter getter, + Property::Setter setter, QString special_value_text) { assert(configurable_); properties_.push_back(shared_ptr(new Int(name, desc, suffix, - range, getter, setter))); + range, getter, setter, special_value_text))); } QString Device::print_timebase(Glib::VariantBase gvar) diff --git a/pv/binding/device.hpp b/pv/binding/device.hpp index 9f5daf57..30d89ddd 100644 --- a/pv/binding/device.hpp +++ b/pv/binding/device.hpp @@ -62,7 +62,8 @@ private: function printer = print_gvariant); void bind_int(const QString &name, const QString &desc, QString suffix, boost::optional< pair > range, - prop::Property::Getter getter, prop::Property::Setter setter); + prop::Property::Getter getter, prop::Property::Setter setter, + QString special_value_text = ""); static QString print_timebase(Glib::VariantBase gvar); static QString print_vdiv(Glib::VariantBase gvar); diff --git a/pv/prop/bool.hpp b/pv/prop/bool.hpp index fd5744fe..310eec6f 100644 --- a/pv/prop/bool.hpp +++ b/pv/prop/bool.hpp @@ -29,7 +29,7 @@ namespace prop { class Bool : public Property { - Q_OBJECT; + Q_OBJECT public: Bool(QString name, QString desc, Getter getter, Setter setter); diff --git a/pv/prop/enum.hpp b/pv/prop/enum.hpp index 1434e7e9..8050bcdf 100644 --- a/pv/prop/enum.hpp +++ b/pv/prop/enum.hpp @@ -41,7 +41,7 @@ namespace prop { class Enum : public Property { - Q_OBJECT; + Q_OBJECT public: Enum(QString name, QString desc, diff --git a/pv/prop/int.cpp b/pv/prop/int.cpp index 3f29951b..c1b2d22a 100644 --- a/pv/prop/int.cpp +++ b/pv/prop/int.cpp @@ -35,14 +35,12 @@ using std::pair; namespace pv { namespace prop { -Int::Int(QString name, - QString desc, - QString suffix, - optional< pair > range, - Getter getter, - Setter setter) : +Int::Int(QString name, QString desc, QString suffix, + optional< pair > range, Getter getter, Setter setter, + QString special_value_text) : Property(name, desc, getter, setter), suffix_(suffix), + special_value_text_(special_value_text), range_(range), spin_box_(nullptr) { @@ -72,6 +70,7 @@ QWidget* Int::get_widget(QWidget *parent, bool auto_commit) spin_box_ = new QSpinBox(parent); spin_box_->setSuffix(suffix_); + spin_box_->setSpecialValueText(special_value_text_); const GVariantType *const type = g_variant_get_type(value); assert(type); diff --git a/pv/prop/int.hpp b/pv/prop/int.hpp index f6b7c2d1..1f6a64ca 100644 --- a/pv/prop/int.hpp +++ b/pv/prop/int.hpp @@ -35,12 +35,12 @@ namespace prop { class Int : public Property { - Q_OBJECT; + Q_OBJECT public: Int(QString name, QString desc, QString suffix, boost::optional< pair > range, - Getter getter, Setter setter); + Getter getter, Setter setter, QString special_value_text = ""); virtual ~Int() = default; @@ -53,7 +53,7 @@ private Q_SLOTS: void on_value_changed(int); private: - const QString suffix_; + const QString suffix_, special_value_text_; const boost::optional< pair > range_; Glib::VariantBase value_; diff --git a/pv/prop/property.hpp b/pv/prop/property.hpp index 4ce352e1..da1c260e 100644 --- a/pv/prop/property.hpp +++ b/pv/prop/property.hpp @@ -40,7 +40,7 @@ namespace prop { class Property : public QObject { - Q_OBJECT; + Q_OBJECT public: typedef function Getter; diff --git a/pv/prop/string.hpp b/pv/prop/string.hpp index 8282cb7f..3e303568 100644 --- a/pv/prop/string.hpp +++ b/pv/prop/string.hpp @@ -29,7 +29,7 @@ namespace prop { class String : public Property { - Q_OBJECT; + Q_OBJECT public: String(QString name, QString desc, Getter getter, Setter setter);