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 |
capela |
487 |
m_pMainForm = NULL; |
40 |
capela |
431 |
m_pClient = NULL; |
41 |
capela |
426 |
m_iDirtySetup = 0; |
42 |
capela |
488 |
m_iDirtyCount = 0; |
43 |
capela |
431 |
m_bNewDevice = false; |
44 |
capela |
436 |
m_deviceType = qsamplerDevice::None; |
45 |
capela |
442 |
m_pAudioItems = NULL; |
46 |
|
|
m_pMidiItems = NULL; |
47 |
capela |
487 |
|
48 |
capela |
433 |
// This an outsider (from designer), but rather important. |
49 |
|
|
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
50 |
capela |
463 |
this, SLOT(changeDeviceParam(int,int))); |
51 |
|
|
QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)), |
52 |
|
|
this, SLOT(changeDevicePortParam(int,int))); |
53 |
|
|
|
54 |
capela |
467 |
// Initial contents. |
55 |
|
|
refreshDevices(); |
56 |
capela |
431 |
// Try to restore normal window positioning. |
57 |
|
|
adjustSize(); |
58 |
capela |
426 |
} |
59 |
|
|
|
60 |
|
|
|
61 |
|
|
// Kind of destructor. |
62 |
|
|
void qsamplerDeviceForm::destroy (void) |
63 |
|
|
{ |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
|
67 |
capela |
428 |
// Notify our parent that we're emerging. |
68 |
|
|
void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent ) |
69 |
|
|
{ |
70 |
capela |
431 |
if (m_pMainForm) |
71 |
|
|
m_pMainForm->stabilizeForm(); |
72 |
capela |
428 |
|
73 |
capela |
431 |
stabilizeForm(); |
74 |
capela |
428 |
|
75 |
capela |
431 |
QWidget::showEvent(pShowEvent); |
76 |
capela |
428 |
} |
77 |
|
|
|
78 |
|
|
|
79 |
|
|
// Notify our parent that we're closing. |
80 |
|
|
void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent ) |
81 |
|
|
{ |
82 |
capela |
431 |
QWidget::hideEvent(pHideEvent); |
83 |
capela |
428 |
|
84 |
capela |
431 |
if (m_pMainForm) |
85 |
|
|
m_pMainForm->stabilizeForm(); |
86 |
capela |
488 |
|
87 |
|
|
// Signal special whether we changed the device set. |
88 |
|
|
if (m_iDirtyCount > 0) { |
89 |
|
|
m_iDirtyCount = 0; |
90 |
|
|
emit devicesChanged(); |
91 |
|
|
} |
92 |
capela |
428 |
} |
93 |
|
|
|
94 |
|
|
|
95 |
capela |
487 |
// Application main form settler (life depends on it). |
96 |
|
|
void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm ) |
97 |
|
|
{ |
98 |
|
|
m_pMainForm = pMainForm; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
|
102 |
capela |
426 |
// Device configuration dialog setup formal initializer. |
103 |
capela |
428 |
void qsamplerDeviceForm::setClient ( lscp_client_t *pClient ) |
104 |
capela |
426 |
{ |
105 |
capela |
428 |
// If it has not changed, do nothing. |
106 |
|
|
if (m_pClient && m_pClient == pClient) |
107 |
capela |
431 |
return; |
108 |
capela |
426 |
|
109 |
capela |
428 |
// Set new reference. |
110 |
|
|
m_pClient = pClient; |
111 |
|
|
|
112 |
|
|
// OK. Do a whole refresh around. |
113 |
|
|
refreshDevices(); |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
|
117 |
capela |
487 |
// Set current selected device by type and id. |
118 |
|
|
void qsamplerDeviceForm::setDevice ( |
119 |
|
|
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
120 |
|
|
{ |
121 |
|
|
// Get the device view root item... |
122 |
|
|
qsamplerDeviceItem *pRootItem = NULL; |
123 |
|
|
switch (deviceType) { |
124 |
|
|
case qsamplerDevice::Audio: |
125 |
|
|
pRootItem = m_pAudioItems; |
126 |
|
|
break; |
127 |
|
|
case qsamplerDevice::Midi: |
128 |
|
|
pRootItem = m_pMidiItems; |
129 |
|
|
break; |
130 |
|
|
case qsamplerDevice::None: |
131 |
|
|
break; |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
// Is the root present? |
135 |
|
|
if (pRootItem == NULL) |
136 |
|
|
return; |
137 |
|
|
|
138 |
|
|
// For each child, test for identity... |
139 |
|
|
qsamplerDeviceItem *pDeviceItem = |
140 |
|
|
(qsamplerDeviceItem *) pRootItem->firstChild(); |
141 |
|
|
while (pDeviceItem) { |
142 |
|
|
// If identities match, select as current device item. |
143 |
|
|
if (pDeviceItem->device().deviceID() == iDeviceID) { |
144 |
|
|
DeviceListView->setSelected(pDeviceItem, true); |
145 |
|
|
break; |
146 |
|
|
} |
147 |
|
|
pDeviceItem = (qsamplerDeviceItem *) pDeviceItem->nextSibling(); |
148 |
|
|
} |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
capela |
433 |
// Create a new device from current table view. |
154 |
|
|
void qsamplerDeviceForm::createDevice (void) |
155 |
capela |
428 |
{ |
156 |
capela |
487 |
if (m_pMainForm == NULL) |
157 |
|
|
return; |
158 |
|
|
|
159 |
capela |
433 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
160 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
161 |
|
|
return; |
162 |
capela |
428 |
|
163 |
capela |
484 |
// About a brand new device instance... |
164 |
|
|
qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device()); |
165 |
|
|
if (device.createDevice()) { |
166 |
|
|
// Now it depends on the device type... |
167 |
|
|
qsamplerDeviceItem *pRootItem = NULL; |
168 |
|
|
switch (device.deviceType()) { |
169 |
|
|
case qsamplerDevice::Audio: |
170 |
|
|
pRootItem = m_pAudioItems; |
171 |
|
|
break; |
172 |
|
|
case qsamplerDevice::Midi: |
173 |
|
|
pRootItem = m_pMidiItems; |
174 |
|
|
break; |
175 |
|
|
case qsamplerDevice::None: |
176 |
|
|
break; |
177 |
|
|
} |
178 |
capela |
442 |
// Append the new device item. |
179 |
|
|
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
180 |
capela |
484 |
m_pMainForm, device.deviceType(), device.deviceID()); |
181 |
capela |
442 |
// Just make it the new selection... |
182 |
|
|
DeviceListView->setSelected(pDeviceItem, true); |
183 |
capela |
433 |
// Main session should be marked dirty. |
184 |
|
|
m_pMainForm->sessionDirty(); |
185 |
capela |
488 |
m_iDirtyCount++; |
186 |
capela |
433 |
} |
187 |
capela |
428 |
} |
188 |
|
|
|
189 |
|
|
|
190 |
|
|
// Delete current device in table view. |
191 |
|
|
void qsamplerDeviceForm::deleteDevice (void) |
192 |
|
|
{ |
193 |
capela |
487 |
if (m_pMainForm == NULL) |
194 |
|
|
return; |
195 |
|
|
|
196 |
capela |
433 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
197 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
198 |
|
|
return; |
199 |
|
|
|
200 |
capela |
484 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
201 |
capela |
433 |
|
202 |
capela |
442 |
// Prompt user if this is for real... |
203 |
|
|
qsamplerOptions *pOptions = m_pMainForm->options(); |
204 |
capela |
448 |
if (pOptions && pOptions->bConfirmRemove) { |
205 |
|
|
if (QMessageBox::warning(this, tr("Warning"), |
206 |
capela |
484 |
tr("Delete device:\n\n" |
207 |
|
|
"%1\n\n" |
208 |
capela |
448 |
"Are you sure?") |
209 |
|
|
.arg(device.deviceName()), |
210 |
|
|
tr("OK"), tr("Cancel")) > 0) |
211 |
|
|
return; |
212 |
|
|
} |
213 |
capela |
442 |
|
214 |
capela |
484 |
// Go and destroy... |
215 |
|
|
if (device.deleteDevice()) { |
216 |
|
|
// Remove it from the device view... |
217 |
capela |
442 |
delete pItem; |
218 |
capela |
433 |
// Main session should be marked dirty. |
219 |
|
|
m_pMainForm->sessionDirty(); |
220 |
capela |
488 |
m_iDirtyCount++; |
221 |
capela |
433 |
} |
222 |
capela |
428 |
} |
223 |
|
|
|
224 |
|
|
|
225 |
|
|
// Refresh all device list and views. |
226 |
|
|
void qsamplerDeviceForm::refreshDevices (void) |
227 |
|
|
{ |
228 |
capela |
487 |
if (m_pMainForm == NULL) |
229 |
|
|
return; |
230 |
|
|
|
231 |
capela |
431 |
// Avoid nested changes. |
232 |
|
|
m_iDirtySetup++; |
233 |
capela |
428 |
|
234 |
|
|
// |
235 |
capela |
442 |
// (Re)Load complete device configuration data ... |
236 |
capela |
431 |
// |
237 |
capela |
442 |
m_pAudioItems = NULL; |
238 |
|
|
m_pMidiItems = NULL; |
239 |
capela |
431 |
DeviceListView->clear(); |
240 |
|
|
if (m_pClient) { |
241 |
capela |
429 |
int *piDeviceIDs; |
242 |
capela |
430 |
// Grab and pop Audio devices... |
243 |
capela |
487 |
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, |
244 |
|
|
m_pMainForm, qsamplerDevice::Audio); |
245 |
capela |
442 |
if (m_pAudioItems) { |
246 |
capela |
429 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
247 |
|
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
248 |
capela |
484 |
new qsamplerDeviceItem(m_pAudioItems, m_pMainForm, |
249 |
capela |
429 |
qsamplerDevice::Audio, piDeviceIDs[i]); |
250 |
|
|
} |
251 |
capela |
442 |
m_pAudioItems->setOpen(true); |
252 |
capela |
428 |
} |
253 |
capela |
430 |
// Grab and pop MIDI devices... |
254 |
capela |
487 |
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, |
255 |
|
|
m_pMainForm, qsamplerDevice::Midi); |
256 |
capela |
442 |
if (m_pMidiItems) { |
257 |
capela |
429 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
258 |
|
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
259 |
capela |
484 |
new qsamplerDeviceItem(m_pMidiItems, m_pMainForm, |
260 |
capela |
429 |
qsamplerDevice::Midi, piDeviceIDs[i]); |
261 |
|
|
} |
262 |
capela |
442 |
m_pMidiItems->setOpen(true); |
263 |
capela |
429 |
} |
264 |
capela |
428 |
} |
265 |
|
|
|
266 |
capela |
431 |
// Done. |
267 |
capela |
433 |
m_iDirtySetup--; |
268 |
capela |
436 |
|
269 |
capela |
433 |
// Show something. |
270 |
capela |
431 |
selectDevice(); |
271 |
capela |
428 |
} |
272 |
|
|
|
273 |
capela |
430 |
|
274 |
|
|
// Driver selection slot. |
275 |
|
|
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
276 |
|
|
{ |
277 |
capela |
433 |
if (m_iDirtySetup > 0) |
278 |
capela |
436 |
return; |
279 |
capela |
433 |
|
280 |
capela |
430 |
// |
281 |
capela |
442 |
// Driver name has changed for a new device... |
282 |
capela |
430 |
// |
283 |
|
|
|
284 |
capela |
431 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
285 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
286 |
|
|
return; |
287 |
|
|
|
288 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
289 |
capela |
436 |
|
290 |
|
|
// Driver change is only valid for scratch devices... |
291 |
capela |
431 |
if (m_bNewDevice) { |
292 |
capela |
442 |
m_iDirtySetup++; |
293 |
capela |
484 |
device.setDriver(sDriverName); |
294 |
capela |
462 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
295 |
capela |
442 |
m_iDirtySetup--; |
296 |
capela |
436 |
// Done. |
297 |
|
|
stabilizeForm(); |
298 |
capela |
431 |
} |
299 |
capela |
430 |
} |
300 |
|
|
|
301 |
|
|
|
302 |
capela |
429 |
// Device selection slot. |
303 |
capela |
430 |
void qsamplerDeviceForm::selectDevice (void) |
304 |
capela |
429 |
{ |
305 |
capela |
433 |
if (m_iDirtySetup > 0) |
306 |
capela |
436 |
return; |
307 |
capela |
433 |
|
308 |
capela |
430 |
// |
309 |
capela |
442 |
// Device selection has changed... |
310 |
capela |
430 |
// |
311 |
capela |
428 |
|
312 |
capela |
431 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
313 |
capela |
430 |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
314 |
capela |
436 |
m_deviceType = qsamplerDevice::None; |
315 |
|
|
DeviceNameTextLabel->setText(QString::null); |
316 |
|
|
DeviceParamTable->setNumRows(0); |
317 |
capela |
468 |
DevicePortComboBox->clear(); |
318 |
capela |
467 |
DevicePortParamTable->setNumRows(0); |
319 |
capela |
463 |
DevicePortComboBox->setEnabled(false); |
320 |
|
|
DevicePortParamTable->setEnabled(false); |
321 |
capela |
430 |
stabilizeForm(); |
322 |
|
|
return; |
323 |
|
|
} |
324 |
capela |
429 |
|
325 |
capela |
431 |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
326 |
capela |
436 |
|
327 |
capela |
463 |
m_iDirtySetup++; |
328 |
capela |
436 |
// Flag whether this is a new device. |
329 |
capela |
430 |
m_bNewDevice = (device.deviceID() < 0); |
330 |
|
|
|
331 |
capela |
433 |
// Fill the device/driver heading... |
332 |
capela |
484 |
DeviceNameTextLabel->setText(device.deviceName()); |
333 |
capela |
436 |
// The driver combobox is only rebuilt if device type has changed... |
334 |
|
|
if (device.deviceType() != m_deviceType) { |
335 |
|
|
DriverNameComboBox->clear(); |
336 |
|
|
DriverNameComboBox->insertStringList( |
337 |
|
|
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
338 |
|
|
m_deviceType = device.deviceType(); |
339 |
|
|
} |
340 |
|
|
// Do we need a driver name? |
341 |
|
|
if (m_bNewDevice || device.driverName().isEmpty()) |
342 |
capela |
484 |
device.setDriver(DriverNameComboBox->currentText()); |
343 |
capela |
430 |
const QString& sDriverName = device.driverName(); |
344 |
capela |
436 |
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
345 |
|
|
DriverNameComboBox->insertItem(sDriverName); |
346 |
|
|
DriverNameComboBox->setCurrentText(sDriverName); |
347 |
capela |
430 |
DriverNameTextLabel->setEnabled(m_bNewDevice); |
348 |
|
|
DriverNameComboBox->setEnabled(m_bNewDevice); |
349 |
|
|
// Fill the device parameter table... |
350 |
capela |
462 |
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
351 |
capela |
463 |
// And now the device port/channel parameter table... |
352 |
|
|
DevicePortComboBox->clear(); |
353 |
|
|
DevicePortParamTable->setNumRows(0); |
354 |
|
|
if (m_bNewDevice) { |
355 |
|
|
DevicePortComboBox->setEnabled(false); |
356 |
|
|
DevicePortParamTable->setEnabled(false); |
357 |
|
|
} else { |
358 |
|
|
QPixmap pixmap; |
359 |
|
|
switch (device.deviceType()) { |
360 |
|
|
case qsamplerDevice::Audio: |
361 |
|
|
pixmap = QPixmap::fromMimeSource("audio2.png"); |
362 |
|
|
break; |
363 |
|
|
case qsamplerDevice::Midi: |
364 |
|
|
pixmap = QPixmap::fromMimeSource("midi2.png"); |
365 |
|
|
break; |
366 |
|
|
case qsamplerDevice::None: |
367 |
|
|
break; |
368 |
|
|
} |
369 |
|
|
qsamplerDevicePortList& ports = device.ports(); |
370 |
|
|
qsamplerDevicePort *pPort; |
371 |
|
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
372 |
capela |
484 |
DevicePortComboBox->insertItem(pixmap, device.deviceTypeName() |
373 |
|
|
+ ' ' + device.driverName() |
374 |
|
|
+ ' ' + pPort->portName()); |
375 |
capela |
463 |
} |
376 |
|
|
bool bEnabled = (ports.count() > 0); |
377 |
|
|
DevicePortComboBox->setEnabled(bEnabled); |
378 |
|
|
DevicePortParamTable->setEnabled(bEnabled); |
379 |
|
|
} |
380 |
capela |
430 |
// Done. |
381 |
capela |
442 |
m_iDirtySetup--; |
382 |
capela |
463 |
|
383 |
|
|
// Make the device port/channel selection effective. |
384 |
|
|
selectDevicePort(DevicePortComboBox->currentItem()); |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
|
388 |
|
|
// Device port/channel selection slot. |
389 |
|
|
void qsamplerDeviceForm::selectDevicePort ( int iPort ) |
390 |
|
|
{ |
391 |
|
|
if (m_iDirtySetup > 0) |
392 |
|
|
return; |
393 |
|
|
|
394 |
|
|
// |
395 |
|
|
// Device port/channel selection has changed... |
396 |
|
|
// |
397 |
|
|
|
398 |
|
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
399 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
400 |
|
|
return; |
401 |
|
|
|
402 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
403 |
|
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
404 |
|
|
if (pPort) { |
405 |
|
|
m_iDirtySetup++; |
406 |
capela |
465 |
DevicePortParamTable->refresh(pPort->params(), false); |
407 |
capela |
463 |
m_iDirtySetup--; |
408 |
|
|
} |
409 |
|
|
// Done. |
410 |
capela |
430 |
stabilizeForm(); |
411 |
capela |
429 |
} |
412 |
|
|
|
413 |
|
|
|
414 |
capela |
463 |
// Device parameter value change slot. |
415 |
|
|
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
416 |
capela |
432 |
{ |
417 |
capela |
487 |
if (m_pMainForm == NULL) |
418 |
|
|
return; |
419 |
capela |
442 |
if (m_iDirtySetup > 0) |
420 |
capela |
448 |
return; |
421 |
capela |
442 |
if (iRow < 0 || iCol < 0) |
422 |
capela |
448 |
return; |
423 |
|
|
|
424 |
capela |
432 |
// |
425 |
capela |
442 |
// Device parameter change... |
426 |
capela |
432 |
// |
427 |
capela |
442 |
|
428 |
capela |
432 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
429 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
430 |
|
|
return; |
431 |
|
|
|
432 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
433 |
|
|
|
434 |
capela |
436 |
// Table 1st column has the parameter name; |
435 |
|
|
const QString sParam = DeviceParamTable->text(iRow, 0); |
436 |
capela |
433 |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
437 |
capela |
462 |
// Set the local device parameter value. |
438 |
capela |
484 |
if (device.setParam(sParam, sValue)) { |
439 |
capela |
467 |
selectDevice(); |
440 |
capela |
484 |
} else { |
441 |
capela |
467 |
stabilizeForm(); |
442 |
capela |
484 |
} |
443 |
capela |
433 |
// Main session should be dirtier... |
444 |
|
|
m_pMainForm->sessionDirty(); |
445 |
capela |
432 |
} |
446 |
|
|
|
447 |
|
|
|
448 |
capela |
463 |
// Device port/channel parameter value change slot. |
449 |
|
|
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
450 |
|
|
{ |
451 |
capela |
487 |
if (m_pMainForm == NULL) |
452 |
|
|
return; |
453 |
capela |
463 |
if (m_iDirtySetup > 0) |
454 |
|
|
return; |
455 |
|
|
if (iRow < 0 || iCol < 0) |
456 |
|
|
return; |
457 |
|
|
|
458 |
|
|
// |
459 |
|
|
// Device port/channel parameter change... |
460 |
|
|
// |
461 |
|
|
|
462 |
|
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
463 |
|
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
464 |
|
|
return; |
465 |
|
|
|
466 |
|
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
467 |
|
|
|
468 |
|
|
int iPort = DevicePortComboBox->currentItem(); |
469 |
|
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
470 |
|
|
if (pPort == NULL) |
471 |
|
|
return; |
472 |
|
|
|
473 |
|
|
// Table 1st column has the parameter name; |
474 |
|
|
const QString sParam = DevicePortParamTable->text(iRow, 0); |
475 |
|
|
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
476 |
|
|
// Set the local device port/channel parameter value. |
477 |
|
|
pPort->setParam(sParam, sValue); |
478 |
|
|
// Done. |
479 |
|
|
stabilizeForm(); |
480 |
|
|
// Main session should be dirtier... |
481 |
|
|
m_pMainForm->sessionDirty(); |
482 |
|
|
} |
483 |
|
|
|
484 |
|
|
|
485 |
capela |
452 |
// Device list view context menu handler. |
486 |
|
|
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
487 |
|
|
{ |
488 |
|
|
int iItemID; |
489 |
|
|
|
490 |
|
|
// Build the device context menu... |
491 |
|
|
QPopupMenu* pContextMenu = new QPopupMenu(this); |
492 |
|
|
|
493 |
|
|
bool bClient = (m_pClient != NULL); |
494 |
|
|
bool bEnabled = (pItem != NULL); |
495 |
|
|
iItemID = pContextMenu->insertItem( |
496 |
|
|
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
497 |
capela |
463 |
tr("&Create device"), this, SLOT(createDevice())); |
498 |
capela |
452 |
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
499 |
|
|
iItemID = pContextMenu->insertItem( |
500 |
|
|
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
501 |
capela |
463 |
tr("&Delete device"), this, SLOT(deleteDevice())); |
502 |
capela |
452 |
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
503 |
|
|
pContextMenu->insertSeparator(); |
504 |
|
|
iItemID = pContextMenu->insertItem( |
505 |
|
|
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
506 |
|
|
tr("&Refresh"), this, SLOT(refreshDevices())); |
507 |
|
|
pContextMenu->setItemEnabled(iItemID, bClient); |
508 |
|
|
|
509 |
|
|
pContextMenu->exec(pos); |
510 |
|
|
|
511 |
|
|
delete pContextMenu; |
512 |
|
|
} |
513 |
|
|
|
514 |
|
|
|
515 |
capela |
426 |
// Stabilize current form state. |
516 |
|
|
void qsamplerDeviceForm::stabilizeForm (void) |
517 |
|
|
{ |
518 |
capela |
431 |
QListViewItem *pItem = DeviceListView->selectedItem(); |
519 |
capela |
452 |
bool bClient = (m_pClient != NULL); |
520 |
capela |
431 |
bool bEnabled = (pItem != NULL); |
521 |
capela |
433 |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
522 |
|
|
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
523 |
capela |
430 |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
524 |
|
|
DeviceParamTable->setEnabled(bEnabled); |
525 |
capela |
452 |
RefreshDevicesPushButton->setEnabled(bClient); |
526 |
|
|
CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice)); |
527 |
capela |
433 |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
528 |
capela |
426 |
} |
529 |
|
|
|
530 |
|
|
|
531 |
|
|
// end of qsamplerDeviceForm.ui.h |
532 |
capela |
463 |
|
533 |
|
|
|
534 |
|
|
|