24 |
#include <qfiledialog.h> |
#include <qfiledialog.h> |
25 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
26 |
#include <qlistbox.h> |
#include <qlistbox.h> |
27 |
|
#include <qptrlist.h> |
28 |
#include <qpopupmenu.h> |
#include <qpopupmenu.h> |
29 |
|
|
30 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
46 |
|
|
47 |
// This an outsider (from designer), but rather important. |
// This an outsider (from designer), but rather important. |
48 |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
49 |
this, SLOT(changeValue(int,int))); |
this, SLOT(changeDeviceParam(int,int))); |
50 |
|
QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)), |
51 |
|
this, SLOT(changeDevicePortParam(int,int))); |
52 |
|
|
53 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
54 |
adjustSize(); |
adjustSize(); |
55 |
} |
} |
303 |
m_deviceType = qsamplerDevice::None; |
m_deviceType = qsamplerDevice::None; |
304 |
DeviceNameTextLabel->setText(QString::null); |
DeviceNameTextLabel->setText(QString::null); |
305 |
DeviceParamTable->setNumRows(0); |
DeviceParamTable->setNumRows(0); |
306 |
|
DevicePortComboBox->setEnabled(false); |
307 |
|
DevicePortParamTable->setEnabled(false); |
308 |
stabilizeForm(); |
stabilizeForm(); |
309 |
return; |
return; |
310 |
} |
} |
311 |
|
|
|
m_iDirtySetup++; |
|
312 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
313 |
|
|
314 |
|
m_iDirtySetup++; |
315 |
// Flag whether this is a new device. |
// Flag whether this is a new device. |
316 |
m_bNewDevice = (device.deviceID() < 0); |
m_bNewDevice = (device.deviceID() < 0); |
317 |
|
|
338 |
DriverNameComboBox->setEnabled(m_bNewDevice); |
DriverNameComboBox->setEnabled(m_bNewDevice); |
339 |
// Fill the device parameter table... |
// Fill the device parameter table... |
340 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
341 |
|
// And now the device port/channel parameter table... |
342 |
|
DevicePortComboBox->clear(); |
343 |
|
DevicePortParamTable->setNumRows(0); |
344 |
|
if (m_bNewDevice) { |
345 |
|
DevicePortComboBox->setEnabled(false); |
346 |
|
DevicePortParamTable->setEnabled(false); |
347 |
|
} else { |
348 |
|
QPixmap pixmap; |
349 |
|
switch (device.deviceType()) { |
350 |
|
case qsamplerDevice::Audio: |
351 |
|
pixmap = QPixmap::fromMimeSource("audio2.png"); |
352 |
|
break; |
353 |
|
case qsamplerDevice::Midi: |
354 |
|
pixmap = QPixmap::fromMimeSource("midi2.png"); |
355 |
|
break; |
356 |
|
case qsamplerDevice::None: |
357 |
|
break; |
358 |
|
} |
359 |
|
qsamplerDevicePortList& ports = device.ports(); |
360 |
|
qsamplerDevicePort *pPort; |
361 |
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
362 |
|
DevicePortComboBox->insertItem(pixmap, |
363 |
|
device.deviceTypeName() + ' ' + pPort->portName()); |
364 |
|
} |
365 |
|
bool bEnabled = (ports.count() > 0); |
366 |
|
DevicePortComboBox->setEnabled(bEnabled); |
367 |
|
DevicePortParamTable->setEnabled(bEnabled); |
368 |
|
} |
369 |
// Done. |
// Done. |
370 |
m_iDirtySetup--; |
m_iDirtySetup--; |
371 |
|
|
372 |
|
// Make the device port/channel selection effective. |
373 |
|
selectDevicePort(DevicePortComboBox->currentItem()); |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
|
// Device port/channel selection slot. |
378 |
|
void qsamplerDeviceForm::selectDevicePort ( int iPort ) |
379 |
|
{ |
380 |
|
if (m_iDirtySetup > 0) |
381 |
|
return; |
382 |
|
|
383 |
|
// |
384 |
|
// Device port/channel selection has changed... |
385 |
|
// |
386 |
|
|
387 |
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
388 |
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
389 |
|
return; |
390 |
|
|
391 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
392 |
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
393 |
|
if (pPort) { |
394 |
|
m_iDirtySetup++; |
395 |
|
DevicePortParamTable->refresh(pPort->params(), true); |
396 |
|
m_iDirtySetup--; |
397 |
|
} |
398 |
|
// Done. |
399 |
stabilizeForm(); |
stabilizeForm(); |
400 |
} |
} |
401 |
|
|
402 |
|
|
403 |
// parameter value change slot. |
// Device parameter value change slot. |
404 |
void qsamplerDeviceForm::changeValue ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
405 |
{ |
{ |
406 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
407 |
return; |
return; |
416 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
417 |
return; |
return; |
418 |
|
|
|
m_iDirtySetup++; |
|
419 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
420 |
|
|
421 |
|
m_iDirtySetup++; |
422 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
423 |
const qsamplerDeviceParamMap& params = device.params(); |
const qsamplerDeviceParamMap& params = device.params(); |
424 |
const QString sParam = DeviceParamTable->text(iRow, 0); |
const QString sParam = DeviceParamTable->text(iRow, 0); |
434 |
param.key = (char *) sParam.latin1(); |
param.key = (char *) sParam.latin1(); |
435 |
param.value = (char *) sValue.latin1(); |
param.value = (char *) sValue.latin1(); |
436 |
// Now it depends on the device type... |
// Now it depends on the device type... |
437 |
|
bool bRefresh = false; |
438 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
439 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
440 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
441 |
|
bRefresh = (sParam == "CHANNELS"); |
442 |
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
443 |
device.deviceID(), ¶m)) != LSCP_OK) |
device.deviceID(), ¶m)) != LSCP_OK) |
444 |
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
445 |
break; |
break; |
446 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
447 |
|
bRefresh = (sParam == "PORTS"); |
448 |
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
449 |
device.deviceID(), ¶m)) != LSCP_OK) |
device.deviceID(), ¶m)) != LSCP_OK) |
450 |
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
456 |
if (ret == LSCP_OK) { |
if (ret == LSCP_OK) { |
457 |
m_pMainForm->appendMessages(device.deviceName() + ' ' |
m_pMainForm->appendMessages(device.deviceName() + ' ' |
458 |
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
459 |
|
// Special care for specific parameter changes... |
460 |
|
if (bRefresh) |
461 |
|
device.refresh(m_pClient); |
462 |
|
} |
463 |
|
} |
464 |
|
|
465 |
|
// Done. |
466 |
|
m_iDirtySetup--; |
467 |
|
stabilizeForm(); |
468 |
|
// Main session should be dirtier... |
469 |
|
m_pMainForm->sessionDirty(); |
470 |
|
} |
471 |
|
|
472 |
|
|
473 |
|
// Device port/channel parameter value change slot. |
474 |
|
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
475 |
|
{ |
476 |
|
if (m_iDirtySetup > 0) |
477 |
|
return; |
478 |
|
if (iRow < 0 || iCol < 0) |
479 |
|
return; |
480 |
|
|
481 |
|
// |
482 |
|
// Device port/channel parameter change... |
483 |
|
// |
484 |
|
|
485 |
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
486 |
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
487 |
|
return; |
488 |
|
|
489 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
490 |
|
|
491 |
|
int iPort = DevicePortComboBox->currentItem(); |
492 |
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
493 |
|
if (pPort == NULL) |
494 |
|
return; |
495 |
|
|
496 |
|
m_iDirtySetup++; |
497 |
|
// Table 1st column has the parameter name; |
498 |
|
const qsamplerDeviceParamMap& params = pPort->params(); |
499 |
|
const QString sParam = DevicePortParamTable->text(iRow, 0); |
500 |
|
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
501 |
|
|
502 |
|
// Set the local device port/channel parameter value. |
503 |
|
pPort->setParam(sParam, sValue); |
504 |
|
|
505 |
|
// Set proper device port/channel parameter, if any... |
506 |
|
if (device.deviceID() >= 0 && pPort->portID() >= 0) { |
507 |
|
// Prepare parameter struct. |
508 |
|
lscp_param_t param; |
509 |
|
param.key = (char *) sParam.latin1(); |
510 |
|
param.value = (char *) sValue.latin1(); |
511 |
|
// Now it depends on the device type... |
512 |
|
lscp_status_t ret = LSCP_FAILED; |
513 |
|
switch (device.deviceType()) { |
514 |
|
case qsamplerDevice::Audio: |
515 |
|
if ((ret = ::lscp_set_audio_channel_param(m_pClient, |
516 |
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
517 |
|
m_pMainForm->appendMessagesClient("lscp_set_audio_channel_param"); |
518 |
|
break; |
519 |
|
case qsamplerDevice::Midi: |
520 |
|
if ((ret = ::lscp_set_midi_port_param(m_pClient, |
521 |
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
522 |
|
m_pMainForm->appendMessagesClient("lscp_set_midi_port_param"); |
523 |
|
break; |
524 |
|
case qsamplerDevice::None: |
525 |
|
break; |
526 |
|
} |
527 |
|
// Show result. |
528 |
|
if (ret == LSCP_OK) { |
529 |
|
m_pMainForm->appendMessages(device.deviceName() + ' ' |
530 |
|
+ pPort->portName() + ' ' |
531 |
|
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
532 |
} |
} |
533 |
} |
} |
534 |
|
|
552 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
553 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
554 |
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
555 |
tr("&Create"), this, SLOT(createDevice())); |
tr("&Create device"), this, SLOT(createDevice())); |
556 |
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
557 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
558 |
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
559 |
tr("&Delete"), this, SLOT(deleteDevice())); |
tr("&Delete device"), this, SLOT(deleteDevice())); |
560 |
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
561 |
pContextMenu->insertSeparator(); |
pContextMenu->insertSeparator(); |
562 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
587 |
|
|
588 |
|
|
589 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
590 |
|
|
591 |
|
|
592 |
|
|