RestUiWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GAZEBO_PLUGINS_REST_WEB_RESTUIWIDGET_HH_
19 #define GAZEBO_PLUGINS_REST_WEB_RESTUIWIDGET_HH_
20 
21 #include <string>
22 #include <list>
23 #include <vector>
24 
25 // See: https://bugreports.qt-project.org/browse/QTBUG-22829
26 #ifndef Q_MOC_RUN
27 # include <gazebo/gazebo.hh>
28 #endif
29 #include <gazebo/util/system.hh>
30 #include "RestUiLoginDialog.hh"
31 
32 namespace gazebo
33 {
34  namespace gui
35  {
36  class TopToolbar;
37  }
38 
41  class GAZEBO_VISIBLE RestUiWidget : public QWidget
42  {
43  Q_OBJECT
44 
51  public: RestUiWidget(QWidget *_parent,
52  QAction &_login,
53  QAction &_logout,
54  const std::string &_menuTitle,
55  const std::string &_loginTitle,
56  const std::string &_urlLabel,
57  const std::string &_defautlUrl);
58 
60  public: virtual ~RestUiWidget() = default;
61 
63  public slots: void Login();
64 
66  public slots: void Logout();
67 
70  public: void Update();
71 
74  private: void OnResponse(ConstRestResponsePtr &_msg);
75 
78  private: void OnWindowMode(const std::string &_mode);
79 
81  private: QAction &loginMenuAction;
82 
84  private: QAction &logoutMenuAction;
85 
87  private: std::string title;
88 
90  private: gazebo::transport::NodePtr node;
91 
93  private: gui::RestUiLoginDialog loginDialog;
94 
96  private: gazebo::transport::PublisherPtr loginPub;
97 
99  private: gazebo::transport::PublisherPtr logoutPub;
100 
102  private: gazebo::transport::SubscriberPtr responseSub;
103 
106  private: std::list<boost::shared_ptr<const gazebo::msgs::RestResponse>>
107  msgRespQ;
108 
110  private: gui::TopToolbar *toolbar;
111 
113  private: QLabel *loginLabel;
114 
116  private: unsigned int restID;
117 
119  private: QAction *loginLabelAct;
120 
123  private: QAction *spacerAct;
124 
126  public: std::vector<event::ConnectionPtr> connections;
127  };
128 }
129 
130 #endif
std::vector< event::ConnectionPtr > connections
Event based connections.
Definition: RestUiWidget.hh:126
Forward declarations for the common classes.
Definition: Animation.hh:33
Provides a means to login to a webservice.
Definition: RestUiLoginDialog.hh:34
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
Toolbar on the top of the main window.
Definition: TopToolbar.hh:32
REST user interface widget.
Definition: RestUiWidget.hh:41
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:58