switch to single button for mode switching

This commit is contained in:
ZappoMan 2014-11-26 19:43:01 -08:00
parent fe9fab68bf
commit 184acaedef
2 changed files with 17 additions and 18 deletions

View file

@ -28,6 +28,8 @@
HMDToolsDialog::HMDToolsDialog(QWidget* parent) : HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint) , QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint) ,
_switchModeButton(NULL),
_debugDetails(NULL),
_previousScreen(NULL), _previousScreen(NULL),
_hmdScreen(NULL), _hmdScreen(NULL),
_previousDialogScreen(NULL), _previousDialogScreen(NULL),
@ -37,21 +39,17 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
// Create layouter // Create layouter
QFormLayout* form = new QFormLayout(); QFormLayout* form = new QFormLayout();
const int WIDTH = 350;
// Add a button to enter // Add a button to enter
QPushButton* enterModeButton = new QPushButton("Enter HMD Mode"); _switchModeButton = new QPushButton("Enter HMD Mode");
form->addRow("", enterModeButton); _switchModeButton->setFixedWidth(WIDTH);
connect(enterModeButton,SIGNAL(clicked(bool)),this,SLOT(enterModeClicked(bool))); form->addRow("", _switchModeButton);
connect(_switchModeButton,SIGNAL(clicked(bool)),this,SLOT(switchModeClicked(bool)));
// Add a button to leave
QPushButton* leaveModeButton = new QPushButton("Leave HMD Mode");
form->addRow("", leaveModeButton);
connect(leaveModeButton,SIGNAL(clicked(bool)),this,SLOT(leaveModeClicked(bool)));
// Create a label with debug details... // Create a label with debug details...
_debugDetails = new QLabel(); _debugDetails = new QLabel();
_debugDetails->setText(getDebugDetails()); _debugDetails->setText(getDebugDetails());
const int WIDTH = 350;
const int HEIGHT = 100; const int HEIGHT = 100;
_debugDetails->setFixedSize(WIDTH, HEIGHT); _debugDetails->setFixedSize(WIDTH, HEIGHT);
form->addRow("", _debugDetails); form->addRow("", _debugDetails);
@ -163,12 +161,17 @@ QString HMDToolsDialog::getDebugDetails() const {
return results; return results;
} }
void HMDToolsDialog::enterModeClicked(bool checked) { void HMDToolsDialog::switchModeClicked(bool checked) {
enterHDMMode(); if (!_inHDMMode) {
enterHDMMode();
} else {
leaveHDMMode();
}
} }
void HMDToolsDialog::enterHDMMode() { void HMDToolsDialog::enterHDMMode() {
if (!_inHDMMode) { if (!_inHDMMode) {
_switchModeButton->setText("Leave HMD Mode");
_debugDetails->setText(getDebugDetails()); _debugDetails->setText(getDebugDetails());
int hmdScreen = OculusManager::getHMDScreen(); int hmdScreen = OculusManager::getHMDScreen();
@ -212,13 +215,9 @@ void HMDToolsDialog::activateWindowAfterEnterMode() {
centerCursorOnWidget(Application::getInstance()->getWindow()); centerCursorOnWidget(Application::getInstance()->getWindow());
} }
void HMDToolsDialog::leaveModeClicked(bool checked) {
leaveHDMMode();
}
void HMDToolsDialog::leaveHDMMode() { void HMDToolsDialog::leaveHDMMode() {
if (_inHDMMode) { if (_inHDMMode) {
_switchModeButton->setText("Enter HMD Mode");
_debugDetails->setText(getDebugDetails()); _debugDetails->setText(getDebugDetails());
Application::getInstance()->setFullscreen(false); Application::getInstance()->setFullscreen(false);

View file

@ -28,8 +28,7 @@ signals:
public slots: public slots:
void reject(); void reject();
void enterModeClicked(bool checked); void switchModeClicked(bool checked);
void leaveModeClicked(bool checked);
void activateWindowAfterEnterMode(); void activateWindowAfterEnterMode();
void moveWindowAfterLeaveMode(); void moveWindowAfterLeaveMode();
void applicationWindowScreenChanged(QScreen* screen); void applicationWindowScreenChanged(QScreen* screen);
@ -51,6 +50,7 @@ private:
QRect _previousRect; QRect _previousRect;
QScreen* _previousScreen; QScreen* _previousScreen;
QScreen* _hmdScreen; QScreen* _hmdScreen;
QPushButton* _switchModeButton;
QLabel* _debugDetails; QLabel* _debugDetails;
QRect _previousDialogRect; QRect _previousDialogRect;