pv/dialogs/about.cpp
pv/dialogs/connect.cpp
pv/dialogs/deviceoptions.cpp
+ pv/prop/bool.cpp
pv/prop/double.cpp
pv/prop/enum.cpp
pv/prop/property.cpp
BOOST_FOREACH(shared_ptr<Property> p, _properties)
{
assert(p);
- layout->addRow(p->name(), p->get_widget(_form));
+ const QString label = p->labeled_widget() ? QString() : p->name();
+ layout->addRow(label, p->get_widget(_form));
}
return _form;
#include "deviceoptions.h"
+#include <pv/prop/bool.h>
#include <pv/prop/double.h>
#include <pv/prop/enum.h>
const struct sr_config_info *const info =
sr_config_info_get(options[i]);
+ if (!info)
+ continue;
+
const int key = info->key;
- if (!info || sr_config_list(_sdi->driver, key,
- &gvar_list, _sdi) != SR_OK)
- continue;
+ if(sr_config_list(_sdi->driver, key, &gvar_list, _sdi) != SR_OK)
+ gvar_list = NULL;
const QString name(info->name);
bind_enum(name, key, gvar_list);
break;
+ case SR_CONF_RLE:
+ bind_bool(name, key);
+ break;
+
case SR_CONF_TIMEBASE:
bind_enum(name, key, gvar_list, print_timebase);
break;
break;
}
- g_variant_unref(gvar_list);
+ if (gvar_list)
+ g_variant_unref(gvar_list);
}
g_variant_unref(gvar_opts);
}
qDebug() << "WARNING: Failed to set value of sample rate";
}
+void DeviceOptions::bind_bool(const QString &name, int key)
+{
+ _properties.push_back(shared_ptr<Property>(
+ new Bool(name, bind(config_getter, _sdi, key),
+ bind(config_setter, _sdi, key, _1))));
+}
+
void DeviceOptions::bind_enum(const QString &name, int key,
GVariant *const gvar_list, function<QString (GVariant*)> printer)
{
GVariantIter iter;
vector< pair<GVariant*, QString> > values;
+ assert(gvar_list);
+
g_variant_iter_init (&iter, gvar_list);
while ((gvar = g_variant_iter_next_value (&iter)))
values.push_back(make_pair(gvar, printer(gvar)));
{
GVariant *gvar_list_samplerates;
+ assert(gvar_list);
+
if ((gvar_list_samplerates = g_variant_lookup_value(gvar_list,
"samplerate-steps", G_VARIANT_TYPE("at"))))
{
static void config_setter(
const struct sr_dev_inst *sdi, int key, GVariant* value);
+ void bind_bool(const QString &name, int key);
void bind_enum(const QString &name, int key,
GVariant *const gvar_list,
boost::function<QString (GVariant*)> printer = print_gvariant);
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <assert.h>
+
+#include <QCheckBox>
+
+#include "bool.h"
+
+using namespace std;
+using namespace boost;
+
+namespace pv {
+namespace prop {
+
+Bool::Bool(QString name, Getter getter, Setter setter) :
+ Property(name, getter, setter),
+ _check_box(NULL)
+{
+}
+
+QWidget* Bool::get_widget(QWidget *parent)
+{
+ if (_check_box)
+ return _check_box;
+
+ _check_box = new QCheckBox(name(), parent);
+
+ GVariant *const value = _getter ? _getter() : NULL;
+
+ if (value) {
+ _check_box->setCheckState(g_variant_get_boolean(value) ?
+ Qt::Checked : Qt::Unchecked);
+ g_variant_unref(value);
+ }
+
+ return _check_box;
+}
+
+bool Bool::labeled_widget() const
+{
+ return true;
+}
+
+void Bool::commit()
+{
+ assert(_setter);
+
+ if (!_check_box)
+ return;
+
+ _setter(g_variant_new_boolean(
+ _check_box->checkState() == Qt::Checked));
+}
+
+} // prop
+} // pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_PROP_BOOL_H
+#define PULSEVIEW_PV_PROP_BOOL_H
+
+#include "property.h"
+
+class QCheckBox;
+
+namespace pv {
+namespace prop {
+
+class Bool : public Property
+{
+public:
+ Bool(QString name, Getter getter, Setter setter);
+
+ QWidget* get_widget(QWidget *parent);
+ bool labeled_widget() const;
+
+ void commit();
+
+private:
+ QCheckBox *_check_box;
+};
+
+} // prop
+} // pv
+
+#endif // PULSEVIEW_PV_PROP_BOOL_H
return _name;
}
+bool Property::labeled_widget() const
+{
+ return false;
+}
+
} // prop
} // pv
const QString& name() const;
virtual QWidget* get_widget(QWidget *parent) = 0;
+ virtual bool labeled_widget() const;
virtual void commit() = 0;