QWidget *dSettingWindow::createWidget() { QWidget * widget = new QWidget(); QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(1); layout->setSpacing(5); layout->addWidget( new QLabel("Непрозрачноть окна (заначения от 0 до 100).<br>Прозрачные окна имеют проблемы с прорисовкой!") ); QSpinBox *opacitySpinBox = new QSpinBox; opacitySpinBox->setRange(30, 100); opacitySpinBox->setSingleStep(1); opacitySpinBox->setValue(int(window->windowOpacity()*100)); connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(opacityValueChanged(int))); QSlider *opacitySlider = new QSlider(Qt::Horizontal); opacitySlider->setFocusPolicy(Qt::StrongFocus); opacitySlider->setTickPosition(QSlider::TicksBothSides); opacitySlider->setTickInterval(10); opacitySlider->setSingleStep(1); opacitySlider->setMaximum ( 100 ); opacitySlider->setMinimum ( 30 ); opacitySlider->setValue(opacitySpinBox->value()); connect(opacitySlider, SIGNAL(valueChanged(int)), opacitySpinBox, SLOT(setValue(int))); connect(opacitySpinBox, SIGNAL(valueChanged(int)), opacitySlider, SLOT(setValue(int))); QHBoxLayout *opacityLayout = new QHBoxLayout; opacityLayout->setSpacing(15); opacityLayout->addWidget( opacitySpinBox ); opacityLayout->addWidget( opacitySlider ); layout->addItem( opacityLayout ); layout->addWidget( new QLabel("Изменение рамки окна. Есть возможность использовать стандартное окно,<br> но тогда пропадет эффект \"магнетизма\" окон.") ); QHBoxLayout *skinLayout = new QHBoxLayout; skinLayout->setSpacing(15); skinPushButton = new QPushButton(tr("Load skin")); skinPushButton->setDefault(true); skinPushButton->setIcon(QIcon(tr("pic/open32x32.png"))); connect(skinPushButton, SIGNAL(clicked(bool)), this, SLOT(clickedSkinButton(bool))); skinLayout->addWidget( skinPushButton ); QCheckBox *standartFrameCheckBox = new QCheckBox(tr("Стандартная рамка окна")); connect(standartFrameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int))); skinLayout->addWidget( standartFrameCheckBox ); skinLayout->addStretch ( 1 ); layout->addItem(skinLayout); widget->setLayout(layout); return widget; };
/*! * Creates and returns a new horizontal slider with range from [min] to [max], * value [value] and single step size [step], adds it to [layout] if it is not * NULL, and sets it for no focus. The page step and single step are both set * to 1. */ QSlider *diaSlider(int min, int max, int step, int value, QWidget *parent, QBoxLayout *layout) { QSlider *slider = new QSlider(parent); if (layout) layout->addWidget(slider); slider->setOrientation(Qt::Horizontal); slider->setRange(min, max); slider->setSingleStep(step); slider->setPageStep(step); slider->setValue(value); slider->setFocusPolicy(Qt::NoFocus); return slider; }