EventSenderComponent.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarX::Gui
17* @author Mirko Waechter ( mirko.waechter at kit dot edu)
18* @date 2012
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
24
25#include <QSpacerItem>
26
27#include <IceUtil/IceUtil.h>
28
29#include <ArmarXGui/gui-plugins/StatechartEventSenderPlugin/ui_EventSenderConfig.h>
30
31using namespace armarx;
32
33EventSenderComponent::EventSenderComponent(QString eventSenderName, QWidget* parent) : dialog(0)
34{
35
36 config.eventSenderName = eventSenderName;
37 setupUi();
38}
39
41{
42 // ARMARX_INFO << "~EventSenderComponent" << flush;
43 delete dialog;
44}
45
46//QWidget *EventSenderComponent::getMainWidget()
47//{
48// return this;
49//}
50
51void
53{
54 if (dialog)
55 {
56 return;
57 }
58
59 // gbEventSender = new QGroupBox(this);
60 this->setObjectName(QString::fromUtf8("this"));
61 this->setMinimumSize(QSize(0, 40));
62 horizontalLayout = new QHBoxLayout(this);
63 horizontalLayout->setSpacing(2);
64 horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
65 horizontalLayout->setContentsMargins(2, 3, 2, -1);
66 tbSend = new QToolButton(this);
67 tbSend->setObjectName(QString::fromUtf8("tbSend"));
68 tbSend->setMinimumSize(QSize(60, 20));
69 QIcon icon;
70 icon.addFile(
71 QString::fromUtf8(":/icons/media-playback-start.ico"), QSize(), QIcon::Normal, QIcon::Off);
72 tbSend->setIcon(icon);
73 tbSend->setIconSize(QSize(16, 16));
74 tbSend->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
75 horizontalLayout->addWidget(tbSend);
76
77 tbConfig = new QToolButton(this);
78 tbConfig->setObjectName(QString::fromUtf8("tbConfig"));
79 tbConfig->setMinimumSize(QSize(20, 20));
80
81 QIcon icon2;
82 icon2.addFile(QString::fromUtf8(":/icons/configure-3.png"), QSize(), QIcon::Normal, QIcon::Off);
83 tbConfig->setIcon(icon2);
84 tbConfig->setIconSize(QSize(16, 16));
85 horizontalLayout->addWidget(tbConfig);
86
87 tbDelete = new QToolButton(this);
88 tbDelete->setObjectName(QString::fromUtf8("tbDelete"));
89 tbDelete->setMinimumSize(QSize(20, 20));
90
91 QIcon iconClose;
92 iconClose.addFile(
93 QString::fromUtf8(":/icons/dialog-close.ico"), QSize(), QIcon::Normal, QIcon::Off);
94 tbDelete->setIcon(iconClose);
95 tbDelete->setIconSize(QSize(16, 16));
96 tbDelete->setToolButtonStyle(Qt::ToolButtonIconOnly);
97 horizontalLayout->addWidget(tbDelete);
98
99 QSpacerItem* spacer =
100 new QSpacerItem(1, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
101 horizontalLayout->addItem(spacer);
102
103 this->setTitle(QApplication::translate(
104 "EventSenderOverview", config.eventSenderName.toStdString().c_str(), 0));
105#ifndef QT_NO_TOOLTIP
106 tbSend->setToolTip(QApplication::translate("EventSenderOverview", "Send Event", 0));
107 tbDelete->setToolTip(
108 QApplication::translate("EventSenderOverview", "Delete this EventSender", 0));
109 tbConfig->setToolTip(
110 QApplication::translate("EventSenderOverview", "Configure this EventSender", 0));
111#endif // QT_NO_TOOLTIP
112 tbSend->setText(QApplication::translate("EventSenderOverview", "Send", 0));
113 tbConfig->setText(QApplication::translate("EventSenderOverview", "...", 0));
114
115
116 dialog = new EventSenderConfigDialog(this);
117
118
119 // slots and signals
120 connect(tbSend, SIGNAL(clicked()), this, SLOT(sendClicked()));
121 connect(tbConfig, SIGNAL(clicked()), this, SLOT(openConfig()));
122 connect(tbDelete, SIGNAL(clicked()), this, SLOT(deleteClicked()));
123
124 connect(dialog, SIGNAL(accepted()), this, SLOT(configDone()));
125}
126
127void
129{
130 this->config = EventSenderConfig(conf);
131
132 if (conf.event)
133 {
134 this->config.event = EventPtr::dynamicCast(conf.event->clone());
135 }
136
137 this->setTitle(conf.eventSenderName);
138}
139
140void
142{
143 if (dialog)
144 {
145 dialog->setIceManager(iceMan);
146 }
147
148 this->iceManager = iceMan;
149}
150
151void
156
157void
159{
160 dialog->setConfig(config);
161 dialog->setModal(true);
162 dialog->show();
163 dialog->raise();
164 dialog->activateWindow();
165 dialog->setParent(0);
166
167
168 //ARMARX_INFO_S << config.componentName.toStdString() << ", " << config.globalStateIdentifier << ", " << config.event->eventName << flush;
169}
170
171void
176
177void
179{
180 config.componentName = dialog->getSelectedComponentName();
181 config.globalStateIdentifier = dialog->getSelectedState().toStdString();
182 config.event = dialog->getSelectedEvent();
183 config.description = dialog->ui->edtDescription->text();
184 config.eventSenderName = dialog->ui->edtEventSenderName->text();
185 this->setTitle(config.eventSenderName);
186 setToolTip(config.description);
187}
void sendEvent(const EventSenderConfig &config)
EventSenderComponent(QString eventSenderName, QWidget *parent=0)
void setConfig(const EventSenderConfig &conf)
void setIceManager(IceManagerPtr iceMan)
Throw this exception to indicate missing functionality.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
Definition ArmarXFwd.h:39