History

Merge branch 'master' of https://github.com/highfidelity/hifi into decouple-avatar-updates

Howard Stearns committed 11 years ago

Commit 828509e2 parents e84cc03 275cdf955 files · +1710 −452Browse files

Showing the changes to interface/src/Application.cpp (1 of 55 files). Show all

Unified · Split

interface/src/Application.cpp+24−134
@@ -58,6 +58,8 @@ · 57 unmodified lines
5858 #include <AutoUpdater.h>
5959 #include <DeferredLightingEffect.h>
6060 #include <DependencyManager.h>
61+#include <plugins/PluginContainer.h>
62+#include <plugins/PluginManager.h>
6163 #include <display-plugins/DisplayPlugin.h>
6264
6365 #include <EntityScriptingInterface.h>
@@ -148,6 +150,8 @@ · 84 unmodified lines
148150
149151 #include "ui/overlays/Cube3DOverlay.h"
150152
153+#include "PluginContainerProxy.h"
154+
151155 // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
152156 // FIXME seems to be broken.
153157 #if defined(Q_OS_WIN)
@@ -301,7 +305,7 @@ bool setupEssentials(int& argc, char** argv) { · 147 unmodified lines
301305 // continuing to overburden Application.cpp
302306 Cube3DOverlay* _keyboardFocusHighlight{ nullptr };
303307 int _keyboardFocusHighlightID{ -1 };
304−
308+PluginContainer* _pluginContainer;
305309
306310 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
307311 QApplication(argc, argv),
@@ -351,7 +355,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 43 unmodified lines
351355 _applicationOverlay()
352356 {
353357 setInstance(this);
354− Plugin::setContainer(this);
358+
359+ _pluginContainer = new PluginContainerProxy();
360+ Plugin::setContainer(_pluginContainer);
355361 #ifdef Q_OS_WIN
356362 installNativeEventFilter(&MyNativeEventFilter::getInstance());
357363 #endif
@@ -1263,6 +1269,7 @@ void Application::resizeGL() { · 905 unmodified lines
12631269 // Possible change in aspect ratio
12641270 loadViewFrustum(_myCamera, _viewFrustum);
12651271 float fov = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES);
1272+ // FIXME the aspect ratio for stereo displays is incorrect based on this.
12661273 float aspectRatio = aspect(_renderResolution);
12671274 _myCamera.setProjection(glm::perspective(fov, aspectRatio, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
12681275 }
@@ -1422,7 +1429,15 @@ void Application::keyPressEvent(QKeyEvent* event) { · 153 unmodified lines
14221429 break;
14231430 case Qt::Key_Enter:
14241431 case Qt::Key_Return:
1425− Menu::getInstance()->triggerOption(MenuOption::AddressBar);
1432+ if (isOption) {
1433+ if (_window->isFullScreen()) {
1434+ _pluginContainer->unsetFullscreen();
1435+ } else {
1436+ _pluginContainer->setFullscreen(nullptr);
1437+ }
1438+ } else {
1439+ Menu::getInstance()->triggerOption(MenuOption::AddressBar);
1440+ }
14261441 break;
14271442
14281443 case Qt::Key_B:
@@ -3327,7 +3342,7 @@ namespace render { · 1898 unmodified lines
33273342 template <> const ItemKey payloadGetKey(const WorldBoxRenderData::Pointer& stuff) { return ItemKey::Builder::opaqueShape(); }
33283343 template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff) { return Item::Bound(); }
33293344 template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args) {
3330− if (args->_renderMode != RenderArgs::MIRROR_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
3345+ if (args->_renderMode != RenderArgs::MIRROR_RENDER_MODE && Menu::getInstance()->isOptionChecked(MenuOption::WorldAxes)) {
33313346 PerformanceTimer perfTimer("worldBox");
33323347
33333348 auto& batch = *args->_batch;
@@ -4625,10 +4640,6 @@ void Application::checkSkeleton() { · 1291 unmodified lines
46254640 }
46264641 }
46274642
4628−bool Application::isForeground() {
4629− return _isForeground && !getWindow()->isMinimized();
4630−}
4631−
46324643 void Application::activeChanged(Qt::ApplicationState state) {
46334644 switch (state) {
46344645 case Qt::ApplicationActive:
@@ -4734,6 +4745,10 @@ const DisplayPlugin * Application::getActiveDisplayPlugin() const { · 99 unmodified lines
47344745 return ((Application*)this)->getActiveDisplayPlugin();
47354746 }
47364747
4748+bool _activatingDisplayPlugin{ false };
4749+QVector<QPair<QString, QString>> _currentDisplayPluginActions;
4750+QVector<QPair<QString, QString>> _currentInputPluginActions;
4751+
47374752
47384753 static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) {
47394754 auto menu = Menu::getInstance();
@@ -4755,9 +4770,6 @@ static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool acti · 15 unmodified lines
47554770 Q_ASSERT(menu->menuItemExists(MenuOption::OutputMenu, name));
47564771 }
47574772
4758−static QVector<QPair<QString, QString>> _currentDisplayPluginActions;
4759−static bool _activatingDisplayPlugin{false};
4760−
47614773 void Application::updateDisplayMode() {
47624774 auto menu = Menu::getInstance();
47634775 auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
@@ -4824,7 +4836,7 @@ void Application::updateDisplayMode() { · 60 unmodified lines
48244836 // Only show the hmd tools after the correct plugin has
48254837 // been activated so that it's UI is setup correctly
48264838 if (newPluginWantsHMDTools) {
4827− showDisplayPluginsTools();
4839+ _pluginContainer->showDisplayPluginsTools();
48284840 }
48294841
48304842 if (oldDisplayPlugin) {
@@ -4842,9 +4854,6 @@ void Application::updateDisplayMode() { · 11 unmodified lines
48424854 Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
48434855 }
48444856
4845−static QVector<QPair<QString, QString>> _currentInputPluginActions;
4846−
4847−
48484857 static void addInputPluginToMenu(InputPluginPointer inputPlugin, bool active = false) {
48494858 auto menu = Menu::getInstance();
48504859 QString name = inputPlugin->getName();
@@ -4918,42 +4927,6 @@ void Application::updateInputModes() { · 67 unmodified lines
49184927 //}
49194928 }
49204929
4921−void Application::addMenu(const QString& menuName) {
4922− Menu::getInstance()->addMenu(menuName);
4923−}
4924−
4925−void Application::removeMenu(const QString& menuName) {
4926− Menu::getInstance()->removeMenu(menuName);
4927−}
4928−
4929−void Application::addMenuItem(const QString& path, const QString& name, std::function<void(bool)> onClicked, bool checkable, bool checked, const QString& groupName) {
4930− auto menu = Menu::getInstance();
4931− MenuWrapper* parentItem = menu->getMenu(path);
4932− QAction* action = menu->addActionToQMenuAndActionHash(parentItem, name);
4933− connect(action, &QAction::triggered, [=] {
4934− onClicked(action->isChecked());
4935− });
4936− action->setCheckable(checkable);
4937− action->setChecked(checked);
4938− if (_activatingDisplayPlugin) {
4939− _currentDisplayPluginActions.push_back({ path, name });
4940− } else {
4941− _currentInputPluginActions.push_back({ path, name });
4942− }
4943−}
4944−
4945−void Application::removeMenuItem(const QString& menuName, const QString& menuItem) {
4946− Menu::getInstance()->removeMenuItem(menuName, menuItem);
4947−}
4948−
4949−bool Application::isOptionChecked(const QString& name) {
4950− return Menu::getInstance()->isOptionChecked(name);
4951−}
4952−
4953−void Application::setIsOptionChecked(const QString& path, bool checked) {
4954− Menu::getInstance()->setIsOptionChecked(path, checked);
4955−}
4956−
49574930 mat4 Application::getEyeProjection(int eye) const {
49584931 if (isHMDMode()) {
49594932 return getActiveDisplayPlugin()->getProjection((Eye)eye, _viewFrustum.getProjection());
@@ -4986,89 +4959,6 @@ mat4 Application::getHMDSensorPose() const { · 26 unmodified lines
49864959 return mat4();
49874960 }
49884961
4989−// FIXME there is a bug in the fullscreen setting, where leaving
4990−// fullscreen does not restore the window frame, making it difficult
4991−// or impossible to move or size the window.
4992−// Additionally, setting fullscreen isn't hiding the menu on windows
4993−// make it useless for stereoscopic modes.
4994−void Application::setFullscreen(const QScreen* target) {
4995− if (!_window->isFullScreen()) {
4996− _savedGeometry = _window->geometry();
4997− }
4998−#ifdef Q_OS_MAC
4999− _window->setGeometry(target->availableGeometry());
5000−#endif
5001− _window->windowHandle()->setScreen((QScreen*)target);
5002− _window->showFullScreen();
5003−
5004−#ifndef Q_OS_MAC
5005− // also hide the QMainWindow's menuBar
5006− QMenuBar* menuBar = _window->menuBar();
5007− if (menuBar) {
5008− menuBar->setVisible(false);
5009− }
5010−#endif
5011−}
5012−
5013−void Application::unsetFullscreen(const QScreen* avoid) {
5014− _window->showNormal();
5015−
5016− QRect targetGeometry = _savedGeometry;
5017− if (avoid != nullptr) {
5018− QRect avoidGeometry = avoid->geometry();
5019− if (avoidGeometry.contains(targetGeometry.topLeft())) {
5020− QScreen* newTarget = primaryScreen();
5021− if (newTarget == avoid) {
5022− foreach(auto screen, screens()) {
5023− if (screen != avoid) {
5024− newTarget = screen;
5025− break;
5026− }
5027− }
5028− }
5029− targetGeometry = newTarget->availableGeometry();
5030− }
5031− }
5032−#ifdef Q_OS_MAC
5033− QTimer* timer = new QTimer();
5034− timer->singleShot(2000, [=] {
5035− _window->setGeometry(targetGeometry);
5036− timer->deleteLater();
5037− });
5038−#else
5039− _window->setGeometry(targetGeometry);
5040−#endif
5041−
5042−#ifndef Q_OS_MAC
5043− // also show the QMainWindow's menuBar
5044− QMenuBar* menuBar = _window->menuBar();
5045− if (menuBar) {
5046− menuBar->setVisible(true);
5047− }
5048−#endif
5049−}
5050−
5051−
5052−void Application::showDisplayPluginsTools() {
5053− DependencyManager::get<DialogsManager>()->hmdTools(true);
5054−}
5055−
5056−QGLWidget* Application::getPrimarySurface() {
5057− return _glWidget;
5058−}
5059−
5060−void Application::setActiveDisplayPlugin(const QString& pluginName) {
5061− auto menu = Menu::getInstance();
5062− foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
5063− QString name = displayPlugin->getName();
5064− QAction* action = menu->getActionForOption(name);
5065− if (pluginName == name) {
5066− action->setChecked(true);
5067− }
5068− }
5069− updateDisplayMode();
5070−}
5071−
50724962 void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float deltaTime, int index) {
50734963 PalmData* palm;
50744964 bool foundHand = false;