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 
8 namespace armarx::RemoteGui
9 {
10  struct CheckBoxHandler : TypedWidget<CheckBox, QCheckBox, VALUE_VARIANT_BOOL>
11  {
12  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
13  const QObject* stateChangeReceiver, const char* stateChangeSlot)
14  {
16  QWidgetT* widget = new QWidgetT();
17  widget->setToolTip(QString::fromStdString(desc.toolTip));
18  widget->setText(toQString(desc.label));
19 
20  QObject::connect(widget, SIGNAL(stateChanged(int)), stateChangeReceiver, stateChangeSlot);
21 
22  return widget;
23  }
24 
25  static void updateGui(RemoteWidgetT const& desc, QWidgetT* widget, ValueT const& value)
26  {
27  widget->setCheckState(value ? Qt::Checked : Qt::Unchecked);
28  }
29 
30  static ValueT handleGuiChange(RemoteWidgetT const& desc, QWidgetT* widget)
31  {
32  return widget->checkState() == Qt::Checked;
33  }
34  };
35 
36  struct ToggleButtonHandler : TypedWidget<ToggleButton, QPushButton, VALUE_VARIANT_BOOL>
37  {
38  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
39  const QObject* stateChangeReceiver, const char* stateChangeSlot)
40  {
42  QWidgetT* widget = new QWidgetT();
43  widget->setToolTip(QString::fromStdString(desc.toolTip));
44  widget->setText(toQString(desc.label));
45  widget->setCheckable(true);
46 
47  QObject::connect(widget, SIGNAL(toggled(bool)), stateChangeReceiver, stateChangeSlot);
48 
49  return widget;
50  }
51 
52  static void updateGui(RemoteWidgetT const& desc, QWidgetT* widget, ValueT const& value)
53  {
54  widget->setChecked(value);
55  }
56 
57  static ValueT handleGuiChange(RemoteWidgetT const& desc, QWidgetT* widget)
58  {
59  return widget->isChecked();
60  }
61  };
62 }
armarx::RemoteGui::Client::ToggleButton
Definition: Widgets.h:139
armarx::RemoteGui
Definition: LightweightRemoteGuiComponentPlugin.h:30
armarx::RemoteGui::TypedWidget
Definition: TypedWidget.h:115
armarx::RemoteGui::ToggleButtonHandler
Definition: BoolWidgets.h:36
armarx::RemoteGui::TypedWidget< CheckBox, QCheckBox, VALUE_VARIANT_BOOL >::ValueT
typename Storage< ValueType >::Type ValueT
Definition: TypedWidget.h:120
armarx::RemoteGui::CheckBoxHandler::updateGui
static void updateGui(RemoteWidgetT const &desc, QWidgetT *widget, ValueT const &value)
Definition: BoolWidgets.h:25
armarx::RemoteGui::CheckBoxHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: BoolWidgets.h:12
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
Basic.h
armarx::RemoteGui::ToggleButtonHandler::handleGuiChange
static ValueT handleGuiChange(RemoteWidgetT const &desc, QWidgetT *widget)
Definition: BoolWidgets.h:57
armarx::RemoteGui::CheckBoxHandler::handleGuiChange
static ValueT handleGuiChange(RemoteWidgetT const &desc, QWidgetT *widget)
Definition: BoolWidgets.h:30
armarx::RemoteGui::TypedWidget< CheckBox, QCheckBox, VALUE_VARIANT_BOOL >::QWidgetT
QCheckBox QWidgetT
Definition: TypedWidget.h:118
armarx::RemoteGui::ToggleButtonHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: BoolWidgets.h:38
armarx::RemoteGui::Client::CheckBox
Definition: Widgets.h:129
armarx::RemoteGui::toQString
QString toQString(std::string const &string)
Definition: WidgetHandler.cpp:12
armarx::RemoteGui::CreateWidgetCallback
std::function< QWidgetPtr(WidgetPtr const &)> CreateWidgetCallback
Definition: WidgetHandler.h:20
armarx::RemoteGui::CheckBoxHandler
Definition: BoolWidgets.h:10
armarx::RemoteGui::ToggleButtonHandler::updateGui
static void updateGui(RemoteWidgetT const &desc, QWidgetT *widget, ValueT const &value)
Definition: BoolWidgets.h:52