1 |
capela |
426 |
// qsamplerDeviceForm.ui.h |
2 |
|
|
// |
3 |
|
|
// ui.h extension file, included from the uic-generated form implementation. |
4 |
|
|
/**************************************************************************** |
5 |
capela |
430 |
Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
capela |
426 |
|
7 |
|
|
This program is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU General Public License |
9 |
|
|
as published by the Free Software Foundation; either version 2 |
10 |
|
|
of the License, or (at your option) any later version. |
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
GNU General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License |
18 |
|
|
along with this program; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 |
|
|
|
21 |
|
|
*****************************************************************************/ |
22 |
|
|
|
23 |
|
|
#include <qmessagebox.h> |
24 |
capela |
428 |
#include <qfiledialog.h> |
25 |
|
|
#include <qfileinfo.h> |
26 |
capela |
430 |
#include <qlistbox.h> |
27 |
capela |
463 |
#include <qptrlist.h> |
28 |
capela |
452 |
#include <qpopupmenu.h> |
29 |
capela |
426 |
|
30 |
|
|
#include "qsamplerMainForm.h" |
31 |
|
|
|
32 |
|
|
#include "config.h" |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
// Kind of constructor. |
36 |
|
|
void qsamplerDeviceForm::init (void) |
37 |
|
|
{ |
38 |
capela |
431 |
// Initialize locals. |
39 |
|
|
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
40 |
|
|
m_pClient = NULL; |
41 |
capela |
426 |
m_iDirtySetup = 0; |
42 |
capela |
431 |
m_bNewDevice = false; |
43 |
capela |
436 |
m_deviceType = qsamplerDevice::None; |
44 |
capela |
442 |
m_pAudioItems = NULL; |
45 |
|
|
m_pMidiItems = NULL; |
46 |
capela |
426 |
|
47 |
capela |
433 |
// This an outsider (from designer), but rather important. |
48 |
|
|
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
49 |
capela |
463 |
this, SLOT(changeDeviceParam(int,int))); |
50 |
|
|
QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)), |
51 |
|
|
this, SLOT(changeDevicePortParam(int,int))); |
52 |
|
|
|
53 |
capela |
467 |
// Initial contents. |
54 |
|
|
refreshDevices(); |
55 |
capela |
431 |
// Try to restore normal window positioning. |
56 |
|
|
adjustSize(); |
57 |
capela |
426 |
} |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
// Kind of destructor. |
61 |
|
|
void qsamplerDeviceForm::destroy (void) |
62 |
|
|
{ |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
|
66 |
capela |
428 |
// Notify our parent that we're emerging. |
67 |
|
|
void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent ) |
68 |
|
|
{ |
69 |
capela |
431 |
if (m_pMainForm) |
70 |
|
|
m_pMainForm->stabilizeForm(); |
71 |
capela |
428 |
|
72 |
capela |
431 |
stabilizeForm(); |
73 |
capela |
428 |
|
74 |
capela |
431 |
QWidget::showEvent(pShowEvent); |
75 |
capela |
428 |
} |
76 |
|
|
|
77 |
|
|
|
78 |
|
|
// Notify our parent that we're closing. |
79 |
|
|
void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent ) |
80 |
|
|
{ |
81 |
capela |
431 |
QWidget::hideEvent(pHideEvent); |
82 |
capela |
428 |
|
83 |
capela |
431 |
if (m_pMainForm) |
84 |
|
|
m_pMainForm->stabilizeForm(); |
85 |
capela |
428 |
} |
86 |
|
|
|
87 |
|
|
|
88 |
capela |
426 |
// Device configuration dialog setup formal initializer. |
89 |
capela |
428 |
void qsamplerDeviceForm::setClient ( lscp_client_t *pClient ) |
90 |
capela |
426 |
{ |
91 |
capela |
428 |
// If it has not changed, do nothing. |
92 |
|
|
if (m_pClient && m_pClient == pClient) |
93 |
capela |
431 |
return; |
94 |
capela |
426 |
|
95 |
capela |
428 |
// Set new reference. |
96 |
|
|
m_pClient = pClient; |
97 |
|
|
|
98 |
|
|
// OK. Do a whole refresh around. |
99 |
|
|
refreshDevices(); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
|
103 |
capela |
433 |
// Create a new device from current table view. |
104 |
|
|
void qsamplerDeviceForm::createDevice (void) |
105 |
capela |
428 |
{ |
106 |
capela |
433 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
107 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
108 |
|
|
return; |
109 |
capela |
428 |
|
110 |
capela |
462 |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
111 |
capela |
428 |
|
112 |
capela |
433 |
// Build the parameter list... |
113 |
capela |
462 |
const qsamplerDeviceParamMap& params = device.params(); |
114 |
capela |
433 |
lscp_param_t *pParams = new lscp_param_t [params.count() + 1]; |
115 |
capela |
436 |
int iParam = 0; |
116 |
capela |
433 |
qsamplerDeviceParamMap::ConstIterator iter; |
117 |
|
|
for (iter = params.begin(); iter != params.end(); ++iter) { |
118 |
capela |
436 |
pParams[iParam].key = (char *) iter.key().latin1(); |
119 |
|
|
pParams[iParam].value = (char *) iter.data().value.latin1(); |
120 |
|
|
++iParam; |
121 |
capela |
433 |
} |
122 |
|
|
// Null terminated. |
123 |
capela |
436 |
pParams[iParam].key = NULL; |
124 |
|
|
pParams[iParam].value = NULL; |
125 |
capela |
428 |
|
126 |
capela |
433 |
// Now it depends on the device type... |
127 |
capela |
442 |
qsamplerDeviceItem *pRootItem = NULL; |
128 |
capela |
433 |
int iDeviceID = -1; |
129 |
|
|
switch (device.deviceType()) { |
130 |
|
|
case qsamplerDevice::Audio: |
131 |
capela |
448 |
pRootItem = m_pAudioItems; |
132 |
capela |
436 |
if ((iDeviceID = ::lscp_create_audio_device(m_pClient, |
133 |
capela |
433 |
device.driverName().latin1(), pParams)) < 0) |
134 |
|
|
m_pMainForm->appendMessagesClient("lscp_create_audio_device"); |
135 |
|
|
break; |
136 |
|
|
case qsamplerDevice::Midi: |
137 |
capela |
448 |
pRootItem = m_pMidiItems; |
138 |
capela |
436 |
if ((iDeviceID = ::lscp_create_midi_device(m_pClient, |
139 |
capela |
433 |
device.driverName().latin1(), pParams)) < 0) |
140 |
|
|
m_pMainForm->appendMessagesClient("lscp_create_midi_device"); |
141 |
|
|
break; |
142 |
capela |
436 |
case qsamplerDevice::None: |
143 |
|
|
break; |
144 |
capela |
433 |
} |
145 |
capela |
428 |
|
146 |
capela |
433 |
// Free used parameter array. |
147 |
capela |
436 |
delete pParams; |
148 |
capela |
428 |
|
149 |
capela |
442 |
// We're on to create the new device item. |
150 |
capela |
433 |
if (iDeviceID >= 0) { |
151 |
capela |
442 |
// Append the new device item. |
152 |
|
|
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
153 |
|
|
m_pClient, device.deviceType(), iDeviceID); |
154 |
|
|
// Just make it the new selection... |
155 |
|
|
DeviceListView->setSelected(pDeviceItem, true); |
156 |
capela |
433 |
// Done. |
157 |
capela |
467 |
m_pMainForm->appendMessages(pDeviceItem->device().deviceTypeName() |
158 |
|
|
+ ' ' + pDeviceItem->device().deviceName() |
159 |
|
|
+ ' ' + tr("created.")); |
160 |
capela |
433 |
// Main session should be marked dirty. |
161 |
|
|
m_pMainForm->sessionDirty(); |
162 |
|
|
} |
163 |
capela |
428 |
} |
164 |
|
|
|
165 |
|
|
|
166 |
|
|
// Delete current device in table view. |
167 |
|
|
void qsamplerDeviceForm::deleteDevice (void) |
168 |
|
|
{ |
169 |
capela |
433 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
170 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
171 |
|
|
return; |
172 |
|
|
|
173 |
capela |
462 |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
174 |
capela |
433 |
|
175 |
capela |
442 |
// Prompt user if this is for real... |
176 |
|
|
qsamplerOptions *pOptions = m_pMainForm->options(); |
177 |
capela |
448 |
if (pOptions && pOptions->bConfirmRemove) { |
178 |
|
|
if (QMessageBox::warning(this, tr("Warning"), |
179 |
|
|
tr("Delete %1 device:\n\n" |
180 |
|
|
"%2\n\n" |
181 |
|
|
"Are you sure?") |
182 |
|
|
.arg(device.deviceTypeName()) |
183 |
|
|
.arg(device.deviceName()), |
184 |
|
|
tr("OK"), tr("Cancel")) > 0) |
185 |
|
|
return; |
186 |
|
|
} |
187 |
capela |
442 |
|
188 |
capela |
433 |
// Now it depends on the device type... |
189 |
|
|
lscp_status_t ret = LSCP_FAILED; |
190 |
|
|
switch (device.deviceType()) { |
191 |
|
|
case qsamplerDevice::Audio: |
192 |
capela |
436 |
if ((ret = ::lscp_destroy_audio_device(m_pClient, |
193 |
capela |
433 |
device.deviceID())) != LSCP_OK) |
194 |
|
|
m_pMainForm->appendMessagesClient("lscp_destroy_audio_device"); |
195 |
|
|
break; |
196 |
|
|
case qsamplerDevice::Midi: |
197 |
capela |
436 |
if ((ret = ::lscp_destroy_midi_device(m_pClient, |
198 |
capela |
433 |
device.deviceID())) != LSCP_OK) |
199 |
|
|
m_pMainForm->appendMessagesClient("lscp_destroy_midi_device"); |
200 |
|
|
break; |
201 |
capela |
436 |
case qsamplerDevice::None: |
202 |
|
|
break; |
203 |
capela |
433 |
} |
204 |
|
|
|
205 |
|
|
// Show result. |
206 |
|
|
if (ret == LSCP_OK) { |
207 |
capela |
442 |
// Show log message before loosing it. |
208 |
capela |
467 |
m_pMainForm->appendMessages(device.deviceTypeName() |
209 |
|
|
+ ' ' + device.deviceName() |
210 |
|
|
+ ' ' + tr("deleted.")); |
211 |
capela |
433 |
// Done. |
212 |
capela |
442 |
delete pItem; |
213 |
capela |
433 |
// Main session should be marked dirty. |
214 |
|
|
m_pMainForm->sessionDirty(); |
215 |
|
|
} |
216 |
capela |
428 |
} |
217 |
|
|
|
218 |
|
|
|
219 |
|
|
// Refresh all device list and views. |
220 |
|
|
void qsamplerDeviceForm::refreshDevices (void) |
221 |
|
|
{ |
222 |
capela |
431 |
// Avoid nested changes. |
223 |
|
|
m_iDirtySetup++; |
224 |
capela |
428 |
|
225 |
|
|
// |
226 |
capela |
442 |
// (Re)Load complete device configuration data ... |
227 |
capela |
431 |
// |
228 |
capela |
442 |
m_pAudioItems = NULL; |
229 |
|
|
m_pMidiItems = NULL; |
230 |
capela |
431 |
DeviceListView->clear(); |
231 |
|
|
if (m_pClient) { |
232 |
capela |
429 |
int *piDeviceIDs; |
233 |
capela |
430 |
// Grab and pop Audio devices... |
234 |
capela |
442 |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
235 |
capela |
429 |
qsamplerDevice::Audio); |
236 |
capela |
442 |
if (m_pAudioItems) { |
237 |
|
|
m_pAudioItems->setText(0, tr("Audio")); |
238 |
capela |
429 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
239 |
|
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
240 |
capela |
442 |
new qsamplerDeviceItem(m_pAudioItems, m_pClient, |
241 |
capela |
429 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
242 |
|
|
} |
243 |
capela |
442 |
m_pAudioItems->setOpen(true); |
244 |
capela |
428 |
} |
245 |
capela |
430 |
// Grab and pop MIDI devices... |
246 |
capela |
442 |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
247 |
capela |
429 |
qsamplerDevice::Midi); |
248 |
capela |
442 |
if (m_pMidiItems) { |
249 |
|
|
m_pMidiItems->setText(0, tr("MIDI")); |
250 |
capela |
429 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
251 |
|
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
252 |
capela |
442 |
new qsamplerDeviceItem(m_pMidiItems, m_pClient, |
253 |
capela |
429 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
254 |
|
|
} |
255 |
capela |
442 |
m_pMidiItems->setOpen(true); |
256 |
capela |
429 |
} |
257 |
capela |
428 |
} |
258 |
|
|
|
259 |
capela |
431 |
// Done. |
260 |
capela |
433 |
m_iDirtySetup--; |
261 |
capela |
436 |
|
262 |
capela |
433 |
// Show something. |
263 |
capela |
431 |
selectDevice(); |
264 |
capela |
428 |
} |
265 |
|
|
|
266 |
capela |
430 |
|
267 |
|
|
// Driver selection slot. |
268 |
|
|
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
269 |
|
|
{ |
270 |
capela |
433 |
if (m_iDirtySetup > 0) |
271 |
capela |
436 |
return; |
272 |
capela |
433 |
|
273 |
capela |
430 |
// |
274 |
capela |
442 |
// Driver name has changed for a new device... |
275 |
capela |
430 |
// |
276 |
|
|
|
277 |
capela |
431 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
278 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
279 |
|
|
return; |
280 |
|
|
|
281 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
282 |
capela |
436 |
|
283 |
|
|
// Driver change is only valid for scratch devices... |
284 |
capela |
431 |
if (m_bNewDevice) { |
285 |
capela |
442 |
m_iDirtySetup++; |
286 |
capela |
431 |
device.setDriver(m_pClient, sDriverName); |
287 |
capela |
462 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
288 |
capela |
442 |
m_iDirtySetup--; |
289 |
capela |
436 |
// Done. |
290 |
|
|
stabilizeForm(); |
291 |
capela |
431 |
} |
292 |
capela |
430 |
} |
293 |
|
|
|
294 |
|
|
|
295 |
capela |
429 |
// Device selection slot. |
296 |
capela |
430 |
void qsamplerDeviceForm::selectDevice (void) |
297 |
capela |
429 |
{ |
298 |
capela |
433 |
if (m_iDirtySetup > 0) |
299 |
capela |
436 |
return; |
300 |
capela |
433 |
|
301 |
capela |
430 |
// |
302 |
capela |
442 |
// Device selection has changed... |
303 |
capela |
430 |
// |
304 |
capela |
428 |
|
305 |
capela |
431 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
306 |
capela |
430 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
307 |
capela |
436 |
m_deviceType = qsamplerDevice::None; |
308 |
|
|
DeviceNameTextLabel->setText(QString::null); |
309 |
|
|
DeviceParamTable->setNumRows(0); |
310 |
capela |
467 |
DevicePortParamTable->setNumRows(0); |
311 |
capela |
463 |
DevicePortComboBox->setEnabled(false); |
312 |
|
|
DevicePortParamTable->setEnabled(false); |
313 |
capela |
430 |
stabilizeForm(); |
314 |
|
|
return; |
315 |
|
|
} |
316 |
capela |
429 |
|
317 |
capela |
431 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
318 |
capela |
436 |
|
319 |
capela |
463 |
m_iDirtySetup++; |
320 |
capela |
436 |
// Flag whether this is a new device. |
321 |
capela |
430 |
m_bNewDevice = (device.deviceID() < 0); |
322 |
|
|
|
323 |
capela |
433 |
// Fill the device/driver heading... |
324 |
capela |
452 |
QString sPrefix; |
325 |
|
|
if (!m_bNewDevice) |
326 |
|
|
sPrefix += device.deviceTypeName() + ' '; |
327 |
|
|
DeviceNameTextLabel->setText(sPrefix + device.deviceName()); |
328 |
capela |
436 |
// The driver combobox is only rebuilt if device type has changed... |
329 |
|
|
if (device.deviceType() != m_deviceType) { |
330 |
|
|
DriverNameComboBox->clear(); |
331 |
|
|
DriverNameComboBox->insertStringList( |
332 |
|
|
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
333 |
|
|
m_deviceType = device.deviceType(); |
334 |
|
|
} |
335 |
|
|
// Do we need a driver name? |
336 |
|
|
if (m_bNewDevice || device.driverName().isEmpty()) |
337 |
|
|
device.setDriver(m_pClient, DriverNameComboBox->currentText()); |
338 |
capela |
430 |
const QString& sDriverName = device.driverName(); |
339 |
capela |
436 |
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
340 |
|
|
DriverNameComboBox->insertItem(sDriverName); |
341 |
|
|
DriverNameComboBox->setCurrentText(sDriverName); |
342 |
capela |
430 |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
343 |
|
|
DriverNameComboBox->setEnabled(m_bNewDevice); |
344 |
|
|
// Fill the device parameter table... |
345 |
capela |
462 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
346 |
capela |
463 |
// And now the device port/channel parameter table... |
347 |
|
|
DevicePortComboBox->clear(); |
348 |
|
|
DevicePortParamTable->setNumRows(0); |
349 |
|
|
if (m_bNewDevice) { |
350 |
|
|
DevicePortComboBox->setEnabled(false); |
351 |
|
|
DevicePortParamTable->setEnabled(false); |
352 |
|
|
} else { |
353 |
|
|
QPixmap pixmap; |
354 |
|
|
switch (device.deviceType()) { |
355 |
|
|
case qsamplerDevice::Audio: |
356 |
|
|
pixmap = QPixmap::fromMimeSource("audio2.png"); |
357 |
|
|
break; |
358 |
|
|
case qsamplerDevice::Midi: |
359 |
|
|
pixmap = QPixmap::fromMimeSource("midi2.png"); |
360 |
|
|
break; |
361 |
|
|
case qsamplerDevice::None: |
362 |
|
|
break; |
363 |
|
|
} |
364 |
|
|
qsamplerDevicePortList& ports = device.ports(); |
365 |
|
|
qsamplerDevicePort *pPort; |
366 |
|
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
367 |
|
|
DevicePortComboBox->insertItem(pixmap, |
368 |
|
|
device.deviceTypeName() + ' ' + pPort->portName()); |
369 |
|
|
} |
370 |
|
|
bool bEnabled = (ports.count() > 0); |
371 |
|
|
DevicePortComboBox->setEnabled(bEnabled); |
372 |
|
|
DevicePortParamTable->setEnabled(bEnabled); |
373 |
|
|
} |
374 |
capela |
430 |
// Done. |
375 |
capela |
442 |
m_iDirtySetup--; |
376 |
capela |
463 |
|
377 |
|
|
// Make the device port/channel selection effective. |
378 |
|
|
selectDevicePort(DevicePortComboBox->currentItem()); |
379 |
|
|
} |
380 |
|
|
|
381 |
|
|
|
382 |
|
|
// Device port/channel selection slot. |
383 |
|
|
void qsamplerDeviceForm::selectDevicePort ( int iPort ) |
384 |
|
|
{ |
385 |
|
|
if (m_iDirtySetup > 0) |
386 |
|
|
return; |
387 |
|
|
|
388 |
|
|
// |
389 |
|
|
// Device port/channel selection has changed... |
390 |
|
|
// |
391 |
|
|
|
392 |
|
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
393 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
394 |
|
|
return; |
395 |
|
|
|
396 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
397 |
|
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
398 |
|
|
if (pPort) { |
399 |
|
|
m_iDirtySetup++; |
400 |
capela |
465 |
DevicePortParamTable->refresh(pPort->params(), false); |
401 |
capela |
463 |
m_iDirtySetup--; |
402 |
|
|
} |
403 |
|
|
// Done. |
404 |
capela |
430 |
stabilizeForm(); |
405 |
capela |
429 |
} |
406 |
|
|
|
407 |
|
|
|
408 |
capela |
463 |
// Device parameter value change slot. |
409 |
|
|
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
410 |
capela |
432 |
{ |
411 |
capela |
442 |
if (m_iDirtySetup > 0) |
412 |
capela |
448 |
return; |
413 |
capela |
442 |
if (iRow < 0 || iCol < 0) |
414 |
capela |
448 |
return; |
415 |
|
|
|
416 |
capela |
432 |
// |
417 |
capela |
442 |
// Device parameter change... |
418 |
capela |
432 |
// |
419 |
capela |
442 |
|
420 |
capela |
432 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
421 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
422 |
|
|
return; |
423 |
|
|
|
424 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
425 |
|
|
|
426 |
capela |
463 |
m_iDirtySetup++; |
427 |
capela |
436 |
// Table 1st column has the parameter name; |
428 |
|
|
const QString sParam = DeviceParamTable->text(iRow, 0); |
429 |
capela |
433 |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
430 |
capela |
467 |
int iRefresh = 0; |
431 |
capela |
462 |
|
432 |
|
|
// Set the local device parameter value. |
433 |
|
|
device.setParam(sParam, sValue); |
434 |
capela |
432 |
|
435 |
capela |
433 |
// Set proper device parameter, on existing device ... |
436 |
|
|
if (device.deviceID() >= 0) { |
437 |
|
|
// Prepare parameter struct. |
438 |
|
|
lscp_param_t param; |
439 |
|
|
param.key = (char *) sParam.latin1(); |
440 |
|
|
param.value = (char *) sValue.latin1(); |
441 |
|
|
// Now it depends on the device type... |
442 |
|
|
lscp_status_t ret = LSCP_FAILED; |
443 |
|
|
switch (device.deviceType()) { |
444 |
|
|
case qsamplerDevice::Audio: |
445 |
capela |
467 |
if (sParam == "CHANNELS") iRefresh++; |
446 |
capela |
436 |
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
447 |
capela |
433 |
device.deviceID(), ¶m)) != LSCP_OK) |
448 |
|
|
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
449 |
|
|
break; |
450 |
|
|
case qsamplerDevice::Midi: |
451 |
capela |
467 |
if (sParam == "PORTS") iRefresh++; |
452 |
capela |
436 |
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
453 |
capela |
433 |
device.deviceID(), ¶m)) != LSCP_OK) |
454 |
|
|
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
455 |
|
|
break; |
456 |
capela |
436 |
case qsamplerDevice::None: |
457 |
|
|
break; |
458 |
capela |
433 |
} |
459 |
|
|
// Show result. |
460 |
|
|
if (ret == LSCP_OK) { |
461 |
capela |
467 |
m_pMainForm->appendMessages(device.deviceTypeName() |
462 |
|
|
+ ' ' + device.deviceName() |
463 |
|
|
+ ' ' + QString("%1: %2.").arg(sParam).arg(sValue)); |
464 |
capela |
463 |
// Special care for specific parameter changes... |
465 |
capela |
467 |
if (iRefresh > 0) |
466 |
|
|
iRefresh += device.refreshPorts(m_pClient); |
467 |
|
|
iRefresh += device.refreshDepends(m_pClient, sParam); |
468 |
capela |
433 |
} |
469 |
|
|
} |
470 |
capela |
436 |
|
471 |
capela |
433 |
// Done. |
472 |
capela |
442 |
m_iDirtySetup--; |
473 |
capela |
467 |
// Finally, we might need refreshing... |
474 |
|
|
if (iRefresh > 0) |
475 |
|
|
selectDevice(); |
476 |
|
|
else |
477 |
|
|
stabilizeForm(); |
478 |
capela |
433 |
// Main session should be dirtier... |
479 |
|
|
m_pMainForm->sessionDirty(); |
480 |
capela |
432 |
} |
481 |
|
|
|
482 |
|
|
|
483 |
capela |
463 |
// Device port/channel parameter value change slot. |
484 |
|
|
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
485 |
|
|
{ |
486 |
|
|
if (m_iDirtySetup > 0) |
487 |
|
|
return; |
488 |
|
|
if (iRow < 0 || iCol < 0) |
489 |
|
|
return; |
490 |
|
|
|
491 |
|
|
// |
492 |
|
|
// Device port/channel parameter change... |
493 |
|
|
// |
494 |
|
|
|
495 |
|
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
496 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
497 |
|
|
return; |
498 |
|
|
|
499 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
500 |
|
|
|
501 |
|
|
int iPort = DevicePortComboBox->currentItem(); |
502 |
|
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
503 |
|
|
if (pPort == NULL) |
504 |
|
|
return; |
505 |
|
|
|
506 |
|
|
m_iDirtySetup++; |
507 |
|
|
// Table 1st column has the parameter name; |
508 |
|
|
const QString sParam = DevicePortParamTable->text(iRow, 0); |
509 |
|
|
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
510 |
|
|
|
511 |
|
|
// Set the local device port/channel parameter value. |
512 |
|
|
pPort->setParam(sParam, sValue); |
513 |
|
|
|
514 |
|
|
// Set proper device port/channel parameter, if any... |
515 |
|
|
if (device.deviceID() >= 0 && pPort->portID() >= 0) { |
516 |
|
|
// Prepare parameter struct. |
517 |
|
|
lscp_param_t param; |
518 |
|
|
param.key = (char *) sParam.latin1(); |
519 |
|
|
param.value = (char *) sValue.latin1(); |
520 |
|
|
// Now it depends on the device type... |
521 |
|
|
lscp_status_t ret = LSCP_FAILED; |
522 |
|
|
switch (device.deviceType()) { |
523 |
|
|
case qsamplerDevice::Audio: |
524 |
|
|
if ((ret = ::lscp_set_audio_channel_param(m_pClient, |
525 |
|
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
526 |
|
|
m_pMainForm->appendMessagesClient("lscp_set_audio_channel_param"); |
527 |
|
|
break; |
528 |
|
|
case qsamplerDevice::Midi: |
529 |
|
|
if ((ret = ::lscp_set_midi_port_param(m_pClient, |
530 |
|
|
device.deviceID(), pPort->portID(), ¶m)) != LSCP_OK) |
531 |
|
|
m_pMainForm->appendMessagesClient("lscp_set_midi_port_param"); |
532 |
|
|
break; |
533 |
|
|
case qsamplerDevice::None: |
534 |
|
|
break; |
535 |
|
|
} |
536 |
|
|
// Show result. |
537 |
|
|
if (ret == LSCP_OK) { |
538 |
capela |
467 |
m_pMainForm->appendMessages(device.deviceTypeName() |
539 |
|
|
+ ' ' + device.deviceName() + ' ' + pPort->portName() |
540 |
|
|
+ ' ' + QString("%1: %2.").arg(sParam).arg(sValue)); |
541 |
capela |
463 |
} |
542 |
|
|
} |
543 |
|
|
|
544 |
|
|
// Done. |
545 |
|
|
m_iDirtySetup--; |
546 |
|
|
stabilizeForm(); |
547 |
|
|
// Main session should be dirtier... |
548 |
|
|
m_pMainForm->sessionDirty(); |
549 |
|
|
} |
550 |
|
|
|
551 |
|
|
|
552 |
capela |
452 |
// Device list view context menu handler. |
553 |
|
|
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
554 |
|
|
{ |
555 |
|
|
int iItemID; |
556 |
|
|
|
557 |
|
|
// Build the device context menu... |
558 |
|
|
QPopupMenu* pContextMenu = new QPopupMenu(this); |
559 |
|
|
|
560 |
|
|
bool bClient = (m_pClient != NULL); |
561 |
|
|
bool bEnabled = (pItem != NULL); |
562 |
|
|
iItemID = pContextMenu->insertItem( |
563 |
|
|
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
564 |
capela |
463 |
tr("&Create device"), this, SLOT(createDevice())); |
565 |
capela |
452 |
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
566 |
|
|
iItemID = pContextMenu->insertItem( |
567 |
|
|
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
568 |
capela |
463 |
tr("&Delete device"), this, SLOT(deleteDevice())); |
569 |
capela |
452 |
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
570 |
|
|
pContextMenu->insertSeparator(); |
571 |
|
|
iItemID = pContextMenu->insertItem( |
572 |
|
|
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
573 |
|
|
tr("&Refresh"), this, SLOT(refreshDevices())); |
574 |
|
|
pContextMenu->setItemEnabled(iItemID, bClient); |
575 |
|
|
|
576 |
|
|
pContextMenu->exec(pos); |
577 |
|
|
|
578 |
|
|
delete pContextMenu; |
579 |
|
|
} |
580 |
|
|
|
581 |
|
|
|
582 |
capela |
426 |
// Stabilize current form state. |
583 |
|
|
void qsamplerDeviceForm::stabilizeForm (void) |
584 |
|
|
{ |
585 |
capela |
431 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
586 |
capela |
452 |
bool bClient = (m_pClient != NULL); |
587 |
capela |
431 |
bool bEnabled = (pItem != NULL); |
588 |
capela |
433 |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
589 |
|
|
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
590 |
capela |
430 |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
591 |
|
|
DeviceParamTable->setEnabled(bEnabled); |
592 |
capela |
452 |
RefreshDevicesPushButton->setEnabled(bClient); |
593 |
|
|
CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice)); |
594 |
capela |
433 |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
595 |
capela |
426 |
} |
596 |
|
|
|
597 |
|
|
|
598 |
|
|
// end of qsamplerDeviceForm.ui.h |
599 |
capela |
463 |
|
600 |
|
|
|
601 |
|
|
|