mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
more improvements to HMD Tools
This commit is contained in:
parent
6108f7d9cd
commit
bc376a0a15
2 changed files with 28 additions and 8 deletions
|
@ -51,8 +51,8 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
|
||||||
|
|
||||||
_previousRect = Application::getInstance()->getWindow()->rect();
|
_previousRect = Application::getInstance()->getWindow()->rect();
|
||||||
|
|
||||||
|
|
||||||
// QDesktopWidget::screenCountChanged() SIGNAL
|
Application::getInstance()->getWindow()->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
HMDToolsDialog::~HMDToolsDialog() {
|
HMDToolsDialog::~HMDToolsDialog() {
|
||||||
|
@ -70,7 +70,7 @@ void HMDToolsDialog::enterModeClicked(bool checked) {
|
||||||
|
|
||||||
if (hmdScreen >= 0) {
|
if (hmdScreen >= 0) {
|
||||||
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
||||||
QScreen* targetScreen = QGuiApplication::screens()[hmdScreen];
|
_hmdScreen = QGuiApplication::screens()[hmdScreen];
|
||||||
|
|
||||||
_previousRect = Application::getInstance()->getWindow()->rect();
|
_previousRect = Application::getInstance()->getWindow()->rect();
|
||||||
qDebug() << "_previousRect:" << _previousRect;
|
qDebug() << "_previousRect:" << _previousRect;
|
||||||
|
@ -85,27 +85,36 @@ void HMDToolsDialog::enterModeClicked(bool checked) {
|
||||||
|
|
||||||
qDebug() << "about to move to:" << rect.topLeft();
|
qDebug() << "about to move to:" << rect.topLeft();
|
||||||
|
|
||||||
mainWindow->setScreen(targetScreen);
|
mainWindow->setScreen(_hmdScreen);
|
||||||
mainWindow->setGeometry(rect);
|
mainWindow->setGeometry(rect);
|
||||||
|
|
||||||
_wasMoved = true;
|
_wasMoved = true;
|
||||||
}
|
}
|
||||||
Application::getInstance()->setFullscreen(true);
|
Application::getInstance()->setFullscreen(true);
|
||||||
Application::getInstance()->setEnableVRMode(true);
|
Application::getInstance()->setEnableVRMode(true);
|
||||||
|
|
||||||
|
const int SLIGHT_DELAY = 500;
|
||||||
|
QTimer::singleShot(SLIGHT_DELAY, this, SLOT(activateWindowAfterEnterMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMDToolsDialog::moveWindowAfterLeaveMode() {
|
void HMDToolsDialog::activateWindowAfterEnterMode() {
|
||||||
qDebug() << "moveWindowAfterLeaveMode";
|
qDebug() << "activateWindowAfterEnterMode";
|
||||||
|
Application::getInstance()->getWindow()->activateWindow();
|
||||||
|
|
||||||
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
||||||
mainWindow->setScreen(_previousScreen);
|
QPoint windowCenter = mainWindow->geometry().center();
|
||||||
mainWindow->setGeometry(_previousRect);
|
//QPoint desktopCenter = mainWindow->mapToGlobal(windowCenter);
|
||||||
|
qDebug() << "windowCenter:" << windowCenter;
|
||||||
|
QCursor::setPos(_hmdScreen, windowCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HMDToolsDialog::leaveModeClicked(bool checked) {
|
void HMDToolsDialog::leaveModeClicked(bool checked) {
|
||||||
qDebug() << "leaveModeClicked";
|
qDebug() << "leaveModeClicked";
|
||||||
|
|
||||||
Application::getInstance()->setFullscreen(false);
|
Application::getInstance()->setFullscreen(false);
|
||||||
Application::getInstance()->setEnableVRMode(false);
|
Application::getInstance()->setEnableVRMode(false);
|
||||||
|
Application::getInstance()->getWindow()->activateWindow();
|
||||||
|
|
||||||
if (_wasMoved) {
|
if (_wasMoved) {
|
||||||
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
||||||
|
@ -118,6 +127,15 @@ void HMDToolsDialog::leaveModeClicked(bool checked) {
|
||||||
_wasMoved = false;
|
_wasMoved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HMDToolsDialog::moveWindowAfterLeaveMode() {
|
||||||
|
qDebug() << "moveWindowAfterLeaveMode";
|
||||||
|
QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle();
|
||||||
|
mainWindow->setScreen(_previousScreen);
|
||||||
|
mainWindow->setGeometry(_previousRect);
|
||||||
|
Application::getInstance()->getWindow()->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HMDToolsDialog::reject() {
|
void HMDToolsDialog::reject() {
|
||||||
// Just regularly close upon ESC
|
// Just regularly close upon ESC
|
||||||
this->QDialog::close();
|
this->QDialog::close();
|
||||||
|
|
|
@ -28,6 +28,7 @@ public slots:
|
||||||
void reject();
|
void reject();
|
||||||
void enterModeClicked(bool checked);
|
void enterModeClicked(bool checked);
|
||||||
void leaveModeClicked(bool checked);
|
void leaveModeClicked(bool checked);
|
||||||
|
void activateWindowAfterEnterMode();
|
||||||
void moveWindowAfterLeaveMode();
|
void moveWindowAfterLeaveMode();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -38,6 +39,7 @@ private:
|
||||||
bool _wasMoved;
|
bool _wasMoved;
|
||||||
QRect _previousRect;
|
QRect _previousRect;
|
||||||
QScreen* _previousScreen;
|
QScreen* _previousScreen;
|
||||||
|
QScreen* _hmdScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_HMDToolsDialog_h
|
#endif // hifi_HMDToolsDialog_h
|
||||||
|
|
Loading…
Reference in a new issue