35 |
void qsamplerDeviceForm::init (void) |
void qsamplerDeviceForm::init (void) |
36 |
{ |
{ |
37 |
// Initialize locals. |
// Initialize locals. |
|
m_pMainForm = NULL; |
|
|
m_pClient = NULL; |
|
38 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
39 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
40 |
m_bNewDevice = false; |
m_bNewDevice = false; |
66 |
// Notify our parent that we're emerging. |
// Notify our parent that we're emerging. |
67 |
void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent ) |
void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent ) |
68 |
{ |
{ |
69 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
70 |
m_pMainForm->stabilizeForm(); |
if (pMainForm) |
71 |
|
pMainForm->stabilizeForm(); |
72 |
|
|
73 |
stabilizeForm(); |
stabilizeForm(); |
74 |
|
|
81 |
{ |
{ |
82 |
QWidget::hideEvent(pHideEvent); |
QWidget::hideEvent(pHideEvent); |
83 |
|
|
84 |
if (m_pMainForm) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
85 |
m_pMainForm->stabilizeForm(); |
if (pMainForm) |
86 |
|
pMainForm->stabilizeForm(); |
87 |
|
|
88 |
// Signal special whether we changed the device set. |
// Signal special whether we changed the device set. |
89 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
93 |
} |
} |
94 |
|
|
95 |
|
|
|
// Application main form settler (life depends on it). |
|
|
void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm ) |
|
|
{ |
|
|
m_pMainForm = pMainForm; |
|
|
} |
|
|
|
|
|
|
|
96 |
// Set device type spacial exclusive mode. |
// Set device type spacial exclusive mode. |
97 |
void qsamplerDeviceForm::setDeviceTypeMode ( |
void qsamplerDeviceForm::setDeviceTypeMode ( |
98 |
qsamplerDevice::qsamplerDeviceType deviceTypeMode ) |
qsamplerDevice::qsamplerDeviceType deviceTypeMode ) |
108 |
} |
} |
109 |
|
|
110 |
|
|
|
// Device configuration dialog setup formal initializer. |
|
|
void qsamplerDeviceForm::setClient ( lscp_client_t *pClient ) |
|
|
{ |
|
|
// If it has not changed, do nothing. |
|
|
if (m_pClient && m_pClient == pClient) |
|
|
return; |
|
|
|
|
|
// Set new reference. |
|
|
m_pClient = pClient; |
|
|
|
|
|
// OK. Do a whole refresh around. |
|
|
refreshDevices(); |
|
|
} |
|
|
|
|
|
|
|
111 |
// Device driver name setup formal initializer. |
// Device driver name setup formal initializer. |
112 |
void qsamplerDeviceForm::setDriverName ( const QString& sDriverName ) |
void qsamplerDeviceForm::setDriverName ( const QString& sDriverName ) |
113 |
{ |
{ |
168 |
// Create a new device from current table view. |
// Create a new device from current table view. |
169 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::createDevice (void) |
170 |
{ |
{ |
171 |
if (m_pMainForm == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
172 |
|
if (pMainForm == NULL) |
173 |
return; |
return; |
174 |
|
|
175 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
193 |
} |
} |
194 |
// Append the new device item. |
// Append the new device item. |
195 |
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
196 |
m_pMainForm, device.deviceType(), device.deviceID()); |
device.deviceType(), device.deviceID()); |
197 |
// Just make it the new selection... |
// Just make it the new selection... |
198 |
DeviceListView->setSelected(pDeviceItem, true); |
DeviceListView->setSelected(pDeviceItem, true); |
199 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
200 |
m_pMainForm->sessionDirty(); |
pMainForm->sessionDirty(); |
201 |
m_iDirtyCount++; |
m_iDirtyCount++; |
202 |
} |
} |
203 |
} |
} |
206 |
// Delete current device in table view. |
// Delete current device in table view. |
207 |
void qsamplerDeviceForm::deleteDevice (void) |
void qsamplerDeviceForm::deleteDevice (void) |
208 |
{ |
{ |
209 |
if (m_pMainForm == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
210 |
|
if (pMainForm == NULL) |
211 |
return; |
return; |
212 |
|
|
213 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
217 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
218 |
|
|
219 |
// Prompt user if this is for real... |
// Prompt user if this is for real... |
220 |
qsamplerOptions *pOptions = m_pMainForm->options(); |
qsamplerOptions *pOptions = pMainForm->options(); |
221 |
if (pOptions && pOptions->bConfirmRemove) { |
if (pOptions && pOptions->bConfirmRemove) { |
222 |
if (QMessageBox::warning(this, |
if (QMessageBox::warning(this, |
223 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
234 |
// Remove it from the device view... |
// Remove it from the device view... |
235 |
delete pItem; |
delete pItem; |
236 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
237 |
m_pMainForm->sessionDirty(); |
pMainForm->sessionDirty(); |
238 |
m_iDirtyCount++; |
m_iDirtyCount++; |
239 |
} |
} |
240 |
} |
} |
243 |
// Refresh all device list and views. |
// Refresh all device list and views. |
244 |
void qsamplerDeviceForm::refreshDevices (void) |
void qsamplerDeviceForm::refreshDevices (void) |
245 |
{ |
{ |
246 |
if (m_pMainForm == NULL) |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
247 |
|
if (pMainForm == NULL) |
248 |
return; |
return; |
249 |
|
|
250 |
// Avoid nested changes. |
// Avoid nested changes. |
256 |
m_pAudioItems = NULL; |
m_pAudioItems = NULL; |
257 |
m_pMidiItems = NULL; |
m_pMidiItems = NULL; |
258 |
DeviceListView->clear(); |
DeviceListView->clear(); |
259 |
if (m_pClient) { |
if (pMainForm->client()) { |
260 |
int *piDeviceIDs; |
int *piDeviceIDs; |
261 |
// Grab and pop Audio devices... |
// Grab and pop Audio devices... |
262 |
if (m_deviceTypeMode == qsamplerDevice::None || |
if (m_deviceTypeMode == qsamplerDevice::None || |
263 |
m_deviceTypeMode == qsamplerDevice::Audio) { |
m_deviceTypeMode == qsamplerDevice::Audio) { |
264 |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
265 |
m_pMainForm, qsamplerDevice::Audio); |
qsamplerDevice::Audio); |
266 |
} |
} |
267 |
if (m_pAudioItems) { |
if (m_pAudioItems) { |
268 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
269 |
|
qsamplerDevice::Audio); |
270 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
271 |
new qsamplerDeviceItem(m_pAudioItems, m_pMainForm, |
new qsamplerDeviceItem(m_pAudioItems, |
272 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
qsamplerDevice::Audio, piDeviceIDs[i]); |
273 |
} |
} |
274 |
m_pAudioItems->setOpen(true); |
m_pAudioItems->setOpen(true); |
277 |
if (m_deviceTypeMode == qsamplerDevice::None || |
if (m_deviceTypeMode == qsamplerDevice::None || |
278 |
m_deviceTypeMode == qsamplerDevice::Midi) { |
m_deviceTypeMode == qsamplerDevice::Midi) { |
279 |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
280 |
m_pMainForm, qsamplerDevice::Midi); |
qsamplerDevice::Midi); |
281 |
} |
} |
282 |
if (m_pMidiItems) { |
if (m_pMidiItems) { |
283 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(), |
284 |
|
qsamplerDevice::Midi); |
285 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
286 |
new qsamplerDeviceItem(m_pMidiItems, m_pMainForm, |
new qsamplerDeviceItem(m_pMidiItems, |
287 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
qsamplerDevice::Midi, piDeviceIDs[i]); |
288 |
} |
} |
289 |
m_pMidiItems->setOpen(true); |
m_pMidiItems->setOpen(true); |
329 |
// Device selection slot. |
// Device selection slot. |
330 |
void qsamplerDeviceForm::selectDevice (void) |
void qsamplerDeviceForm::selectDevice (void) |
331 |
{ |
{ |
332 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
333 |
|
if (pMainForm == NULL) |
334 |
|
return; |
335 |
|
|
336 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
337 |
return; |
return; |
338 |
|
|
366 |
if (device.deviceType() != m_deviceType) { |
if (device.deviceType() != m_deviceType) { |
367 |
DriverNameComboBox->clear(); |
DriverNameComboBox->clear(); |
368 |
DriverNameComboBox->insertStringList( |
DriverNameComboBox->insertStringList( |
369 |
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType())); |
370 |
m_deviceType = device.deviceType(); |
m_deviceType = device.deviceType(); |
371 |
} |
} |
372 |
// Do we need a driver name? |
// Do we need a driver name? |
455 |
// Device parameter value change slot. |
// Device parameter value change slot. |
456 |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
457 |
{ |
{ |
|
if (m_pMainForm == NULL) |
|
|
return; |
|
458 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
459 |
return; |
return; |
460 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
479 |
} else { |
} else { |
480 |
stabilizeForm(); |
stabilizeForm(); |
481 |
} |
} |
482 |
|
|
483 |
// Main session should be dirtier... |
// Main session should be dirtier... |
484 |
m_pMainForm->sessionDirty(); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
485 |
|
if (pMainForm) |
486 |
|
pMainForm->sessionDirty(); |
487 |
} |
} |
488 |
|
|
489 |
|
|
490 |
// Device port/channel parameter value change slot. |
// Device port/channel parameter value change slot. |
491 |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
492 |
{ |
{ |
|
if (m_pMainForm == NULL) |
|
|
return; |
|
493 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
494 |
return; |
return; |
495 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
517 |
pPort->setParam(sParam, sValue); |
pPort->setParam(sParam, sValue); |
518 |
// Done. |
// Done. |
519 |
stabilizeForm(); |
stabilizeForm(); |
520 |
|
|
521 |
// Main session should be dirtier... |
// Main session should be dirtier... |
522 |
m_pMainForm->sessionDirty(); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
523 |
|
if (pMainForm) |
524 |
|
pMainForm->sessionDirty(); |
525 |
} |
} |
526 |
|
|
527 |
|
|
528 |
// Device list view context menu handler. |
// Device list view context menu handler. |
529 |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
530 |
{ |
{ |
531 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
532 |
|
if (pMainForm == NULL) |
533 |
|
return; |
534 |
|
|
535 |
int iItemID; |
int iItemID; |
536 |
|
|
537 |
// Build the device context menu... |
// Build the device context menu... |
538 |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
539 |
|
|
540 |
bool bClient = (m_pClient != NULL); |
bool bClient = (pMainForm->client() != NULL); |
541 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
542 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
543 |
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
562 |
// Stabilize current form state. |
// Stabilize current form state. |
563 |
void qsamplerDeviceForm::stabilizeForm (void) |
void qsamplerDeviceForm::stabilizeForm (void) |
564 |
{ |
{ |
565 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
566 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
567 |
bool bClient = (m_pClient != NULL); |
bool bClient = (pMainForm && pMainForm->client() != NULL); |
568 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
569 |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
570 |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |