Ignition Gui

API Reference

5.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 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 #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  class MainWindowPrivate;
43  struct WindowConfig;
44 
48  class IGNITION_GUI_VISIBLE MainWindow : public QObject
49  {
50  Q_OBJECT
51 
53  Q_PROPERTY(
54  int pluginCount
55  READ PluginCount
56  WRITE SetPluginCount
57  NOTIFY PluginCountChanged
58  )
59 
60 
61  Q_PROPERTY(
62  QString materialTheme
63  READ MaterialTheme
64  WRITE SetMaterialTheme
65  NOTIFY MaterialThemeChanged
66  )
67 
69  Q_PROPERTY(
70  QString materialPrimary
71  READ MaterialPrimary
72  WRITE SetMaterialPrimary
73  NOTIFY MaterialPrimaryChanged
74  )
75 
77  Q_PROPERTY(
78  QString materialAccent
79  READ MaterialAccent
80  WRITE SetMaterialAccent
81  NOTIFY MaterialAccentChanged
82  )
83 
86  Q_PROPERTY(
87  QString toolBarColorLight
88  READ ToolBarColorLight
89  WRITE SetToolBarColorLight
90  NOTIFY ToolBarColorLightChanged
91  )
92 
95  Q_PROPERTY(
96  QString toolBarTextColorLight
97  READ ToolBarTextColorLight
98  WRITE SetToolBarTextColorLight
99  NOTIFY ToolBarTextColorLightChanged
100  )
101 
104  Q_PROPERTY(
105  QString toolBarColorDark
106  READ ToolBarColorDark
107  WRITE SetToolBarColorDark
108  NOTIFY ToolBarColorDarkChanged
109  )
110 
113  Q_PROPERTY(
114  QString toolBarTextColorDark
115  READ ToolBarTextColorDark
116  WRITE SetToolBarTextColorDark
117  NOTIFY ToolBarTextColorDarkChanged
118  )
119 
122  Q_PROPERTY(
123  QString pluginToolBarColorLight
124  READ PluginToolBarColorLight
125  WRITE SetPluginToolBarColorLight
126  NOTIFY PluginToolBarColorLightChanged
127  )
128 
131  Q_PROPERTY(
132  QString pluginToolBarTextColorLight
133  READ PluginToolBarTextColorLight
134  WRITE SetPluginToolBarTextColorLight
135  NOTIFY PluginToolBarTextColorLightChanged
136  )
137 
140  Q_PROPERTY(
141  QString pluginToolBarColorDark
142  READ PluginToolBarColorDark
143  WRITE SetPluginToolBarColorDark
144  NOTIFY PluginToolBarColorDarkChanged
145  )
146 
149  Q_PROPERTY(
150  QString pluginToolBarTextColorDark
151  READ PluginToolBarTextColorDark
152  WRITE SetPluginToolBarTextColorDark
153  NOTIFY PluginToolBarTextColorDarkChanged
154  )
155 
157  Q_PROPERTY(
158  bool showDrawer
159  READ ShowDrawer
160  WRITE SetShowDrawer
161  NOTIFY ShowDrawerChanged
162  )
163 
165  Q_PROPERTY(
166  bool showDefaultDrawerOpts
167  READ ShowDefaultDrawerOpts
168  WRITE SetShowDefaultDrawerOpts
169  NOTIFY ShowDefaultDrawerOptsChanged
170  )
171 
173  Q_PROPERTY(
174  bool showPluginMenu
175  READ ShowPluginMenu
176  WRITE SetShowPluginMenu
177  NOTIFY ShowPluginMenuChanged
178  )
179 
181  public: MainWindow();
182 
184  public: virtual ~MainWindow();
185 
188  public: QQuickWindow *QuickWindow() const;
189 
194  public: void SaveConfig(const std::string &_path);
195 
199  public: bool ApplyConfig(const WindowConfig &_config);
200 
203  public: WindowConfig CurrentWindowConfig() const;
204 
207  public slots: void OnAddPlugin(QString _plugin);
208 
211  public: Q_INVOKABLE QStringList PluginListModel() const;
212 
216  public: Q_INVOKABLE int PluginCount() const;
217 
221  public: Q_INVOKABLE void SetPluginCount(const int _pluginCount);
222 
225  public: Q_INVOKABLE QString MaterialTheme() const;
226 
229  public: Q_INVOKABLE void SetMaterialTheme(
230  const QString &_materialTheme);
231 
234  public: Q_INVOKABLE QString MaterialPrimary() const;
235 
238  public: Q_INVOKABLE void SetMaterialPrimary(
239  const QString &_materialPrimary);
240 
243  public: Q_INVOKABLE QString MaterialAccent() const;
244 
247  public: Q_INVOKABLE void SetMaterialAccent(
248  const QString &_materialAccent);
249 
252  public: Q_INVOKABLE QString ToolBarColorLight() const;
253 
256  public: Q_INVOKABLE void SetToolBarColorLight(
257  const QString &_toolBarColorLight);
258 
261  public: Q_INVOKABLE QString ToolBarTextColorLight() const;
262 
265  public: Q_INVOKABLE void SetToolBarTextColorLight(
266  const QString &_toolBarTextColorLight);
267 
270  public: Q_INVOKABLE QString ToolBarColorDark() const;
271 
274  public: Q_INVOKABLE void SetToolBarColorDark(
275  const QString &_toolBarColorDark);
276 
279  public: Q_INVOKABLE QString ToolBarTextColorDark() const;
280 
283  public: Q_INVOKABLE void SetToolBarTextColorDark(
284  const QString &_toolBarTextColorDark);
285 
288  public: Q_INVOKABLE QString PluginToolBarColorLight() const;
289 
292  public: Q_INVOKABLE void SetPluginToolBarColorLight(
293  const QString &_pluginPluginToolBarColorLight);
294 
297  public: Q_INVOKABLE QString PluginToolBarTextColorLight() const;
298 
301  public: Q_INVOKABLE void SetPluginToolBarTextColorLight(
302  const QString &_pluginPluginToolBarTextColorLight);
303 
306  public: Q_INVOKABLE QString PluginToolBarColorDark() const;
307 
310  public: Q_INVOKABLE void SetPluginToolBarColorDark(
311  const QString &_pluginPluginToolBarColorDark);
312 
315  public: Q_INVOKABLE QString PluginToolBarTextColorDark() const;
316 
319  public: Q_INVOKABLE void SetPluginToolBarTextColorDark(
320  const QString &_pluginPluginToolBarTextColorDark);
321 
324  public: Q_INVOKABLE bool ShowDrawer() const;
325 
328  public: Q_INVOKABLE void SetShowDrawer(const bool _showDrawer);
329 
332  public: Q_INVOKABLE bool ShowDefaultDrawerOpts() const;
333 
336  public: Q_INVOKABLE void SetShowDefaultDrawerOpts(
337  const bool _showDefaultDrawerOpts);
338 
341  public: Q_INVOKABLE bool ShowPluginMenu() const;
342 
345  public: Q_INVOKABLE void SetShowPluginMenu(const bool _showPluginMenu);
346 
348  public slots: void OnLoadConfig(const QString &_path);
349 
351  public slots: void OnSaveConfig();
352 
354  public slots: void OnSaveConfigAs(const QString &_path);
355 
357  signals: void PluginCountChanged();
358 
360  signals: void MaterialThemeChanged();
361 
363  signals: void MaterialPrimaryChanged();
364 
366  signals: void MaterialAccentChanged();
367 
369  signals: void ToolBarColorLightChanged();
370 
372  signals: void ToolBarTextColorLightChanged();
373 
375  signals: void ToolBarColorDarkChanged();
376 
378  signals: void ToolBarTextColorDarkChanged();
379 
381  signals: void PluginToolBarColorLightChanged();
382 
384  signals: void PluginToolBarTextColorLightChanged();
385 
387  signals: void PluginToolBarColorDarkChanged();
388 
390  signals: void PluginToolBarTextColorDarkChanged();
391 
393  signals: void ShowDrawerChanged();
394 
396  signals: void ShowDefaultDrawerOptsChanged();
397 
399  signals: void ShowPluginMenuChanged();
400 
402  signals: void configChanged();
403 
405  signals: void notify(const QString &_message);
406 
409  private: std::unique_ptr<MainWindowPrivate> dataPtr;
410  };
411 
413  struct IGNITION_GUI_VISIBLE WindowConfig
414  {
420  bool MergeFromXML(const std::string &_xml);
421 
424  std::string XMLString() const;
425 
428  bool IsIgnoring(const std::string &_prop) const;
429 
431  int posX{-1};
432 
434  int posY{-1};
435 
437  int width{-1};
438 
440  int height{-1};
441 
444 
446  std::string materialTheme{""};
447 
449  std::string materialPrimary{""};
450 
452  std::string materialAccent{""};
453 
455  std::string toolBarColorLight{""};
456 
458  std::string toolBarTextColorLight{""};
459 
461  std::string toolBarColorDark{""};
462 
464  std::string toolBarTextColorDark{""};
465 
467  std::string pluginToolBarColorLight{""};
468 
470  std::string pluginToolBarTextColorLight{""};
471 
473  std::string pluginToolBarColorDark{""};
474 
476  std::string pluginToolBarTextColorDark{""};
477 
479  bool showDrawer{true};
480 
482  bool showDefaultDrawerOpts{true};
483 
485  bool showPluginMenu{true};
486 
489  bool pluginsFromPaths{true};
490 
493 
496 
498  std::string plugins{""};
499  };
500  }
501 }
502 
503 #ifdef _MSC_VER
504 #pragma warning(pop)
505 #endif
506 
507 #endif
STL namespace.
Holds configurations related to a MainWindow.
Definition: MainWindow.hh:413
STL class.
std::set< std::string > ignoredProps
List of window properties which should be ignored on load.
Definition: MainWindow.hh:495
The main window class creates a QQuickWindow and acts as an interface which provides properties and f...
Definition: MainWindow.hh:48
QByteArray state
Window state (dock configuration)
Definition: MainWindow.hh:443
Definition: Application.hh:40
std::vector< std::string > showPlugins
List of plugins which should be shown on the list.
Definition: MainWindow.hh:492