mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
dry up code and make chat window avoid the hmd screen
This commit is contained in:
parent
06d348c399
commit
ec54b609df
5 changed files with 30 additions and 44 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>
|
||||||
|
@ -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()
|
// loadViewFrustum()
|
||||||
//
|
//
|
||||||
|
|
|
@ -327,6 +327,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;
|
||||||
|
|
|
@ -94,29 +94,9 @@ void FramelessDialog::showEvent(QShowEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
void FramelessDialog::resizeAndPosition(bool resizeParent) {
|
||||||
QSize parentSize = parentWidget()->size();
|
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
|
||||||
QRect parentGeometry = parentWidget()->geometry();
|
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
|
// keep full app height or width depending on position
|
||||||
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
|
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
|
||||||
setFixedHeight(parentSize.height());
|
setFixedHeight(parentSize.height());
|
||||||
|
|
|
@ -151,27 +151,7 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
|
||||||
ui->filterLineEdit->setFocus();
|
ui->filterLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect parentGeometry = parentWidget()->geometry();
|
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue