Overte C++ Documentation
PluginContainer.h
1 //
2 // Created by Bradley Austin Davis on 2015/08/08
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 #pragma once
9 
10 #include <functional>
11 #include <map>
12 #include <stdint.h>
13 
14 #include <QtCore/QString>
15 #include <QtCore/QVector>
16 #include <QtCore/QPair>
17 #include <QtCore/QRect>
18 
19 #include <plugins/Forward.h>
20 
21 class QAction;
22 #ifdef USE_GL
23 class GLWidget;
24 #else
25 class VKWidget;
26 #endif
27 class QScreen;
28 class QOpenGLContext;
29 class QWindow;
30 
31 class DisplayPlugin;
32 
33 namespace gpu {
34  class Texture;
35  using TexturePointer = std::shared_ptr<Texture>;
36 }
37 
38 namespace ui {
39  class Menu;
40 }
41 
42 class QActionGroup;
43 class MainWindow;
44 
45 class PluginContainer {
46 public:
47  static PluginContainer& getInstance();
48  PluginContainer();
49  virtual ~PluginContainer();
50 
51  void addMenu(const QString& menuName);
52  void removeMenu(const QString& menuName);
53  void addMenuItem(PluginType pluginType, const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable = false, bool checked = false, const QString& groupName = "");
54  void removeMenuItem(const QString& menuName, const QString& menuItem);
55  bool isOptionChecked(const QString& name);
56  void setIsOptionChecked(const QString& path, bool checked);
57 
58  void setFullscreen(const QScreen* targetScreen, bool hideMenu = false);
59  void unsetFullscreen(const QScreen* avoidScreen = nullptr);
60 
61  // FIXME remove access tot he menu from the plugin container
62  // Instead let display plugins expose a structure about the kinds
63  // of actions and menu items they want to have appear when they are
64  // active and allow the application to act on that when the display
65  // plugin becomes active (or when the UI is initialized, and a
66  // display plugin is already active)
67  virtual ui::Menu* getPrimaryMenu() = 0;
68  virtual void showDisplayPluginsTools(bool show = true) = 0;
69  virtual void requestReset() = 0;
70  virtual bool makeRenderingContextCurrent() = 0;
71 #ifdef USE_GL
72  virtual GLWidget* getPrimaryWidget() = 0;
73 #else
74  virtual VKWidget* getPrimaryWidget() = 0;
75 #endif
76  virtual MainWindow* getPrimaryWindow() = 0;
77  virtual QOpenGLContext* getPrimaryContext() = 0;
78  virtual bool isForeground() const = 0;
79  virtual DisplayPluginPointer getActiveDisplayPlugin() const = 0;
80 
82  bool getBoolSetting(const QString& settingName, bool defaultValue);
83  void setBoolSetting(const QString& settingName, bool value);
84 
85  QVector<QPair<QString, QString>>& currentDisplayActions() {
86  return _currentDisplayPluginActions;
87  }
88 
89  QVector<QPair<QString, QString>>& currentInputActions() {
90  return _currentInputPluginActions;
91  }
92 
93 protected:
94  void flushMenuUpdates();
95  QVector<QPair<QString, QString>> _currentDisplayPluginActions;
96  QVector<QPair<QString, QString>> _currentInputPluginActions;
97  QRect _savedGeometry { 10, 120, 800, 600 };
98 };
99 
customized canvas that simply forwards requests/events to the singleton application
Definition: GLWidget.h:22
A simple object wrapper for an OpenGL texture.
Definition: material-networking/src/material-networking/TextureCache.h:39
customized canvas that simply forwards requests/events to the singleton application
Definition: VKWidget.h:31