26 #include <libsigrokcxx/libsigrokcxx.hpp> 30 using boost::optional;
38 Int::Int(QString name, QString desc, QString suffix,
39 optional< pair<int64_t, int64_t> > range,
Getter getter,
Setter setter,
40 QString special_value_text) :
41 Property(name, desc, getter, setter),
43 special_value_text_(special_value_text),
51 int64_t range_min = 0;
52 uint64_t range_max = 0;
62 }
catch (
const sigrok::Error &
e) {
63 qWarning() << tr(
"Querying config key %1 resulted in %2").arg(
name_, e.what());
75 const GVariantType *
const type = g_variant_get_type(value);
78 if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) {
79 range_min = 0, range_max = UINT8_MAX;
80 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16)) {
81 range_min = INT16_MIN, range_max = INT16_MAX;
82 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16)) {
83 range_min = 0, range_max = UINT16_MAX;
84 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32)) {
85 range_min = INT32_MIN, range_max = INT32_MAX;
86 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32)) {
87 range_min = 0, range_max = UINT32_MAX;
88 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64)) {
89 range_min = INT64_MIN, range_max = INT64_MAX;
90 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64)) {
91 range_min = 0, range_max = UINT64_MAX;
102 range_min =
max(range_min, (int64_t)INT_MIN);
103 range_max =
min(range_max, (uint64_t)INT_MAX);
108 spin_box_->setRange((
int)range_min, (
int)range_max);
113 connect(
spin_box_, SIGNAL(valueChanged(
int)),
126 }
catch (
const sigrok::Error &
e) {
127 qWarning() << tr(
"Querying config key %1 resulted in %2").arg(
name_, e.what());
134 const GVariantType *
const type = g_variant_get_type(value);
139 if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) {
140 int_val = g_variant_get_byte(value);
141 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16)) {
142 int_val = g_variant_get_int16(value);
143 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16)) {
144 int_val = g_variant_get_uint16(value);
145 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32)) {
146 int_val = g_variant_get_int32(value);
147 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32)) {
148 int_val = g_variant_get_uint32(value);
149 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64)) {
150 int_val = g_variant_get_int64(value);
151 }
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64)) {
152 int_val = g_variant_get_uint64(value);
168 GVariant *new_value =
nullptr;
169 const GVariantType *
const type = g_variant_get_type(
value_.gobj());
172 if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
173 new_value = g_variant_new_byte(
spin_box_->value());
174 else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
175 new_value = g_variant_new_int16(
spin_box_->value());
176 else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
177 new_value = g_variant_new_uint16(
spin_box_->value());
178 else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
179 new_value = g_variant_new_int32(
spin_box_->value());
180 else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
181 new_value = g_variant_new_uint32(
spin_box_->value());
182 else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
183 new_value = g_variant_new_int64(
spin_box_->value());
184 else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
185 new_value = g_variant_new_uint64(
spin_box_->value());
193 value_ = Glib::VariantBase(new_value);
const QString special_value_text_
T value(details::expression_node< T > *n)
QWidget * get_widget(QWidget *parent, bool auto_commit)
T max(const T v0, const T v1)
T min(const T v0, const T v1)
void on_value_changed(int)
Int(QString name, QString desc, QString suffix, boost::optional< pair< int64_t, int64_t > > range, Getter getter, Setter setter, QString special_value_text="")
function< Glib::VariantBase()> Getter
const boost::optional< pair< int64_t, int64_t > > range_
function< void(Glib::VariantBase)> Setter