/*! Create and return the toolbar to use for digital signal generation. */ QToolBar* UiDigitalGenerator::createToolBar() { // Deallocation: // Re-parented when calling verticalLayout->addWidget in the constructor QToolBar* toolBar = new QToolBar("Digital generator settings"); mAddAction = toolBar->addAction("Add"); connect(mAddAction, SIGNAL(triggered()), this, SLOT(addSignal())); mRemoveAction = toolBar->addAction("Remove"); connect(mRemoveAction, SIGNAL(triggered()), this, SLOT(removeSelectedSignals())); mRemoveAction->setEnabled(false); toolBar->addSeparator(); mRate = createRateBox(); // Deallocation: Toolbar takes ownership of label toolBar->addWidget(new QLabel(tr(" Rate "))); toolBar->addWidget(mRate); mStatesBox = createStatesBox(); toolBar->addSeparator(); // Deallocation: Toolbar takes ownership of label toolBar->addWidget(new QLabel(tr(" States "))); toolBar->addWidget(mStatesBox); return toolBar; }
SoundDialog::SoundDialog(MainWindow const &mw, QWidget *const parent) : QDialog(parent) , mw_(mw) , engineSelector_("sound/engineIndex", createEngineBox(mw, this)) , resamplerSelector_("sound/resamplerNum", createResamplerBox(mw, this)) , rateBox_(createRateBox(this)) , latencyBox_(new QSpinBox(this)) , engineWidget_() , rate_(0) , latency_(68) { setWindowTitle(tr("Sound Settings")); QVBoxLayout *const mainLayout = new QVBoxLayout(this); QVBoxLayout *const topLayout = addLayout(mainLayout, new QVBoxLayout); { QHBoxLayout *const hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(tr("Sound engine:"))); hLayout->addWidget(engineSelector_.box()); } { QHBoxLayout *const hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(tr("Resampler:"))); hLayout->addWidget(resamplerSelector_.box()); } { QHBoxLayout *const hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(tr("Sample rate:"))); hLayout->addWidget(rateBox_); } { QHBoxLayout *const hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(tr("Buffer latency:"))); latencyBox_->setRange(8, 999); latencyBox_->setSuffix(" ms"); hLayout->addWidget(latencyBox_); } { QHBoxLayout *const hLayout = addLayout(mainLayout, new QHBoxLayout, Qt::AlignBottom | Qt::AlignRight); QPushButton *const okButton = addWidget(hLayout, new QPushButton(tr("OK"))); QPushButton *const cancelButton = addWidget(hLayout, new QPushButton(tr("Cancel"))); okButton->setDefault(true); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); } QSettings settings; setRate(rateBox_, settings.value("sound/rate", rateBox_->itemData(rateBox_->currentIndex())).toInt()); rate_ = rateBox_->itemData(rateBox_->currentIndex()).toInt(); latency_ = filterValue(settings.value("sound/latency", latency_).toInt(), latencyBox_->maximum() + 1, latencyBox_->minimum(), latency_); latencyBox_->setValue(latency_); engineChange(engineSelector_.index()); connect(engineSelector_.box(), SIGNAL(currentIndexChanged(int)), this, SLOT(engineChange(int))); connect(rateBox_, SIGNAL(currentIndexChanged(int)), this, SLOT(rateIndexChange(int))); }