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) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2005, 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 |
23 |
#include <qmessagebox.h> |
#include <qmessagebox.h> |
24 |
#include <qfiledialog.h> |
#include <qfiledialog.h> |
25 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
26 |
|
#include <qlistbox.h> |
27 |
|
#include <qptrlist.h> |
28 |
|
#include <qpopupmenu.h> |
29 |
|
|
30 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
31 |
|
|
35 |
// Kind of constructor. |
// Kind of constructor. |
36 |
void qsamplerDeviceForm::init (void) |
void qsamplerDeviceForm::init (void) |
37 |
{ |
{ |
38 |
// Initialize locals. |
// Initialize locals. |
39 |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
40 |
m_pClient = NULL; |
m_pClient = NULL; |
41 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
42 |
m_iDirtyCount = 0; |
m_bNewDevice = false; |
43 |
m_iUntitled = 1; |
m_deviceType = qsamplerDevice::None; |
44 |
|
m_pAudioItems = NULL; |
45 |
|
m_pMidiItems = NULL; |
46 |
|
|
47 |
|
// This an outsider (from designer), but rather important. |
48 |
|
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
49 |
|
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. |
// Initial contents. |
54 |
adjustSize(); |
refreshDevices(); |
55 |
|
// Try to restore normal window positioning. |
56 |
|
adjustSize(); |
57 |
} |
} |
58 |
|
|
59 |
|
|
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) |
if (m_pMainForm) |
70 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
71 |
|
|
72 |
stabilizeForm(); |
stabilizeForm(); |
73 |
|
|
74 |
QWidget::showEvent(pShowEvent); |
QWidget::showEvent(pShowEvent); |
75 |
} |
} |
76 |
|
|
77 |
|
|
78 |
// Notify our parent that we're closing. |
// Notify our parent that we're closing. |
79 |
void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent ) |
void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent ) |
80 |
{ |
{ |
81 |
QWidget::hideEvent(pHideEvent); |
QWidget::hideEvent(pHideEvent); |
82 |
|
|
83 |
if (m_pMainForm) |
if (m_pMainForm) |
84 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
85 |
} |
} |
86 |
|
|
87 |
|
|
90 |
{ |
{ |
91 |
// If it has not changed, do nothing. |
// If it has not changed, do nothing. |
92 |
if (m_pClient && m_pClient == pClient) |
if (m_pClient && m_pClient == pClient) |
93 |
return; |
return; |
94 |
|
|
95 |
// Set new reference. |
// Set new reference. |
96 |
m_pClient = pClient; |
m_pClient = pClient; |
100 |
} |
} |
101 |
|
|
102 |
|
|
103 |
// Format the displayable device configuration filename. |
// Create a new device from current table view. |
104 |
QString qsamplerDeviceForm::devicesName ( const QString& sFilename ) |
void qsamplerDeviceForm::createDevice (void) |
105 |
{ |
{ |
106 |
QString sDevicesName = sFilename; |
QListViewItem *pItem = DeviceListView->selectedItem(); |
107 |
qsamplerOptions *pOptions = m_pMainForm->options(); |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
108 |
if (pOptions) { |
return; |
109 |
bool bCompletePath = (pOptions && pOptions->bCompletePath); |
|
110 |
if (sDevicesName.isEmpty()) |
// About a brand new device instance... |
111 |
sDevicesName = tr("Untitled") + QString::number(m_iUntitled); |
qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device()); |
112 |
else if (!bCompletePath) |
if (device.createDevice()) { |
113 |
sDevicesName = QFileInfo(sDevicesName).fileName(); |
// Now it depends on the device type... |
114 |
|
qsamplerDeviceItem *pRootItem = NULL; |
115 |
|
switch (device.deviceType()) { |
116 |
|
case qsamplerDevice::Audio: |
117 |
|
pRootItem = m_pAudioItems; |
118 |
|
break; |
119 |
|
case qsamplerDevice::Midi: |
120 |
|
pRootItem = m_pMidiItems; |
121 |
|
break; |
122 |
|
case qsamplerDevice::None: |
123 |
|
break; |
124 |
|
} |
125 |
|
// Append the new device item. |
126 |
|
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
127 |
|
m_pMainForm, device.deviceType(), device.deviceID()); |
128 |
|
// Just make it the new selection... |
129 |
|
DeviceListView->setSelected(pDeviceItem, true); |
130 |
|
// Main session should be marked dirty. |
131 |
|
m_pMainForm->sessionDirty(); |
132 |
} |
} |
|
return sDevicesName; |
|
133 |
} |
} |
134 |
|
|
135 |
|
|
136 |
// Window close event handlers. |
// Delete current device in table view. |
137 |
bool qsamplerDeviceForm::queryClose (void) |
void qsamplerDeviceForm::deleteDevice (void) |
|
{ |
|
|
bool bQueryClose = true; |
|
|
|
|
|
if (m_iDirtyCount > 0) { |
|
|
switch (QMessageBox::warning(this, tr("Warning"), |
|
|
tr("The device configuration has been changed.\n\n" |
|
|
"\"%1\"\n\n" |
|
|
"Do you want to save the changes?") |
|
|
.arg(devicesName(m_sFilename)), |
|
|
tr("Save"), tr("Discard"), tr("Cancel"))) { |
|
|
case 0: // Save... |
|
|
saveDevices(); |
|
|
// Fall thru.... |
|
|
case 1: // Discard |
|
|
break; |
|
|
default: // Cancel. |
|
|
bQueryClose = false; |
|
|
} |
|
|
} |
|
|
|
|
|
return bQueryClose; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Dirty up settings. |
|
|
void qsamplerDeviceForm::contentsChanged (void) |
|
138 |
{ |
{ |
139 |
if (m_iDirtySetup > 0) |
QListViewItem *pItem = DeviceListView->selectedItem(); |
140 |
return; |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
141 |
|
return; |
142 |
|
|
143 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
144 |
|
|
145 |
|
// Prompt user if this is for real... |
146 |
|
qsamplerOptions *pOptions = m_pMainForm->options(); |
147 |
|
if (pOptions && pOptions->bConfirmRemove) { |
148 |
|
if (QMessageBox::warning(this, tr("Warning"), |
149 |
|
tr("Delete device:\n\n" |
150 |
|
"%1\n\n" |
151 |
|
"Are you sure?") |
152 |
|
.arg(device.deviceName()), |
153 |
|
tr("OK"), tr("Cancel")) > 0) |
154 |
|
return; |
155 |
|
} |
156 |
|
|
157 |
m_iDirtyCount++; |
// Go and destroy... |
158 |
stabilizeForm(); |
if (device.deleteDevice()) { |
159 |
|
// Remove it from the device view... |
160 |
|
delete pItem; |
161 |
|
// Main session should be marked dirty. |
162 |
|
m_pMainForm->sessionDirty(); |
163 |
|
} |
164 |
} |
} |
165 |
|
|
166 |
|
|
167 |
// Load device configuration slot. |
// Refresh all device list and views. |
168 |
void qsamplerDeviceForm::loadDevices (void) |
void qsamplerDeviceForm::refreshDevices (void) |
169 |
{ |
{ |
170 |
QString sFilename = QFileDialog::getOpenFileName( |
// Avoid nested changes. |
171 |
m_sFilename, // Start here. |
m_iDirtySetup++; |
|
tr("Device Configuration files") + " (*.lscp)", // Filter (XML files) |
|
|
this, 0, // Parent and name (none) |
|
|
tr("Load Device Configuration") // Caption. |
|
|
); |
|
172 |
|
|
173 |
if (sFilename.isEmpty()) |
// |
174 |
return; |
// (Re)Load complete device configuration data ... |
175 |
|
// |
176 |
|
m_pAudioItems = NULL; |
177 |
|
m_pMidiItems = NULL; |
178 |
|
DeviceListView->clear(); |
179 |
|
if (m_pClient) { |
180 |
|
int *piDeviceIDs; |
181 |
|
// Grab and pop Audio devices... |
182 |
|
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, m_pMainForm, |
183 |
|
qsamplerDevice::Audio); |
184 |
|
if (m_pAudioItems) { |
185 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
186 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
187 |
|
new qsamplerDeviceItem(m_pAudioItems, m_pMainForm, |
188 |
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
189 |
|
} |
190 |
|
m_pAudioItems->setOpen(true); |
191 |
|
} |
192 |
|
// Grab and pop MIDI devices... |
193 |
|
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, m_pMainForm, |
194 |
|
qsamplerDevice::Midi); |
195 |
|
if (m_pMidiItems) { |
196 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
197 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
198 |
|
new qsamplerDeviceItem(m_pMidiItems, m_pMainForm, |
199 |
|
qsamplerDevice::Midi, piDeviceIDs[i]); |
200 |
|
} |
201 |
|
m_pMidiItems->setOpen(true); |
202 |
|
} |
203 |
|
} |
204 |
|
|
205 |
// Check if we're going to discard safely the current one... |
// Done. |
206 |
if (!queryClose()) |
m_iDirtySetup--; |
|
return; |
|
207 |
|
|
208 |
// Load it right away... |
// Show something. |
209 |
loadDevicesFile(sFilename); |
selectDevice(); |
210 |
} |
} |
211 |
|
|
212 |
|
|
213 |
// Save device configuration slot. |
// Driver selection slot. |
214 |
void qsamplerDeviceForm::saveDevices (void) |
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
215 |
{ |
{ |
216 |
QString sFilename = QFileDialog::getSaveFileName( |
if (m_iDirtySetup > 0) |
217 |
m_sFilename, // Start here. |
return; |
|
tr("Device Configuration files") + " (*.lscp)", // Filter (XML files) |
|
|
this, 0, // Parent and name (none) |
|
|
tr("Save Device Configuration") // Caption. |
|
|
); |
|
|
|
|
|
if (sFilename.isEmpty()) |
|
|
return; |
|
218 |
|
|
219 |
// Enforce .xml extension... |
// |
220 |
if (QFileInfo(sFilename).extension().isEmpty()) |
// Driver name has changed for a new device... |
221 |
sFilename += ".lscp"; |
// |
222 |
|
|
223 |
// Save it right away... |
QListViewItem *pItem = DeviceListView->selectedItem(); |
224 |
saveDevicesFile(sFilename); |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
225 |
|
return; |
226 |
|
|
227 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
228 |
|
|
229 |
|
// Driver change is only valid for scratch devices... |
230 |
|
if (m_bNewDevice) { |
231 |
|
m_iDirtySetup++; |
232 |
|
device.setDriver(sDriverName); |
233 |
|
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
234 |
|
m_iDirtySetup--; |
235 |
|
// Done. |
236 |
|
stabilizeForm(); |
237 |
|
} |
238 |
} |
} |
239 |
|
|
240 |
|
|
241 |
// Load device configuration from file. |
// Device selection slot. |
242 |
void qsamplerDeviceForm::loadDevicesFile ( const QString& sFilename ) |
void qsamplerDeviceForm::selectDevice (void) |
243 |
{ |
{ |
244 |
|
if (m_iDirtySetup > 0) |
245 |
|
return; |
246 |
|
|
247 |
// |
// |
248 |
// TODO: Load device configuration from file... |
// Device selection has changed... |
249 |
// |
// |
|
m_pMainForm->appendMessages("qsamplerDeviceForm::loadDevicesFile(\"" + sFilename + "\")..."); |
|
250 |
|
|
251 |
m_sFilename = sFilename; |
QListViewItem *pItem = DeviceListView->selectedItem(); |
252 |
m_iDirtyCount = 0; |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
253 |
|
m_deviceType = qsamplerDevice::None; |
254 |
|
DeviceNameTextLabel->setText(QString::null); |
255 |
|
DeviceParamTable->setNumRows(0); |
256 |
|
DevicePortComboBox->clear(); |
257 |
|
DevicePortParamTable->setNumRows(0); |
258 |
|
DevicePortComboBox->setEnabled(false); |
259 |
|
DevicePortParamTable->setEnabled(false); |
260 |
|
stabilizeForm(); |
261 |
|
return; |
262 |
|
} |
263 |
|
|
264 |
refreshDevices(); |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
265 |
|
|
266 |
|
m_iDirtySetup++; |
267 |
|
// Flag whether this is a new device. |
268 |
|
m_bNewDevice = (device.deviceID() < 0); |
269 |
|
|
270 |
|
// Fill the device/driver heading... |
271 |
|
DeviceNameTextLabel->setText(device.deviceName()); |
272 |
|
// The driver combobox is only rebuilt if device type has changed... |
273 |
|
if (device.deviceType() != m_deviceType) { |
274 |
|
DriverNameComboBox->clear(); |
275 |
|
DriverNameComboBox->insertStringList( |
276 |
|
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
277 |
|
m_deviceType = device.deviceType(); |
278 |
|
} |
279 |
|
// Do we need a driver name? |
280 |
|
if (m_bNewDevice || device.driverName().isEmpty()) |
281 |
|
device.setDriver(DriverNameComboBox->currentText()); |
282 |
|
const QString& sDriverName = device.driverName(); |
283 |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
284 |
|
DriverNameComboBox->insertItem(sDriverName); |
285 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
286 |
|
DriverNameTextLabel->setEnabled(m_bNewDevice); |
287 |
|
DriverNameComboBox->setEnabled(m_bNewDevice); |
288 |
|
// Fill the device parameter table... |
289 |
|
DeviceParamTable->refresh(device.params(), m_bNewDevice); |
290 |
|
// And now the device port/channel parameter table... |
291 |
|
DevicePortComboBox->clear(); |
292 |
|
DevicePortParamTable->setNumRows(0); |
293 |
|
if (m_bNewDevice) { |
294 |
|
DevicePortComboBox->setEnabled(false); |
295 |
|
DevicePortParamTable->setEnabled(false); |
296 |
|
} else { |
297 |
|
QPixmap pixmap; |
298 |
|
switch (device.deviceType()) { |
299 |
|
case qsamplerDevice::Audio: |
300 |
|
pixmap = QPixmap::fromMimeSource("audio2.png"); |
301 |
|
break; |
302 |
|
case qsamplerDevice::Midi: |
303 |
|
pixmap = QPixmap::fromMimeSource("midi2.png"); |
304 |
|
break; |
305 |
|
case qsamplerDevice::None: |
306 |
|
break; |
307 |
|
} |
308 |
|
qsamplerDevicePortList& ports = device.ports(); |
309 |
|
qsamplerDevicePort *pPort; |
310 |
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
311 |
|
DevicePortComboBox->insertItem(pixmap, device.deviceTypeName() |
312 |
|
+ ' ' + device.driverName() |
313 |
|
+ ' ' + pPort->portName()); |
314 |
|
} |
315 |
|
bool bEnabled = (ports.count() > 0); |
316 |
|
DevicePortComboBox->setEnabled(bEnabled); |
317 |
|
DevicePortParamTable->setEnabled(bEnabled); |
318 |
|
} |
319 |
|
// Done. |
320 |
|
m_iDirtySetup--; |
321 |
|
|
322 |
|
// Make the device port/channel selection effective. |
323 |
|
selectDevicePort(DevicePortComboBox->currentItem()); |
324 |
} |
} |
325 |
|
|
326 |
|
|
327 |
// Save device configuration into file. |
// Device port/channel selection slot. |
328 |
void qsamplerDeviceForm::saveDevicesFile ( const QString& sFilename ) |
void qsamplerDeviceForm::selectDevicePort ( int iPort ) |
329 |
{ |
{ |
330 |
|
if (m_iDirtySetup > 0) |
331 |
|
return; |
332 |
|
|
333 |
|
// |
334 |
|
// Device port/channel selection has changed... |
335 |
// |
// |
|
// TODO: Save device configuration into file... |
|
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::saveDevicesFile(\"" + sFilename + "\")..."); |
|
336 |
|
|
337 |
m_sFilename = sFilename; |
QListViewItem *pItem = DeviceListView->selectedItem(); |
338 |
m_iDirtyCount = 0; |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
339 |
|
return; |
340 |
|
|
341 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
342 |
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
343 |
|
if (pPort) { |
344 |
|
m_iDirtySetup++; |
345 |
|
DevicePortParamTable->refresh(pPort->params(), false); |
346 |
|
m_iDirtySetup--; |
347 |
|
} |
348 |
|
// Done. |
349 |
stabilizeForm(); |
stabilizeForm(); |
350 |
} |
} |
351 |
|
|
352 |
|
|
353 |
// Create a new device from current table view. |
// Device parameter value change slot. |
354 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol ) |
355 |
{ |
{ |
356 |
|
if (m_iDirtySetup > 0) |
357 |
|
return; |
358 |
|
if (iRow < 0 || iCol < 0) |
359 |
|
return; |
360 |
|
|
361 |
// |
// |
362 |
// TODO: Create a new device from current table view... |
// Device parameter change... |
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()..."); |
|
|
} |
|
|
|
|
|
|
|
|
// Update current device in table view. |
|
|
void qsamplerDeviceForm::updateDevice (void) |
|
|
{ |
|
363 |
// |
// |
|
// TODO: Update current device in table view... |
|
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::updateDevice()..."); |
|
|
} |
|
|
|
|
364 |
|
|
365 |
// Delete current device in table view. |
QListViewItem *pItem = DeviceListView->selectedItem(); |
366 |
void qsamplerDeviceForm::deleteDevice (void) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
367 |
{ |
return; |
368 |
// |
|
369 |
// TODO: Delete current device in table view... |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
370 |
// |
|
371 |
m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()..."); |
// Table 1st column has the parameter name; |
372 |
|
const QString sParam = DeviceParamTable->text(iRow, 0); |
373 |
|
const QString sValue = DeviceParamTable->text(iRow, iCol); |
374 |
|
// Set the local device parameter value. |
375 |
|
if (device.setParam(sParam, sValue)) { |
376 |
|
selectDevice(); |
377 |
|
} else { |
378 |
|
stabilizeForm(); |
379 |
|
} |
380 |
|
// Main session should be dirtier... |
381 |
|
m_pMainForm->sessionDirty(); |
382 |
} |
} |
383 |
|
|
384 |
|
|
385 |
// Refresh all device list and views. |
// Device port/channel parameter value change slot. |
386 |
void qsamplerDeviceForm::refreshDevices (void) |
void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol ) |
387 |
{ |
{ |
388 |
// Avoid nested changes. |
if (m_iDirtySetup > 0) |
389 |
m_iDirtySetup++; |
return; |
390 |
|
if (iRow < 0 || iCol < 0) |
391 |
|
return; |
392 |
|
|
393 |
// |
// |
394 |
// TODO: Load device configuration data ... |
// Device port/channel parameter change... |
395 |
// |
// |
|
|
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()"); |
|
|
|
|
|
DeviceListView->clear(); |
|
|
if (m_pClient) { |
|
|
qsamplerDeviceItem *pItem; |
|
|
int *piDeviceIDs; |
|
|
// Grab audio devices... |
|
|
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
|
|
qsamplerDevice::Audio); |
|
|
if (pItem) { |
|
|
pItem->setText(0, tr("Audio")); |
|
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
|
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
|
|
new qsamplerDeviceItem(pItem, m_pClient, |
|
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
|
|
} |
|
|
} |
|
|
// Grab MIDI devices... |
|
|
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
|
|
qsamplerDevice::Midi); |
|
|
if (pItem) { |
|
|
pItem->setText(0, tr("MIDI")); |
|
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
|
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
|
|
new qsamplerDeviceItem(pItem, m_pClient, |
|
|
qsamplerDevice::Midi, piDeviceIDs[i]); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// Done. |
|
|
m_iDirtySetup--; |
|
|
// stabilizeForm(); |
|
|
} |
|
396 |
|
|
397 |
// Device selection slot. |
QListViewItem *pItem = DeviceListView->selectedItem(); |
398 |
void qsamplerDeviceForm::selectDevice ( QListViewItem *pItem ) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
399 |
{ |
return; |
400 |
if (pItem == NULL) |
|
401 |
return; |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
402 |
if (pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
|
403 |
|
int iPort = DevicePortComboBox->currentItem(); |
404 |
|
qsamplerDevicePort *pPort = device.ports().at(iPort); |
405 |
|
if (pPort == NULL) |
406 |
return; |
return; |
407 |
|
|
408 |
m_pMainForm->appendMessages("qsamplerDeviceForm::selectDevice(" + pItem->text(0) + ")"); |
// Table 1st column has the parameter name; |
409 |
|
const QString sParam = DevicePortParamTable->text(iRow, 0); |
410 |
|
const QString sValue = DevicePortParamTable->text(iRow, iCol); |
411 |
|
// Set the local device port/channel parameter value. |
412 |
|
pPort->setParam(sParam, sValue); |
413 |
|
// Done. |
414 |
|
stabilizeForm(); |
415 |
|
// Main session should be dirtier... |
416 |
|
m_pMainForm->sessionDirty(); |
417 |
|
} |
418 |
|
|
419 |
|
|
420 |
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
// Device list view context menu handler. |
421 |
DeviceParamTable->setDevice(m_pClient, |
void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int ) |
422 |
device.deviceType(), device.deviceID()); |
{ |
423 |
|
int iItemID; |
424 |
|
|
425 |
|
// Build the device context menu... |
426 |
|
QPopupMenu* pContextMenu = new QPopupMenu(this); |
427 |
|
|
428 |
|
bool bClient = (m_pClient != NULL); |
429 |
|
bool bEnabled = (pItem != NULL); |
430 |
|
iItemID = pContextMenu->insertItem( |
431 |
|
QIconSet(QPixmap::fromMimeSource("deviceCreate.png")), |
432 |
|
tr("&Create device"), this, SLOT(createDevice())); |
433 |
|
pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice)); |
434 |
|
iItemID = pContextMenu->insertItem( |
435 |
|
QIconSet(QPixmap::fromMimeSource("deviceDelete.png")), |
436 |
|
tr("&Delete device"), this, SLOT(deleteDevice())); |
437 |
|
pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice); |
438 |
|
pContextMenu->insertSeparator(); |
439 |
|
iItemID = pContextMenu->insertItem( |
440 |
|
QIconSet(QPixmap::fromMimeSource("formRefresh.png")), |
441 |
|
tr("&Refresh"), this, SLOT(refreshDevices())); |
442 |
|
pContextMenu->setItemEnabled(iItemID, bClient); |
443 |
|
|
444 |
|
pContextMenu->exec(pos); |
445 |
|
|
446 |
|
delete pContextMenu; |
447 |
} |
} |
448 |
|
|
449 |
|
|
450 |
// Stabilize current form state. |
// Stabilize current form state. |
451 |
void qsamplerDeviceForm::stabilizeForm (void) |
void qsamplerDeviceForm::stabilizeForm (void) |
452 |
{ |
{ |
453 |
// Update the main caption... |
QListViewItem *pItem = DeviceListView->selectedItem(); |
454 |
QString sDevicesName = devicesName(m_sFilename); |
bool bClient = (m_pClient != NULL); |
455 |
if (m_iDirtyCount > 0) |
bool bEnabled = (pItem != NULL); |
456 |
sDevicesName += '*'; |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
457 |
setCaption(tr("Devices - [%1]").arg(sDevicesName)); |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
458 |
|
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
459 |
// |
DeviceParamTable->setEnabled(bEnabled); |
460 |
// TODO: Enable/disable available command buttons. |
RefreshDevicesPushButton->setEnabled(bClient); |
461 |
// |
CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice)); |
462 |
m_pMainForm->appendMessages("qsamplerDeviceForm::stabilizeForm()"); |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
|
|
|
|
SaveDevicesPushButton->setEnabled(m_iDirtyCount > 0); |
|
|
|
|
|
CreateDevicePushButton->setEnabled(m_iDirtyCount > 0); |
|
|
UpdateDevicePushButton->setEnabled(m_iDirtyCount > 0); |
|
|
DeleteDevicePushButton->setEnabled(m_iDirtyCount > 0); |
|
463 |
} |
} |
464 |
|
|
465 |
|
|
466 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
467 |
|
|
468 |
|
|
469 |
|
|