StaticWidgets.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QLabel>
4 
5 #include "Basic.h"
6 
7 namespace armarx::RemoteGui
8 {
9  struct LabelHandler : TypedWidget<Label, QLabel, VALUE_VARIANT_STRING>
10  {
11  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
12  const QObject* stateChangeReceiver, const char* stateChangeSlot)
13  {
15  QWidgetT* widget = new QWidgetT();
16  widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
17  widget->setToolTip(QString::fromStdString(desc.toolTip));
18  return widget;
19  }
20 
21  static void updateGui(RemoteWidgetT const& desc, QWidgetT* widget, ValueT const& value)
22  {
23  widget->setText(toQString(value));
24  }
25 
26  static ValueT handleGuiChange(RemoteWidgetT const& desc, QWidgetT* widget)
27  {
28  return toUtf8(widget->text());
29  }
30  };
31 
32  struct HSpacerHandler : TypedWidget<HSpacer, QWidget>
33  {
34  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
35  const QObject* stateChangeReceiver, const char* stateChangeSlot)
36  {
38  QWidgetT* widget = new QWidget();
39 
40  widget->setLayout(new QVBoxLayout);
41  widget->layout()->setContentsMargins(0, 0, 0, 0);
42  widget->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
43 
44  return widget;
45  }
46  };
47 
48  struct VSpacerHandler : TypedWidget<VSpacer, QWidget>
49  {
50  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
51  const QObject* stateChangeReceiver, const char* stateChangeSlot)
52  {
54  QWidgetT* widget = new QWidget();
55 
56  widget->setLayout(new QVBoxLayout);
57  widget->layout()->setContentsMargins(0, 0, 0, 0);
58  widget->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
59 
60  return widget;
61  }
62  };
63 
64  struct HLineHandler : TypedWidget<HLine, QFrame>
65  {
66  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
67  const QObject* stateChangeReceiver, const char* stateChangeSlot)
68  {
70  QWidgetT* widget = new QFrame();
71 
72  widget->setFrameShape(QFrame::HLine);
73  widget->setFrameShadow(QFrame::Sunken);
74 
75  return widget;
76  }
77  };
78  struct VLineHandler : TypedWidget<VLine, QFrame>
79  {
80  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
81  const QObject* stateChangeReceiver, const char* stateChangeSlot)
82  {
84  QWidgetT* widget = new QFrame();
85 
86  widget->setFrameShape(QFrame::VLine);
87  widget->setFrameShadow(QFrame::Sunken);
88 
89  return widget;
90  }
91  };
92 
93  struct EmptyWidgetHandler : TypedWidget<Widget, QWidget>
94  {
95  static QWidgetT* createWidget(RemoteWidgetT const& desc, CreateWidgetCallback const& createChild,
96  const QObject* stateChangeReceiver, const char* stateChangeSlot)
97  {
99  auto widget = new QWidget();
100  widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
101  return widget;
102  }
103  };
104 }
armarx::RemoteGui::VLineHandler
Definition: StaticWidgets.h:78
armarx::RemoteGui::VLineHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: StaticWidgets.h:80
armarx::RemoteGui
Definition: LightweightRemoteGuiComponentPlugin.h:30
armarx::RemoteGui::HSpacerHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: StaticWidgets.h:34
armarx::RemoteGui::LabelHandler
Definition: StaticWidgets.h:9
armarx::RemoteGui::Client::Label
Definition: Widgets.h:31
armarx::RemoteGui::Client::HSpacer
Definition: Widgets.h:209
armarx::RemoteGui::TypedWidget
Definition: TypedWidget.h:115
armarx::RemoteGui::HLineHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: StaticWidgets.h:66
armarx::RemoteGui::EmptyWidgetHandler
Definition: StaticWidgets.h:93
armarx::RemoteGui::VSpacerHandler
Definition: StaticWidgets.h:48
armarx::RemoteGui::TypedWidget< Label, QLabel, VALUE_VARIANT_STRING >::ValueT
typename Storage< ValueType >::Type ValueT
Definition: TypedWidget.h:120
armarx::RemoteGui::Client::VSpacer
Definition: Widgets.h:204
armarx::RemoteGui::HLineHandler
Definition: StaticWidgets.h:64
armarx::RemoteGui::toUtf8
std::string toUtf8(QString const &qstring)
Definition: WidgetHandler.cpp:7
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::RemoteGui::Client::Widget
Definition: Widgets.h:21
armarx::RemoteGui::LabelHandler::updateGui
static void updateGui(RemoteWidgetT const &desc, QWidgetT *widget, ValueT const &value)
Definition: StaticWidgets.h:21
Basic.h
armarx::RemoteGui::TypedWidget< Label, QLabel, VALUE_VARIANT_STRING >::QWidgetT
QLabel QWidgetT
Definition: TypedWidget.h:118
armarx::RemoteGui::LabelHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: StaticWidgets.h:11
armarx::RemoteGui::EmptyWidgetHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: StaticWidgets.h:95
armarx::RemoteGui::VSpacerHandler::createWidget
static QWidgetT * createWidget(RemoteWidgetT const &desc, CreateWidgetCallback const &createChild, const QObject *stateChangeReceiver, const char *stateChangeSlot)
Definition: StaticWidgets.h:50
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::LabelHandler::handleGuiChange
static ValueT handleGuiChange(RemoteWidgetT const &desc, QWidgetT *widget)
Definition: StaticWidgets.h:26
armarx::RemoteGui::TypedWidget< HLine, QFrame >::RemoteWidgetT
HLine RemoteWidgetT
Definition: TypedWidget.h:117
armarx::RemoteGui::HSpacerHandler
Definition: StaticWidgets.h:32