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 class GLWidget;
23 class QScreen;
24 class QOpenGLContext;
25 class QWindow;
26 
27 class DisplayPlugin;
28 
29 namespace gpu {
30  class Texture;
31  using TexturePointer = std::shared_ptr<Texture>;
32 }
33 
34 namespace ui {
35  class Menu;
36 }
37 
38 class QActionGroup;
39 class MainWindow;
40 
41 class PluginContainer {
42 public:
43  static PluginContainer& getInstance();
44  PluginContainer();
45  virtual ~PluginContainer();
46 
47  void addMenu(const QString& menuName);
48  void removeMenu(const QString& menuName);
49  void addMenuItem(PluginType pluginType, const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable = false, bool checked = false, const QString& groupName = "");
50  void removeMenuItem(const QString& menuName, const QString& menuItem);
51  bool isOptionChecked(const QString& name);
52  void setIsOptionChecked(const QString& path, bool checked);
53 
54  void setFullscreen(const QScreen* targetScreen, bool hideMenu = false);
55  void unsetFullscreen(const QScreen* avoidScreen = nullptr);
56 
57  // FIXME remove access tot he menu from the plugin container
58  // Instead let display plugins expose a structure about the kinds
59  // of actions and menu items they want to have appear when they are
60  // active and allow the application to act on that when the display
61  // plugin becomes active (or when the UI is initialized, and a
62  // display plugin is already active)
63  virtual ui::Menu* getPrimaryMenu() = 0;
64  virtual void showDisplayPluginsTools(bool show = true) = 0;
65  virtual void requestReset() = 0;
66  virtual bool makeRenderingContextCurrent() = 0;
67  virtual GLWidget* getPrimaryWidget() = 0;
68  virtual MainWindow* getPrimaryWindow() = 0;
69  virtual QOpenGLContext* getPrimaryContext() = 0;
70  virtual bool isForeground() const = 0;
71  virtual DisplayPluginPointer getActiveDisplayPlugin() const = 0;
72 
74  bool getBoolSetting(const QString& settingName, bool defaultValue);
75  void setBoolSetting(const QString& settingName, bool value);
76 
77  QVector<QPair<QString, QString>>& currentDisplayActions() {
78  return _currentDisplayPluginActions;
79  }
80 
81  QVector<QPair<QString, QString>>& currentInputActions() {
82  return _currentInputPluginActions;
83  }
84 
85 protected:
86  void flushMenuUpdates();
87  QVector<QPair<QString, QString>> _currentDisplayPluginActions;
88  QVector<QPair<QString, QString>> _currentInputPluginActions;
89  QRect _savedGeometry { 10, 120, 800, 600 };
90 };
91 
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