Gazebo Gui

API Reference

9.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 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
31namespace gz::gui
32{
33 Q_NAMESPACE
34 struct WindowConfig;
35
37 enum class ExitAction
38 {
43 };
45 Q_ENUM_NS(ExitAction)
47
51 class GZ_GUI_VISIBLE MainWindow : public QObject
52 {
53 Q_OBJECT
54
56 Q_PROPERTY(
57 int pluginCount
58 READ PluginCount
59 WRITE SetPluginCount
60 NOTIFY PluginCountChanged
61 )
62
63
64 Q_PROPERTY(
65 QString materialTheme
66 READ MaterialTheme
67 WRITE SetMaterialTheme
68 NOTIFY MaterialThemeChanged
69 )
70
72 Q_PROPERTY(
73 QString materialPrimary
74 READ MaterialPrimary
75 WRITE SetMaterialPrimary
76 NOTIFY MaterialPrimaryChanged
77 )
78
80 Q_PROPERTY(
81 QString materialAccent
82 READ MaterialAccent
83 WRITE SetMaterialAccent
84 NOTIFY MaterialAccentChanged
85 )
86
89 Q_PROPERTY(
90 QString toolBarColorLight
91 READ ToolBarColorLight
92 WRITE SetToolBarColorLight
93 NOTIFY ToolBarColorLightChanged
94 )
95
98 Q_PROPERTY(
99 QString toolBarTextColorLight
100 READ ToolBarTextColorLight
101 WRITE SetToolBarTextColorLight
102 NOTIFY ToolBarTextColorLightChanged
103 )
104
107 Q_PROPERTY(
108 QString toolBarColorDark
109 READ ToolBarColorDark
110 WRITE SetToolBarColorDark
111 NOTIFY ToolBarColorDarkChanged
112 )
113
116 Q_PROPERTY(
117 QString toolBarTextColorDark
118 READ ToolBarTextColorDark
119 WRITE SetToolBarTextColorDark
120 NOTIFY ToolBarTextColorDarkChanged
121 )
122
125 Q_PROPERTY(
126 QString pluginToolBarColorLight
127 READ PluginToolBarColorLight
128 WRITE SetPluginToolBarColorLight
129 NOTIFY PluginToolBarColorLightChanged
130 )
131
134 Q_PROPERTY(
135 QString pluginToolBarTextColorLight
136 READ PluginToolBarTextColorLight
137 WRITE SetPluginToolBarTextColorLight
138 NOTIFY PluginToolBarTextColorLightChanged
139 )
140
143 Q_PROPERTY(
144 QString pluginToolBarColorDark
145 READ PluginToolBarColorDark
146 WRITE SetPluginToolBarColorDark
147 NOTIFY PluginToolBarColorDarkChanged
148 )
149
152 Q_PROPERTY(
153 QString pluginToolBarTextColorDark
154 READ PluginToolBarTextColorDark
155 WRITE SetPluginToolBarTextColorDark
156 NOTIFY PluginToolBarTextColorDarkChanged
157 )
158
160 Q_PROPERTY(
161 bool showDrawer
162 READ ShowDrawer
163 WRITE SetShowDrawer
164 NOTIFY ShowDrawerChanged
165 )
166
168 Q_PROPERTY(
169 bool showDefaultDrawerOpts
170 READ ShowDefaultDrawerOpts
171 WRITE SetShowDefaultDrawerOpts
172 NOTIFY ShowDefaultDrawerOptsChanged
173 )
174
176 Q_PROPERTY(
177 bool showPluginMenu
178 READ ShowPluginMenu
179 WRITE SetShowPluginMenu
180 NOTIFY ShowPluginMenuChanged
181 )
182
184 Q_PROPERTY(
185 ExitAction defaultExitAction
186 READ DefaultExitAction
187 WRITE SetDefaultExitAction
188 NOTIFY DefaultExitActionChanged
189 )
190
192 Q_PROPERTY(
193 bool showDialogOnExit
194 READ ShowDialogOnExit
195 WRITE SetShowDialogOnExit
196 NOTIFY ShowDialogOnExitChanged
197 )
198
200 Q_PROPERTY(
201 QString dialogOnExitText
202 READ DialogOnExitText
203 WRITE SetDialogOnExitText
204 NOTIFY DialogOnExitTextChanged
205 )
206
208 Q_PROPERTY(
209 bool exitDialogShowShutdown
210 READ ExitDialogShowShutdown
211 WRITE SetExitDialogShowShutdown
212 NOTIFY ExitDialogShowShutdownChanged
213 )
214
216 Q_PROPERTY(
217 bool exitDialogShowCloseGui
218 READ ExitDialogShowCloseGui
219 WRITE SetExitDialogShowCloseGui
220 NOTIFY ExitDialogShowCloseGuiChanged
221 )
222
224 Q_PROPERTY(
225 QString exitDialogShutdownText
226 READ ExitDialogShutdownText
227 WRITE SetExitDialogShutdownText
228 NOTIFY ExitDialogShutdownTextChanged
229 )
230
232 Q_PROPERTY(
233 QString exitDialogCloseGuiText
234 READ ExitDialogCloseGuiText
235 WRITE SetExitDialogCloseGuiText
236 NOTIFY ExitDialogCloseGuiTextChanged
237 )
238
240 public: MainWindow();
241
243 public: virtual ~MainWindow();
244
247 public: QQuickWindow *QuickWindow() const;
248
253 public: void SaveConfig(const std::string &_path);
254
258 public: bool ApplyConfig(const WindowConfig &_config);
259
262 public: WindowConfig CurrentWindowConfig() const;
263
266 public: void SetRenderEngine(const std::string &_renderEngine);
267
270 public slots: void OnAddPlugin(QString _plugin);
271
274 public: Q_INVOKABLE QStringList PluginListModel() const;
275
279 public: Q_INVOKABLE int PluginCount() const;
280
284 public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
285
288 public: Q_INVOKABLE QString MaterialTheme() const;
289
292 public: Q_INVOKABLE void SetMaterialTheme(
293 const QString &_materialTheme);
294
297 public: Q_INVOKABLE QString MaterialPrimary() const;
298
301 public: Q_INVOKABLE void SetMaterialPrimary(
302 const QString &_materialPrimary);
303
306 public: Q_INVOKABLE QString MaterialAccent() const;
307
310 public: Q_INVOKABLE void SetMaterialAccent(
311 const QString &_materialAccent);
312
315 public: Q_INVOKABLE QString ToolBarColorLight() const;
316
319 public: Q_INVOKABLE void SetToolBarColorLight(
320 const QString &_toolBarColorLight);
321
324 public: Q_INVOKABLE QString ToolBarTextColorLight() const;
325
328 public: Q_INVOKABLE void SetToolBarTextColorLight(
329 const QString &_toolBarTextColorLight);
330
333 public: Q_INVOKABLE QString ToolBarColorDark() const;
334
337 public: Q_INVOKABLE void SetToolBarColorDark(
338 const QString &_toolBarColorDark);
339
342 public: Q_INVOKABLE QString ToolBarTextColorDark() const;
343
346 public: Q_INVOKABLE void SetToolBarTextColorDark(
347 const QString &_toolBarTextColorDark);
348
351 public: Q_INVOKABLE QString PluginToolBarColorLight() const;
352
355 public: Q_INVOKABLE void SetPluginToolBarColorLight(
356 const QString &_pluginPluginToolBarColorLight);
357
360 public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
361
364 public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
365 const QString &_pluginPluginToolBarTextColorLight);
366
369 public: Q_INVOKABLE QString PluginToolBarColorDark() const;
370
373 public: Q_INVOKABLE void SetPluginToolBarColorDark(
374 const QString &_pluginPluginToolBarColorDark);
375
378 public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
379
382 public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
383 const QString &_pluginPluginToolBarTextColorDark);
384
387 public: Q_INVOKABLE bool ShowDrawer() const;
388
391 public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
392
395 public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
396
399 public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
400 const bool _showDefaultDrawerOpts);
401
404 public: Q_INVOKABLE bool ShowPluginMenu() const;
405
408 public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
409
412 public: Q_INVOKABLE gz::gui::ExitAction DefaultExitAction() const;
413
416 public: Q_INVOKABLE void SetDefaultExitAction(
417 enum ExitAction _defaultExitAction);
418
421 public: Q_INVOKABLE bool ShowDialogOnExit() const;
422
425 public: Q_INVOKABLE void SetShowDialogOnExit(bool _showDialogOnExit);
426
429 public: Q_INVOKABLE QString DialogOnExitText() const;
430
433 public: Q_INVOKABLE void SetDialogOnExitText(
434 const QString &_dialogOnExitText);
435
438 public: Q_INVOKABLE bool ExitDialogShowShutdown() const;
439
442 public: Q_INVOKABLE void SetExitDialogShowShutdown(
443 bool _exitDialogShowShutdown);
444
447 public: Q_INVOKABLE bool ExitDialogShowCloseGui() const;
448
451 public: Q_INVOKABLE void SetExitDialogShowCloseGui(
452 bool _exitDialogShowCloseGui);
453
456 public: Q_INVOKABLE QString ExitDialogShutdownText() const;
457
460 public: Q_INVOKABLE void SetExitDialogShutdownText(
461 const QString &_exitDialogShutdownText);
462
465 public: Q_INVOKABLE QString ExitDialogCloseGuiText() const;
466
469 public: Q_INVOKABLE void SetExitDialogCloseGuiText(
470 const QString &_exitDialogCloseGuiText);
471
474 public: Q_INVOKABLE std::string ServerControlService() const;
475
478 public: Q_INVOKABLE void SetServerControlService(
479 const std::string &_service);
480
482 public slots: void OnLoadConfig(const QString &_path);
483
485 public slots: void OnSaveConfig();
486
488 public slots: void OnSaveConfigAs(const QString &_path);
489
491 public slots: void OnStopServer();
492
494 signals: void PluginCountChanged();
495
497 signals: void MaterialThemeChanged();
498
500 signals: void MaterialPrimaryChanged();
501
503 signals: void MaterialAccentChanged();
504
506 signals: void ToolBarColorLightChanged();
507
509 signals: void ToolBarTextColorLightChanged();
510
512 signals: void ToolBarColorDarkChanged();
513
515 signals: void ToolBarTextColorDarkChanged();
516
518 signals: void PluginToolBarColorLightChanged();
519
521 signals: void PluginToolBarTextColorLightChanged();
522
524 signals: void PluginToolBarColorDarkChanged();
525
527 signals: void PluginToolBarTextColorDarkChanged();
528
530 signals: void ShowDrawerChanged();
531
533 signals: void ShowDefaultDrawerOptsChanged();
534
536 signals: void ShowPluginMenuChanged();
537
539 signals: void DefaultExitActionChanged();
540
542 signals: void ShowDialogOnExitChanged();
543
545 signals: void DialogOnExitTextChanged();
546
548 signals: void ExitDialogShowShutdownChanged();
549
551 signals: void ExitDialogShowCloseGuiChanged();
552
554 signals: void ExitDialogShutdownTextChanged();
555
557 signals: void ExitDialogCloseGuiTextChanged();
558
560 signals: void configChanged();
561
565 signals: void notify(const QString &_message);
566
574 signals: void notifyWithDuration(const QString &_message, int _duration);
575
579 private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
580 };
581
583 struct GZ_GUI_VISIBLE WindowConfig
584 {
590 bool MergeFromXML(const std::string &_xml);
591
595
598 bool IsIgnoring(const std::string &_prop) const;
599
601 int posX{-1};
602
604 int posY{-1};
605
607 int width{-1};
608
610 int height{-1};
611
614
616 std::string materialTheme{""};
617
619 std::string materialPrimary{""};
620
622 std::string materialAccent{""};
623
625 std::string toolBarColorLight{""};
626
628 std::string toolBarTextColorLight{""};
629
631 std::string toolBarColorDark{""};
632
634 std::string toolBarTextColorDark{""};
635
637 std::string pluginToolBarColorLight{""};
638
640 std::string pluginToolBarTextColorLight{""};
641
643 std::string pluginToolBarColorDark{""};
644
646 std::string pluginToolBarTextColorDark{""};
647
649 bool showDrawer{true};
650
652 bool showDefaultDrawerOpts{true};
653
655 bool showPluginMenu{true};
656
659 bool pluginsFromPaths{true};
660
663
666
669 };
670} // namespace gz::gui
671#endif // GZ_GUI_MAINWINDOW_HH_