mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:29:42 +02:00
Merge pull request #3947 from ZappoMan/HMDMode
Make the Chat, Running Scripts, and Address bar "avoid" HMD Screen
This commit is contained in:
commit
84e82cd03b
8 changed files with 45 additions and 19 deletions
|
@ -37,6 +37,7 @@
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
#include <QScreen>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -415,9 +416,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
|
_previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(_window, &MainWindow::windowGeometryChanged,
|
|
||||||
_runningScriptsWidget, &RunningScriptsWidget::setBoundary);
|
|
||||||
|
|
||||||
_trayIcon->show();
|
_trayIcon->show();
|
||||||
|
|
||||||
// set the local loopback interface for local sounds from audio scripts
|
// set the local loopback interface for local sounds from audio scripts
|
||||||
|
@ -2706,6 +2704,29 @@ bool Application::isHMDMode() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect Application::getDesirableApplicationGeometry() {
|
||||||
|
QRect applicationGeometry = getWindow()->geometry();
|
||||||
|
|
||||||
|
// If our parent window is on the HMD, then don't use it's geometry, instead use
|
||||||
|
// the "main screen" geometry.
|
||||||
|
HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog();
|
||||||
|
if (hmdTools && hmdTools->hasHMDScreen()) {
|
||||||
|
QScreen* hmdScreen = hmdTools->getHMDScreen();
|
||||||
|
QWindow* appWindow = getWindow()->windowHandle();
|
||||||
|
QScreen* appScreen = appWindow->screen();
|
||||||
|
|
||||||
|
// if our app's screen is the hmd screen, we don't want to place the
|
||||||
|
// running scripts widget on it. So we need to pick a better screen.
|
||||||
|
// we will use the screen for the HMDTools since it's a guarenteed
|
||||||
|
// better screen.
|
||||||
|
if (appScreen == hmdScreen) {
|
||||||
|
QScreen* betterScreen = hmdTools->windowHandle()->screen();
|
||||||
|
applicationGeometry = betterScreen->geometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return applicationGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// loadViewFrustum()
|
// loadViewFrustum()
|
||||||
//
|
//
|
||||||
|
|
|
@ -325,6 +325,8 @@ public:
|
||||||
// rendering of several elements depend on that
|
// rendering of several elements depend on that
|
||||||
// TODO: carry that information on the Camera as a setting
|
// TODO: carry that information on the Camera as a setting
|
||||||
bool isHMDMode() const;
|
bool isHMDMode() const;
|
||||||
|
|
||||||
|
QRect getDesirableApplicationGeometry();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ void ChatWindow::showEvent(QShowEvent* event) {
|
||||||
if (!event->spontaneous()) {
|
if (!event->spontaneous()) {
|
||||||
_ui->messagePlainTextEdit->setFocus();
|
_ui->messagePlainTextEdit->setFocus();
|
||||||
}
|
}
|
||||||
const QRect parentGeometry = parentWidget()->geometry();
|
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
|
||||||
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
||||||
int menuBarHeight = Menu::getInstance()->geometry().height();
|
int menuBarHeight = Menu::getInstance()->geometry().height();
|
||||||
int topMargin = titleBarHeight + menuBarHeight;
|
int topMargin = titleBarHeight + menuBarHeight;
|
||||||
|
|
|
@ -9,8 +9,12 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "FramelessDialog.h"
|
#include "FramelessDialog.h"
|
||||||
|
#include "Menu.h"
|
||||||
|
|
||||||
const int RESIZE_HANDLE_WIDTH = 7;
|
const int RESIZE_HANDLE_WIDTH = 7;
|
||||||
|
|
||||||
|
@ -90,24 +94,27 @@ void FramelessDialog::showEvent(QShowEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
||||||
|
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
|
||||||
|
QSize parentSize = parentGeometry.size();
|
||||||
|
|
||||||
// keep full app height or width depending on position
|
// keep full app height or width depending on position
|
||||||
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
|
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
|
||||||
setFixedHeight(parentWidget()->size().height());
|
setFixedHeight(parentSize.height());
|
||||||
} else {
|
} else {
|
||||||
setFixedWidth(parentWidget()->size().width());
|
setFixedWidth(parentSize.width());
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize parrent if width is smaller than this dialog
|
// resize parrent if width is smaller than this dialog
|
||||||
if (resizeParent && parentWidget()->size().width() < size().width()) {
|
if (resizeParent && parentSize.width() < size().width()) {
|
||||||
parentWidget()->resize(size().width(), parentWidget()->size().height());
|
parentWidget()->resize(size().width(), parentSize.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_position == POSITION_LEFT || _position == POSITION_TOP) {
|
if (_position == POSITION_LEFT || _position == POSITION_TOP) {
|
||||||
// move to upper left corner
|
// move to upper left corner
|
||||||
move(parentWidget()->geometry().topLeft());
|
move(parentGeometry.topLeft());
|
||||||
} else if (_position == POSITION_RIGHT) {
|
} else if (_position == POSITION_RIGHT) {
|
||||||
// move to upper right corner
|
// move to upper right corner
|
||||||
QPoint pos = parentWidget()->geometry().topRight();
|
QPoint pos = parentGeometry.topRight();
|
||||||
pos.setX(pos.x() - size().width());
|
pos.setX(pos.x() - size().width());
|
||||||
move(pos);
|
move(pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
|
||||||
|
|
||||||
// keep track of changes to the number of screens
|
// keep track of changes to the number of screens
|
||||||
connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);
|
connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HMDToolsDialog::~HMDToolsDialog() {
|
HMDToolsDialog::~HMDToolsDialog() {
|
||||||
|
|
|
@ -22,6 +22,8 @@ public:
|
||||||
~HMDToolsDialog();
|
~HMDToolsDialog();
|
||||||
|
|
||||||
QString getDebugDetails() const;
|
QString getDebugDetails() const;
|
||||||
|
QScreen* getHMDScreen() const { return _hmdScreen; }
|
||||||
|
bool hasHMDScreen() const { return _hmdScreenNumber >= -1; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closed();
|
void closed();
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QScreen>
|
||||||
#include <QTableWidgetItem>
|
#include <QTableWidgetItem>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
|
@ -82,10 +84,6 @@ void RunningScriptsWidget::loadSelectedScript() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunningScriptsWidget::setBoundary(const QRect& rect) {
|
|
||||||
_boundary = rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
QLayoutItem* widget;
|
QLayoutItem* widget;
|
||||||
|
@ -153,7 +151,7 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
|
||||||
ui->filterLineEdit->setFocus();
|
ui->filterLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QRect parentGeometry = parentWidget()->geometry();
|
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
|
||||||
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
||||||
int menuBarHeight = Menu::getInstance()->geometry().height();
|
int menuBarHeight = Menu::getInstance()->geometry().height();
|
||||||
int topMargin = titleBarHeight + menuBarHeight;
|
int topMargin = titleBarHeight + menuBarHeight;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include "ScriptsModel.h"
|
#include "ScriptsModel.h"
|
||||||
#include "FramelessDialog.h"
|
|
||||||
#include "ScriptsTableWidget.h"
|
#include "ScriptsTableWidget.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -44,7 +43,6 @@ protected:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void scriptStopped(const QString& scriptName);
|
void scriptStopped(const QString& scriptName);
|
||||||
void setBoundary(const QRect& rect);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void allScriptsStopped();
|
void allScriptsStopped();
|
||||||
|
@ -61,7 +59,6 @@ private:
|
||||||
ScriptsTableWidget* _recentlyLoadedScriptsTable;
|
ScriptsTableWidget* _recentlyLoadedScriptsTable;
|
||||||
QStringList _recentlyLoadedScripts;
|
QStringList _recentlyLoadedScripts;
|
||||||
QString _lastStoppedScript;
|
QString _lastStoppedScript;
|
||||||
QRect _boundary;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RunningScriptsWidget_h
|
#endif // hifi_RunningScriptsWidget_h
|
||||||
|
|
Loading…
Reference in a new issue