Ignition Gui

API Reference

1.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 namespace tinyxml2
29 {
30  class XMLElement;
31 }
32 
33 namespace ignition
34 {
35  namespace gui
36  {
37  class ApplicationPrivate;
38  class Dialog;
39  class MainWindow;
40  class Plugin;
41 
43  enum class WindowType : int
44  {
47  kMainWindow = 0,
48 
50  kDialog = 1
51  };
52 
57  class IGNITION_GUI_VISIBLE Application : public QGuiApplication
58  {
59  Q_OBJECT
60 
65  public: Application(int &_argc, char **_argv,
66  const WindowType _type = WindowType::kMainWindow);
67 
69  public: virtual ~Application();
70 
73  public: QQmlApplicationEngine *Engine() const;
74 
85  public: bool LoadPlugin(const std::string &_filename,
86  const tinyxml2::XMLElement *_pluginElem = nullptr);
87 
96  public: bool LoadConfig(const std::string &_config);
97 
103  public: bool LoadDefaultConfig();
104 
112  public: void SetDefaultConfigPath(const std::string &_path);
113 
118  public: std::string DefaultConfigPath();
119 
123  public: void SetPluginPathEnv(const std::string &_env);
124 
127  public: void AddPluginPath(const std::string &_path);
128 
141  PluginList();
142 
148  public: bool RemovePlugin(const std::string &_pluginName);
149 
151  public slots: void OnPluginClose();
152 
159  private: bool InitializeMainWindow();
160 
166  private: bool InitializeDialogs();
167 
170  private: void RemovePlugin(std::shared_ptr<Plugin> _plugin);
171 
176  private: bool AddPluginsToWindow();
177 
181  private: bool ApplyConfig();
182 
185  private: std::unique_ptr<ApplicationPrivate> dataPtr;
186  };
187 
190  IGNITION_GUI_VISIBLE
191  Application *App();
192  }
193 }
194 #endif
A main window, which may contain top-level menus and multiple plugins.
Definition: Application.hh:28
Base class for Ignition GUI plugins.
Definition: Plugin.hh:47
STL class.
An Ignition GUI application loads a QML engine and provides an API to load plugins and configuration ...
Definition: Application.hh:57
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: MainWindow.hh:41
STL class.
One independent dialog per plugin.
WindowType
Type of window which the application will display.
Definition: Application.hh:43
Gui plugin.
Definition: Dialog.hh:33
Application * App()
Get current running application, this is a cast of qGuiApp.
Definition: Application.hh:33