projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Build fixes for Qt5 Windows/mingw/MXE support.
[pulseview.git]
/
pv
/
prop
/
bool.cpp
diff --git
a/pv/prop/bool.cpp
b/pv/prop/bool.cpp
index ad9a13e7c0e05bc710fc7d385b6ad7e6b22a04be..61b2f17adaa9848cc28d6735a49cbff3d024001a 100644
(file)
--- a/
pv/prop/bool.cpp
+++ b/
pv/prop/bool.cpp
@@
-14,48
+14,47
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <QCheckBox>
*/
#include <assert.h>
#include <QCheckBox>
-#include "bool.h"
-
-using namespace std;
-using namespace boost;
+#include "bool.hpp"
namespace pv {
namespace prop {
Bool::Bool(QString name, Getter getter, Setter setter) :
Property(name, getter, setter),
namespace pv {
namespace prop {
Bool::Bool(QString name, Getter getter, Setter setter) :
Property(name, getter, setter),
-
_check_box(NULL
)
+
check_box_(nullptr
)
{
}
{
}
-
Bool::~Bool(
)
+
QWidget* Bool::get_widget(QWidget *parent, bool auto_commit
)
{
{
-}
+ if (check_box_)
+ return check_box_;
-QWidget* Bool::get_widget(QWidget *parent)
-{
- if (_check_box)
- return _check_box;
+ if (!getter_)
+ return nullptr;
+
+ Glib::VariantBase variant = getter_();
+ if (!variant.gobj())
+ return nullptr;
- _check_box = new QCheckBox(name(), parent);
+ bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
+ variant).get();
- GVariant *const value = _getter ? _getter() : NULL;
+ check_box_ = new QCheckBox(name(), parent);
+ check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked);
- if (value) {
- _check_box->setCheckState(g_variant_get_boolean(value) ?
- Qt::Checked : Qt::Unchecked);
- g_variant_unref(value);
- }
+ if (auto_commit)
+ connect(check_box_, SIGNAL(stateChanged(int)),
+ this, SLOT(on_state_changed(int)));
- return
_check_box
;
+ return
check_box_
;
}
bool Bool::labeled_widget() const
}
bool Bool::labeled_widget() const
@@
-65,13
+64,18
@@
bool Bool::labeled_widget() const
void Bool::commit()
{
void Bool::commit()
{
- assert(
_setter
);
+ assert(
setter_
);
- if (!
_check_box
)
+ if (!
check_box_
)
return;
return;
- _setter(g_variant_new_boolean(
- _check_box->checkState() == Qt::Checked));
+ setter_(Glib::Variant<bool>::create(
+ check_box_->checkState() == Qt::Checked));
+}
+
+void Bool::on_state_changed(int)
+{
+ commit();
}
} // prop
}
} // prop