BoolWidgets.h
Go to the documentation of this file.
1#pragma once
2
3#include <QCheckBox>
4#include <QPushButton>
5
6#include "Basic.h"
7
8namespace armarx::RemoteGui
9{
10 struct CheckBoxHandler : TypedWidget<CheckBox, QCheckBox, VALUE_VARIANT_BOOL>
11 {
12 static QWidgetT*
14 CreateWidgetCallback const& createChild,
15 const QObject* stateChangeReceiver,
16 const char* stateChangeSlot)
17 {
19 QWidgetT* widget = new QWidgetT();
20 widget->setToolTip(QString::fromStdString(desc.toolTip));
21 widget->setText(toQString(desc.label));
22
23 QObject::connect(
24 widget, SIGNAL(stateChanged(int)), stateChangeReceiver, stateChangeSlot);
25
26 return widget;
27 }
28
29 static void
30 updateGui(RemoteWidgetT const& desc, QWidgetT* widget, ValueT const& value)
31 {
32 widget->setCheckState(value ? Qt::Checked : Qt::Unchecked);
33 }
34
35 static ValueT
37 {
38 return widget->checkState() == Qt::Checked;
39 }
40 };
41
42 struct ToggleButtonHandler : TypedWidget<ToggleButton, QPushButton, VALUE_VARIANT_BOOL>
43 {
44 static QWidgetT*
46 CreateWidgetCallback const& createChild,
47 const QObject* stateChangeReceiver,
48 const char* stateChangeSlot)
49 {
51 QWidgetT* widget = new QWidgetT();
52 widget->setToolTip(QString::fromStdString(desc.toolTip));
53 widget->setText(toQString(desc.label));
54 widget->setCheckable(true);
55
56 QObject::connect(widget, SIGNAL(toggled(bool)), stateChangeReceiver, stateChangeSlot);
57
58 return widget;
59 }
60
61 static void
62 updateGui(RemoteWidgetT const& desc, QWidgetT* widget, ValueT const& value)
63 {
64 widget->setChecked(value);
65 }
66
67 static ValueT
69 {
70 return widget->isChecked();
71 }
72 };
73} // namespace armarx::RemoteGui
std::function< QWidgetPtr(WidgetPtr const &)> CreateWidgetCallback
QString toQString(std::string const &string)
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition BoolWidgets.h:13
static void updateGui(RemoteWidgetT const &desc, QWidgetT *widget, ValueT const &value)
Definition BoolWidgets.h:30
static ValueT handleGuiChange(RemoteWidgetT const &desc, QWidgetT *widget)
Definition BoolWidgets.h:36
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition BoolWidgets.h:45
static void updateGui(RemoteWidgetT const &desc, QWidgetT *widget, ValueT const &value)
Definition BoolWidgets.h:62
static ValueT handleGuiChange(RemoteWidgetT const &desc, QWidgetT *widget)
Definition BoolWidgets.h:68
#define ARMARX_TRACE
Definition trace.h:77