void DlgPreferences::addPageWidget(DlgPreferencePage* pWidget) { connect(this, SIGNAL(showDlg()), pWidget, SLOT(slotShow())); connect(this, SIGNAL(closeDlg()), pWidget, SLOT(slotHide())); connect(this, SIGNAL(showDlg()), pWidget, SLOT(slotUpdate())); connect(this, SIGNAL(applyPreferences()), pWidget, SLOT(slotApply())); connect(this, SIGNAL(cancelPreferences()), pWidget, SLOT(slotCancel())); connect(this, SIGNAL(resetToDefaults()), pWidget, SLOT(slotResetToDefaults())); QScrollArea* sa = new QScrollArea(pagesWidget); sa->setWidgetResizable(true); sa->setWidget(pWidget); pagesWidget->addWidget(sa); int iframe = 2 * sa->frameWidth(); m_pageSizeHint = m_pageSizeHint.expandedTo( pWidget->sizeHint()+QSize(iframe, iframe)); }
void DlgPreferences::slotButtonPressed(QAbstractButton* pButton) { QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(pButton); DlgPreferencePage* pCurrentPage = currentPage(); switch (role) { case QDialogButtonBox::ResetRole: // Only reset to defaults on the current page. if (pCurrentPage != NULL) { pCurrentPage->slotResetToDefaults(); } break; case QDialogButtonBox::ApplyRole: // Only apply settings on the current page. if (pCurrentPage != NULL) { pCurrentPage->slotApply(); } break; case QDialogButtonBox::AcceptRole: emit(applyPreferences()); accept(); break; case QDialogButtonBox::RejectRole: emit(cancelPreferences()); reject(); break; default: break; } }
DlgPrefAutoDJ::DlgPrefAutoDJ(QWidget* pParent, ConfigObject<ConfigValue>* pConfig) : DlgPreferencePage(pParent), m_pConfig(pConfig) { setupUi(this); // Re-queue tracks in Auto DJ ComboBoxAutoDjRequeue->addItem(tr("Off")); ComboBoxAutoDjRequeue->addItem(tr("On")); ComboBoxAutoDjRequeue->setCurrentIndex(m_pConfig->getValueString(ConfigKey("[Auto DJ]", "Requeue")).toInt()); connect(ComboBoxAutoDjRequeue, SIGNAL(activated(int)), this, SLOT(slotSetAutoDjRequeue(int))); #ifdef __AUTODJCRATES__ // The minimum available for randomly-selected tracks autoDjMinimumAvailableSpinBox->setValue( m_pConfig->getValueString( ConfigKey("[Auto DJ]", "MinimumAvailable"), "20").toInt()); connect(autoDjMinimumAvailableSpinBox, SIGNAL(valueChanged(int)), this, SLOT(slotSetAutoDjMinimumAvailable(int))); // The auto-DJ replay-age for randomly-selected tracks autoDjIgnoreTimeCheckBox->setChecked( (bool) m_pConfig->getValueString( ConfigKey("[Auto DJ]", "UseIgnoreTime"), "0").toInt()); connect(autoDjIgnoreTimeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotSetAutoDjUseIgnoreTime(int))); autoDjIgnoreTimeEdit->setTime( QTime::fromString( m_pConfig->getValueString( ConfigKey("[Auto DJ]", "IgnoreTime"), "23:59"), autoDjIgnoreTimeEdit->displayFormat())); autoDjIgnoreTimeEdit->setEnabled( autoDjIgnoreTimeCheckBox->checkState() == Qt::Checked); connect(autoDjIgnoreTimeEdit, SIGNAL(timeChanged(const QTime &)), this, SLOT(slotSetAutoDjIgnoreTime(const QTime &))); // Auto DJ random enqueue ComboBoxAutoDjRandomQueue->addItem(tr("Off")); ComboBoxAutoDjRandomQueue->addItem(tr("On")); ComboBoxAutoDjRandomQueue->setCurrentIndex( m_pConfig->getValueString( ConfigKey("[Auto DJ]", "EnableRandomQueue"),"0").toInt()); // 5-arbitrary autoDJRandomQueueMinimumSpinBox->setValue( m_pConfig->getValueString( ConfigKey("[Auto DJ]", "RandomQueueMinimumAllowed"),"5").toInt()); slotEnableAutoDJRandomQueueComboBox( m_pConfig->getValueString(ConfigKey("[Auto DJ]", "Requeue")).toInt()); slotEnableAutoDJRandomQueue( m_pConfig->getValueString( ConfigKey("[Auto DJ]", "EnableRandomQueue")).toInt()); // Be ready to enable disable the random enque as reque is modified connect(ComboBoxAutoDjRequeue, SIGNAL(activated(int)), this, SLOT(slotEnableAutoDJRandomQueueComboBox(int))); // Be ready to enable and modify the minimum number and enable disable the spinbox connect(ComboBoxAutoDjRandomQueue, SIGNAL(activated(int)), this, SLOT(slotEnableAutoDJRandomQueue(int))); connect(autoDJRandomQueueMinimumSpinBox, SIGNAL(valueChanged(int)), this, SLOT(slotSetAutoDJRandomQueueMin(int))); #else // __AUTODJCRATES__ // Remove the preferences. autoDjMinimumAvailableLabel->setVisible(false); GridLayout1->removeWidget(autoDjMinimumAvailableLabel); autoDjMinimumAvailableSpinBox->setVisible(false); GridLayout1->removeWidget(autoDjMinimumAvailableSpinBox); autoDjIgnoreTimeCheckBox->setVisible(false); GridLayout1->removeWidget(autoDjIgnoreTimeCheckBox); autoDjIgnoreTimeEdit->setVisible(false); GridLayout1->removeWidget(autoDjIgnoreTimeEdit); #endif // __AUTODJCRATES__ // Connect the global cancell signal connect(this,SIGNAL(cancelPreferences()),this, SLOT(slotCancel())); }