Ignition Gui

API Reference

7.0.0~pre1
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 
27 
28 #include "ignition/gui/qt.h"
29 #include "ignition/gui/Export.hh"
30 
31 #ifdef _WIN32
32 // Disable warning C4251 which is triggered by
33 // std::unique_ptr
34 #pragma warning(push)
35 #pragma warning(disable: 4251)
36 #endif
37 
38 namespace ignition
39 {
40  namespace gui
41  {
42  class MainWindowPrivate;
43  struct WindowConfig;
44 
48  class IGNITION_GUI_VISIBLE MainWindow : public QObject
49  {
50  Q_OBJECT
51 
53  Q_PROPERTY(
54  int pluginCount
55  READ PluginCount
56  WRITE SetPluginCount
57  NOTIFY PluginCountChanged
58  )
59 
60 
61  Q_PROPERTY(
62  QString materialTheme
63  READ MaterialTheme
64  WRITE SetMaterialTheme
65  NOTIFY MaterialThemeChanged
66  )
67 
69  Q_PROPERTY(
70  QString materialPrimary
71  READ MaterialPrimary
72  WRITE SetMaterialPrimary
73  NOTIFY MaterialPrimaryChanged
74  )
75 
77  Q_PROPERTY(
78  QString materialAccent
79  READ MaterialAccent
80  WRITE SetMaterialAccent
81  NOTIFY MaterialAccentChanged
82  )
83 
86  Q_PROPERTY(
87  QString toolBarColorLight
88  READ ToolBarColorLight
89  WRITE SetToolBarColorLight
90  NOTIFY ToolBarColorLightChanged
91  )
92 
95  Q_PROPERTY(
96  QString toolBarTextColorLight
97  READ ToolBarTextColorLight
98  WRITE SetToolBarTextColorLight
99  NOTIFY ToolBarTextColorLightChanged
100  )
101 
104  Q_PROPERTY(
105  QString toolBarColorDark
106  READ ToolBarColorDark
107  WRITE SetToolBarColorDark
108  NOTIFY ToolBarColorDarkChanged
109  )
110 
113  Q_PROPERTY(
114  QString toolBarTextColorDark
115  READ ToolBarTextColorDark
116  WRITE SetToolBarTextColorDark
117  NOTIFY ToolBarTextColorDarkChanged
118  )
119 
122  Q_PROPERTY(
123  QString pluginToolBarColorLight
124  READ PluginToolBarColorLight
125  WRITE SetPluginToolBarColorLight
126  NOTIFY PluginToolBarColorLightChanged
127  )
128 
131  Q_PROPERTY(
132  QString pluginToolBarTextColorLight
133  READ PluginToolBarTextColorLight
134  WRITE SetPluginToolBarTextColorLight
135  NOTIFY PluginToolBarTextColorLightChanged
136  )
137 
140  Q_PROPERTY(
141  QString pluginToolBarColorDark
142  READ PluginToolBarColorDark
143  WRITE SetPluginToolBarColorDark
144  NOTIFY PluginToolBarColorDarkChanged
145  )
146 
149  Q_PROPERTY(
150  QString pluginToolBarTextColorDark
151  READ PluginToolBarTextColorDark
152  WRITE SetPluginToolBarTextColorDark
153  NOTIFY PluginToolBarTextColorDarkChanged
154  )
155 
157  Q_PROPERTY(
158  bool showDrawer
159  READ ShowDrawer
160  WRITE SetShowDrawer
161  NOTIFY ShowDrawerChanged
162  )
163 
165  Q_PROPERTY(
166  bool showDefaultDrawerOpts
167  READ ShowDefaultDrawerOpts
168  WRITE SetShowDefaultDrawerOpts
169  NOTIFY ShowDefaultDrawerOptsChanged
170  )
171 
173  Q_PROPERTY(
174  bool showPluginMenu
175  READ ShowPluginMenu
176  WRITE SetShowPluginMenu
177  NOTIFY ShowPluginMenuChanged
178  )
179 
181  Q_PROPERTY(
182  bool showDialogOnExit
183  READ ShowDialogOnExit
184  WRITE SetShowDialogOnExit
185  NOTIFY ShowDialogOnExitChanged
186  )
187 
189  public: MainWindow();
190 
192  public: virtual ~MainWindow();
193 
196  public: QQuickWindow *QuickWindow() const;
197 
202  public: void SaveConfig(const std::string &_path);
203 
207  public: bool ApplyConfig(const WindowConfig &_config);
208 
211  public: WindowConfig CurrentWindowConfig() const;
212 
215  public: void SetRenderEngine(const std::string &_renderEngine);
216 
219  public slots: void OnAddPlugin(QString _plugin);
220 
223  public: Q_INVOKABLE QStringList PluginListModel() const;
224 
228  public: Q_INVOKABLE int PluginCount() const;
229 
233  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
234 
237  public: Q_INVOKABLE QString MaterialTheme() const;
238 
241  public: Q_INVOKABLE void SetMaterialTheme(
242  const QString &_materialTheme);
243 
246  public: Q_INVOKABLE QString MaterialPrimary() const;
247 
250  public: Q_INVOKABLE void SetMaterialPrimary(
251  const QString &_materialPrimary);
252 
255  public: Q_INVOKABLE QString MaterialAccent() const;
256 
259  public: Q_INVOKABLE void SetMaterialAccent(
260  const QString &_materialAccent);
261 
264  public: Q_INVOKABLE QString ToolBarColorLight() const;
265 
268  public: Q_INVOKABLE void SetToolBarColorLight(
269  const QString &_toolBarColorLight);
270 
273  public: Q_INVOKABLE QString ToolBarTextColorLight() const;
274 
277  public: Q_INVOKABLE void SetToolBarTextColorLight(
278  const QString &_toolBarTextColorLight);
279 
282  public: Q_INVOKABLE QString ToolBarColorDark() const;
283 
286  public: Q_INVOKABLE void SetToolBarColorDark(
287  const QString &_toolBarColorDark);
288 
291  public: Q_INVOKABLE QString ToolBarTextColorDark() const;
292 
295  public: Q_INVOKABLE void SetToolBarTextColorDark(
296  const QString &_toolBarTextColorDark);
297 
300  public: Q_INVOKABLE QString PluginToolBarColorLight() const;
301 
304  public: Q_INVOKABLE void SetPluginToolBarColorLight(
305  const QString &_pluginPluginToolBarColorLight);
306 
309  public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
310 
313  public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
314  const QString &_pluginPluginToolBarTextColorLight);
315 
318  public: Q_INVOKABLE QString PluginToolBarColorDark() const;
319 
322  public: Q_INVOKABLE void SetPluginToolBarColorDark(
323  const QString &_pluginPluginToolBarColorDark);
324 
327  public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
328 
331  public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
332  const QString &_pluginPluginToolBarTextColorDark);
333 
336  public: Q_INVOKABLE bool ShowDrawer() const;
337 
340  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
341 
344  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
345 
348  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
349  const bool _showDefaultDrawerOpts);
350 
353  public: Q_INVOKABLE bool ShowPluginMenu() const;
354 
357  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
358 
361  public: Q_INVOKABLE bool ShowDialogOnExit() const;
362 
365  public: Q_INVOKABLE void SetShowDialogOnExit(bool _showDialogOnExit);
366 
368  public slots: void OnLoadConfig(const QString &_path);
369 
371  public slots: void OnSaveConfig();
372 
374  public slots: void OnSaveConfigAs(const QString &_path);
375 
377  signals: void PluginCountChanged();
378 
380  signals: void MaterialThemeChanged();
381 
383  signals: void MaterialPrimaryChanged();
384 
386  signals: void MaterialAccentChanged();
387 
389  signals: void ToolBarColorLightChanged();
390 
392  signals: void ToolBarTextColorLightChanged();
393 
395  signals: void ToolBarColorDarkChanged();
396 
398  signals: void ToolBarTextColorDarkChanged();
399 
401  signals: void PluginToolBarColorLightChanged();
402 
404  signals: void PluginToolBarTextColorLightChanged();
405 
407  signals: void PluginToolBarColorDarkChanged();
408 
410  signals: void PluginToolBarTextColorDarkChanged();
411 
413  signals: void ShowDrawerChanged();
414 
416  signals: void ShowDefaultDrawerOptsChanged();
417 
419  signals: void ShowPluginMenuChanged();
420 
422  signals: void ShowDialogOnExitChanged();
423 
425  signals: void configChanged();
426 
428  signals: void notify(const QString &_message);
429 
432  private: std::unique_ptr<MainWindowPrivate> dataPtr;
433  };
434 
436  struct IGNITION_GUI_VISIBLE WindowConfig
437  {
443  bool MergeFromXML(const std::string &_xml);
444 
447  std::string XMLString() const;
448 
451  bool IsIgnoring(const std::string &_prop) const;
452 
454  int posX{-1};
455 
457  int posY{-1};
458 
460  int width{-1};
461 
463  int height{-1};
464 
467 
469  std::string materialTheme{""};
470 
472  std::string materialPrimary{""};
473 
475  std::string materialAccent{""};
476 
478  std::string toolBarColorLight{""};
479 
481  std::string toolBarTextColorLight{""};
482 
484  std::string toolBarColorDark{""};
485 
487  std::string toolBarTextColorDark{""};
488 
490  std::string pluginToolBarColorLight{""};
491 
493  std::string pluginToolBarTextColorLight{""};
494 
496  std::string pluginToolBarColorDark{""};
497 
499  std::string pluginToolBarTextColorDark{""};
500 
502  bool showDrawer{true};
503 
505  bool showDefaultDrawerOpts{true};
506 
508  bool showPluginMenu{true};
509 
512  bool pluginsFromPaths{true};
513 
516 
519 
521  std::string plugins{""};
522  };
523  }
524 }
525 
526 #ifdef _MSC_VER
527 #pragma warning(pop)
528 #endif
529 
530 #endif
STL namespace.
Holds configurations related to a MainWindow.
Definition: MainWindow.hh:436
STL class.
std::set< std::string > ignoredProps
List of window properties which should be ignored on load.
Definition: MainWindow.hh:518
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: MainWindow.hh:48
QByteArray state
Window state (dock configuration)
Definition: MainWindow.hh:466
std::vector< std::string > showPlugins
List of plugins which should be shown on the list.
Definition: MainWindow.hh:515