Ignition Gui

API Reference

5.0.0
Application.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 #ifndef IGNITION_GUI_APPLICATION_HH_
18 #define IGNITION_GUI_APPLICATION_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 #include "ignition/gui/qt.h"
26 #include "ignition/gui/Export.hh"
27 
28 #ifdef _WIN32
29 // Disable warning C4251 which is triggered by
30 // std::unique_ptr
31 #pragma warning(push)
32 #pragma warning(disable: 4251)
33 #endif
34 
35 namespace tinyxml2
36 {
37  class XMLElement;
38 }
39 
40 namespace ignition
41 {
42  namespace gui
43  {
44  class ApplicationPrivate;
45  class Dialog;
46  class MainWindow;
47  class Plugin;
48 
50  enum class WindowType : int
51  {
54  kMainWindow = 0,
55 
57  kDialog = 1
58  };
59 
64  class IGNITION_GUI_VISIBLE Application : public QApplication
65  {
66  Q_OBJECT
67 
72  public: Application(int &_argc, char **_argv,
73  const WindowType _type = WindowType::kMainWindow);
74 
76  public: virtual ~Application();
77 
80  public: QQmlApplicationEngine *Engine() const;
81 
92  public: bool LoadPlugin(const std::string &_filename,
93  const tinyxml2::XMLElement *_pluginElem = nullptr);
94 
103  public: bool LoadConfig(const std::string &_config);
104 
110  public: bool LoadDefaultConfig();
111 
119  public: void SetDefaultConfigPath(const std::string &_path);
120 
125  public: std::string DefaultConfigPath();
126 
130  public: void SetPluginPathEnv(const std::string &_env);
131 
134  public: void AddPluginPath(const std::string &_path);
135 
148  PluginList();
149 
155  public: bool RemovePlugin(const std::string &_pluginName);
156 
159  signals: void PluginAdded(const QString &_objectName);
160 
162  public slots: void OnPluginClose();
163 
170  private: bool InitializeMainWindow();
171 
177  private: bool InitializeDialogs();
178 
181  private: void RemovePlugin(std::shared_ptr<Plugin> _plugin);
182 
187  private: bool AddPluginsToWindow();
188 
192  private: bool ApplyConfig();
193 
196  private: std::unique_ptr<ApplicationPrivate> dataPtr;
197  };
198 
201  IGNITION_GUI_VISIBLE
202  Application *App();
203  }
204 }
205 
206 #ifdef _MSC_VER
207 #pragma warning(pop)
208 #endif
209 
210 #endif
A main window, which may contain top-level menus and multiple plugins.
Definition: Application.hh:35
Base class for Ignition GUI plugins.
Definition: Plugin.hh:54
STL class.
An Ignition GUI application loads a QML engine and provides an API to load plugins and configuration ...
Definition: Application.hh:64
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: MainWindow.hh:48
STL class.
One independent dialog per plugin.
WindowType
Type of window which the application will display.
Definition: Application.hh:50
Gui plugin.
Definition: Dialog.hh:40
Application * App()
Get current running application, this is a cast of qGuiApp.
Definition: Application.hh:40