pv/dialogs/connect.h
pv/popups/deviceoptions.h
pv/popups/probes.h
+ pv/prop/bool.h
+ pv/prop/double.h
+ pv/prop/enum.h
+ pv/prop/int.h
+ pv/prop/property.h
+ pv/prop/string.h
pv/toolbars/samplingbar.h
pv/view/cursor.h
pv/view/decodesignal.h
{
}
-QWidget* Bool::get_widget(QWidget *parent)
+QWidget* Bool::get_widget(QWidget *parent, bool auto_commit)
{
if (_check_box)
return _check_box;
g_variant_unref(value);
}
+ if (auto_commit)
+ connect(_check_box, SIGNAL(stateChanged(int)),
+ this, SLOT(on_state_changed(int)));
+
return _check_box;
}
_check_box->checkState() == Qt::Checked));
}
+void Bool::on_state_changed(int)
+{
+ commit();
+}
+
} // prop
} // pv
class Bool : public Property
{
+ Q_OBJECT;
+
public:
Bool(QString name, Getter getter, Setter setter);
virtual ~Bool();
- QWidget* get_widget(QWidget *parent);
+ QWidget* get_widget(QWidget *parent, bool auto_commit);
bool labeled_widget() const;
void commit();
+private slots:
+ void on_state_changed(int);
+
private:
QCheckBox *_check_box;
};
{
}
-QWidget* Double::get_widget(QWidget *parent)
+QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
{
if (_spin_box)
return _spin_box;
g_variant_unref(value);
}
+ if (auto_commit)
+ connect(_spin_box, SIGNAL(valueChanged(double)),
+ this, SLOT(on_value_changed(double)));
+
return _spin_box;
}
_setter(g_variant_new_double(_spin_box->value()));
}
+void Double::on_value_changed(double)
+{
+ commit();
+}
+
} // prop
} // pv
class Double : public Property
{
+ Q_OBJECT
+
public:
Double(QString name, int decimals, QString suffix,
boost::optional< std::pair<double, double> > range,
virtual ~Double();
- QWidget* get_widget(QWidget *parent);
+ QWidget* get_widget(QWidget *parent, bool auto_commit);
void commit();
+private slots:
+ void on_value_changed(double);
+
private:
const int _decimals;
const QString _suffix;
g_variant_unref(_values[i].first);
}
-QWidget* Enum::get_widget(QWidget *parent)
+QWidget* Enum::get_widget(QWidget *parent, bool auto_commit)
{
if (_selector)
return _selector;
g_variant_unref(value);
+ if (auto_commit)
+ connect(_selector, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_current_item_changed(int)));
+
return _selector;
}
_setter((GVariant*)_selector->itemData(index).value<void*>());
}
+void Enum::on_current_item_changed(int)
+{
+ commit();
+}
+
} // prop
} // pv
class Enum : public Property
{
+ Q_OBJECT;
+
public:
Enum(QString name, std::vector<std::pair<GVariant*, QString> > values,
Getter getter, Setter setter);
virtual ~Enum();
- QWidget* get_widget(QWidget *parent);
+ QWidget* get_widget(QWidget *parent, bool auto_commit);
void commit();
+private slots:
+ void on_current_item_changed(int);
+
private:
const std::vector< std::pair<GVariant*, QString> > _values;
{
}
-QWidget* Int::get_widget(QWidget *parent)
+QWidget* Int::get_widget(QWidget *parent, bool auto_commit)
{
if (_spin_box)
return _spin_box;
g_variant_unref(value);
}
+ if (auto_commit)
+ connect(_spin_box, SIGNAL(valueChanged(int)),
+ this, SLOT(on_value_changed(int)));
+
return _spin_box;
}
_setter(g_variant_new_int64(_spin_box->value()));
}
+void Int::on_value_changed(int)
+{
+ commit();
+}
+
} // prop
} // pv
class Int : public Property
{
+ Q_OBJECT;
+
public:
Int(QString name, QString suffix,
boost::optional< std::pair<int64_t, int64_t> > range,
virtual ~Int();
- QWidget* get_widget(QWidget *parent);
+ QWidget* get_widget(QWidget *parent, bool auto_commit);
void commit();
+private slots:
+ void on_value_changed(int);
+
private:
const QString _suffix;
const boost::optional< std::pair<int64_t, int64_t> > _range;
namespace pv {
namespace prop {
-class Property
+class Property : public QObject
{
+ Q_OBJECT;
+
public:
typedef boost::function<GVariant* ()> Getter;
typedef boost::function<void (GVariant*)> Setter;
public:
const QString& name() const;
- virtual QWidget* get_widget(QWidget *parent) = 0;
+ virtual QWidget* get_widget(QWidget *parent,
+ bool auto_commit = false) = 0;
virtual bool labeled_widget() const;
virtual void commit() = 0;
{
}
-QWidget* String::get_widget(QWidget *parent)
+QWidget* String::get_widget(QWidget *parent, bool auto_commit)
{
if (_line_edit)
return _line_edit;
g_variant_unref(value);
}
+ if (auto_commit)
+ connect(_line_edit, SIGNAL(textEdited(const QString&)),
+ this, SLOT(on_text_edited(const QString&)));
+
return _line_edit;
}
_setter(g_variant_new_string(ba.data()));
}
+void String::on_text_edited(const QString&)
+{
+ commit();
+}
+
} // prop
} // pv
class String : public Property
{
+ Q_OBJECT;
+
public:
String(QString name, Getter getter, Setter setter);
- QWidget* get_widget(QWidget *parent);
+ QWidget* get_widget(QWidget *parent, bool auto_commit);
void commit();
+private slots:
+ void on_text_edited(const QString&);
+
private:
QLineEdit *_line_edit;
};