#include "rm_design_dialog.h" #if (DESIGN_LAYOUT_MODE) #include "../rm_include.h" #include "../ui/window_main.h" #include #include #include #include #include #include #include #include #include #include #include FMDesignDialog* FMDesignDialog::instance(QWidget* parent) { static FMDesignDialog * _instance = NULL; if ( _instance == NULL ) { _instance = new FMDesignDialog(parent); } return _instance; } FMDesignDialog::FMDesignDialog(QWidget *parent) : QDialog(parent) { QString version; version.sprintf("model:%s %d.%d.%d.%d",WINDOW_TITLE,RM_MODEL_VERSION_0,RM_MODEL_VERSION_1,RM_MODEL_VERSION_1,RM_MODEL_SVN_VERSION); this->setWindowModality(Qt::NonModal); this->setWindowTitle("DESIGN (" + version + ")"); this->setWindowFlags(Qt::Window | Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint); this->setWindowModality(Qt::NonModal); setMinimumSize(300,500); _layout = new QVBoxLayout(this); _layout->setAlignment(Qt::AlignTop | Qt::AlignLeft); _layout->setMargin(0); _layout->setSpacing(0); //_swap = false; createToolbar(); createSliderPanel(); createParamConsole(); } void FMDesignDialog::showEvent(QShowEvent * event) { Q_UNUSED(event) QRect r = RMApp::instance()->pMainWindow->geometry(); r.moveLeft(1480); r.moveTop(190); setGeometry(r.right(),r.top(),300,500); //loadPreset(); } void FMDesignDialog::createToolbar() { _toolbar = new QWidget(this); _toolbar->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); _toolbar->setFixedHeight(36); _layout->addWidget(_toolbar); _toolbar->setStyleSheet("background-color: #818181;"); //_toolbar->setObjectName("test_widget"); QHBoxLayout* toolLayout = new QHBoxLayout(_toolbar); toolLayout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); toolLayout->setSpacing(6); toolLayout->setMargin(2); _resetButton = _button(_toolbar,toolLayout,"RESET"); _button(_toolbar,toolLayout,"VR"); _button(_toolbar,toolLayout,"WIDE"); _button(_toolbar,toolLayout,"GET"); _button(_toolbar,toolLayout,"SET"); _button(_toolbar,toolLayout,"SWAP"); } void FMDesignDialog::createSliderPanel() { QWidget* info = new QWidget(this); info->setStyleSheet("background-color: #616161;"); //info->setObjectName("test_widget"); info->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); //info->setFixedHeight(48); _layout->addWidget(info); //info->setStyleSheet("background-color: #000000;"); QVBoxLayout* infoLayout = new QVBoxLayout(info); infoLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop); infoLayout->setSpacing(2); infoLayout->setMargin(2); _labels = new QList(); _sliders = new QList(); _resetButtons = new QList(); _slider(info,infoLayout,"ALPHA"); } void FMDesignDialog::createParamConsole() { _paramTextEdit = new QPlainTextEdit(this); //_paramTextEdit->setReadOnly(true); _paramTextEdit->setStyleSheet("font-family: Fixedsys;color : #00FF00;background-color: #111111;border:1px;border-style:solid;border-color:#313131;"); _paramTextEdit->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); _layout->addWidget(_paramTextEdit); QString scrollStyle = "QScrollBar:vertical\ {\ border-width: 0px;\ border-style: solid;\ background: #3B3B3B;\ width: 10px;\ margin: 21px 0 21px 0;\ }\ QScrollBar::handle:vertical:disabled{background: #3B3B3B;}\ QScrollBar::handle:vertical\ {\ border-width: 0px;\ background: #6A74FF;\ min-height: 25px;\ }\ QScrollBar::add-line:vertical\ {\ border: none;\ background: none;\ height: 20px;\ width: 15px;\ subcontrol-position: bottom;\ subcontrol-origin: margin;\ }\ QScrollBar::sub-line:vertical\ {\ border: none;\ background: none;\ height: 20px;\ width: 15px;\ subcontrol-position: top;\ subcontrol-origin: margin;\ }\ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical\ {\ background: none;\ }\ QScrollBar::up-arrow:vertical\ {\ border: none;\ background: #5A5A5A;\ }\ QScrollBar::down-arrow:vertical\ {\ border: none;\ background: #5A5A5A;\ }"; _paramTextEdit->verticalScrollBar()->setStyleSheet(scrollStyle); } QSlider* FMDesignDialog::_slider(QWidget* parent,QLayout* layout, QString title) { QWidget* view = new QWidget(parent); QHBoxLayout* viewLayout = new QHBoxLayout(view); viewLayout->setAlignment(Qt::AlignCenter); layout->addWidget(view); QLabel* tl = new QLabel(view); tl->setText(title); tl->setStyleSheet("font-family: Fixedsys;color : #F0F0F0;"); viewLayout->addWidget(tl); QSlider* slider = new QSlider(view); slider->setOrientation(Qt::Horizontal); slider->setMinimum(0); slider->setMaximum(100); slider->setValue(100); slider->setWindowTitle(title); connect(slider,SIGNAL(valueChanged(int)),SLOT(onSliderChange(int))); _sliders->append(slider); viewLayout->addWidget(slider); QLabel* label = new QLabel(view); label->setText("0.500"); label->setStyleSheet("font-family: Fixedsys;color : #F0F0F0;"); _labels->append(label); viewLayout->addWidget(label); QPushButton* reset = _button(view,viewLayout,"RS"); _resetButtons->append(reset); return slider; } QPushButton* FMDesignDialog::_button(QWidget* parent,QLayout* layout,QString title) { QPushButton* btn = new QPushButton(parent); btn->setText(title); btn->setStyleSheet("QPushButton{font-family: Fixedsys;color : white;}" "QPushButton[enabled=\"false\"]{color : #AAAAAA;}"); btn->setFixedWidth(title.length() * 10); layout->addWidget(btn); connect(btn,SIGNAL(clicked()),SLOT(onButton())); return btn; } void FMDesignDialog::onSliderChange(int value) { QSlider* slider = qobject_cast(sender()); int index = _sliders->indexOf(slider); QLabel* label = _labels->at(index); QString str; double v = ((double)value)/((double)100.0); label->setText(str.sprintf("%.3f",v)); QString key = slider->windowTitle(); if(key == "ALPHA") { WindowMain::instance()->alpha->setOpacity(v); } } void FMDesignDialog::onButton() { QPushButton* btn = qobject_cast(sender()); QString cmd = btn->text().toUpper(); //FAV::OpenGLVideo* opengl = (FAV::OpenGLVideo*)gl(); if(cmd == "RESET") { for(int i=0;i<_sliders->count();i++) { _sliders->at(i)->setValue(0); } } else if (cmd == "RS") { int index = _resetButtons->indexOf(btn); _sliders->at(index)->setValue(0); } } #endif // DESIGN_LAYOUT_MODE