Gazebo Gui

API Reference

7.2.2
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 gz::gui
39 {
40  Q_NAMESPACE
41  class MainWindowPrivate;
42  struct WindowConfig;
43 
45  enum class ExitAction
46  {
48  CLOSE_GUI,
51  };
53  Q_ENUM_NS(ExitAction)
55 
59  class GZ_GUI_VISIBLE MainWindow : public QObject
60  {
61  Q_OBJECT
62 
64  Q_PROPERTY(
65  int pluginCount
66  READ PluginCount
67  WRITE SetPluginCount
68  NOTIFY PluginCountChanged
69  )
70 
71 
72  Q_PROPERTY(
73  QString materialTheme
74  READ MaterialTheme
75  WRITE SetMaterialTheme
76  NOTIFY MaterialThemeChanged
77  )
78 
80  Q_PROPERTY(
81  QString materialPrimary
82  READ MaterialPrimary
83  WRITE SetMaterialPrimary
84  NOTIFY MaterialPrimaryChanged
85  )
86 
88  Q_PROPERTY(
89  QString materialAccent
90  READ MaterialAccent
91  WRITE SetMaterialAccent
92  NOTIFY MaterialAccentChanged
93  )
94 
97  Q_PROPERTY(
98  QString toolBarColorLight
99  READ ToolBarColorLight
100  WRITE SetToolBarColorLight
101  NOTIFY ToolBarColorLightChanged
102  )
103 
106  Q_PROPERTY(
107  QString toolBarTextColorLight
108  READ ToolBarTextColorLight
109  WRITE SetToolBarTextColorLight
110  NOTIFY ToolBarTextColorLightChanged
111  )
112 
115  Q_PROPERTY(
116  QString toolBarColorDark
117  READ ToolBarColorDark
118  WRITE SetToolBarColorDark
119  NOTIFY ToolBarColorDarkChanged
120  )
121 
124  Q_PROPERTY(
125  QString toolBarTextColorDark
126  READ ToolBarTextColorDark
127  WRITE SetToolBarTextColorDark
128  NOTIFY ToolBarTextColorDarkChanged
129  )
130 
133  Q_PROPERTY(
134  QString pluginToolBarColorLight
135  READ PluginToolBarColorLight
136  WRITE SetPluginToolBarColorLight
137  NOTIFY PluginToolBarColorLightChanged
138  )
139 
142  Q_PROPERTY(
143  QString pluginToolBarTextColorLight
144  READ PluginToolBarTextColorLight
145  WRITE SetPluginToolBarTextColorLight
146  NOTIFY PluginToolBarTextColorLightChanged
147  )
148 
151  Q_PROPERTY(
152  QString pluginToolBarColorDark
153  READ PluginToolBarColorDark
154  WRITE SetPluginToolBarColorDark
155  NOTIFY PluginToolBarColorDarkChanged
156  )
157 
160  Q_PROPERTY(
161  QString pluginToolBarTextColorDark
162  READ PluginToolBarTextColorDark
163  WRITE SetPluginToolBarTextColorDark
164  NOTIFY PluginToolBarTextColorDarkChanged
165  )
166 
168  Q_PROPERTY(
169  bool showDrawer
170  READ ShowDrawer
171  WRITE SetShowDrawer
172  NOTIFY ShowDrawerChanged
173  )
174 
176  Q_PROPERTY(
177  bool showDefaultDrawerOpts
178  READ ShowDefaultDrawerOpts
179  WRITE SetShowDefaultDrawerOpts
180  NOTIFY ShowDefaultDrawerOptsChanged
181  )
182 
184  Q_PROPERTY(
185  bool showPluginMenu
186  READ ShowPluginMenu
187  WRITE SetShowPluginMenu
188  NOTIFY ShowPluginMenuChanged
189  )
190 
192  Q_PROPERTY(
193  ExitAction defaultExitAction
194  READ DefaultExitAction
195  WRITE SetDefaultExitAction
196  NOTIFY DefaultExitActionChanged
197  )
198 
200  Q_PROPERTY(
201  bool showDialogOnExit
202  READ ShowDialogOnExit
203  WRITE SetShowDialogOnExit
204  NOTIFY ShowDialogOnExitChanged
205  )
206 
208  Q_PROPERTY(
209  QString dialogOnExitText
210  READ DialogOnExitText
211  WRITE SetDialogOnExitText
212  NOTIFY DialogOnExitTextChanged
213  )
214 
216  Q_PROPERTY(
217  bool exitDialogShowShutdown
218  READ ExitDialogShowShutdown
219  WRITE SetExitDialogShowShutdown
220  NOTIFY ExitDialogShowShutdownChanged
221  )
222 
224  Q_PROPERTY(
225  bool exitDialogShowCloseGui
226  READ ExitDialogShowCloseGui
227  WRITE SetExitDialogShowCloseGui
228  NOTIFY ExitDialogShowCloseGuiChanged
229  )
230 
232  Q_PROPERTY(
233  QString exitDialogShutdownText
234  READ ExitDialogShutdownText
235  WRITE SetExitDialogShutdownText
236  NOTIFY ExitDialogShutdownTextChanged
237  )
238 
240  Q_PROPERTY(
241  QString exitDialogCloseGuiText
242  READ ExitDialogCloseGuiText
243  WRITE SetExitDialogCloseGuiText
244  NOTIFY ExitDialogCloseGuiTextChanged
245  )
246 
248  public: MainWindow();
249 
251  public: virtual ~MainWindow();
252 
255  public: QQuickWindow *QuickWindow() const;
256 
261  public: void SaveConfig(const std::string &_path);
262 
266  public: bool ApplyConfig(const WindowConfig &_config);
267 
270  public: WindowConfig CurrentWindowConfig() const;
271 
274  public: void SetRenderEngine(const std::string &_renderEngine);
275 
278  public slots: void OnAddPlugin(QString _plugin);
279 
282  public: Q_INVOKABLE QStringList PluginListModel() const;
283 
287  public: Q_INVOKABLE int PluginCount() const;
288 
292  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
293 
296  public: Q_INVOKABLE QString MaterialTheme() const;
297 
300  public: Q_INVOKABLE void SetMaterialTheme(
301  const QString &_materialTheme);
302 
305  public: Q_INVOKABLE QString MaterialPrimary() const;
306 
309  public: Q_INVOKABLE void SetMaterialPrimary(
310  const QString &_materialPrimary);
311 
314  public: Q_INVOKABLE QString MaterialAccent() const;
315 
318  public: Q_INVOKABLE void SetMaterialAccent(
319  const QString &_materialAccent);
320 
323  public: Q_INVOKABLE QString ToolBarColorLight() const;
324 
327  public: Q_INVOKABLE void SetToolBarColorLight(
328  const QString &_toolBarColorLight);
329 
332  public: Q_INVOKABLE QString ToolBarTextColorLight() const;
333 
336  public: Q_INVOKABLE void SetToolBarTextColorLight(
337  const QString &_toolBarTextColorLight);
338 
341  public: Q_INVOKABLE QString ToolBarColorDark() const;
342 
345  public: Q_INVOKABLE void SetToolBarColorDark(
346  const QString &_toolBarColorDark);
347 
350  public: Q_INVOKABLE QString ToolBarTextColorDark() const;
351 
354  public: Q_INVOKABLE void SetToolBarTextColorDark(
355  const QString &_toolBarTextColorDark);
356 
359  public: Q_INVOKABLE QString PluginToolBarColorLight() const;
360 
363  public: Q_INVOKABLE void SetPluginToolBarColorLight(
364  const QString &_pluginPluginToolBarColorLight);
365 
368  public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
369 
372  public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
373  const QString &_pluginPluginToolBarTextColorLight);
374 
377  public: Q_INVOKABLE QString PluginToolBarColorDark() const;
378 
381  public: Q_INVOKABLE void SetPluginToolBarColorDark(
382  const QString &_pluginPluginToolBarColorDark);
383 
386  public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
387 
390  public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
391  const QString &_pluginPluginToolBarTextColorDark);
392 
395  public: Q_INVOKABLE bool ShowDrawer() const;
396 
399  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
400 
403  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
404 
407  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
408  const bool _showDefaultDrawerOpts);
409 
412  public: Q_INVOKABLE bool ShowPluginMenu() const;
413 
416  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
417 
420  public: Q_INVOKABLE ExitAction DefaultExitAction() const;
421 
424  public: Q_INVOKABLE void SetDefaultExitAction(
425  enum ExitAction _defaultExitAction);
426 
429  public: Q_INVOKABLE bool ShowDialogOnExit() const;
430 
433  public: Q_INVOKABLE void SetShowDialogOnExit(bool _showDialogOnExit);
434 
437  public: Q_INVOKABLE QString DialogOnExitText() const;
438 
441  public: Q_INVOKABLE void SetDialogOnExitText(
442  const QString &_dialogOnExitText);
443 
446  public: Q_INVOKABLE bool ExitDialogShowShutdown() const;
447 
450  public: Q_INVOKABLE void SetExitDialogShowShutdown(
451  bool _exitDialogShowShutdown);
452 
455  public: Q_INVOKABLE bool ExitDialogShowCloseGui() const;
456 
459  public: Q_INVOKABLE void SetExitDialogShowCloseGui(
460  bool _exitDialogShowCloseGui);
461 
464  public: Q_INVOKABLE QString ExitDialogShutdownText() const;
465 
468  public: Q_INVOKABLE void SetExitDialogShutdownText(
469  const QString &_exitDialogShutdownText);
470 
473  public: Q_INVOKABLE QString ExitDialogCloseGuiText() const;
474 
477  public: Q_INVOKABLE void SetExitDialogCloseGuiText(
478  const QString &_exitDialogCloseGuiText);
479 
482  public: Q_INVOKABLE std::string ServerControlService() const;
483 
486  public: Q_INVOKABLE void SetServerControlService(
487  const std::string &_service);
488 
490  public slots: void OnLoadConfig(const QString &_path);
491 
493  public slots: void OnSaveConfig();
494 
496  public slots: void OnSaveConfigAs(const QString &_path);
497 
499  public slots: void OnStopServer();
500 
502  signals: void PluginCountChanged();
503 
505  signals: void MaterialThemeChanged();
506 
508  signals: void MaterialPrimaryChanged();
509 
511  signals: void MaterialAccentChanged();
512 
514  signals: void ToolBarColorLightChanged();
515 
517  signals: void ToolBarTextColorLightChanged();
518 
520  signals: void ToolBarColorDarkChanged();
521 
523  signals: void ToolBarTextColorDarkChanged();
524 
526  signals: void PluginToolBarColorLightChanged();
527 
529  signals: void PluginToolBarTextColorLightChanged();
530 
532  signals: void PluginToolBarColorDarkChanged();
533 
535  signals: void PluginToolBarTextColorDarkChanged();
536 
538  signals: void ShowDrawerChanged();
539 
541  signals: void ShowDefaultDrawerOptsChanged();
542 
544  signals: void ShowPluginMenuChanged();
545 
547  signals: void DefaultExitActionChanged();
548 
550  signals: void ShowDialogOnExitChanged();
551 
553  signals: void DialogOnExitTextChanged();
554 
556  signals: void ExitDialogShowShutdownChanged();
557 
559  signals: void ExitDialogShowCloseGuiChanged();
560 
562  signals: void ExitDialogShutdownTextChanged();
563 
565  signals: void ExitDialogCloseGuiTextChanged();
566 
568  signals: void configChanged();
569 
573  signals: void notify(const QString &_message);
574 
582  signals: void notifyWithDuration(const QString &_message, int _duration);
583 
586  private: std::unique_ptr<MainWindowPrivate> dataPtr;
587  };
588 
590  struct GZ_GUI_VISIBLE WindowConfig
591  {
597  bool MergeFromXML(const std::string &_xml);
598 
601  std::string XMLString() const;
602 
605  bool IsIgnoring(const std::string &_prop) const;
606 
608  int posX{-1};
609 
611  int posY{-1};
612 
614  int width{-1};
615 
617  int height{-1};
618 
621 
623  std::string materialTheme{""};
624 
626  std::string materialPrimary{""};
627 
629  std::string materialAccent{""};
630 
632  std::string toolBarColorLight{""};
633 
635  std::string toolBarTextColorLight{""};
636 
638  std::string toolBarColorDark{""};
639 
641  std::string toolBarTextColorDark{""};
642 
644  std::string pluginToolBarColorLight{""};
645 
647  std::string pluginToolBarTextColorLight{""};
648 
650  std::string pluginToolBarColorDark{""};
651 
653  std::string pluginToolBarTextColorDark{""};
654 
656  bool showDrawer{true};
657 
659  bool showDefaultDrawerOpts{true};
660 
662  bool showPluginMenu{true};
663 
666  bool pluginsFromPaths{true};
667 
670 
673 
676  };
677 } // namespace gz::gui
678 
679 #ifdef _MSC_VER
680 #pragma warning(pop)
681 #endif
682 
683 #endif // GZ_GUI_MAINWINDOW_HH_