mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
trying to reenable fullscreen
This commit is contained in:
parent
e27ba86f75
commit
fe632e13b2
4 changed files with 56 additions and 5 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "Basic2DWindowOpenGLDisplayPlugin.h"
|
||||
|
||||
#include <plugins/PluginContainer.h>
|
||||
#include <QWindow>
|
||||
|
||||
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("2D Display");
|
||||
|
||||
|
@ -20,10 +21,10 @@ const QString& Basic2DWindowOpenGLDisplayPlugin::getName() const {
|
|||
return NAME;
|
||||
}
|
||||
|
||||
void Basic2DWindowOpenGLDisplayPlugin::activate(PluginContainer * container) {
|
||||
void Basic2DWindowOpenGLDisplayPlugin::activate(PluginContainer* container) {
|
||||
container->addMenu(MENU_PATH);
|
||||
container->addMenuItem(MENU_PATH, FULLSCREEN,
|
||||
[this, container] (bool clicked) { },
|
||||
[this] (bool clicked) { this->setFullscreen(clicked); },
|
||||
true, false);
|
||||
MainWindowOpenGLDisplayPlugin::activate(container);
|
||||
}
|
||||
|
@ -32,4 +33,51 @@ void Basic2DWindowOpenGLDisplayPlugin::deactivate(PluginContainer* container) {
|
|||
container->removeMenuItem(MENU_NAME, FULLSCREEN);
|
||||
container->removeMenu(MENU_PATH);
|
||||
MainWindowOpenGLDisplayPlugin::deactivate(container);
|
||||
}
|
||||
}
|
||||
|
||||
void Basic2DWindowOpenGLDisplayPlugin::setFullscreen(bool fullscreen) {
|
||||
// The following code block is useful on platforms that can have a visible
|
||||
// app menu in a fullscreen window. However the OSX mechanism hides the
|
||||
// application menu for fullscreen apps, so the check is not required.
|
||||
//#ifndef Q_OS_MAC
|
||||
// if (fullscreen) {
|
||||
// // Move menu to a QWidget floating above _glWidget so that show/hide doesn't adjust viewport.
|
||||
// _menuBarHeight = Menu::getInstance()->height();
|
||||
// Menu::getInstance()->setParent(_fullscreenMenuWidget);
|
||||
// Menu::getInstance()->setFixedWidth(_window->windowHandle()->screen()->size().width());
|
||||
// _fullscreenMenuWidget->show();
|
||||
// }
|
||||
// else {
|
||||
// // Restore menu to being part of MainWindow.
|
||||
// _fullscreenMenuWidget->hide();
|
||||
// _window->setMenuBar(Menu::getInstance());
|
||||
// _window->menuBar()->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
// }
|
||||
//#endif
|
||||
|
||||
// Work around Qt bug that prevents floating menus being shown when in fullscreen mode.
|
||||
// https://bugreports.qt.io/browse/QTBUG-41883
|
||||
// Known issue: Top-level menu items don't highlight when cursor hovers. This is probably a side-effect of the work-around.
|
||||
// TODO: Remove this work-around once the bug has been fixed and restore the following lines.
|
||||
//_window->setWindowState(fullscreen ? (_window->windowState() | Qt::WindowFullScreen) :
|
||||
// (_window->windowState() & ~Qt::WindowFullScreen));
|
||||
auto window = this->getWindow();
|
||||
window->hide();
|
||||
if (fullscreen) {
|
||||
auto state = window->windowState() | Qt::WindowFullScreen;
|
||||
window->setWindowState(Qt::WindowState((int)state));
|
||||
window->setPosition(0, 0);
|
||||
// The next line produces the following warning in the log:
|
||||
// [WARNING][03 / 06 12:17 : 58] QWidget::setMinimumSize: (/ MainWindow) Negative sizes
|
||||
// (0, -1) are not possible
|
||||
// This is better than the alternative which is to have the window slightly less than fullscreen with a visible line
|
||||
// of pixels for the remainder of the screen.
|
||||
//window->setContentsMargins(0, 0, 0, -1);
|
||||
}
|
||||
else {
|
||||
window->setWindowState(Qt::WindowState(window->windowState() & ~Qt::WindowFullScreen));
|
||||
//window->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
window->show();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ public:
|
|||
|
||||
virtual const QString & getName() const override;
|
||||
|
||||
public slots:
|
||||
void setFullscreen(bool fullscreen);
|
||||
|
||||
private:
|
||||
static const QString NAME;
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ void SixenseManager::activate(PluginContainer* container) {
|
|||
|
||||
container->addMenu(MENU_PATH);
|
||||
container->addMenuItem(MENU_PATH, TOGGLE_SMOOTH,
|
||||
[this, container] (bool clicked) { this->setFilter(clicked); },
|
||||
[this] (bool clicked) { this->setFilter(clicked); },
|
||||
true, true);
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
|
|
@ -75,7 +75,7 @@ void ViveControllerManager::activate(PluginContainer* container) {
|
|||
#ifndef Q_OS_MAC
|
||||
container->addMenu(MENU_PATH);
|
||||
container->addMenuItem(MENU_PATH, RENDER_CONTROLLERS,
|
||||
[this, &container] (bool clicked) { this->setRenderControllers(clicked); },
|
||||
[this] (bool clicked) { this->setRenderControllers(clicked); },
|
||||
true, true);
|
||||
|
||||
hmdRefCount++;
|
||||
|
|
Loading…
Reference in a new issue