![]() |
Mixxx
|
00001 /*************************************************************************** 00002 dlgprefvinyl.cpp - description 00003 ------------------- 00004 begin : Thu Oct 23 2006 00005 copyright : (C) 2006 by Stefan Langhammer 00006 (C) 2007 by Albert Santoni 00007 email : stefan.langhammer@9elements.com 00008 gamegod \a\t users.sf.net 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 ***************************************************************************/ 00019 00020 00021 #include <QtCore> 00022 #include <QtDebug> 00023 #include <QtGui> 00024 #include "dlgprefvinyl.h" 00025 #include "controlobject.h" 00026 #include "vinylcontrol/vinylcontrolmanager.h" 00027 #include "vinylcontrol/vinylcontrol.h" //For vinyl type string constants 00028 #include "controlobjectthreadmain.h" 00029 #include "dlgprefvinyl.h" 00030 00031 DlgPrefVinyl::DlgPrefVinyl(QWidget * parent, VinylControlManager *pVCMan, 00032 ConfigObject<ConfigValue> * _config) : QWidget(parent), Ui::DlgPrefVinylDlg(), 00033 m_COMode(ControlObject::getControl(ConfigKey("[VinylControl]", "mode"))), 00034 m_COSpeed1(ControlObject::getControl(ConfigKey("[Channel1]", "vinylcontrol_speed_type"))), 00035 m_COSpeed2(ControlObject::getControl(ConfigKey("[Channel2]", "vinylcontrol_speed_type"))) 00036 { 00037 m_pVCManager = pVCMan; 00038 config = _config; 00039 00040 setupUi(this); 00041 00042 //Set up a button group for the vinyl control behaviour options 00043 QButtonGroup vinylControlMode; 00044 vinylControlMode.addButton(AbsoluteMode); 00045 vinylControlMode.addButton(RelativeMode); 00046 00047 m_signalWidget1.setSize(MIXXX_VINYL_SCOPE_SIZE); 00048 m_signalWidget2.setSize(MIXXX_VINYL_SCOPE_SIZE); 00049 00050 delete groupBoxSignalQuality->layout(); 00051 QHBoxLayout *layout = new QHBoxLayout; 00052 layout->layout()->addWidget(&m_signalWidget1); 00053 layout->layout()->addWidget(&m_signalWidget2); 00054 groupBoxSignalQuality->setLayout(layout); 00055 00056 // Add vinyl types 00057 ComboBoxVinylType1->addItem(MIXXX_VINYL_SERATOCV02VINYLSIDEA); 00058 ComboBoxVinylType1->addItem(MIXXX_VINYL_SERATOCV02VINYLSIDEB); 00059 ComboBoxVinylType1->addItem(MIXXX_VINYL_SERATOCD); 00060 ComboBoxVinylType1->addItem(MIXXX_VINYL_TRAKTORSCRATCHSIDEA); 00061 ComboBoxVinylType1->addItem(MIXXX_VINYL_TRAKTORSCRATCHSIDEB); 00062 00063 ComboBoxVinylType2->addItem(MIXXX_VINYL_SERATOCV02VINYLSIDEA); 00064 ComboBoxVinylType2->addItem(MIXXX_VINYL_SERATOCV02VINYLSIDEB); 00065 ComboBoxVinylType2->addItem(MIXXX_VINYL_SERATOCD); 00066 ComboBoxVinylType2->addItem(MIXXX_VINYL_TRAKTORSCRATCHSIDEA); 00067 ComboBoxVinylType2->addItem(MIXXX_VINYL_TRAKTORSCRATCHSIDEB); 00068 00069 ComboBoxVinylSpeed1->addItem(MIXXX_VINYL_SPEED_33); 00070 ComboBoxVinylSpeed1->addItem(MIXXX_VINYL_SPEED_45); 00071 00072 ComboBoxVinylSpeed2->addItem(MIXXX_VINYL_SPEED_33); 00073 ComboBoxVinylSpeed2->addItem(MIXXX_VINYL_SPEED_45); 00074 00075 connect(applyButton, SIGNAL(clicked()), this, SLOT(slotApply())); 00076 connect(VinylGain, SIGNAL(sliderReleased()), this, SLOT(VinylGainSlotApply())); 00077 //connect(ComboBoxDeviceDeck1, SIGNAL(currentIndexChanged()), this, SLOT(())); 00078 } 00079 00080 DlgPrefVinyl::~DlgPrefVinyl() 00081 { 00082 } 00083 00085 void DlgPrefVinyl::slotShow() 00086 { 00087 QList<VinylControlProxy*> VCProxiesList = m_pVCManager->vinylControlProxies(); 00088 if (VCProxiesList.value(0) != NULL) 00089 m_signalWidget1.setVinylControlProxy(VCProxiesList.value(0)); 00090 if (VCProxiesList.value(1) != NULL) 00091 m_signalWidget2.setVinylControlProxy(VCProxiesList.value(1)); 00092 00093 //(Re)Initialize the signal quality indicators 00094 m_signalWidget1.resetWidget(); 00095 m_signalWidget1.startDrawing(); 00096 m_signalWidget2.resetWidget(); 00097 m_signalWidget2.startDrawing(); 00098 00099 } 00100 00102 void DlgPrefVinyl::slotClose() 00103 { 00104 //Stop updating the vinyl control signal indicators when the prefs dialog is closed. 00105 m_signalWidget1.stopDrawing(); 00106 m_signalWidget2.stopDrawing(); 00107 } 00108 00109 void DlgPrefVinyl::slotUpdate() 00110 { 00111 // Set vinyl control types in the comboboxes 00112 int combo_index = ComboBoxVinylType1->findText(config->getValueString(ConfigKey("[Channel1]","vinylcontrol_vinyl_type"))); 00113 if (combo_index != -1) 00114 ComboBoxVinylType1->setCurrentIndex(combo_index); 00115 00116 combo_index = ComboBoxVinylType2->findText(config->getValueString(ConfigKey("[Channel2]","vinylcontrol_vinyl_type"))); 00117 if (combo_index != -1) 00118 ComboBoxVinylType2->setCurrentIndex(combo_index); 00119 00120 combo_index = ComboBoxVinylSpeed1->findText(config->getValueString(ConfigKey("[Channel1]","vinylcontrol_speed_type"))); 00121 if (combo_index != -1) 00122 ComboBoxVinylSpeed1->setCurrentIndex(combo_index); 00123 00124 combo_index = ComboBoxVinylSpeed2->findText(config->getValueString(ConfigKey("[Channel2]","vinylcontrol_speed_type"))); 00125 if (combo_index != -1) 00126 ComboBoxVinylSpeed2->setCurrentIndex(combo_index); 00127 00128 // set lead-in time 00129 LeadinTime->setText (config->getValueString(ConfigKey("[VinylControl]","lead_in_time")) ); 00130 00131 // set Relative mode 00132 int iMode = config->getValueString(ConfigKey("[VinylControl]","mode")).toInt(); 00133 if (iMode == MIXXX_VCMODE_ABSOLUTE) 00134 AbsoluteMode->setChecked(true); 00135 else if (iMode == MIXXX_VCMODE_RELATIVE) 00136 RelativeMode->setChecked(true); 00137 00138 // Honour the Needle Skip Prevention setting. 00139 NeedleSkipEnable->setChecked( (bool)config->getValueString( ConfigKey("[VinylControl]", "needle_skip_prevention") ).toInt() ); 00140 00141 SignalQualityEnable->setChecked((bool)config->getValueString(ConfigKey("[VinylControl]", "show_signal_quality") ).toInt() ); 00142 00143 //set vinyl control gain 00144 VinylGain->setValue( config->getValueString(ConfigKey("[VinylControl]","gain")).toInt()); 00145 00146 QList<VinylControlProxy*> VCProxiesList = m_pVCManager->vinylControlProxies(); 00147 if (VCProxiesList.value(0) != NULL) { 00148 m_signalWidget1.setVinylControlProxy(VCProxiesList.value(0)); 00149 } 00150 if (VCProxiesList.value(1) != NULL) { 00151 m_signalWidget2.setVinylControlProxy(VCProxiesList.value(1)); 00152 } 00153 00154 m_signalWidget1.setVinylActive(m_pVCManager->vinylInputEnabled(1)); 00155 m_signalWidget2.setVinylActive(m_pVCManager->vinylInputEnabled(2)); 00156 } 00157 00158 // Update the config object with parameters from dialog 00159 void DlgPrefVinyl::slotApply() 00160 { 00161 qDebug() << "DlgPrefVinyl::Apply"; 00162 00163 // Lead-in time 00164 QString strLeadIn = LeadinTime->text(); 00165 bool isInteger; 00166 strLeadIn.toInt(&isInteger); 00167 if (isInteger) 00168 config->set(ConfigKey("[VinylControl]","lead_in_time"), strLeadIn); 00169 else 00170 config->set(ConfigKey("[VinylControl]","lead_in_time"), MIXXX_VC_DEFAULT_LEADINTIME); 00171 00172 //Apply updates for everything else... 00173 VinylTypeSlotApply(); 00174 VinylGainSlotApply(); 00175 00176 int iMode = 0; 00177 if (AbsoluteMode->isChecked()) 00178 iMode = MIXXX_VCMODE_ABSOLUTE; 00179 if (RelativeMode->isChecked()) 00180 iMode = MIXXX_VCMODE_RELATIVE; 00181 00182 ControlObject::getControl(ConfigKey("[Channel1]", "vinylcontrol_mode"))->set(iMode); 00183 ControlObject::getControl(ConfigKey("[Channel2]", "vinylcontrol_mode"))->set(iMode); 00184 m_COMode.slotSet(iMode); 00185 config->set(ConfigKey("[VinylControl]","mode"), ConfigValue(iMode)); 00186 config->set(ConfigKey("[VinylControl]","needle_skip_prevention" ), ConfigValue( (int)(NeedleSkipEnable->isChecked( )) ) ); 00187 config->set(ConfigKey("[VinylControl]","show_signal_quality" ), ConfigValue( (int)(SignalQualityEnable->isChecked( )) ) ); 00188 00189 m_pVCManager->reloadConfig(); 00190 slotUpdate(); 00191 } 00192 00193 void DlgPrefVinyl::EnableRelativeModeSlotApply() 00194 { 00195 00196 } 00197 00198 void DlgPrefVinyl::VinylTypeSlotApply() 00199 { 00200 config->set(ConfigKey("[Channel1]","vinylcontrol_vinyl_type"), ConfigValue(ComboBoxVinylType1->currentText())); 00201 config->set(ConfigKey("[Channel2]","vinylcontrol_vinyl_type"), ConfigValue(ComboBoxVinylType2->currentText())); 00202 config->set(ConfigKey("[Channel1]","vinylcontrol_speed_type"), ConfigValue(ComboBoxVinylSpeed1->currentText())); 00203 config->set(ConfigKey("[Channel2]","vinylcontrol_speed_type"), ConfigValue(ComboBoxVinylSpeed2->currentText())); 00204 00205 //Save the vinylcontrol_speed_type in ControlObjects as well so it can be retrieved quickly 00206 //on the fly. (eg. WSpinny needs to know how fast to spin) 00207 if (ComboBoxVinylSpeed1->currentText() == MIXXX_VINYL_SPEED_33) { 00208 m_COSpeed1.slotSet(MIXXX_VINYL_SPEED_33_NUM); 00209 } else if (ComboBoxVinylSpeed1->currentText() == MIXXX_VINYL_SPEED_45) { 00210 m_COSpeed1.slotSet(MIXXX_VINYL_SPEED_45_NUM); 00211 } 00212 if (ComboBoxVinylSpeed2->currentText() == MIXXX_VINYL_SPEED_33) { 00213 m_COSpeed2.slotSet(MIXXX_VINYL_SPEED_33_NUM); 00214 } else if (ComboBoxVinylSpeed2->currentText() == MIXXX_VINYL_SPEED_45) { 00215 m_COSpeed2.slotSet(MIXXX_VINYL_SPEED_45_NUM); 00216 } 00217 } 00218 00219 void DlgPrefVinyl::VinylGainSlotApply() 00220 { 00221 qDebug() << "in VinylGainSlotApply()" << "with gain:" << VinylGain->value(); 00222 //Update the config key... 00223 config->set(ConfigKey("[VinylControl]","gain"), ConfigValue(VinylGain->value())); 00224 00225 //Update the ControlObject... 00226 ControlObject* pControlObjectVinylControlGain = ControlObject::getControl(ConfigKey("[VinylControl]", "gain")); 00227 pControlObjectVinylControlGain->set(VinylGain->value()); 00228 }