2 |
// |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
/**************************************************************************** |
5 |
Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
18 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerAbout.h" |
24 |
|
#include "qsamplerMainForm.h" |
25 |
|
|
26 |
#include <qmessagebox.h> |
#include <qmessagebox.h> |
27 |
#include <qfiledialog.h> |
#include <qfiledialog.h> |
28 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
30 |
#include <qptrlist.h> |
#include <qptrlist.h> |
31 |
#include <qpopupmenu.h> |
#include <qpopupmenu.h> |
32 |
|
|
|
#include "qsamplerMainForm.h" |
|
|
|
|
|
#include "config.h" |
|
|
|
|
33 |
|
|
34 |
// Kind of constructor. |
// Kind of constructor. |
35 |
void qsamplerDeviceForm::init (void) |
void qsamplerDeviceForm::init (void) |
36 |
{ |
{ |
37 |
// Initialize locals. |
// Initialize locals. |
38 |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
m_pMainForm = NULL; |
39 |
m_pClient = NULL; |
m_pClient = NULL; |
40 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
41 |
|
m_iDirtyCount = 0; |
42 |
m_bNewDevice = false; |
m_bNewDevice = false; |
43 |
m_deviceType = qsamplerDevice::None; |
m_deviceType = qsamplerDevice::None; |
44 |
m_pAudioItems = NULL; |
m_pAudioItems = NULL; |
45 |
m_pMidiItems = NULL; |
m_pMidiItems = NULL; |
46 |
|
// No exclusive mode as default. |
47 |
|
m_deviceTypeMode = qsamplerDevice::None; |
48 |
|
|
49 |
// This an outsider (from designer), but rather important. |
// This an outsider (from designer), but rather important. |
50 |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
84 |
|
|
85 |
if (m_pMainForm) |
if (m_pMainForm) |
86 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
87 |
|
|
88 |
|
// Signal special whether we changed the device set. |
89 |
|
if (m_iDirtyCount > 0) { |
90 |
|
m_iDirtyCount = 0; |
91 |
|
emit devicesChanged(); |
92 |
|
} |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
// Application main form settler (life depends on it). |
97 |
|
void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm ) |
98 |
|
{ |
99 |
|
m_pMainForm = pMainForm; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
|
// Set device type spacial exclusive mode. |
104 |
|
void qsamplerDeviceForm::setDeviceTypeMode ( |
105 |
|
qsamplerDevice::qsamplerDeviceType deviceTypeMode ) |
106 |
|
{ |
107 |
|
// If it has not changed, do nothing. |
108 |
|
if (m_deviceTypeMode == deviceTypeMode) |
109 |
|
return; |
110 |
|
|
111 |
|
m_deviceTypeMode = deviceTypeMode; |
112 |
|
|
113 |
|
// OK. Do a whole refresh around. |
114 |
|
refreshDevices(); |
115 |
} |
} |
116 |
|
|
117 |
|
|
124 |
|
|
125 |
// Set new reference. |
// Set new reference. |
126 |
m_pClient = pClient; |
m_pClient = pClient; |
127 |
|
|
128 |
// OK. Do a whole refresh around. |
// OK. Do a whole refresh around. |
129 |
refreshDevices(); |
refreshDevices(); |
130 |
} |
} |
131 |
|
|
132 |
|
|
133 |
// Create a new device from current table view. |
// Device driver name setup formal initializer. |
134 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::setDriverName ( const QString& sDriverName ) |
135 |
{ |
{ |
136 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
if (DriverNameComboBox->listBox()->findItem(sDriverName, |
137 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
Qt::ExactMatch | Qt::CaseSensitive) == NULL) { |
138 |
return; |
DriverNameComboBox->insertItem(sDriverName); |
139 |
|
} |
140 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
141 |
|
} |
142 |
|
|
|
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
|
143 |
|
|
144 |
// Build the parameter list... |
// Set current selected device by type and id. |
145 |
const qsamplerDeviceParamMap& params = device.params(); |
void qsamplerDeviceForm::setDevice ( qsamplerDevice *pDevice ) |
146 |
lscp_param_t *pParams = new lscp_param_t [params.count() + 1]; |
{ |
147 |
int iParam = 0; |
// In case no device is given... |
148 |
qsamplerDeviceParamMap::ConstIterator iter; |
qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode; |
149 |
for (iter = params.begin(); iter != params.end(); ++iter) { |
if (pDevice) |
150 |
pParams[iParam].key = (char *) iter.key().latin1(); |
deviceType = pDevice->deviceType(); |
|
pParams[iParam].value = (char *) iter.data().value.latin1(); |
|
|
++iParam; |
|
|
} |
|
|
// Null terminated. |
|
|
pParams[iParam].key = NULL; |
|
|
pParams[iParam].value = NULL; |
|
151 |
|
|
152 |
// Now it depends on the device type... |
// Get the device view root item... |
153 |
qsamplerDeviceItem *pRootItem = NULL; |
qsamplerDeviceItem *pRootItem = NULL; |
154 |
int iDeviceID = -1; |
switch (deviceType) { |
|
switch (device.deviceType()) { |
|
155 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
156 |
pRootItem = m_pAudioItems; |
pRootItem = m_pAudioItems; |
|
if ((iDeviceID = ::lscp_create_audio_device(m_pClient, |
|
|
device.driverName().latin1(), pParams)) < 0) |
|
|
m_pMainForm->appendMessagesClient("lscp_create_audio_device"); |
|
157 |
break; |
break; |
158 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
159 |
pRootItem = m_pMidiItems; |
pRootItem = m_pMidiItems; |
|
if ((iDeviceID = ::lscp_create_midi_device(m_pClient, |
|
|
device.driverName().latin1(), pParams)) < 0) |
|
|
m_pMainForm->appendMessagesClient("lscp_create_midi_device"); |
|
160 |
break; |
break; |
161 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
162 |
break; |
break; |
163 |
} |
} |
164 |
|
|
165 |
// Free used parameter array. |
// Is the root present? |
166 |
delete pParams; |
if (pRootItem == NULL) |
167 |
|
return; |
168 |
|
|
169 |
|
// So there's no device huh? |
170 |
|
if (pDevice == NULL) { |
171 |
|
DeviceListView->setSelected(pRootItem, true); |
172 |
|
return; |
173 |
|
} |
174 |
|
|
175 |
|
// For each child, test for identity... |
176 |
|
qsamplerDeviceItem *pDeviceItem = |
177 |
|
(qsamplerDeviceItem *) pRootItem->firstChild(); |
178 |
|
while (pDeviceItem) { |
179 |
|
// If identities match, select as current device item. |
180 |
|
if (pDeviceItem->device().deviceID() == pDevice->deviceID()) { |
181 |
|
DeviceListView->setSelected(pDeviceItem, true); |
182 |
|
break; |
183 |
|
} |
184 |
|
pDeviceItem = (qsamplerDeviceItem *) pDeviceItem->nextSibling(); |
185 |
|
} |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
// Create a new device from current table view. |
191 |
|
void qsamplerDeviceForm::createDevice (void) |
192 |
|
{ |
193 |
|
if (m_pMainForm == NULL) |
194 |
|
return; |
195 |
|
|
196 |
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
197 |
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
198 |
|
return; |
199 |
|
|
200 |
// We're on to create the new device item. |
// About a brand new device instance... |
201 |
if (iDeviceID >= 0) { |
qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device()); |
202 |
|
if (device.createDevice()) { |
203 |
|
// Now it depends on the device type... |
204 |
|
qsamplerDeviceItem *pRootItem = NULL; |
205 |
|
switch (device.deviceType()) { |
206 |
|
case qsamplerDevice::Audio: |
207 |
|
pRootItem = m_pAudioItems; |
208 |
|
break; |
209 |
|
case qsamplerDevice::Midi: |
210 |
|
pRootItem = m_pMidiItems; |
211 |
|
break; |
212 |
|
case qsamplerDevice::None: |
213 |
|
break; |
214 |
|
} |
215 |
// Append the new device item. |
// Append the new device item. |
216 |
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
217 |
m_pClient, device.deviceType(), iDeviceID); |
m_pMainForm, device.deviceType(), device.deviceID()); |
218 |
// Just make it the new selection... |
// Just make it the new selection... |
219 |
DeviceListView->setSelected(pDeviceItem, true); |
DeviceListView->setSelected(pDeviceItem, true); |
|
// Done. |
|
|
m_pMainForm->appendMessages(pDeviceItem->device().deviceTypeName() |
|
|
+ ' ' + pDeviceItem->device().deviceName() |
|
|
+ ' ' + tr("created.")); |
|
220 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
221 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
222 |
|
m_iDirtyCount++; |
223 |
} |
} |
224 |
} |
} |
225 |
|
|
227 |
// Delete current device in table view. |
// Delete current device in table view. |
228 |
void qsamplerDeviceForm::deleteDevice (void) |
void qsamplerDeviceForm::deleteDevice (void) |
229 |
{ |
{ |
230 |
|
if (m_pMainForm == NULL) |
231 |
|
return; |
232 |
|
|
233 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
234 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
235 |
return; |
return; |
236 |
|
|
237 |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
238 |
|
|
239 |
// Prompt user if this is for real... |
// Prompt user if this is for real... |
240 |
qsamplerOptions *pOptions = m_pMainForm->options(); |
qsamplerOptions *pOptions = m_pMainForm->options(); |
241 |
if (pOptions && pOptions->bConfirmRemove) { |
if (pOptions && pOptions->bConfirmRemove) { |
242 |
if (QMessageBox::warning(this, tr("Warning"), |
if (QMessageBox::warning(this, |
243 |
tr("Delete %1 device:\n\n" |
QSAMPLER_TITLE ": " + tr("Warning"), |
244 |
"%2\n\n" |
tr("Delete device:\n\n" |
245 |
|
"%1\n\n" |
246 |
"Are you sure?") |
"Are you sure?") |
|
.arg(device.deviceTypeName()) |
|
247 |
.arg(device.deviceName()), |
.arg(device.deviceName()), |
248 |
tr("OK"), tr("Cancel")) > 0) |
tr("OK"), tr("Cancel")) > 0) |
249 |
return; |
return; |
250 |
} |
} |
251 |
|
|
252 |
// Now it depends on the device type... |
// Go and destroy... |
253 |
lscp_status_t ret = LSCP_FAILED; |
if (device.deleteDevice()) { |
254 |
switch (device.deviceType()) { |
// Remove it from the device view... |
|
case qsamplerDevice::Audio: |
|
|
if ((ret = ::lscp_destroy_audio_device(m_pClient, |
|
|
device.deviceID())) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_destroy_audio_device"); |
|
|
break; |
|
|
case qsamplerDevice::Midi: |
|
|
if ((ret = ::lscp_destroy_midi_device(m_pClient, |
|
|
device.deviceID())) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_destroy_midi_device"); |
|
|
break; |
|
|
case qsamplerDevice::None: |
|
|
break; |
|
|
} |
|
|
|
|
|
// Show result. |
|
|
if (ret == LSCP_OK) { |
|
|
// Show log message before loosing it. |
|
|
m_pMainForm->appendMessages(device.deviceTypeName() |
|
|
+ ' ' + device.deviceName() |
|
|
+ ' ' + tr("deleted.")); |
|
|
// Done. |
|
255 |
delete pItem; |
delete pItem; |
256 |
// Main session should be marked dirty. |
// Main session should be marked dirty. |
257 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
258 |
|
m_iDirtyCount++; |
259 |
} |
} |
260 |
} |
} |
261 |
|
|
263 |
// Refresh all device list and views. |
// Refresh all device list and views. |
264 |
void qsamplerDeviceForm::refreshDevices (void) |
void qsamplerDeviceForm::refreshDevices (void) |
265 |
{ |
{ |
266 |
|
if (m_pMainForm == NULL) |
267 |
|
return; |
268 |
|
|
269 |
// Avoid nested changes. |
// Avoid nested changes. |
270 |
m_iDirtySetup++; |
m_iDirtySetup++; |
271 |
|
|
278 |
if (m_pClient) { |
if (m_pClient) { |
279 |
int *piDeviceIDs; |
int *piDeviceIDs; |
280 |
// Grab and pop Audio devices... |
// Grab and pop Audio devices... |
281 |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
if (m_deviceTypeMode == qsamplerDevice::None || |
282 |
qsamplerDevice::Audio); |
m_deviceTypeMode == qsamplerDevice::Audio) { |
283 |
|
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
284 |
|
m_pMainForm, qsamplerDevice::Audio); |
285 |
|
} |
286 |
if (m_pAudioItems) { |
if (m_pAudioItems) { |
|
m_pAudioItems->setText(0, tr("Audio")); |
|
287 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
288 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
289 |
new qsamplerDeviceItem(m_pAudioItems, m_pClient, |
new qsamplerDeviceItem(m_pAudioItems, m_pMainForm, |
290 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
qsamplerDevice::Audio, piDeviceIDs[i]); |
291 |
} |
} |
292 |
m_pAudioItems->setOpen(true); |
m_pAudioItems->setOpen(true); |
293 |
} |
} |
294 |
// Grab and pop MIDI devices... |
// Grab and pop MIDI devices... |
295 |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
if (m_deviceTypeMode == qsamplerDevice::None || |
296 |
qsamplerDevice::Midi); |
m_deviceTypeMode == qsamplerDevice::Midi) { |
297 |
|
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
298 |
|
m_pMainForm, qsamplerDevice::Midi); |
299 |
|
} |
300 |
if (m_pMidiItems) { |
if (m_pMidiItems) { |
|
m_pMidiItems->setText(0, tr("MIDI")); |
|
301 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
302 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
303 |
new qsamplerDeviceItem(m_pMidiItems, m_pClient, |
new qsamplerDeviceItem(m_pMidiItems, m_pMainForm, |
304 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
qsamplerDevice::Midi, piDeviceIDs[i]); |
305 |
} |
} |
306 |
m_pMidiItems->setOpen(true); |
m_pMidiItems->setOpen(true); |
334 |
// Driver change is only valid for scratch devices... |
// Driver change is only valid for scratch devices... |
335 |
if (m_bNewDevice) { |
if (m_bNewDevice) { |
336 |
m_iDirtySetup++; |
m_iDirtySetup++; |
337 |
device.setDriver(m_pClient, sDriverName); |
device.setDriver(sDriverName); |
338 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
339 |
m_iDirtySetup--; |
m_iDirtySetup--; |
340 |
// Done. |
// Done. |
358 |
m_deviceType = qsamplerDevice::None; |
m_deviceType = qsamplerDevice::None; |
359 |
DeviceNameTextLabel->setText(QString::null); |
DeviceNameTextLabel->setText(QString::null); |
360 |
DeviceParamTable->setNumRows(0); |
DeviceParamTable->setNumRows(0); |
361 |
|
DevicePortComboBox->clear(); |
362 |
DevicePortParamTable->setNumRows(0); |
DevicePortParamTable->setNumRows(0); |
363 |
|
DevicePortTextLabel->setEnabled(false); |
364 |
DevicePortComboBox->setEnabled(false); |
DevicePortComboBox->setEnabled(false); |
365 |
DevicePortParamTable->setEnabled(false); |
DevicePortParamTable->setEnabled(false); |
366 |
stabilizeForm(); |
stabilizeForm(); |
374 |
m_bNewDevice = (device.deviceID() < 0); |
m_bNewDevice = (device.deviceID() < 0); |
375 |
|
|
376 |
// Fill the device/driver heading... |
// Fill the device/driver heading... |
377 |
QString sPrefix; |
DeviceNameTextLabel->setText(device.deviceName()); |
|
if (!m_bNewDevice) |
|
|
sPrefix += device.deviceTypeName() + ' '; |
|
|
DeviceNameTextLabel->setText(sPrefix + device.deviceName()); |
|
378 |
// The driver combobox is only rebuilt if device type has changed... |
// The driver combobox is only rebuilt if device type has changed... |
379 |
if (device.deviceType() != m_deviceType) { |
if (device.deviceType() != m_deviceType) { |
380 |
DriverNameComboBox->clear(); |
DriverNameComboBox->clear(); |
384 |
} |
} |
385 |
// Do we need a driver name? |
// Do we need a driver name? |
386 |
if (m_bNewDevice || device.driverName().isEmpty()) |
if (m_bNewDevice || device.driverName().isEmpty()) |
387 |
device.setDriver(m_pClient, DriverNameComboBox->currentText()); |
device.setDriver(DriverNameComboBox->currentText()); |
388 |
const QString& sDriverName = device.driverName(); |
setDriverName(device.driverName()); |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
|
|
DriverNameComboBox->insertItem(sDriverName); |
|
|
DriverNameComboBox->setCurrentText(sDriverName); |
|
389 |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
390 |
DriverNameComboBox->setEnabled(m_bNewDevice); |
DriverNameComboBox->setEnabled(m_bNewDevice); |
391 |
// Fill the device parameter table... |
// Fill the device parameter table... |
392 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
393 |
// And now the device port/channel parameter table... |
// And now the device port/channel parameter table... |
394 |
|
switch (device.deviceType()) { |
395 |
|
case qsamplerDevice::Audio: |
396 |
|
DevicePortTextLabel->setText(tr("Ch&annel:")); |
397 |
|
break; |
398 |
|
case qsamplerDevice::Midi: |
399 |
|
DevicePortTextLabel->setText(tr("P&ort:")); |
400 |
|
break; |
401 |
|
case qsamplerDevice::None: |
402 |
|
break; |
403 |
|
} |
404 |
DevicePortComboBox->clear(); |
DevicePortComboBox->clear(); |
405 |
DevicePortParamTable->setNumRows(0); |
DevicePortParamTable->setNumRows(0); |
406 |
if (m_bNewDevice) { |
if (m_bNewDevice) { |
407 |
|
DevicePortTextLabel->setEnabled(false); |
408 |
DevicePortComboBox->setEnabled(false); |
DevicePortComboBox->setEnabled(false); |
409 |
DevicePortParamTable->setEnabled(false); |
DevicePortParamTable->setEnabled(false); |
410 |
} else { |
} else { |
411 |
QPixmap pixmap; |
QPixmap pixmap; |
412 |
switch (device.deviceType()) { |
switch (device.deviceType()) { |
413 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
414 |
pixmap = QPixmap::fromMimeSource("audio2.png"); |
pixmap = QPixmap::fromMimeSource("audio2.png"); |
415 |
break; |
break; |
416 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
417 |
pixmap = QPixmap::fromMimeSource("midi2.png"); |
pixmap = QPixmap::fromMimeSource("midi2.png"); |
418 |
break; |
break; |
419 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
420 |
break; |
break; |
421 |
} |
} |
422 |
qsamplerDevicePortList& ports = device.ports(); |
qsamplerDevicePortList& ports = device.ports(); |
423 |
qsamplerDevicePort *pPort; |
qsamplerDevicePort *pPort; |
424 |
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
425 |
DevicePortComboBox->insertItem(pixmap, |
DevicePortComboBox->insertItem(pixmap, device.deviceTypeName() |
426 |
device.deviceTypeName() + ' ' + pPort->portName()); |
+ ' ' + device.driverName() |
427 |
|
+ ' ' + pPort->portName()); |
428 |
} |
} |
429 |
bool bEnabled = (ports.count() > 0); |
bool bEnabled = (ports.count() > 0); |
430 |
|
DevicePortTextLabel->setEnabled(bEnabled); |
431 |
DevicePortComboBox->setEnabled(bEnabled); |
DevicePortComboBox->setEnabled(bEnabled); |
432 |
DevicePortParamTable->setEnabled(bEnabled); |
DevicePortParamTable->setEnabled(bEnabled); |
433 |
} |
} |
434 |
// Done. |
// Done. |
435 |
m_iDirtySetup--; |
m_iDirtySetup--; |
436 |
|
|
437 |
// Make the device port/channel selection effective. |
// Make the device port/channel selection effective. |
438 |
selectDevicePort(DevicePortComboBox->currentItem()); |
selectDevicePort(DevicePortComboBox->currentItem()); |
439 |
} |
} |
468 |
// Device parameter value change slot. |
// Device parameter value change slot. |
469 |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
470 |
{ |
{ |
471 |
|
if (m_pMainForm == NULL) |
472 |
|
return; |
473 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
474 |
return; |
return; |
475 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
476 |
return; |
return; |
477 |
|
|
478 |
// |
// |
479 |
// Device parameter change... |
// Device parameter change... |
480 |
// |
// |
485 |
|
|
486 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
487 |
|
|
|
m_iDirtySetup++; |
|
488 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
489 |
const QString sParam = DeviceParamTable->text(iRow, 0); |
const QString sParam = DeviceParamTable->text(iRow, 0); |
490 |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
|
int iRefresh = 0; |
|
|
|
|
491 |
// Set the local device parameter value. |
// Set the local device parameter value. |
492 |
device.setParam(sParam, sValue); |
if (device.setParam(sParam, sValue)) { |
|
|
|
|
// Set proper device parameter, on existing device ... |
|
|
if (device.deviceID() >= 0) { |
|
|
// Prepare parameter struct. |
|
|
lscp_param_t param; |
|
|
param.key = (char *) sParam.latin1(); |
|
|
param.value = (char *) sValue.latin1(); |
|
|
// Now it depends on the device type... |
|
|
lscp_status_t ret = LSCP_FAILED; |
|
|
switch (device.deviceType()) { |
|
|
case qsamplerDevice::Audio: |
|
|
if (sParam == "CHANNELS") iRefresh++; |
|
|
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
|
|
device.deviceID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
|
|
break; |
|
|
case qsamplerDevice::Midi: |
|
|
if (sParam == "PORTS") iRefresh++; |
|
|
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
|
|
device.deviceID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
|
|
break; |
|
|
case qsamplerDevice::None: |
|
|
break; |
|
|
} |
|
|
// Show result. |
|
|
if (ret == LSCP_OK) { |
|
|
m_pMainForm->appendMessages(device.deviceTypeName() |
|
|
+ ' ' + device.deviceName() |
|
|
+ ' ' + QString("%1: %2.").arg(sParam).arg(sValue)); |
|
|
// Special care for specific parameter changes... |
|
|
if (iRefresh > 0) |
|
|
iRefresh += device.refreshPorts(m_pClient); |
|
|
iRefresh += device.refreshDepends(m_pClient, sParam); |
|
|
} |
|
|
} |
|
|
|
|
|
// Done. |
|
|
m_iDirtySetup--; |
|
|
// Finally, we might need refreshing... |
|
|
if (iRefresh > 0) |
|
493 |
selectDevice(); |
selectDevice(); |
494 |
else |
} else { |
495 |
stabilizeForm(); |
stabilizeForm(); |
496 |
|
} |
497 |
// Main session should be dirtier... |
// Main session should be dirtier... |
498 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
499 |
} |
} |
502 |
// Device port/channel parameter value change slot. |
// Device port/channel parameter value change slot. |
503 |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
504 |
{ |
{ |
505 |
|
if (m_pMainForm == NULL) |
506 |
|
return; |
507 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
508 |
return; |
return; |
509 |
if (iRow < 0 || iCol < 0) |
if (iRow < 0 || iCol < 0) |
522 |
int iPort = DevicePortComboBox->currentItem(); |
int iPort = DevicePortComboBox->currentItem(); |
523 |
qsamplerDevicePort *pPort = device.ports().at(iPort); |
qsamplerDevicePort *pPort = device.ports().at(iPort); |
524 |
if (pPort == NULL) |
if (pPort == NULL) |
525 |
return; |
return; |
526 |
|
|
|
m_iDirtySetup++; |
|
527 |
// Table 1st column has the parameter name; |
// Table 1st column has the parameter name; |
528 |
const QString sParam = DevicePortParamTable->text(iRow, 0); |
const QString sParam = DevicePortParamTable->text(iRow, 0); |
529 |
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
|
|
|
530 |
// Set the local device port/channel parameter value. |
// Set the local device port/channel parameter value. |
531 |
pPort->setParam(sParam, sValue); |
pPort->setParam(sParam, sValue); |
|
|
|
|
// Set proper device port/channel parameter, if any... |
|
|
if (device.deviceID() >= 0 && pPort->portID() >= 0) { |
|
|
// Prepare parameter struct. |
|
|
lscp_param_t param; |
|
|
param.key = (char *) sParam.latin1(); |
|
|
param.value = (char *) sValue.latin1(); |
|
|
// Now it depends on the device type... |
|
|
lscp_status_t ret = LSCP_FAILED; |
|
|
switch (device.deviceType()) { |
|
|
case qsamplerDevice::Audio: |
|
|
if ((ret = ::lscp_set_audio_channel_param(m_pClient, |
|
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_audio_channel_param"); |
|
|
break; |
|
|
case qsamplerDevice::Midi: |
|
|
if ((ret = ::lscp_set_midi_port_param(m_pClient, |
|
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
|
|
m_pMainForm->appendMessagesClient("lscp_set_midi_port_param"); |
|
|
break; |
|
|
case qsamplerDevice::None: |
|
|
break; |
|
|
} |
|
|
// Show result. |
|
|
if (ret == LSCP_OK) { |
|
|
m_pMainForm->appendMessages(device.deviceTypeName() |
|
|
+ ' ' + device.deviceName() + ' ' + pPort->portName() |
|
|
+ ' ' + QString("%1: %2.").arg(sParam).arg(sValue)); |
|
|
} |
|
|
} |
|
|
|
|
532 |
// Done. |
// Done. |
|
m_iDirtySetup--; |
|
533 |
stabilizeForm(); |
stabilizeForm(); |
534 |
// Main session should be dirtier... |
// Main session should be dirtier... |
535 |
m_pMainForm->sessionDirty(); |
m_pMainForm->sessionDirty(); |
540 |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
541 |
{ |
{ |
542 |
int iItemID; |
int iItemID; |
543 |
|
|
544 |
// Build the device context menu... |
// Build the device context menu... |
545 |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
QPopupMenu* pContextMenu = new QPopupMenu(this); |
546 |
|
|
547 |
bool bClient = (m_pClient != NULL); |
bool bClient = (m_pClient != NULL); |
548 |
bool bEnabled = (pItem != NULL); |
bool bEnabled = (pItem != NULL); |
549 |
iItemID = pContextMenu->insertItem( |
iItemID = pContextMenu->insertItem( |
559 |
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
560 |
tr("&Refresh"), this, SLOT(refreshDevices())); |
tr("&Refresh"), this, SLOT(refreshDevices())); |
561 |
pContextMenu->setItemEnabled(iItemID, bClient); |
pContextMenu->setItemEnabled(iItemID, bClient); |
562 |
|
|
563 |
pContextMenu->exec(pos); |
pContextMenu->exec(pos); |
564 |
|
|
565 |
delete pContextMenu; |
delete pContextMenu; |
566 |
} |
} |
567 |
|
|
583 |
|
|
584 |
|
|
585 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
|
|
|
|
|
|
|
|
|