dry up code and make chat window avoid the hmd screen

This commit is contained in:
ZappoMan 2014-12-10 17:23:39 -08:00
parent 06d348c399
commit ec54b609df
5 changed files with 30 additions and 44 deletions

View file

@ -37,6 +37,7 @@
#include <QOpenGLFramebufferObject>
#include <QObject>
#include <QWheelEvent>
#include <QScreen>
#include <QSettings>
#include <QShortcut>
#include <QTimer>
@ -2714,6 +2715,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()
//

View file

@ -327,6 +327,8 @@ public:
// rendering of several elements depend on that
// TODO: carry that information on the Camera as a setting
bool isHMDMode() const;
QRect getDesirableApplicationGeometry();
signals:

View file

@ -124,7 +124,7 @@ void ChatWindow::showEvent(QShowEvent* event) {
if (!event->spontaneous()) {
_ui->messagePlainTextEdit->setFocus();
}
const QRect parentGeometry = parentWidget()->geometry();
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
int menuBarHeight = Menu::getInstance()->geometry().height();
int topMargin = titleBarHeight + menuBarHeight;

View file

@ -94,29 +94,9 @@ void FramelessDialog::showEvent(QShowEvent* event) {
}
void FramelessDialog::resizeAndPosition(bool resizeParent) {
QSize parentSize = parentWidget()->size();
QRect parentGeometry = parentWidget()->geometry();
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
QSize parentSize = parentGeometry.size();
// 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 = parentWidget()->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();
parentGeometry = betterScreen->geometry();
parentSize = betterScreen->size();
}
}
// keep full app height or width depending on position
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
setFixedHeight(parentSize.height());

View file

@ -151,27 +151,7 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
ui->filterLineEdit->setFocus();
}
QRect parentGeometry = parentWidget()->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 = parentWidget()->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();
parentGeometry = betterScreen->geometry();
}
}
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
int menuBarHeight = Menu::getInstance()->geometry().height();
int topMargin = titleBarHeight + menuBarHeight;