void Tuning::setup() { this->setFocusPolicy(Qt::TabFocus); this->installEventFilter(this->parent()); layout_ = new TuningLayout(this); setLayout(layout_); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); /// Setup title bar titleBar_.reset(new TitleBar("Projector", this)); connect(titleBar_.get(), SIGNAL( closeButtonClicked()), this, SLOT(prepareRemove())); connect(titleBar_.get(), SIGNAL(colorChanged( QColor const &)), this, SLOT(updateParameters())); connect(titleBar_.get(), SIGNAL( freeSetupSelected()), this, SLOT( resetToFreeSetup())); connect(titleBar_.get(), SIGNAL( peripheralSetupSelected()), this, SLOT(resetToPeripheralSetup())); layout_->addWidget(titleBar_.get(), TuningLayout::Role::TITLE); /// Setup preview window glView_.reset(new TuningGLView(this)); QSizePolicy _sizePolicy(QSizePolicy::Ignored, QSizePolicy::Expanding); glView_->setSizePolicy(_sizePolicy); glView_->setKeepAspectRatio(true); glView_->setBorder(0.0); glView_->setViewOnly(true); glView_->setUpdateFrequency(10.0); // 10.0 fps glView_->installEventFilter(this); connect(glView_.get(), SIGNAL(dataModelChanged()), this, SIGNAL(dataModelChanged())); layout_->addWidget(glView_.get(), TuningLayout::Role::PREVIEW); /// FOV view slider /// @todo Connect this with threshold slider auto *_fov = addWidget("FOV", 60.0, 10.0, 160.0); _fov->setSingleStep(1.0); _fov->setPageStep(5.0); _fov->setSuffix("°"); connect(_fov, SIGNAL(valueChanged()), this, SLOT(setFov())); auto *_keystone = addWidget("Keystone", 0.0, -1.0, 2.0); _keystone->setSingleStep(0.01); _keystone->setPageStep(0.1); connect(_keystone, SIGNAL(valueChanged()), this, SLOT(setKeyStone())); /// Throw ratio slider /// @todo Connect this with FOV slider auto *_throwRatio = addWidget("Throw Ratio", 1.0, 0.2, 5.0); _throwRatio->setSingleStep(0.01); _throwRatio->setPageStep(0.05); // _throwRatio->setScale(RangedFloat::Scale::RECIPROCAL); connect(_throwRatio, SIGNAL(valueChanged()), this, SLOT(setThrowRatio())); /// Yaw angle slider (all projector setups) auto && _yaw = addAngleWidget("Yaw", 0.0, 0.0, 360.0); _yaw->setSingleStep(0.1); _yaw->setPageStep(1.0); /// Tower height slider (PeripheralSetup only) auto && _towerHeight = addOffsetWidget("Tower Height", 0.2, -0.5, 1.0); /// Distance slider (PeripheralSetup only) auto && _distance = addOffsetWidget("Distance", 0.4, 0.0, 1.0); /// Shift offset slider (PeripheralSetup only) auto && _shift = addOffsetWidget("Shift", 0.0, -0.2, 0.2); /// X offset slider (FreeSetup only) auto && _x = addOffsetWidget("X", 0.0, -1.0, 1.0); /// Y offset slider (FreeSetup only) auto && _y = addOffsetWidget("Y", 0.0, -1.0, 1.0); /// Z offset slider (FreeSetup only) auto && _z = addOffsetWidget("Z", 0.0, -1.0, 1.0); /// Pitch angle slider (both setups) auto && _pitch = addAngleWidget("Pitch", 30.0, -180.0, 180.0); _pitch->setSingleStep(0.1); _pitch->setPageStep(1.0); _pitch->setPivot(0.0); /// Roll angle slider (both setups) auto && _roll = addAngleWidget("Roll", 0.0, -180.0, 180.0); _roll->setSingleStep(0.1); _roll->setPageStep(1.0); _roll->setPivot(0.0); /// Delta yaw angle slider (PeripheralSetup only) auto && _deltaYaw = addAngleWidget("Delta Yaw", 0.0, -45.0, 45.0); _deltaYaw->setSingleStep(0.1); _deltaYaw->setPageStep(1.0); _deltaYaw->setPivot(0.0); widgetgroup_type _titleAndPreview( { { titleBar_.get(), TuningLayout::Role::TITLE }, { glView_.get(), TuningLayout::Role::PREVIEW } }); auto addParameters = [&](widgetgroup_type const& _group, std::vector<QWidget *>const& _widgets) -> widgetgroup_type { widgetgroup_type _result = _group; for (auto& _widget : _widgets) _result.emplace_back(_widget, TuningLayout::Role::PARAMETER); return _result; }; addGroup("Minimized", { { titleBar_.get(), TuningLayout::Role::TITLE } }); /// Make slider groups addGroup("PreviewOnly", _titleAndPreview); addGroup("FOVSliders", addParameters(_titleAndPreview, { _fov, _throwRatio, _keystone })); addGroup("FreeSetup", addParameters(_titleAndPreview, { _yaw, _pitch, _roll, _x, _y, _z, _fov, _throwRatio, _keystone })); addGroup("PeripheralSetup", addParameters(_titleAndPreview, { _yaw, _pitch, _distance, _towerHeight, _shift, _deltaYaw, _roll, _fov, _throwRatio, _keystone })); /// Setup/update mode sessionModeChange(); for (int i = 0; i < layout_->count(); ++i) { auto _widget = layout_->itemAt(i)->widget(); if (!_widget) continue; _widget->installEventFilter(this); _widget->installEventFilter(this->parent()); } }
void TitleBar::setup() { this->label_->setAlignment(Qt::AlignCenter); this->label_->setStyleSheet("QLabel {" " background: transparent; " " color : #0e0e0e; " " font-size : 10pt; " "}"); layout()->removeWidget(this->label_); ///////////////////// Setup buttons auto setupToolButton = [this](QWidgetPtr<QToolButton>& _btn) { _btn.reset(new QToolButton()); _btn->setAutoRaise(true); _btn->setStyleSheet("QToolButton { " " background : transparent; " " border: 0px; " " } " "QToolButton::menu-indicator { image: none; }"); _btn->installEventFilter(this->parent()); _btn->installEventFilter(this); }; setupToolButton(menuButton_); menuButton_->setArrowType(Qt::DownArrow); menu_.reset(new QMenu); /// Generate and add popup menu menuButton_->setMenu(menu_.get()); menuButton_->setPopupMode(QToolButton::InstantPopup); menuButton_->setArrowType(Qt::NoArrow); menuButton_->setIcon(QIcon(":/arrows/212121_90.png")); auto *_changeColor = menu_->addAction("Change color..."); connect(_changeColor, SIGNAL(triggered()), this, SLOT(selectColor())); menu_->addSeparator(); auto *_peripheral = menu_->addAction("Peripheral Setup"); connect(_peripheral, SIGNAL(triggered()), this, SIGNAL(peripheralSetupSelected())); auto *_free = menu_->addAction("Free Setup"); connect(_free, SIGNAL(triggered()), this, SIGNAL(freeSetupSelected())); setupToolButton(displayButton_); displayButton_->setCheckable(true); displayButton_->setChecked(true); displayButton_->setIcon(QIcon(":/icons/eye.png")); connect(displayButton_.get(), SIGNAL(clicked(bool)), tuningWidget(), SLOT(fullscreenToggle(bool))); setupToolButton(maximizeButton_); maximizeButton_->setIcon(QIcon(":/icons/maximize.png")); connect(maximizeButton_.get(), SIGNAL(clicked()), tuningWidget(), SLOT(setNextWindowState())); setupToolButton(closeButton_); closeButton_->setIcon(QIcon(":/icons/close.png")); connect(closeButton_.get(), SIGNAL(clicked()), this, SIGNAL(closeButtonClicked())); ///////////////////// END Setup buttons /// Add widget in this left-to-right order to layout layout()->addWidget(menuButton_.get()); layout()->addWidget(displayButton_.get()); layout()->addWidget(this->label_); layout()->addWidget(maximizeButton_.get()); layout()->addWidget(closeButton_.get()); layout()->setSpacing(0); layout()->setContentsMargins(0, 0, 0, 0); if (tuningWidget_ && tuningWidget_->tuning()) setColor( tuningWidget_->tuning()->color()); }