Gazebo Gui

API Reference

6.8.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: void SetRenderEngine(const std::string &_renderEngine);
277 
280  public slots: void OnAddPlugin(QString _plugin);
281 
284  public: Q_INVOKABLE QStringList PluginListModel() const;
285 
289  public: Q_INVOKABLE int PluginCount() const;
290 
294  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
295 
298  public: Q_INVOKABLE QString MaterialTheme() const;
299 
302  public: Q_INVOKABLE void SetMaterialTheme(
303  const QString &_materialTheme);
304 
307  public: Q_INVOKABLE QString MaterialPrimary() const;
308 
311  public: Q_INVOKABLE void SetMaterialPrimary(
312  const QString &_materialPrimary);
313 
316  public: Q_INVOKABLE QString MaterialAccent() const;
317 
320  public: Q_INVOKABLE void SetMaterialAccent(
321  const QString &_materialAccent);
322 
325  public: Q_INVOKABLE QString ToolBarColorLight() const;
326 
329  public: Q_INVOKABLE void SetToolBarColorLight(
330  const QString &_toolBarColorLight);
331 
334  public: Q_INVOKABLE QString ToolBarTextColorLight() const;
335 
338  public: Q_INVOKABLE void SetToolBarTextColorLight(
339  const QString &_toolBarTextColorLight);
340 
343  public: Q_INVOKABLE QString ToolBarColorDark() const;
344 
347  public: Q_INVOKABLE void SetToolBarColorDark(
348  const QString &_toolBarColorDark);
349 
352  public: Q_INVOKABLE QString ToolBarTextColorDark() const;
353 
356  public: Q_INVOKABLE void SetToolBarTextColorDark(
357  const QString &_toolBarTextColorDark);
358 
361  public: Q_INVOKABLE QString PluginToolBarColorLight() const;
362 
365  public: Q_INVOKABLE void SetPluginToolBarColorLight(
366  const QString &_pluginPluginToolBarColorLight);
367 
370  public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
371 
374  public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
375  const QString &_pluginPluginToolBarTextColorLight);
376 
379  public: Q_INVOKABLE QString PluginToolBarColorDark() const;
380 
383  public: Q_INVOKABLE void SetPluginToolBarColorDark(
384  const QString &_pluginPluginToolBarColorDark);
385 
388  public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
389 
392  public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
393  const QString &_pluginPluginToolBarTextColorDark);
394 
397  public: Q_INVOKABLE bool ShowDrawer() const;
398 
401  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
402 
405  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
406 
409  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
410  const bool _showDefaultDrawerOpts);
411 
414  public: Q_INVOKABLE bool ShowPluginMenu() const;
415 
418  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
419 
422  public: Q_INVOKABLE ExitAction DefaultExitAction() const;
423 
426  public: Q_INVOKABLE void SetDefaultExitAction(
427  enum ExitAction _defaultExitAction);
428 
431  public: Q_INVOKABLE bool ShowDialogOnExit() const;
432 
435  public: Q_INVOKABLE void SetShowDialogOnExit(bool _showDialogOnExit);
436 
439  public: Q_INVOKABLE QString DialogOnExitText() const;
440 
443  public: Q_INVOKABLE void SetDialogOnExitText(
444  const QString &_dialogOnExitText);
445 
448  public: Q_INVOKABLE bool ExitDialogShowShutdown() const;
449 
452  public: Q_INVOKABLE void SetExitDialogShowShutdown(
453  bool _exitDialogShowShutdown);
454 
457  public: Q_INVOKABLE bool ExitDialogShowCloseGui() const;
458 
461  public: Q_INVOKABLE void SetExitDialogShowCloseGui(
462  bool _exitDialogShowCloseGui);
463 
466  public: Q_INVOKABLE QString ExitDialogShutdownText() const;
467 
470  public: Q_INVOKABLE void SetExitDialogShutdownText(
471  const QString &_exitDialogShutdownText);
472 
475  public: Q_INVOKABLE QString ExitDialogCloseGuiText() const;
476 
479  public: Q_INVOKABLE void SetExitDialogCloseGuiText(
480  const QString &_exitDialogCloseGuiText);
481 
484  public: Q_INVOKABLE std::string ServerControlService() const;
485 
488  public: Q_INVOKABLE void SetServerControlService(
489  const std::string &_service);
490 
492  public slots: void OnLoadConfig(const QString &_path);
493 
495  public slots: void OnSaveConfig();
496 
498  public slots: void OnSaveConfigAs(const QString &_path);
499 
501  public slots: void OnStopServer();
502 
504  signals: void PluginCountChanged();
505 
507  signals: void MaterialThemeChanged();
508 
510  signals: void MaterialPrimaryChanged();
511 
513  signals: void MaterialAccentChanged();
514 
516  signals: void ToolBarColorLightChanged();
517 
519  signals: void ToolBarTextColorLightChanged();
520 
522  signals: void ToolBarColorDarkChanged();
523 
525  signals: void ToolBarTextColorDarkChanged();
526 
528  signals: void PluginToolBarColorLightChanged();
529 
531  signals: void PluginToolBarTextColorLightChanged();
532 
534  signals: void PluginToolBarColorDarkChanged();
535 
537  signals: void PluginToolBarTextColorDarkChanged();
538 
540  signals: void ShowDrawerChanged();
541 
543  signals: void ShowDefaultDrawerOptsChanged();
544 
546  signals: void ShowPluginMenuChanged();
547 
549  signals: void DefaultExitActionChanged();
550 
552  signals: void ShowDialogOnExitChanged();
553 
555  signals: void DialogOnExitTextChanged();
556 
558  signals: void ExitDialogShowShutdownChanged();
559 
561  signals: void ExitDialogShowCloseGuiChanged();
562 
564  signals: void ExitDialogShutdownTextChanged();
565 
567  signals: void ExitDialogCloseGuiTextChanged();
568 
570  signals: void configChanged();
571 
575  signals: void notify(const QString &_message);
576 
584  signals: void notifyWithDuration(const QString &_message, int _duration);
585 
588  private: std::unique_ptr<MainWindowPrivate> dataPtr;
589  };
590 
592  struct IGNITION_GUI_VISIBLE WindowConfig
593  {
599  bool MergeFromXML(const std::string &_xml);
600 
603  std::string XMLString() const;
604 
607  bool IsIgnoring(const std::string &_prop) const;
608 
610  int posX{-1};
611 
613  int posY{-1};
614 
616  int width{-1};
617 
619  int height{-1};
620 
623 
625  std::string materialTheme{""};
626 
628  std::string materialPrimary{""};
629 
631  std::string materialAccent{""};
632 
634  std::string toolBarColorLight{""};
635 
637  std::string toolBarTextColorLight{""};
638 
640  std::string toolBarColorDark{""};
641 
643  std::string toolBarTextColorDark{""};
644 
646  std::string pluginToolBarColorLight{""};
647 
649  std::string pluginToolBarTextColorLight{""};
650 
652  std::string pluginToolBarColorDark{""};
653 
655  std::string pluginToolBarTextColorDark{""};
656 
658  bool showDrawer{true};
659 
661  bool showDefaultDrawerOpts{true};
662 
664  bool showPluginMenu{true};
665 
668  bool pluginsFromPaths{true};
669 
672 
675 
677  std::string plugins{""};
678 
679  };
680  }
681 }
682 
683 #ifdef _MSC_VER
684 #pragma warning(pop)
685 #endif
686 
687 #endif
STL class.
Holds configurations related to a MainWindow.
Definition: gz/gui/MainWindow.hh:592
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:674
QByteArray state
Window state (dock configuration)
Definition: gz/gui/MainWindow.hh:622
std::vector< std::string > showPlugins
List of plugins which should be shown on the list.
Definition: gz/gui/MainWindow.hh:671
STL namespace.
@ SHUTDOWN_SERVER
Close GUI and shutdown server.