Merge pull request #3947 from ZappoMan/HMDMode

Make the Chat, Running Scripts, and Address bar "avoid" HMD Screen
This commit is contained in:
AndrewMeadows 2014-12-11 10:48:32 -08:00
commit 84e82cd03b
8 changed files with 45 additions and 19 deletions

View file

@ -37,6 +37,7 @@
#include <QOpenGLFramebufferObject>
#include <QObject>
#include <QWheelEvent>
#include <QScreen>
#include <QSettings>
#include <QShortcut>
#include <QTimer>
@ -415,9 +416,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
}
connect(_window, &MainWindow::windowGeometryChanged,
_runningScriptsWidget, &RunningScriptsWidget::setBoundary);
_trayIcon->show();
// 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()
//

View file

@ -325,6 +325,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

@ -9,8 +9,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QScreen>
#include <QWindow>
#include "Application.h"
#include "FramelessDialog.h"
#include "Menu.h"
const int RESIZE_HANDLE_WIDTH = 7;
@ -90,24 +94,27 @@ void FramelessDialog::showEvent(QShowEvent* event) {
}
void FramelessDialog::resizeAndPosition(bool resizeParent) {
QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry();
QSize parentSize = parentGeometry.size();
// keep full app height or width depending on position
if (_position == POSITION_LEFT || _position == POSITION_RIGHT) {
setFixedHeight(parentWidget()->size().height());
setFixedHeight(parentSize.height());
} else {
setFixedWidth(parentWidget()->size().width());
setFixedWidth(parentSize.width());
}
// resize parrent if width is smaller than this dialog
if (resizeParent && parentWidget()->size().width() < size().width()) {
parentWidget()->resize(size().width(), parentWidget()->size().height());
if (resizeParent && parentSize.width() < size().width()) {
parentWidget()->resize(size().width(), parentSize.height());
}
if (_position == POSITION_LEFT || _position == POSITION_TOP) {
// move to upper left corner
move(parentWidget()->geometry().topLeft());
move(parentGeometry.topLeft());
} else if (_position == POSITION_RIGHT) {
// move to upper right corner
QPoint pos = parentWidget()->geometry().topRight();
QPoint pos = parentGeometry.topRight();
pos.setX(pos.x() - size().width());
move(pos);
}

View file

@ -79,7 +79,6 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
// keep track of changes to the number of screens
connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &HMDToolsDialog::screenCountChanged);
}
HMDToolsDialog::~HMDToolsDialog() {

View file

@ -22,6 +22,8 @@ public:
~HMDToolsDialog();
QString getDebugDetails() const;
QScreen* getHMDScreen() const { return _hmdScreen; }
bool hasHMDScreen() const { return _hmdScreenNumber >= -1; }
signals:
void closed();

View file

@ -17,7 +17,9 @@
#include <QFileInfo>
#include <QKeyEvent>
#include <QPainter>
#include <QScreen>
#include <QTableWidgetItem>
#include <QWindow>
#include "Application.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) {
setUpdatesEnabled(false);
QLayoutItem* widget;
@ -153,7 +151,7 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
ui->filterLineEdit->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

@ -18,7 +18,6 @@
#include <QSortFilterProxyModel>
#include "ScriptsModel.h"
#include "FramelessDialog.h"
#include "ScriptsTableWidget.h"
namespace Ui {
@ -44,7 +43,6 @@ protected:
public slots:
void scriptStopped(const QString& scriptName);
void setBoundary(const QRect& rect);
private slots:
void allScriptsStopped();
@ -61,7 +59,6 @@ private:
ScriptsTableWidget* _recentlyLoadedScriptsTable;
QStringList _recentlyLoadedScripts;
QString _lastStoppedScript;
QRect _boundary;
};
#endif // hifi_RunningScriptsWidget_h