diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h index 753acb77df..f90ec83b42 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/display.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/display.h @@ -81,9 +81,6 @@ private: QPushButton* _removeWindowButton = nullptr; unsigned int _monitorIdx = 0; QVBoxLayout* _layout = nullptr; - QHBoxLayout* _layoutMonBox = nullptr; - QHBoxLayout* _layoutMonButton = nullptr; - QHBoxLayout* _layoutWindows = nullptr; std::vector _winCtrlLayouts; std::vector _layoutWindowWrappers; std::vector _frameBorderLines; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h index 48e709db49..817d6800cf 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/filesupport.h @@ -47,7 +47,6 @@ public: Display* display, Orientation* orientation, std::vector& windowList, sgct::config::Cluster& cluster, std::function cb); - ~FileSupport(); std::string saveFilename(); private slots: diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h index aaa59c3a08..cdb9761d62 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientation.h @@ -62,8 +62,6 @@ private: sgct::quat _orientationValue = {0.0, 0.0, 0.0, 0.0}; OrientationDialog* _orientationDialog = nullptr; QHBoxLayout* _layoutOrientationFull = nullptr; - QVBoxLayout* _layoutOrientationControls = nullptr; - QPushButton* _orientationButton = nullptr; QCheckBox* _checkBoxVsync = nullptr; }; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h index 58a9fe85aa..b4b88bd321 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/orientationdialog.h @@ -50,33 +50,16 @@ class OrientationDialog : public QDialog Q_OBJECT public: explicit OrientationDialog(sgct::quat& orientation, QWidget* parent); - ~OrientationDialog(); private slots: void cancel(); void ok(); private: - sgct::quat& _orientationValue; - QVBoxLayout* _layoutWindow = nullptr; - QHBoxLayout* _layoutPitch = nullptr; - QHBoxLayout* _layoutRoll = nullptr; - QHBoxLayout* _layoutYaw = nullptr; - QHBoxLayout* _layoutButtonBox = nullptr; - - QLabel* _labelPitch = nullptr; - QLabel* _labelRoll = nullptr; - QLabel* _labelYaw = nullptr; - QLineEdit* _linePitch = nullptr; QLineEdit* _lineRoll = nullptr; QLineEdit* _lineYaw = nullptr; - QDoubleValidator* _validatorPitch = nullptr; - QDoubleValidator* _validatorRoll = nullptr; - QDoubleValidator* _validatorYaw = nullptr; - - QPushButton* _buttonSave = nullptr; - QPushButton* _buttonCancel = nullptr; + sgct::quat& _orientationValue; }; #endif // __OPENSPACE_UI_LAUNCHER___ORIENTATIONDIALOG___H__ diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h index 258ea4bc4c..545df93009 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/windowcontrol.h @@ -58,7 +58,6 @@ public: void setWindowChangeCallback(std::function cb); void setWebGuiChangeCallback(std::function cb); void showWindowLabel(const bool show); - void cleanupLayouts(); QVBoxLayout* initializeLayout(); QRectF& dimensions(); QLineEdit* lineEditSizeWidth(); @@ -110,6 +109,7 @@ private slots: void onWebGuiSelection(int selectionState); private: + void createWidgets(QWidget* parent); template void enableProjectionOption(T* comboModel, int selectionIndex, bool enable); void updateScaledWindowDimensions(); @@ -149,67 +149,28 @@ private: std::vector& _monitorResolutions; int _maxWindowSizePixels = 10000; const QString* _colorsForWindows = nullptr; - - QVBoxLayout* _layoutWindowCtrl = nullptr; QVBoxLayout* _layoutFullWindow = nullptr; - - QHBoxLayout* _layoutWinNum = nullptr; QLabel* _labelWinNum = nullptr; - QLineEdit* _size_x = nullptr; QLineEdit* _size_y = nullptr; QLineEdit* _offset_x = nullptr; QLineEdit* _offset_y = nullptr; - - QIntValidator* _validatorSize_x = nullptr; - QIntValidator* _validatorSize_y = nullptr; - QIntValidator* _validatorOffset_x = nullptr; - QIntValidator* _validatorOffset_y = nullptr; - QRectF _windowDims; QPushButton* _fullscreenButton = nullptr; QCheckBox* _checkBoxWindowDecor = nullptr; QCheckBox* _checkBoxWebGui = nullptr; QCheckBox* _checkBoxSpoutOutput = nullptr; - QComboBox* _comboMonitorSelect = nullptr; QComboBox* _comboProjection = nullptr; QComboBox* _comboQuality = nullptr; QLabel* _labelQuality = nullptr; QLabel* _labelFovH = nullptr; QLineEdit* _lineFovH = nullptr; - QDoubleValidator* _validatorFovH = nullptr; QLabel* _labelFovV = nullptr; QLineEdit* _lineFovV = nullptr; - QDoubleValidator* _validatorFovV = nullptr; QLabel* _labelHeightOffset = nullptr; QLineEdit* _lineHeightOffset = nullptr; - QDoubleValidator* _validatorHeightOffset = nullptr; - - QHBoxLayout* _layoutName = nullptr; - QLabel* _labelName = nullptr; QLineEdit* _windowName = nullptr; - QHBoxLayout* _layoutMonitorNum = nullptr; - QLabel* _labelSize = nullptr; - QLabel* _labelDelim = nullptr; - QHBoxLayout* _layoutSize = nullptr; - QWidget* _widgetSize = nullptr; - QHBoxLayout* _layoutOffset = nullptr; - QLabel* _labelOffset = nullptr; - QLabel* _labelComma = nullptr; - QHBoxLayout* _layoutCheckboxesFull1 = nullptr; - QVBoxLayout* _layoutCheckboxesFull2 = nullptr; - QVBoxLayout* _layoutProjectionGroup = nullptr; - QFrame* _borderProjectionGroup = nullptr; - QHBoxLayout* _layoutFullscreenButton = nullptr; - QHBoxLayout* _layoutCBoxWindowDecor = nullptr; - QHBoxLayout* _layoutCBoxWebGui = nullptr; - QHBoxLayout* _layoutComboProjection = nullptr; - QHBoxLayout* _layoutCBoxSpoutOutput = nullptr; - QHBoxLayout* _layoutComboQuality = nullptr; - QHBoxLayout* _layoutFovH = nullptr; - QHBoxLayout* _layoutFovV = nullptr; - QHBoxLayout* _layoutHeightOffset = nullptr; }; #endif // __OPENSPACE_UI_LAUNCHER___WINDOWCONTROL___H__ diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp index c6651e8a80..ed4394146f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/display.cpp @@ -50,48 +50,39 @@ Display::Display(MonitorBox* monitorRenderBox, std::vector& monitorSizeLi } Display::~Display() { - delete _addWindowButton; - delete _removeWindowButton; delete _monBox; - for (auto f : _frameBorderLines) { - delete f; - } for (auto w : _windowControl) { delete w; } - delete _layoutMonBox; - delete _layoutMonButton; - for (auto w : _layoutWindowWrappers) { - delete w; - } - delete _layoutWindows; delete _layout; } void Display::initializeLayout() { _layout = new QVBoxLayout(this); - _layoutMonButton = new QHBoxLayout(); - _layoutMonButton->addWidget(_removeWindowButton); - _layoutMonButton->addStretch(1); - _layoutMonButton->addWidget(_addWindowButton); - _layout->addLayout(_layoutMonButton); - _layoutWindows = new QHBoxLayout(); + { + QHBoxLayout* layoutMonButton = new QHBoxLayout(); + layoutMonButton->addWidget(_removeWindowButton); + layoutMonButton->addStretch(1); + layoutMonButton->addWidget(_addWindowButton); + _layout->addLayout(layoutMonButton); + } + QHBoxLayout* layoutWindows = new QHBoxLayout(); _layout->addStretch(); for (unsigned int i = 0; i < _nMaxWindows; ++i) { _winCtrlLayouts.push_back(_windowControl[i]->initializeLayout()); _layoutWindowWrappers.push_back(new QWidget()); _layoutWindowWrappers.back()->setLayout(_winCtrlLayouts.back()); - _layoutWindows->addWidget(_layoutWindowWrappers.back()); + layoutWindows->addWidget(_layoutWindowWrappers.back()); if (i < (_nMaxWindows - 1)) { _frameBorderLines.push_back(new QFrame()); _frameBorderLines.back()->setFrameShape(QFrame::VLine); - _layoutWindows->addWidget(_frameBorderLines.back()); + layoutWindows->addWidget(_frameBorderLines.back()); } } _nWindowsDisplayed = 1; showWindows(); - _layout->addLayout(_layoutWindows); + _layout->addLayout(layoutWindows); } std::vector Display::windowControls() { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp index 52ad58345c..441ea8a0c0 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/filesupport.cpp @@ -36,32 +36,35 @@ FileSupport::FileSupport(QVBoxLayout* parentLayout, std::vector& monitorL , _finishedCallback(cb) { QVBoxLayout* layoutFullVertical = new QVBoxLayout(); - QHBoxLayout* layoutFilename = new QHBoxLayout(); _lineFilename = new QLineEdit(); _lineFilename->setFixedWidth(190); - QLabel* labelFilename = new QLabel(); - labelFilename->setText("Filename: "); - layoutFilename->addStretch(1); - layoutFilename->addWidget(labelFilename); - layoutFilename->addWidget(_lineFilename); - layoutFilename->addStretch(1); - _layoutButtonBox = new QHBoxLayout; + { + QHBoxLayout* layoutFilename = new QHBoxLayout(); + QLabel* labelFilename = new QLabel(); + labelFilename->setText("Filename: "); + layoutFilename->addStretch(1); + layoutFilename->addWidget(labelFilename); + layoutFilename->addWidget(_lineFilename); + layoutFilename->addStretch(1); + layoutFullVertical->addLayout(layoutFilename); + } _saveButton = new QPushButton("Save"); _saveButton->setToolTip("Save global orientation changes"); - _layoutButtonBox->addStretch(1); - _layoutButtonBox->addWidget(_saveButton); + connect(_saveButton, SIGNAL(released()), this, SLOT(save())); + _saveButton->setEnabled(false); _cancelButton = new QPushButton("Cancel"); _cancelButton->setToolTip("Cancel global orientation changes"); - _layoutButtonBox->addWidget(_cancelButton); - layoutFullVertical->addLayout(layoutFilename); - layoutFullVertical->addLayout(_layoutButtonBox); - parentLayout->addLayout(layoutFullVertical); - connect(_saveButton, SIGNAL(released()), this, SLOT(save())); connect(_cancelButton, SIGNAL(released()), this, SLOT(cancel())); + { + QHBoxLayout* layoutButtonBox = new QHBoxLayout; + layoutButtonBox->addStretch(1); + layoutButtonBox->addWidget(_saveButton); + layoutButtonBox->addWidget(_cancelButton); + layoutFullVertical->addLayout(layoutButtonBox); + } + parentLayout->addLayout(layoutFullVertical); connect(_lineFilename, SIGNAL(textEdited(const QString&)), this, SLOT(filenameEdited(const QString&))); - _saveButton->setEnabled(false); - _cluster.masterAddress = "localhost"; } void FileSupport::saveCluster() { @@ -71,6 +74,7 @@ void FileSupport::saveCluster() { if (_cluster.nodes.size() == 0) { _cluster.nodes.push_back(sgct::config::Node()); } + _cluster.masterAddress = "localhost"; _cluster.nodes.back().address = "localhost"; _cluster.nodes.back().port = 20401; _cluster.scene = std::move(initScene); @@ -154,7 +158,7 @@ void FileSupport::saveWindowsWebGui(unsigned int wIdx) { _windowList.back().tags.push_back("GUI"); } _windowList.back().draw2D = (wIdx == webGuiWindowIndex); - _windowList.back().draw3D = !_windowList.back().draw2D; + _windowList.back().draw3D = !(_windowList.back().draw2D.value()); } } @@ -272,12 +276,3 @@ void FileSupport::save() { void FileSupport::cancel() { _finishedCallback(false); } - -FileSupport::~FileSupport() -{ - delete _saveButton; - delete _cancelButton; - delete _lineFilename; - delete _layoutButtonBox; -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp index f51beaba0e..8ec4cbdd60 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientation.cpp @@ -30,18 +30,18 @@ Orientation::Orientation() { _orientationDialog = new OrientationDialog(_orientationValue, this); _layoutOrientationFull = new QHBoxLayout(); - _layoutOrientationControls = new QVBoxLayout(); - _orientationButton = new QPushButton("Global Orientation"); - _checkBoxVsync = new QCheckBox("VSync All Windows", this); - _layoutOrientationControls->addWidget(_checkBoxVsync); - _layoutOrientationControls->addWidget(_orientationButton); - - _layoutOrientationFull->addStretch(1); - _layoutOrientationFull->addLayout(_layoutOrientationControls); - _layoutOrientationFull->addStretch(1); - - connect(_orientationButton, SIGNAL(released()), this, - SLOT(orientationDialog())); + { + QVBoxLayout* layoutOrientationControls = new QVBoxLayout(); + QPushButton* orientationButton = new QPushButton("Global Orientation"); + _checkBoxVsync = new QCheckBox("VSync All Windows", this); + layoutOrientationControls->addWidget(_checkBoxVsync); + layoutOrientationControls->addWidget(orientationButton); + _layoutOrientationFull->addStretch(1); + _layoutOrientationFull->addLayout(layoutOrientationControls); + _layoutOrientationFull->addStretch(1); + connect(orientationButton, SIGNAL(released()), this, + SLOT(orientationDialog())); + } } void Orientation::addButtonToLayout(QVBoxLayout* parentLayout) { @@ -63,7 +63,5 @@ bool Orientation::vsyncValue() { Orientation::~Orientation() { delete _orientationDialog; - delete _orientationButton; - delete _checkBoxVsync; - delete _layoutOrientationControls; + delete _layoutOrientationFull; } diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp index 846f9763bd..93334b824f 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/orientationdialog.cpp @@ -30,17 +30,7 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) , _orientationValue(orientation) { setWindowTitle("Global Orientation"); - _layoutWindow = new QVBoxLayout(this); - _layoutPitch = new QHBoxLayout(); - _layoutRoll = new QHBoxLayout(); - _layoutYaw = new QHBoxLayout(); - - _labelPitch = new QLabel(this); - _labelRoll = new QLabel(this); - _labelYaw = new QLabel(this); - _labelPitch->setText("Pitch: "); - _labelRoll ->setText("Roll: "); - _labelYaw ->setText("Yaw: "); + QVBoxLayout* layoutWindow = new QVBoxLayout(this); _linePitch = new QLineEdit(this); _lineRoll = new QLineEdit(this); @@ -48,46 +38,54 @@ OrientationDialog::OrientationDialog(sgct::quat& orientation, QWidget* parent) _linePitch->setText(QString::number(_orientationValue.x)); _lineRoll->setText(QString::number(_orientationValue.z)); _lineYaw->setText(QString::number(_orientationValue.y)); - _validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); - _validatorPitch->setNotation(QDoubleValidator::StandardNotation); - _validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); - _validatorRoll->setNotation(QDoubleValidator::StandardNotation); - _validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); - _validatorYaw->setNotation(QDoubleValidator::StandardNotation); - _linePitch->setValidator(_validatorPitch); - _lineRoll->setValidator(_validatorRoll); - _lineYaw->setValidator(_validatorYaw); - - _layoutPitch->addStretch(1); - _layoutPitch->addWidget(_labelPitch); - _layoutPitch->addWidget(_linePitch); - _layoutWindow->addLayout(_layoutPitch); - - _layoutRoll->addStretch(1); - _layoutRoll->addWidget(_labelRoll); - _layoutRoll->addWidget(_lineRoll); - _layoutWindow->addLayout(_layoutRoll); - - _layoutYaw->addStretch(1); - _layoutYaw->addWidget(_labelYaw); - _layoutYaw->addWidget(_lineYaw); - _layoutWindow->addLayout(_layoutYaw); - - _layoutButtonBox = new QHBoxLayout; - _buttonSave = new QPushButton("OK"); - _buttonSave->setToolTip("Save global orientation changes"); - _layoutButtonBox->addStretch(1); - _layoutButtonBox->addWidget(_buttonSave); - - _buttonCancel = new QPushButton("Cancel"); - _buttonCancel->setToolTip("Cancel global orientation changes"); - _layoutButtonBox->addWidget(_buttonCancel); - _layoutButtonBox->addStretch(1); - - connect(_buttonSave, SIGNAL(released()), this, SLOT(ok())); - connect(_buttonCancel, SIGNAL(released()), this, SLOT(cancel())); - - _layoutWindow->addLayout(_layoutButtonBox); + { + QDoubleValidator* validatorPitch = new QDoubleValidator(-90.0, 90.0, 15); + QDoubleValidator* validatorRoll = new QDoubleValidator(-360.0, 360.0, 15); + QDoubleValidator* validatorYaw = new QDoubleValidator(-180.0, 180.0, 15); + validatorPitch->setNotation(QDoubleValidator::StandardNotation); + validatorRoll->setNotation(QDoubleValidator::StandardNotation); + validatorYaw->setNotation(QDoubleValidator::StandardNotation); + _linePitch->setValidator(validatorPitch); + _lineRoll->setValidator(validatorRoll); + _lineYaw->setValidator(validatorYaw); + } + { + QLabel* labelPitch = new QLabel(this); + labelPitch->setText("Pitch: "); + QHBoxLayout* layoutPitch = new QHBoxLayout(); + layoutPitch->addStretch(1); + layoutPitch->addWidget(labelPitch); + layoutPitch->addWidget(_linePitch); + layoutWindow->addLayout(layoutPitch); + QLabel* labelRoll = new QLabel(this); + labelRoll ->setText("Roll: "); + QHBoxLayout* layoutRoll = new QHBoxLayout(); + layoutRoll->addStretch(1); + layoutRoll->addWidget(labelRoll); + layoutRoll->addWidget(_lineRoll); + layoutWindow->addLayout(layoutRoll); + QLabel* labelYaw = new QLabel(this); + labelYaw ->setText("Yaw: "); + QHBoxLayout* layoutYaw = new QHBoxLayout(); + layoutYaw->addStretch(1); + layoutYaw->addWidget(labelYaw); + layoutYaw->addWidget(_lineYaw); + layoutWindow->addLayout(layoutYaw); + } + { + QHBoxLayout* layoutButtonBox = new QHBoxLayout; + QPushButton* buttonSave = new QPushButton("OK"); + buttonSave->setToolTip("Save global orientation changes"); + layoutButtonBox->addStretch(1); + layoutButtonBox->addWidget(buttonSave); + QPushButton* buttonCancel = new QPushButton("Cancel"); + buttonCancel->setToolTip("Cancel global orientation changes"); + layoutButtonBox->addWidget(buttonCancel); + layoutButtonBox->addStretch(1); + connect(buttonSave, SIGNAL(released()), this, SLOT(ok())); + connect(buttonCancel, SIGNAL(released()), this, SLOT(cancel())); + layoutWindow->addLayout(layoutButtonBox); + } } void OrientationDialog::ok() { @@ -101,24 +99,3 @@ void OrientationDialog::ok() { void OrientationDialog::cancel() { reject(); } - -OrientationDialog::~OrientationDialog() -{ - delete _labelPitch; - delete _labelRoll; - delete _labelYaw; - delete _validatorPitch; - delete _validatorRoll; - delete _validatorYaw; - delete _linePitch; - delete _lineRoll; - delete _lineYaw; - delete _buttonSave; - delete _buttonCancel; - delete _layoutPitch; - delete _layoutRoll; - delete _layoutYaw; - delete _layoutButtonBox; - delete _layoutWindow; -} - diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp index 5c6a8f6f79..58e2712c4e 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/windowcontrol.cpp @@ -36,7 +36,11 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, , _monitorResolutions(monitorDims) , _colorsForWindows(winColors) { - _windowDims = defaultWindowSizes[windowIndex]; + createWidgets(parent); +} + +void WindowControl::createWidgets(QWidget* parent) { + _windowDims = defaultWindowSizes[_index]; _size_x = new QLineEdit( QString::fromUtf8(std::to_string(int(_windowDims.width())).c_str()), parent); _size_y = new QLineEdit( @@ -45,19 +49,27 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, QString::fromUtf8(std::to_string(int(_windowDims.x())).c_str()), parent); _offset_y = new QLineEdit( QString::fromUtf8(std::to_string(int(_windowDims.y())).c_str()), parent); - _validatorSize_x = new QIntValidator(10, _maxWindowSizePixels); - _validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); - _validatorOffset_x = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); - _validatorOffset_y = new QIntValidator(-_maxWindowSizePixels, _maxWindowSizePixels); - _size_x->setValidator(_validatorSize_x); - _size_y->setValidator(_validatorSize_y); - _offset_x->setValidator(_validatorOffset_x); - _offset_y->setValidator(_validatorOffset_y); - - _comboMonitorSelect = new QComboBox(this); - _comboMonitorSelect->addItems(_monitorNames); - _comboMonitorSelect->setCurrentIndex(_monIndex); - + { + QIntValidator* validatorSize_x = new QIntValidator(10, _maxWindowSizePixels); + QIntValidator* validatorSize_y = new QIntValidator(10, _maxWindowSizePixels); + QIntValidator* validatorOffset_x = new QIntValidator( + -_maxWindowSizePixels, + _maxWindowSizePixels + ); + QIntValidator* validatorOffset_y = new QIntValidator( + -_maxWindowSizePixels, + _maxWindowSizePixels + ); + _size_x->setValidator(validatorSize_x); + _size_y->setValidator(validatorSize_y); + _offset_x->setValidator(validatorOffset_x); + _offset_y->setValidator(validatorOffset_y); + } + if (_nMonitors > 1) { + _comboMonitorSelect = new QComboBox(this); + _comboMonitorSelect->addItems(_monitorNames); + _comboMonitorSelect->setCurrentIndex(_monIndex); + } _fullscreenButton = new QPushButton(this); _fullscreenButton->setText("Set to Fullscreen"); _checkBoxWindowDecor = new QCheckBox("Window Decoration", this); @@ -70,39 +82,71 @@ WindowControl::WindowControl(unsigned int nMonitors, unsigned int monitorIndex, _comboQuality = new QComboBox(this); _comboQuality->addItems(_qualityTypes); - _lineFovH = new QLineEdit("80.0", parent); - _validatorFovH = new QDoubleValidator(-180.0, 180.0, 10); - _lineFovH->setValidator(_validatorFovH); - _lineFovV = new QLineEdit("50.534", parent); - _validatorFovV = new QDoubleValidator(-90.0, 90.0, 10); - _lineFovV->setValidator(_validatorFovV); - _lineHeightOffset = new QLineEdit("0.0", parent); - _validatorHeightOffset = new QDoubleValidator(-1000000.0, 1000000.0, 12); - _lineHeightOffset->setValidator(_validatorHeightOffset); + { + _lineFovH = new QLineEdit("80.0", parent); + _lineFovV = new QLineEdit("50.534", parent); + QDoubleValidator* validatorFovH = new QDoubleValidator(-180.0, 180.0, 10); + _lineFovH->setValidator(validatorFovH); + QDoubleValidator* validatorFovV = new QDoubleValidator(-90.0, 90.0, 10); + _lineFovV->setValidator(validatorFovV); + _lineHeightOffset = new QLineEdit("0.0", parent); + QDoubleValidator* validatorHtOff= new QDoubleValidator(-1000000.0, 1000000.0, 12); + _lineHeightOffset->setValidator(validatorHtOff); + } - connect(_size_x, SIGNAL(textChanged(const QString&)), this, - SLOT(onSizeXChanged(const QString&))); - connect(_size_y, SIGNAL(textChanged(const QString&)), this, - SLOT(onSizeYChanged(const QString&))); - connect(_offset_x, SIGNAL(textChanged(const QString&)), this, - SLOT(onOffsetXChanged(const QString&))); - connect(_offset_y, SIGNAL(textChanged(const QString&)), this, - SLOT(onOffsetYChanged(const QString&))); - connect(_comboMonitorSelect, SIGNAL(currentIndexChanged(int)), - this, SLOT(onMonitorChanged(int))); - connect(_comboProjection, SIGNAL(currentIndexChanged(int)), - this, SLOT(onProjectionChanged(int))); - connect(_checkBoxSpoutOutput, SIGNAL(stateChanged(int)), - this, SLOT(onSpoutSelection(int))); - connect(_checkBoxWebGui, SIGNAL(stateChanged(int)), - this, SLOT(onWebGuiSelection(int))); + connect( + _size_x, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onSizeXChanged(const QString&)) + ); + connect( + _size_y, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onSizeYChanged(const QString&)) + ); + connect( + _offset_x, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onOffsetXChanged(const QString&)) + ); + connect( + _offset_y, + SIGNAL(textChanged(const QString&)), + this, + SLOT(onOffsetYChanged(const QString&)) + ); + connect( + _comboMonitorSelect, + SIGNAL(currentIndexChanged(int)), + this, + SLOT(onMonitorChanged(int)) + ); + connect(_comboProjection, + SIGNAL(currentIndexChanged(int)), + this, + SLOT(onProjectionChanged(int)) + ); + connect(_checkBoxSpoutOutput, + SIGNAL(stateChanged(int)), + this, + SLOT(onSpoutSelection(int)) + ); + connect( + _checkBoxWebGui, + SIGNAL(stateChanged(int)), + this, + SLOT(onWebGuiSelection(int)) + ); connect(_fullscreenButton, SIGNAL(released()), this, SLOT(onFullscreenClicked())); } QVBoxLayout* WindowControl::initializeLayout() { _layoutFullWindow = new QVBoxLayout(); //Window size - _layoutWindowCtrl = new QVBoxLayout(); + QVBoxLayout* layoutWindowCtrl = new QVBoxLayout(); _labelWinNum = new QLabel(); _labelWinNum->setText("Window " + QString::number(_index + 1)); @@ -111,126 +155,128 @@ QVBoxLayout* WindowControl::initializeLayout() { colorStr += "; }"; _labelWinNum->setStyleSheet(colorStr); - _layoutWinNum = new QHBoxLayout(); - _layoutWinNum->addStretch(1); - _layoutWinNum->addWidget(_labelWinNum); - _layoutWinNum->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutWinNum); + QHBoxLayout* layoutWinNum = new QHBoxLayout(); + layoutWinNum->addStretch(1); + layoutWinNum->addWidget(_labelWinNum); + layoutWinNum->addStretch(1); + layoutWindowCtrl->addLayout(layoutWinNum); - _layoutName = new QHBoxLayout(); - _labelName = new QLabel(this); - _labelName->setText("Name: "); - _windowName = new QLineEdit(this); - _windowName->setFixedWidth(160); - _layoutName->addWidget(_labelName); - _layoutName->addWidget(_windowName); - _layoutName->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutName); + { + QHBoxLayout* layoutName = new QHBoxLayout(); + QLabel* labelName = new QLabel(this); + labelName->setText("Name: "); + _windowName = new QLineEdit(this); + _windowName->setFixedWidth(160); + layoutName->addWidget(labelName); + layoutName->addWidget(_windowName); + layoutName->addStretch(1); + layoutWindowCtrl->addLayout(layoutName); + } if (_nMonitors > 1) { - _layoutMonitorNum = new QHBoxLayout(); - _layoutMonitorNum->addWidget(_comboMonitorSelect); - _layoutMonitorNum->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutMonitorNum); - } - else { - _comboMonitorSelect->setVisible(false); + QHBoxLayout* layoutMonitorNum = new QHBoxLayout(); + layoutMonitorNum->addWidget(_comboMonitorSelect); + layoutMonitorNum->addStretch(1); + layoutWindowCtrl->addLayout(layoutMonitorNum); } _size_x->setFixedWidth(_lineEditWidthFixed); _size_y->setFixedWidth(_lineEditWidthFixed); - _labelSize = new QLabel(this); - _labelDelim = new QLabel(this); - _layoutSize = new QHBoxLayout(); - _layoutSize->addWidget(_labelSize); - _labelSize->setText("Size:"); - _labelSize->setFixedWidth(55); - _layoutSize->addWidget(_size_x); - _layoutSize->addWidget(_labelDelim); - _layoutSize->addWidget(_size_y); - _layoutSize->addStretch(1); - _labelDelim->setText("x"); - _labelDelim->setFixedWidth(9); - _layoutWindowCtrl->addLayout(_layoutSize); + { + QLabel* labelSize = new QLabel(this); + QLabel* labelDelim = new QLabel(this); + QHBoxLayout* layoutSize = new QHBoxLayout(); + layoutSize->addWidget(labelSize); + labelSize->setText("Size:"); + labelSize->setFixedWidth(55); + layoutSize->addWidget(_size_x); + layoutSize->addWidget(labelDelim); + layoutSize->addWidget(_size_y); + layoutSize->addStretch(1); + labelDelim->setText("x"); + labelDelim->setFixedWidth(9); + layoutWindowCtrl->addLayout(layoutSize); + } - //Window offset _offset_x->setFixedWidth(_lineEditWidthFixed); _offset_y->setFixedWidth(_lineEditWidthFixed); - _labelOffset = new QLabel(this); - _labelComma = new QLabel(this); - _layoutOffset = new QHBoxLayout(); - _layoutOffset->addWidget(_labelOffset); - _labelOffset->setText("Offset:"); - _labelOffset->setFixedWidth(55); - _layoutOffset->addWidget(_offset_x); - _layoutOffset->addWidget(_labelComma); - _layoutOffset->addWidget(_offset_y); - _layoutOffset->addStretch(1); - _labelComma->setText(","); - _labelComma->setFixedWidth(9); - _layoutWindowCtrl->addLayout(_layoutOffset); - - //Window options - _layoutCheckboxesFull1 = new QHBoxLayout(); - _layoutCheckboxesFull2 = new QVBoxLayout(); - _layoutFullscreenButton = new QHBoxLayout(); - _layoutFullscreenButton->addWidget(_fullscreenButton); - _layoutFullscreenButton->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutFullscreenButton); - _layoutCBoxWindowDecor = new QHBoxLayout(); - _layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); - _layoutCBoxWindowDecor->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxWindowDecor); - _layoutCBoxWebGui= new QHBoxLayout(); - _layoutCBoxWebGui->addWidget(_checkBoxWebGui); - _layoutCBoxWebGui->addStretch(1); - _layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); - _layoutProjectionGroup = new QVBoxLayout(); - _layoutComboProjection = new QHBoxLayout(); - _layoutComboProjection->addWidget(_comboProjection); - _layoutComboProjection->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutComboProjection); - _borderProjectionGroup = new QFrame; - _borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - _borderProjectionGroup->setLayout(_layoutProjectionGroup); - _borderProjectionGroup->setVisible(true); - _layoutCBoxSpoutOutput= new QHBoxLayout(); - _layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); - _layoutCBoxSpoutOutput->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutCBoxSpoutOutput); - _layoutComboQuality = new QHBoxLayout(); - _labelQuality = new QLabel(); - _labelQuality->setText("Quality:"); - _layoutComboQuality->addWidget(_labelQuality); - _layoutComboQuality->addWidget(_comboQuality); - _layoutComboQuality->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutComboQuality); - _layoutFovH = new QHBoxLayout(); - _labelFovH = new QLabel(); - _labelFovH->setText("Horizontal FOV:"); - _layoutFovH->addWidget(_labelFovH); - _layoutFovH->addWidget(_lineFovH); - _layoutFovH->addStretch(1); - _layoutFovV = new QHBoxLayout(); - _labelFovV = new QLabel(); - _labelFovV->setText("Vertical FOV:"); - _layoutFovV->addWidget(_labelFovV); - _layoutFovV->addWidget(_lineFovV); - _layoutFovV->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutFovH); - _layoutProjectionGroup->addLayout(_layoutFovV); - _layoutHeightOffset = new QHBoxLayout(); - _labelHeightOffset = new QLabel(); - _labelHeightOffset->setText("Height Offset:"); - _layoutHeightOffset->addWidget(_labelHeightOffset); - _layoutHeightOffset->addWidget(_lineHeightOffset); - _layoutHeightOffset->addStretch(1); - _layoutProjectionGroup->addLayout(_layoutHeightOffset); - _layoutCheckboxesFull2->addWidget(_borderProjectionGroup); - _layoutCheckboxesFull1->addLayout(_layoutCheckboxesFull2); - _layoutCheckboxesFull1->addStretch(1); - _layoutWindowCtrl->addLayout(_layoutCheckboxesFull1); - _layoutWindowCtrl->addStretch(1); - _layoutFullWindow->addLayout(_layoutWindowCtrl); + { + QLabel* labelOffset = new QLabel(this); + QLabel* labelComma = new QLabel(this); + QHBoxLayout* layoutOffset = new QHBoxLayout(); + layoutOffset->addWidget(labelOffset); + labelOffset->setText("Offset:"); + labelOffset->setFixedWidth(55); + layoutOffset->addWidget(_offset_x); + layoutOffset->addWidget(labelComma); + layoutOffset->addWidget(_offset_y); + layoutOffset->addStretch(1); + labelComma->setText(","); + labelComma->setFixedWidth(9); + layoutWindowCtrl->addLayout(layoutOffset); + } + { + QHBoxLayout* layoutCheckboxesFull1 = new QHBoxLayout(); + QVBoxLayout* layoutCheckboxesFull2 = new QVBoxLayout(); + QHBoxLayout* layoutFullscreenButton = new QHBoxLayout(); + layoutFullscreenButton->addWidget(_fullscreenButton); + layoutFullscreenButton->addStretch(1); + layoutCheckboxesFull2->addLayout(layoutFullscreenButton); + QHBoxLayout* layoutCBoxWindowDecor = new QHBoxLayout(); + layoutCBoxWindowDecor->addWidget(_checkBoxWindowDecor); + layoutCBoxWindowDecor->addStretch(1); + layoutCheckboxesFull2->addLayout(layoutCBoxWindowDecor); + QHBoxLayout* _layoutCBoxWebGui= new QHBoxLayout(); + _layoutCBoxWebGui->addWidget(_checkBoxWebGui); + _layoutCBoxWebGui->addStretch(1); + layoutCheckboxesFull2->addLayout(_layoutCBoxWebGui); + QVBoxLayout* layoutProjectionGroup = new QVBoxLayout(); + QHBoxLayout* layoutComboProjection = new QHBoxLayout(); + layoutComboProjection->addWidget(_comboProjection); + layoutComboProjection->addStretch(1); + layoutProjectionGroup->addLayout(layoutComboProjection); + QFrame* borderProjectionGroup = new QFrame; + borderProjectionGroup->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + borderProjectionGroup->setLayout(layoutProjectionGroup); + borderProjectionGroup->setVisible(true); + QHBoxLayout* layoutCBoxSpoutOutput= new QHBoxLayout(); + layoutCBoxSpoutOutput->addWidget(_checkBoxSpoutOutput); + layoutCBoxSpoutOutput->addStretch(1); + layoutProjectionGroup->addLayout(layoutCBoxSpoutOutput); + QHBoxLayout* layoutComboQuality = new QHBoxLayout(); + _labelQuality = new QLabel(); + _labelQuality->setText("Quality:"); + layoutComboQuality->addWidget(_labelQuality); + layoutComboQuality->addWidget(_comboQuality); + layoutComboQuality->addStretch(1); + layoutProjectionGroup->addLayout(layoutComboQuality); + QHBoxLayout* layoutFovH = new QHBoxLayout(); + _labelFovH = new QLabel(); + _labelFovH->setText("Horizontal FOV:"); + layoutFovH->addWidget(_labelFovH); + layoutFovH->addWidget(_lineFovH); + layoutFovH->addStretch(1); + QHBoxLayout* layoutFovV = new QHBoxLayout(); + _labelFovV = new QLabel(); + _labelFovV->setText("Vertical FOV:"); + layoutFovV->addWidget(_labelFovV); + layoutFovV->addWidget(_lineFovV); + layoutFovV->addStretch(1); + layoutProjectionGroup->addLayout(layoutFovH); + layoutProjectionGroup->addLayout(layoutFovV); + QHBoxLayout* layoutHeightOffset = new QHBoxLayout(); + _labelHeightOffset = new QLabel(); + _labelHeightOffset->setText("Height Offset:"); + layoutHeightOffset->addWidget(_labelHeightOffset); + layoutHeightOffset->addWidget(_lineHeightOffset); + layoutHeightOffset->addStretch(1); + layoutProjectionGroup->addLayout(layoutHeightOffset); + layoutCheckboxesFull2->addWidget(borderProjectionGroup); + layoutCheckboxesFull1->addLayout(layoutCheckboxesFull2); + layoutCheckboxesFull1->addStretch(1); + layoutWindowCtrl->addLayout(layoutCheckboxesFull1); + } + layoutWindowCtrl->addStretch(1); + _layoutFullWindow->addLayout(layoutWindowCtrl); _comboProjection->setCurrentIndex(0); onProjectionChanged(0); @@ -243,14 +289,6 @@ void WindowControl::showWindowLabel(const bool show) { _labelWinNum->setVisible(show); } -void WindowControl::cleanupLayouts() { - int labelSize1 = _labelSize->width(); - int labelSize2 = _labelOffset->width(); - int labelWidthStandard = std::max(labelSize1, labelSize2); - _labelSize->setFixedWidth(labelWidthStandard); - _labelOffset->setFixedWidth(labelWidthStandard); -} - void WindowControl::onSizeXChanged(const QString& newText) { std::string x = newText.toStdString(); if (!x.empty()) { @@ -478,56 +516,6 @@ unsigned int WindowControl::monitorNum() { WindowControl::~WindowControl() { - delete _size_x; - delete _size_y; - delete _validatorSize_x; - delete _validatorSize_y; - delete _offset_x; - delete _offset_y; - delete _validatorOffset_x; - delete _validatorOffset_y; - delete _layoutName; - delete _labelName; - delete _windowName; - delete _labelWinNum; - delete _labelSize; - delete _labelDelim; - delete _layoutSize; - delete _labelOffset; - delete _labelComma; - delete _layoutOffset; - delete _checkBoxWindowDecor; - delete _checkBoxWebGui; - delete _checkBoxSpoutOutput; - delete _comboProjection; - delete _comboQuality; - delete _fullscreenButton; - delete _labelFovH; - delete _lineFovH; - delete _validatorFovH; - delete _labelFovV; - delete _lineFovV; - delete _validatorFovV; - delete _labelHeightOffset; - delete _lineHeightOffset; - delete _validatorHeightOffset; - delete _labelQuality; - delete _layoutFullscreenButton; - delete _layoutCBoxWindowDecor; - delete _layoutCBoxWebGui; - delete _layoutCBoxSpoutOutput; - delete _layoutComboProjection; - delete _layoutComboQuality; - delete _layoutFovH; - delete _layoutFovV; - delete _layoutHeightOffset; - delete _layoutProjectionGroup; - delete _borderProjectionGroup; - delete _layoutCheckboxesFull2; - delete _layoutCheckboxesFull1; - delete _layoutMonitorNum; - delete _layoutWinNum; - delete _layoutWindowCtrl; delete _layoutFullWindow; }