Gazebo Gui

API Reference

3.12.0
gz/gui/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 GZ_GUI_MAINWINDOW_HH_
18 #define GZ_GUI_MAINWINDOW_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <set>
23 #include <string>
24 #include <vector>
25 
26 #include <gz/common/Console.hh>
27 
28 #include "gz/gui/qt.h"
29 #include "gz/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  Q_NAMESPACE
43  class MainWindowPrivate;
44  struct WindowConfig;
45 
47  enum class ExitAction
48  {
50  CLOSE_GUI,
53  };
55  Q_ENUM_NS(ExitAction)
57 
61  class IGNITION_GUI_VISIBLE MainWindow : public QObject
62  {
63  Q_OBJECT
64 
66  Q_PROPERTY(
67  int pluginCount
68  READ PluginCount
69  WRITE SetPluginCount
70  NOTIFY PluginCountChanged
71  )
72 
73 
74  Q_PROPERTY(
75  QString materialTheme
76  READ MaterialTheme
77  WRITE SetMaterialTheme
78  NOTIFY MaterialThemeChanged
79  )
80 
82  Q_PROPERTY(
83  QString materialPrimary
84  READ MaterialPrimary
85  WRITE SetMaterialPrimary
86  NOTIFY MaterialPrimaryChanged
87  )
88 
90  Q_PROPERTY(
91  QString materialAccent
92  READ MaterialAccent
93  WRITE SetMaterialAccent
94  NOTIFY MaterialAccentChanged
95  )
96 
99  Q_PROPERTY(
100  QString toolBarColorLight
101  READ ToolBarColorLight
102  WRITE SetToolBarColorLight
103  NOTIFY ToolBarColorLightChanged
104  )
105 
108  Q_PROPERTY(
109  QString toolBarTextColorLight
110  READ ToolBarTextColorLight
111  WRITE SetToolBarTextColorLight
112  NOTIFY ToolBarTextColorLightChanged
113  )
114 
117  Q_PROPERTY(
118  QString toolBarColorDark
119  READ ToolBarColorDark
120  WRITE SetToolBarColorDark
121  NOTIFY ToolBarColorDarkChanged
122  )
123 
126  Q_PROPERTY(
127  QString toolBarTextColorDark
128  READ ToolBarTextColorDark
129  WRITE SetToolBarTextColorDark
130  NOTIFY ToolBarTextColorDarkChanged
131  )
132 
135  Q_PROPERTY(
136  QString pluginToolBarColorLight
137  READ PluginToolBarColorLight
138  WRITE SetPluginToolBarColorLight
139  NOTIFY PluginToolBarColorLightChanged
140  )
141 
144  Q_PROPERTY(
145  QString pluginToolBarTextColorLight
146  READ PluginToolBarTextColorLight
147  WRITE SetPluginToolBarTextColorLight
148  NOTIFY PluginToolBarTextColorLightChanged
149  )
150 
153  Q_PROPERTY(
154  QString pluginToolBarColorDark
155  READ PluginToolBarColorDark
156  WRITE SetPluginToolBarColorDark
157  NOTIFY PluginToolBarColorDarkChanged
158  )
159 
162  Q_PROPERTY(
163  QString pluginToolBarTextColorDark
164  READ PluginToolBarTextColorDark
165  WRITE SetPluginToolBarTextColorDark
166  NOTIFY PluginToolBarTextColorDarkChanged
167  )
168 
170  Q_PROPERTY(
171  bool showDrawer
172  READ ShowDrawer
173  WRITE SetShowDrawer
174  NOTIFY ShowDrawerChanged
175  )
176 
178  Q_PROPERTY(
179  bool showDefaultDrawerOpts
180  READ ShowDefaultDrawerOpts
181  WRITE SetShowDefaultDrawerOpts
182  NOTIFY ShowDefaultDrawerOptsChanged
183  )
184 
186  Q_PROPERTY(
187  bool showPluginMenu
188  READ ShowPluginMenu
189  WRITE SetShowPluginMenu
190  NOTIFY ShowPluginMenuChanged
191  )
192 
194  Q_PROPERTY(
195  ExitAction defaultExitAction
196  READ DefaultExitAction
197  WRITE SetDefaultExitAction
198  NOTIFY DefaultExitActionChanged
199  )
200 
202  Q_PROPERTY(
203  bool showDialogOnExit
204  READ ShowDialogOnExit
205  WRITE SetShowDialogOnExit
206  NOTIFY ShowDialogOnExitChanged
207  )
208 
210  Q_PROPERTY(
211  QString dialogOnExitText
212  READ DialogOnExitText
213  WRITE SetDialogOnExitText
214  NOTIFY DialogOnExitTextChanged
215  )
216 
218  Q_PROPERTY(
219  bool exitDialogShowShutdown
220  READ ExitDialogShowShutdown
221  WRITE SetExitDialogShowShutdown
222  NOTIFY ExitDialogShowShutdownChanged
223  )
224 
226  Q_PROPERTY(
227  bool exitDialogShowCloseGui
228  READ ExitDialogShowCloseGui
229  WRITE SetExitDialogShowCloseGui
230  NOTIFY ExitDialogShowCloseGuiChanged
231  )
232 
234  Q_PROPERTY(
235  QString exitDialogShutdownText
236  READ ExitDialogShutdownText
237  WRITE SetExitDialogShutdownText
238  NOTIFY ExitDialogShutdownTextChanged
239  )
240 
242  Q_PROPERTY(
243  QString exitDialogCloseGuiText
244  READ ExitDialogCloseGuiText
245  WRITE SetExitDialogCloseGuiText
246  NOTIFY ExitDialogCloseGuiTextChanged
247  )
248 
250  public: MainWindow();
251 
253  public: virtual ~MainWindow();
254 
257  public: QQuickWindow *QuickWindow() const;
258 
263  public: void SaveConfig(const std::string &_path);
264 
268  public: bool ApplyConfig(const WindowConfig &_config);
269 
272  public: WindowConfig CurrentWindowConfig() const;
273 
276  public slots: void OnAddPlugin(QString _plugin);
277 
280  public: Q_INVOKABLE QStringList PluginListModel() const;
281 
285  public: Q_INVOKABLE int PluginCount() const;
286 
290  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
291 
294  public: Q_INVOKABLE QString MaterialTheme() const;
295 
298  public: Q_INVOKABLE void SetMaterialTheme(
299  const QString &_materialTheme);
300 
303  public: Q_INVOKABLE QString MaterialPrimary() const;
304 
307  public: Q_INVOKABLE void SetMaterialPrimary(
308  const QString &_materialPrimary);
309 
312  public: Q_INVOKABLE QString MaterialAccent() const;
313 
316  public: Q_INVOKABLE void SetMaterialAccent(
317  const QString &_materialAccent);
318 
321  public: Q_INVOKABLE QString ToolBarColorLight() const;
322 
325  public: Q_INVOKABLE void SetToolBarColorLight(
326  const QString &_toolBarColorLight);
327 
330  public: Q_INVOKABLE QString ToolBarTextColorLight() const;
331 
334  public: Q_INVOKABLE void SetToolBarTextColorLight(
335  const QString &_toolBarTextColorLight);
336 
339  public: Q_INVOKABLE QString ToolBarColorDark() const;
340 
343  public: Q_INVOKABLE void SetToolBarColorDark(
344  const QString &_toolBarColorDark);
345 
348  public: Q_INVOKABLE QString ToolBarTextColorDark() const;
349 
352  public: Q_INVOKABLE void SetToolBarTextColorDark(
353  const QString &_toolBarTextColorDark);
354 
357  public: Q_INVOKABLE QString PluginToolBarColorLight() const;
358 
361  public: Q_INVOKABLE void SetPluginToolBarColorLight(
362  const QString &_pluginPluginToolBarColorLight);
363 
366  public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
367 
370  public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
371  const QString &_pluginPluginToolBarTextColorLight);
372 
375  public: Q_INVOKABLE QString PluginToolBarColorDark() const;
376 
379  public: Q_INVOKABLE void SetPluginToolBarColorDark(
380  const QString &_pluginPluginToolBarColorDark);
381 
384  public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
385 
388  public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
389  const QString &_pluginPluginToolBarTextColorDark);
390 
393  public: Q_INVOKABLE bool ShowDrawer() const;
394 
397  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
398 
401  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
402 
405  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
406  const bool _showDefaultDrawerOpts);
407 
410  public: Q_INVOKABLE bool ShowPluginMenu() const;
411 
414  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
415 
418  public: Q_INVOKABLE ExitAction DefaultExitAction() const;
419 
422  public: Q_INVOKABLE void SetDefaultExitAction(
423  enum ExitAction _defaultExitAction);
424 
427  public: Q_INVOKABLE bool ShowDialogOnExit() const;
428 
431  public: Q_INVOKABLE void SetShowDialogOnExit(bool _showDialogOnExit);
432 
435  public: Q_INVOKABLE QString DialogOnExitText() const;
436 
439  public: Q_INVOKABLE void SetDialogOnExitText(
440  const QString &_dialogOnExitText);
441 
444  public: Q_INVOKABLE bool ExitDialogShowShutdown() const;
445 
448  public: Q_INVOKABLE void SetExitDialogShowShutdown(
449  bool _exitDialogShowShutdown);
450 
453  public: Q_INVOKABLE bool ExitDialogShowCloseGui() const;
454 
457  public: Q_INVOKABLE void SetExitDialogShowCloseGui(
458  bool _exitDialogShowCloseGui);
459 
462  public: Q_INVOKABLE QString ExitDialogShutdownText() const;
463 
466  public: Q_INVOKABLE void SetExitDialogShutdownText(
467  const QString &_exitDialogShutdownText);
468 
471  public: Q_INVOKABLE QString ExitDialogCloseGuiText() const;
472 
475  public: Q_INVOKABLE void SetExitDialogCloseGuiText(
476  const QString &_exitDialogCloseGuiText);
477 
480  public: Q_INVOKABLE std::string ServerControlService() const;
481 
484  public: Q_INVOKABLE void SetServerControlService(
485  const std::string &_service);
486 
488  public slots: void OnLoadConfig(const QString &_path);
489 
491  public slots: void OnSaveConfig();
492 
494  public slots: void OnSaveConfigAs(const QString &_path);
495 
497  public slots: void OnStopServer();
498 
500  signals: void PluginCountChanged();
501 
503  signals: void MaterialThemeChanged();
504 
506  signals: void MaterialPrimaryChanged();
507 
509  signals: void MaterialAccentChanged();
510 
512  signals: void ToolBarColorLightChanged();
513 
515  signals: void ToolBarTextColorLightChanged();
516 
518  signals: void ToolBarColorDarkChanged();
519 
521  signals: void ToolBarTextColorDarkChanged();
522 
524  signals: void PluginToolBarColorLightChanged();
525 
527  signals: void PluginToolBarTextColorLightChanged();
528 
530  signals: void PluginToolBarColorDarkChanged();
531 
533  signals: void PluginToolBarTextColorDarkChanged();
534 
536  signals: void ShowDrawerChanged();
537 
539  signals: void ShowDefaultDrawerOptsChanged();
540 
542  signals: void ShowPluginMenuChanged();
543 
545  signals: void DefaultExitActionChanged();
546 
548  signals: void ShowDialogOnExitChanged();
549 
551  signals: void DialogOnExitTextChanged();
552 
554  signals: void ExitDialogShowShutdownChanged();
555 
557  signals: void ExitDialogShowCloseGuiChanged();
558 
560  signals: void ExitDialogShutdownTextChanged();
561 
563  signals: void ExitDialogCloseGuiTextChanged();
564 
566  signals: void configChanged();
567 
571  signals: void notify(const QString &_message);
572 
580  signals: void notifyWithDuration(const QString &_message, int _duration);
581 
584  private: std::unique_ptr<MainWindowPrivate> dataPtr;
585  };
586 
588  struct IGNITION_GUI_VISIBLE WindowConfig
589  {
595  bool MergeFromXML(const std::string &_xml);
596 
599  std::string XMLString() const;
600 
603  bool IsIgnoring(const std::string &_prop) const;
604 
606  int posX{-1};
607 
609  int posY{-1};
610 
612  int width{-1};
613 
615  int height{-1};
616 
619 
621  std::string materialTheme{""};
622 
624  std::string materialPrimary{""};
625 
627  std::string materialAccent{""};
628 
630  std::string toolBarColorLight{""};
631 
633  std::string toolBarTextColorLight{""};
634 
636  std::string toolBarColorDark{""};
637 
639  std::string toolBarTextColorDark{""};
640 
642  std::string pluginToolBarColorLight{""};
643 
645  std::string pluginToolBarTextColorLight{""};
646 
648  std::string pluginToolBarColorDark{""};
649 
651  std::string pluginToolBarTextColorDark{""};
652 
654  bool showDrawer{true};
655 
657  bool showDefaultDrawerOpts{true};
658 
660  bool showPluginMenu{true};
661 
664  bool pluginsFromPaths{true};
665 
668 
671 
673  std::string plugins{""};
674 
675  };
676  }
677 }
678 
679 #ifdef _MSC_VER
680 #pragma warning(pop)
681 #endif
682 
683 #endif
STL class.
Holds configurations related to a MainWindow.
Definition: gz/gui/MainWindow.hh:588
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: gz/gui/MainWindow.hh:61
@ CLOSE_GUI
Close GUI and leave server running.
ExitAction
The action executed when GUI is closed without prompt.
Definition: gz/gui/MainWindow.hh:47
std::set< std::string > ignoredProps
List of window properties which should be ignored on load.
Definition: gz/gui/MainWindow.hh:670
QByteArray state
Window state (dock configuration)
Definition: gz/gui/MainWindow.hh:618
std::vector< std::string > showPlugins
List of plugins which should be shown on the list.
Definition: gz/gui/MainWindow.hh:667
STL namespace.
@ SHUTDOWN_SERVER
Close GUI and shutdown server.