Ignition Gui

API Reference

1.0.0
MainWindow.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_MAINWINDOW_HH_
18 #define IGNITION_GUI_MAINWINDOW_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <set>
23 #include <string>
24 #include <vector>
25 
26 #include <ignition/common/Console.hh>
27 
28 #include "ignition/gui/qt.h"
29 #include "ignition/gui/Export.hh"
30 
31 namespace ignition
32 {
33  namespace gui
34  {
35  class MainWindowPrivate;
36  struct WindowConfig;
37 
41  class IGNITION_GUI_VISIBLE MainWindow : public QObject
42  {
43  Q_OBJECT
44 
46  Q_PROPERTY(
47  int pluginCount
48  READ PluginCount
49  WRITE SetPluginCount
50  NOTIFY PluginCountChanged
51  )
52 
53 
54  Q_PROPERTY(
55  QString materialTheme
56  READ MaterialTheme
57  WRITE SetMaterialTheme
58  NOTIFY MaterialThemeChanged
59  )
60 
62  Q_PROPERTY(
63  QString materialPrimary
64  READ MaterialPrimary
65  WRITE SetMaterialPrimary
66  NOTIFY MaterialPrimaryChanged
67  )
68 
70  Q_PROPERTY(
71  QString materialAccent
72  READ MaterialAccent
73  WRITE SetMaterialAccent
74  NOTIFY MaterialAccentChanged
75  )
76 
78  Q_PROPERTY(
79  bool showDrawer
80  READ ShowDrawer
81  WRITE SetShowDrawer
82  NOTIFY ShowDrawerChanged
83  )
84 
86  Q_PROPERTY(
87  bool showDefaultDrawerOpts
88  READ ShowDefaultDrawerOpts
89  WRITE SetShowDefaultDrawerOpts
90  NOTIFY ShowDefaultDrawerOptsChanged
91  )
92 
94  Q_PROPERTY(
95  bool showPluginMenu
96  READ ShowPluginMenu
97  WRITE SetShowPluginMenu
98  NOTIFY ShowPluginMenuChanged
99  )
100 
102  public: MainWindow();
103 
105  public: virtual ~MainWindow();
106 
109  public: QQuickWindow *QuickWindow() const;
110 
115  public: void SaveConfig(const std::string &_path);
116 
120  public: bool ApplyConfig(const WindowConfig &_config);
121 
124  public: WindowConfig CurrentWindowConfig() const;
125 
128  public slots: void OnAddPlugin(QString _plugin);
129 
132  public: Q_INVOKABLE QStringList PluginListModel() const;
133 
137  public: Q_INVOKABLE int PluginCount() const;
138 
142  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
143 
146  public: Q_INVOKABLE QString MaterialTheme() const;
147 
150  public: Q_INVOKABLE void SetMaterialTheme(
151  const QString &_materialTheme);
152 
155  public: Q_INVOKABLE QString MaterialPrimary() const;
156 
159  public: Q_INVOKABLE void SetMaterialPrimary(
160  const QString &_materialPrimary);
161 
164  public: Q_INVOKABLE QString MaterialAccent() const;
165 
168  public: Q_INVOKABLE void SetMaterialAccent(
169  const QString &_materialAccent);
170 
173  public: Q_INVOKABLE bool ShowDrawer() const;
174 
177  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
178 
181  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
182 
185  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
186  const bool _showDefaultDrawerOpts);
187 
190  public: Q_INVOKABLE bool ShowPluginMenu() const;
191 
194  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
195 
197  public slots: void OnLoadConfig(const QString &_path);
198 
200  public slots: void OnSaveConfig();
201 
203  public slots: void OnSaveConfigAs(const QString &_path);
204 
206  signals: void PluginCountChanged();
207 
209  signals: void MaterialThemeChanged();
210 
212  signals: void MaterialPrimaryChanged();
213 
215  signals: void MaterialAccentChanged();
216 
218  signals: void ShowDrawerChanged();
219 
221  signals: void ShowDefaultDrawerOptsChanged();
222 
224  signals: void ShowPluginMenuChanged();
225 
227  signals: void configChanged();
228 
230  signals: void notify(const QString &_message);
231 
232  // Documentation inherited
233 // protected: void paintEvent(QPaintEvent *_event) override;
234 
235  // Documentation inherited
236 // protected: void closeEvent(QCloseEvent *_event) override;
237 
240  private: std::unique_ptr<MainWindowPrivate> dataPtr;
241  };
242 
244  struct IGNITION_GUI_VISIBLE WindowConfig
245  {
251  bool MergeFromXML(const std::string &_xml);
252 
255  std::string XMLString() const;
256 
259  bool IsIgnoring(const std::string &_prop) const;
260 
262  int posX{-1};
263 
265  int posY{-1};
266 
268  int width{-1};
269 
271  int height{-1};
272 
275 
277  std::string materialTheme{""};
278 
280  std::string materialPrimary{""};
281 
283  std::string materialAccent{""};
284 
286  bool showDrawer{true};
287 
289  bool showDefaultDrawerOpts{true};
290 
292  bool showPluginMenu{true};
293 
296  bool pluginsFromPaths{true};
297 
300 
303 
305  std::string plugins{""};
306  };
307  }
308 }
309 #endif
STL namespace.
Holds configurations related to a MainWindow.
Definition: MainWindow.hh:244
STL class.
std::set< std::string > ignoredProps
List of window properties which should be ignored on load.
Definition: MainWindow.hh:302
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: MainWindow.hh:41
QByteArray state
Window state (dock configuration)
Definition: MainWindow.hh:274
Definition: Application.hh:33
std::vector< std::string > showPlugins
List of plugins which should be shown on the list.
Definition: MainWindow.hh:299