Ignition Gui

API Reference

2.1.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 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 
26 #include <ignition/common/Console.hh>
27 
28 #include "ignition/gui/qt.h"
29 #include "ignition/gui/Export.hh"
30 
31 namespace ignition
32 {
33  namespace gui
34  {
35  class MainWindowPrivate;
36  struct WindowConfig;
37 
41  class IGNITION_GUI_VISIBLE MainWindow : public QObject
42  {
43  Q_OBJECT
44 
46  Q_PROPERTY(
47  int pluginCount
48  READ PluginCount
49  WRITE SetPluginCount
50  NOTIFY PluginCountChanged
51  )
52 
53 
54  Q_PROPERTY(
55  QString materialTheme
56  READ MaterialTheme
57  WRITE SetMaterialTheme
58  NOTIFY MaterialThemeChanged
59  )
60 
62  Q_PROPERTY(
63  QString materialPrimary
64  READ MaterialPrimary
65  WRITE SetMaterialPrimary
66  NOTIFY MaterialPrimaryChanged
67  )
68 
70  Q_PROPERTY(
71  QString materialAccent
72  READ MaterialAccent
73  WRITE SetMaterialAccent
74  NOTIFY MaterialAccentChanged
75  )
76 
79  Q_PROPERTY(
80  QString toolBarColorLight
81  READ ToolBarColorLight
82  WRITE SetToolBarColorLight
83  NOTIFY ToolBarColorLightChanged
84  )
85 
88  Q_PROPERTY(
89  QString toolBarTextColorLight
90  READ ToolBarTextColorLight
91  WRITE SetToolBarTextColorLight
92  NOTIFY ToolBarTextColorLightChanged
93  )
94 
97  Q_PROPERTY(
98  QString toolBarColorDark
99  READ ToolBarColorDark
100  WRITE SetToolBarColorDark
101  NOTIFY ToolBarColorDarkChanged
102  )
103 
106  Q_PROPERTY(
107  QString toolBarTextColorDark
108  READ ToolBarTextColorDark
109  WRITE SetToolBarTextColorDark
110  NOTIFY ToolBarTextColorDarkChanged
111  )
112 
115  Q_PROPERTY(
116  QString pluginToolBarColorLight
117  READ PluginToolBarColorLight
118  WRITE SetPluginToolBarColorLight
119  NOTIFY PluginToolBarColorLightChanged
120  )
121 
124  Q_PROPERTY(
125  QString pluginToolBarTextColorLight
126  READ PluginToolBarTextColorLight
127  WRITE SetPluginToolBarTextColorLight
128  NOTIFY PluginToolBarTextColorLightChanged
129  )
130 
133  Q_PROPERTY(
134  QString pluginToolBarColorDark
135  READ PluginToolBarColorDark
136  WRITE SetPluginToolBarColorDark
137  NOTIFY PluginToolBarColorDarkChanged
138  )
139 
142  Q_PROPERTY(
143  QString pluginToolBarTextColorDark
144  READ PluginToolBarTextColorDark
145  WRITE SetPluginToolBarTextColorDark
146  NOTIFY PluginToolBarTextColorDarkChanged
147  )
148 
150  Q_PROPERTY(
151  bool showDrawer
152  READ ShowDrawer
153  WRITE SetShowDrawer
154  NOTIFY ShowDrawerChanged
155  )
156 
158  Q_PROPERTY(
159  bool showDefaultDrawerOpts
160  READ ShowDefaultDrawerOpts
161  WRITE SetShowDefaultDrawerOpts
162  NOTIFY ShowDefaultDrawerOptsChanged
163  )
164 
166  Q_PROPERTY(
167  bool showPluginMenu
168  READ ShowPluginMenu
169  WRITE SetShowPluginMenu
170  NOTIFY ShowPluginMenuChanged
171  )
172 
174  public: MainWindow();
175 
177  public: virtual ~MainWindow();
178 
181  public: QQuickWindow *QuickWindow() const;
182 
187  public: void SaveConfig(const std::string &_path);
188 
192  public: bool ApplyConfig(const WindowConfig &_config);
193 
196  public: WindowConfig CurrentWindowConfig() const;
197 
200  public slots: void OnAddPlugin(QString _plugin);
201 
204  public: Q_INVOKABLE QStringList PluginListModel() const;
205 
209  public: Q_INVOKABLE int PluginCount() const;
210 
214  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
215 
218  public: Q_INVOKABLE QString MaterialTheme() const;
219 
222  public: Q_INVOKABLE void SetMaterialTheme(
223  const QString &_materialTheme);
224 
227  public: Q_INVOKABLE QString MaterialPrimary() const;
228 
231  public: Q_INVOKABLE void SetMaterialPrimary(
232  const QString &_materialPrimary);
233 
236  public: Q_INVOKABLE QString MaterialAccent() const;
237 
240  public: Q_INVOKABLE void SetMaterialAccent(
241  const QString &_materialAccent);
242 
245  public: Q_INVOKABLE QString ToolBarColorLight() const;
246 
249  public: Q_INVOKABLE void SetToolBarColorLight(
250  const QString &_toolBarColorLight);
251 
254  public: Q_INVOKABLE QString ToolBarTextColorLight() const;
255 
258  public: Q_INVOKABLE void SetToolBarTextColorLight(
259  const QString &_toolBarTextColorLight);
260 
263  public: Q_INVOKABLE QString ToolBarColorDark() const;
264 
267  public: Q_INVOKABLE void SetToolBarColorDark(
268  const QString &_toolBarColorDark);
269 
272  public: Q_INVOKABLE QString ToolBarTextColorDark() const;
273 
276  public: Q_INVOKABLE void SetToolBarTextColorDark(
277  const QString &_toolBarTextColorDark);
278 
281  public: Q_INVOKABLE QString PluginToolBarColorLight() const;
282 
285  public: Q_INVOKABLE void SetPluginToolBarColorLight(
286  const QString &_pluginPluginToolBarColorLight);
287 
290  public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
291 
294  public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
295  const QString &_pluginPluginToolBarTextColorLight);
296 
299  public: Q_INVOKABLE QString PluginToolBarColorDark() const;
300 
303  public: Q_INVOKABLE void SetPluginToolBarColorDark(
304  const QString &_pluginPluginToolBarColorDark);
305 
308  public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
309 
312  public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
313  const QString &_pluginPluginToolBarTextColorDark);
314 
317  public: Q_INVOKABLE bool ShowDrawer() const;
318 
321  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
322 
325  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
326 
329  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
330  const bool _showDefaultDrawerOpts);
331 
334  public: Q_INVOKABLE bool ShowPluginMenu() const;
335 
338  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
339 
341  public slots: void OnLoadConfig(const QString &_path);
342 
344  public slots: void OnSaveConfig();
345 
347  public slots: void OnSaveConfigAs(const QString &_path);
348 
350  signals: void PluginCountChanged();
351 
353  signals: void MaterialThemeChanged();
354 
356  signals: void MaterialPrimaryChanged();
357 
359  signals: void MaterialAccentChanged();
360 
362  signals: void ToolBarColorLightChanged();
363 
365  signals: void ToolBarTextColorLightChanged();
366 
368  signals: void ToolBarColorDarkChanged();
369 
371  signals: void ToolBarTextColorDarkChanged();
372 
374  signals: void PluginToolBarColorLightChanged();
375 
377  signals: void PluginToolBarTextColorLightChanged();
378 
380  signals: void PluginToolBarColorDarkChanged();
381 
383  signals: void PluginToolBarTextColorDarkChanged();
384 
386  signals: void ShowDrawerChanged();
387 
389  signals: void ShowDefaultDrawerOptsChanged();
390 
392  signals: void ShowPluginMenuChanged();
393 
395  signals: void configChanged();
396 
398  signals: void notify(const QString &_message);
399 
402  private: std::unique_ptr<MainWindowPrivate> dataPtr;
403  };
404 
406  struct IGNITION_GUI_VISIBLE WindowConfig
407  {
413  bool MergeFromXML(const std::string &_xml);
414 
417  std::string XMLString() const;
418 
421  bool IsIgnoring(const std::string &_prop) const;
422 
424  int posX{-1};
425 
427  int posY{-1};
428 
430  int width{-1};
431 
433  int height{-1};
434 
437 
439  std::string materialTheme{""};
440 
442  std::string materialPrimary{""};
443 
445  std::string materialAccent{""};
446 
448  std::string toolBarColorLight{""};
449 
451  std::string toolBarTextColorLight{""};
452 
454  std::string toolBarColorDark{""};
455 
457  std::string toolBarTextColorDark{""};
458 
460  std::string pluginToolBarColorLight{""};
461 
463  std::string pluginToolBarTextColorLight{""};
464 
466  std::string pluginToolBarColorDark{""};
467 
469  std::string pluginToolBarTextColorDark{""};
470 
472  bool showDrawer{true};
473 
475  bool showDefaultDrawerOpts{true};
476 
478  bool showPluginMenu{true};
479 
482  bool pluginsFromPaths{true};
483 
486 
489 
491  std::string plugins{""};
492  };
493  }
494 }
495 #endif
STL namespace.
Holds configurations related to a MainWindow.
Definition: MainWindow.hh:406
STL class.
std::set< std::string > ignoredProps
List of window properties which should be ignored on load.
Definition: MainWindow.hh:488
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: MainWindow.hh:41
QByteArray state
Window state (dock configuration)
Definition: MainWindow.hh:436
Definition: Application.hh:33
std::vector< std::string > showPlugins
List of plugins which should be shown on the list.
Definition: MainWindow.hh:485