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 |
|
|
28 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
29 |
|
|
33 |
// Kind of constructor. |
// Kind of constructor. |
34 |
void qsamplerDeviceForm::init (void) |
void qsamplerDeviceForm::init (void) |
35 |
{ |
{ |
36 |
// Initialize locals. |
// Initialize locals. |
37 |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget(); |
38 |
m_pClient = NULL; |
m_pClient = NULL; |
39 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
40 |
m_iDirtyCount = 0; |
m_bNewDevice = false; |
41 |
m_iUntitled = 1; |
m_deviceType = qsamplerDevice::None; |
42 |
|
m_pAudioItems = NULL; |
43 |
// Try to restore normal window positioning. |
m_pMidiItems = NULL; |
44 |
adjustSize(); |
|
45 |
|
// This an outsider (from designer), but rather important. |
46 |
|
QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), |
47 |
|
this, SLOT(changeValue(int,int))); |
48 |
|
|
49 |
|
// Try to restore normal window positioning. |
50 |
|
adjustSize(); |
51 |
} |
} |
52 |
|
|
53 |
|
|
60 |
// Notify our parent that we're emerging. |
// Notify our parent that we're emerging. |
61 |
void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent ) |
void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent ) |
62 |
{ |
{ |
63 |
if (m_pMainForm) |
if (m_pMainForm) |
64 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
65 |
|
|
66 |
stabilizeForm(); |
stabilizeForm(); |
67 |
|
|
68 |
QWidget::showEvent(pShowEvent); |
QWidget::showEvent(pShowEvent); |
69 |
} |
} |
70 |
|
|
71 |
|
|
72 |
// Notify our parent that we're closing. |
// Notify our parent that we're closing. |
73 |
void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent ) |
void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent ) |
74 |
{ |
{ |
75 |
QWidget::hideEvent(pHideEvent); |
QWidget::hideEvent(pHideEvent); |
76 |
|
|
77 |
if (m_pMainForm) |
if (m_pMainForm) |
78 |
m_pMainForm->stabilizeForm(); |
m_pMainForm->stabilizeForm(); |
79 |
} |
} |
80 |
|
|
81 |
|
|
84 |
{ |
{ |
85 |
// If it has not changed, do nothing. |
// If it has not changed, do nothing. |
86 |
if (m_pClient && m_pClient == pClient) |
if (m_pClient && m_pClient == pClient) |
87 |
return; |
return; |
88 |
|
|
89 |
// Set new reference. |
// Set new reference. |
90 |
m_pClient = pClient; |
m_pClient = pClient; |
94 |
} |
} |
95 |
|
|
96 |
|
|
97 |
// Format the displayable device configuration filename. |
// Create a new device from current table view. |
98 |
QString qsamplerDeviceForm::devicesName ( const QString& sFilename ) |
void qsamplerDeviceForm::createDevice (void) |
99 |
{ |
{ |
100 |
QString sDevicesName = sFilename; |
QListViewItem *pItem = DeviceListView->selectedItem(); |
101 |
qsamplerOptions *pOptions = m_pMainForm->options(); |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
102 |
if (pOptions) { |
return; |
103 |
bool bCompletePath = (pOptions && pOptions->bCompletePath); |
|
104 |
if (sDevicesName.isEmpty()) |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
105 |
sDevicesName = tr("Untitled") + QString::number(m_iUntitled); |
|
106 |
else if (!bCompletePath) |
// Build the parameter list... |
107 |
sDevicesName = QFileInfo(sDevicesName).fileName(); |
qsamplerDeviceParamMap& params = device.params(); |
108 |
|
lscp_param_t *pParams = new lscp_param_t [params.count() + 1]; |
109 |
|
int iParam = 0; |
110 |
|
qsamplerDeviceParamMap::ConstIterator iter; |
111 |
|
for (iter = params.begin(); iter != params.end(); ++iter) { |
112 |
|
pParams[iParam].key = (char *) iter.key().latin1(); |
113 |
|
pParams[iParam].value = (char *) iter.data().value.latin1(); |
114 |
|
++iParam; |
115 |
|
} |
116 |
|
// Null terminated. |
117 |
|
pParams[iParam].key = NULL; |
118 |
|
pParams[iParam].value = NULL; |
119 |
|
|
120 |
|
// Now it depends on the device type... |
121 |
|
qsamplerDeviceItem *pRootItem = NULL; |
122 |
|
int iDeviceID = -1; |
123 |
|
switch (device.deviceType()) { |
124 |
|
case qsamplerDevice::Audio: |
125 |
|
pRootItem = m_pAudioItems; |
126 |
|
if ((iDeviceID = ::lscp_create_audio_device(m_pClient, |
127 |
|
device.driverName().latin1(), pParams)) < 0) |
128 |
|
m_pMainForm->appendMessagesClient("lscp_create_audio_device"); |
129 |
|
break; |
130 |
|
case qsamplerDevice::Midi: |
131 |
|
pRootItem = m_pMidiItems; |
132 |
|
if ((iDeviceID = ::lscp_create_midi_device(m_pClient, |
133 |
|
device.driverName().latin1(), pParams)) < 0) |
134 |
|
m_pMainForm->appendMessagesClient("lscp_create_midi_device"); |
135 |
|
break; |
136 |
|
case qsamplerDevice::None: |
137 |
|
break; |
138 |
} |
} |
|
return sDevicesName; |
|
|
} |
|
|
|
|
|
|
|
|
// Window close event handlers. |
|
|
bool qsamplerDeviceForm::queryClose (void) |
|
|
{ |
|
|
bool bQueryClose = true; |
|
139 |
|
|
140 |
if (m_iDirtyCount > 0) { |
// Free used parameter array. |
141 |
switch (QMessageBox::warning(this, tr("Warning"), |
delete pParams; |
|
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; |
|
|
} |
|
|
} |
|
142 |
|
|
143 |
return bQueryClose; |
// We're on to create the new device item. |
144 |
|
if (iDeviceID >= 0) { |
145 |
|
// Append the new device item. |
146 |
|
qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem, |
147 |
|
m_pClient, device.deviceType(), iDeviceID); |
148 |
|
// Just make it the new selection... |
149 |
|
DeviceListView->setSelected(pDeviceItem, true); |
150 |
|
// Done. |
151 |
|
m_pMainForm->appendMessages(pDeviceItem->device().deviceName() + ' ' |
152 |
|
+ tr("created.")); |
153 |
|
// Main session should be marked dirty. |
154 |
|
m_pMainForm->sessionDirty(); |
155 |
|
} |
156 |
} |
} |
157 |
|
|
158 |
|
|
159 |
|
// Delete current device in table view. |
160 |
// Dirty up settings. |
void qsamplerDeviceForm::deleteDevice (void) |
|
void qsamplerDeviceForm::contentsChanged (void) |
|
161 |
{ |
{ |
162 |
if (m_iDirtySetup > 0) |
QListViewItem *pItem = DeviceListView->selectedItem(); |
163 |
return; |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
164 |
|
return; |
165 |
|
|
166 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
167 |
|
|
168 |
|
// Prompt user if this is for real... |
169 |
|
qsamplerOptions *pOptions = m_pMainForm->options(); |
170 |
|
if (pOptions && pOptions->bConfirmRemove) { |
171 |
|
if (QMessageBox::warning(this, tr("Warning"), |
172 |
|
tr("Delete %1 device:\n\n" |
173 |
|
"%2\n\n" |
174 |
|
"Are you sure?") |
175 |
|
.arg(device.deviceTypeName()) |
176 |
|
.arg(device.deviceName()), |
177 |
|
tr("OK"), tr("Cancel")) > 0) |
178 |
|
return; |
179 |
|
} |
180 |
|
|
181 |
|
// Now it depends on the device type... |
182 |
|
lscp_status_t ret = LSCP_FAILED; |
183 |
|
switch (device.deviceType()) { |
184 |
|
case qsamplerDevice::Audio: |
185 |
|
if ((ret = ::lscp_destroy_audio_device(m_pClient, |
186 |
|
device.deviceID())) != LSCP_OK) |
187 |
|
m_pMainForm->appendMessagesClient("lscp_destroy_audio_device"); |
188 |
|
break; |
189 |
|
case qsamplerDevice::Midi: |
190 |
|
if ((ret = ::lscp_destroy_midi_device(m_pClient, |
191 |
|
device.deviceID())) != LSCP_OK) |
192 |
|
m_pMainForm->appendMessagesClient("lscp_destroy_midi_device"); |
193 |
|
break; |
194 |
|
case qsamplerDevice::None: |
195 |
|
break; |
196 |
|
} |
197 |
|
|
198 |
m_iDirtyCount++; |
// Show result. |
199 |
stabilizeForm(); |
if (ret == LSCP_OK) { |
200 |
|
// Show log message before loosing it. |
201 |
|
m_pMainForm->appendMessages(device.deviceName() + ' ' |
202 |
|
+ tr("deleted.")); |
203 |
|
// Done. |
204 |
|
delete pItem; |
205 |
|
// Main session should be marked dirty. |
206 |
|
m_pMainForm->sessionDirty(); |
207 |
|
} |
208 |
} |
} |
209 |
|
|
210 |
|
|
211 |
// Load device configuration slot. |
// Refresh all device list and views. |
212 |
void qsamplerDeviceForm::loadDevices (void) |
void qsamplerDeviceForm::refreshDevices (void) |
213 |
{ |
{ |
214 |
QString sFilename = QFileDialog::getOpenFileName( |
// Avoid nested changes. |
215 |
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. |
|
|
); |
|
216 |
|
|
217 |
if (sFilename.isEmpty()) |
// |
218 |
return; |
// (Re)Load complete device configuration data ... |
219 |
|
// |
220 |
|
m_pAudioItems = NULL; |
221 |
|
m_pMidiItems = NULL; |
222 |
|
DeviceListView->clear(); |
223 |
|
if (m_pClient) { |
224 |
|
int *piDeviceIDs; |
225 |
|
// Grab and pop Audio devices... |
226 |
|
m_pAudioItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
227 |
|
qsamplerDevice::Audio); |
228 |
|
if (m_pAudioItems) { |
229 |
|
m_pAudioItems->setText(0, tr("Audio")); |
230 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
231 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
232 |
|
new qsamplerDeviceItem(m_pAudioItems, m_pClient, |
233 |
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
234 |
|
} |
235 |
|
m_pAudioItems->setOpen(true); |
236 |
|
} |
237 |
|
// Grab and pop MIDI devices... |
238 |
|
m_pMidiItems = new qsamplerDeviceItem(DeviceListView, m_pClient, |
239 |
|
qsamplerDevice::Midi); |
240 |
|
if (m_pMidiItems) { |
241 |
|
m_pMidiItems->setText(0, tr("MIDI")); |
242 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
243 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
244 |
|
new qsamplerDeviceItem(m_pMidiItems, m_pClient, |
245 |
|
qsamplerDevice::Midi, piDeviceIDs[i]); |
246 |
|
} |
247 |
|
m_pMidiItems->setOpen(true); |
248 |
|
} |
249 |
|
} |
250 |
|
|
251 |
// Check if we're going to discard safely the current one... |
// Done. |
252 |
if (!queryClose()) |
m_iDirtySetup--; |
|
return; |
|
253 |
|
|
254 |
// Load it right away... |
// Show something. |
255 |
loadDevicesFile(sFilename); |
selectDevice(); |
256 |
} |
} |
257 |
|
|
258 |
|
|
259 |
// Save device configuration slot. |
// Driver selection slot. |
260 |
void qsamplerDeviceForm::saveDevices (void) |
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
261 |
{ |
{ |
262 |
QString sFilename = QFileDialog::getSaveFileName( |
if (m_iDirtySetup > 0) |
263 |
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; |
|
264 |
|
|
265 |
// Enforce .xml extension... |
// |
266 |
if (QFileInfo(sFilename).extension().isEmpty()) |
// Driver name has changed for a new device... |
267 |
sFilename += ".lscp"; |
// |
268 |
|
|
269 |
// Save it right away... |
QListViewItem *pItem = DeviceListView->selectedItem(); |
270 |
saveDevicesFile(sFilename); |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
271 |
|
return; |
272 |
|
|
273 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
274 |
|
|
275 |
|
// Driver change is only valid for scratch devices... |
276 |
|
if (m_bNewDevice) { |
277 |
|
m_iDirtySetup++; |
278 |
|
device.setDriver(m_pClient, sDriverName); |
279 |
|
DeviceParamTable->refresh(device); |
280 |
|
m_iDirtySetup--; |
281 |
|
// Done. |
282 |
|
stabilizeForm(); |
283 |
|
} |
284 |
} |
} |
285 |
|
|
286 |
|
|
287 |
// Load device configuration from file. |
// Device selection slot. |
288 |
void qsamplerDeviceForm::loadDevicesFile ( const QString& sFilename ) |
void qsamplerDeviceForm::selectDevice (void) |
289 |
{ |
{ |
290 |
|
if (m_iDirtySetup > 0) |
291 |
|
return; |
292 |
|
|
293 |
// |
// |
294 |
// TODO: Load device configuration from file... |
// Device selection has changed... |
295 |
// |
// |
|
m_pMainForm->appendMessages("qsamplerDeviceForm::loadDevicesFile(\"" + sFilename + "\")..."); |
|
|
|
|
|
m_sFilename = sFilename; |
|
|
m_iDirtyCount = 0; |
|
296 |
|
|
297 |
refreshDevices(); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
298 |
} |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
299 |
|
m_deviceType = qsamplerDevice::None; |
300 |
|
DeviceNameTextLabel->setText(QString::null); |
301 |
|
DeviceParamTable->setNumRows(0); |
302 |
|
stabilizeForm(); |
303 |
|
return; |
304 |
|
} |
305 |
|
|
306 |
|
m_iDirtySetup++; |
307 |
|
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
308 |
|
|
309 |
// Save device configuration into file. |
// Flag whether this is a new device. |
310 |
void qsamplerDeviceForm::saveDevicesFile ( const QString& sFilename ) |
m_bNewDevice = (device.deviceID() < 0); |
|
{ |
|
|
// |
|
|
// TODO: Save device configuration into file... |
|
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::saveDevicesFile(\"" + sFilename + "\")..."); |
|
311 |
|
|
312 |
m_sFilename = sFilename; |
// Fill the device/driver heading... |
313 |
m_iDirtyCount = 0; |
DeviceNameTextLabel->setText(device.deviceTypeName() + ' ' + device.deviceName()); |
314 |
|
// The driver combobox is only rebuilt if device type has changed... |
315 |
|
if (device.deviceType() != m_deviceType) { |
316 |
|
DriverNameComboBox->clear(); |
317 |
|
DriverNameComboBox->insertStringList( |
318 |
|
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
319 |
|
m_deviceType = device.deviceType(); |
320 |
|
} |
321 |
|
// Do we need a driver name? |
322 |
|
if (m_bNewDevice || device.driverName().isEmpty()) |
323 |
|
device.setDriver(m_pClient, DriverNameComboBox->currentText()); |
324 |
|
const QString& sDriverName = device.driverName(); |
325 |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
326 |
|
DriverNameComboBox->insertItem(sDriverName); |
327 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
328 |
|
DriverNameTextLabel->setEnabled(m_bNewDevice); |
329 |
|
DriverNameComboBox->setEnabled(m_bNewDevice); |
330 |
|
// Fill the device parameter table... |
331 |
|
DeviceParamTable->refresh(device); |
332 |
|
// Done. |
333 |
|
m_iDirtySetup--; |
334 |
stabilizeForm(); |
stabilizeForm(); |
335 |
} |
} |
336 |
|
|
337 |
|
|
338 |
// Create a new device from current table view. |
// parameter value change slot. |
339 |
void qsamplerDeviceForm::createDevice (void) |
void qsamplerDeviceForm::changeValue ( int iRow, int iCol ) |
340 |
{ |
{ |
341 |
|
if (m_iDirtySetup > 0) |
342 |
|
return; |
343 |
|
if (iRow < 0 || iCol < 0) |
344 |
|
return; |
345 |
|
|
346 |
// |
// |
347 |
// 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) |
|
|
{ |
|
348 |
// |
// |
|
// TODO: Update current device in table view... |
|
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::updateDevice()..."); |
|
|
} |
|
|
|
|
349 |
|
|
350 |
// Delete current device in table view. |
QListViewItem *pItem = DeviceListView->selectedItem(); |
351 |
void qsamplerDeviceForm::deleteDevice (void) |
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
352 |
{ |
return; |
353 |
// |
|
354 |
// TODO: Delete current device in table view... |
m_iDirtySetup++; |
355 |
// |
qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
356 |
m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()..."); |
|
357 |
} |
// Table 1st column has the parameter name; |
358 |
|
qsamplerDeviceParamMap& params = device.params(); |
359 |
|
const QString sParam = DeviceParamTable->text(iRow, 0); |
360 |
// Refresh all device list and views. |
const QString sValue = DeviceParamTable->text(iRow, iCol); |
361 |
void qsamplerDeviceForm::refreshDevices (void) |
params[sParam].value = sValue; |
362 |
{ |
|
363 |
// Avoid nested changes. |
// Set proper device parameter, on existing device ... |
364 |
m_iDirtySetup++; |
if (device.deviceID() >= 0) { |
365 |
|
// Prepare parameter struct. |
366 |
// |
lscp_param_t param; |
367 |
// TODO: Load device configuration data ... |
param.key = (char *) sParam.latin1(); |
368 |
// |
param.value = (char *) sValue.latin1(); |
369 |
|
// Now it depends on the device type... |
370 |
m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()"); |
lscp_status_t ret = LSCP_FAILED; |
371 |
|
switch (device.deviceType()) { |
372 |
DeviceListView->clear(); |
case qsamplerDevice::Audio: |
373 |
if (m_pClient) { |
if ((ret = ::lscp_set_audio_device_param(m_pClient, |
374 |
qsamplerDeviceItem *pItem; |
device.deviceID(), ¶m)) != LSCP_OK) |
375 |
int *piDeviceIDs; |
m_pMainForm->appendMessagesClient("lscp_set_audio_device_param"); |
376 |
// Grab audio devices... |
break; |
377 |
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
case qsamplerDevice::Midi: |
378 |
qsamplerDevice::Audio); |
if ((ret = ::lscp_set_midi_device_param(m_pClient, |
379 |
if (pItem) { |
device.deviceID(), ¶m)) != LSCP_OK) |
380 |
pItem->setText(0, tr("Audio")); |
m_pMainForm->appendMessagesClient("lscp_set_midi_device_param"); |
381 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
break; |
382 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
case qsamplerDevice::None: |
383 |
new qsamplerDeviceItem(pItem, m_pClient, |
break; |
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
|
|
} |
|
384 |
} |
} |
385 |
// Grab MIDI devices... |
// Show result. |
386 |
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
if (ret == LSCP_OK) { |
387 |
qsamplerDevice::Midi); |
m_pMainForm->appendMessages(device.deviceName() + ' ' |
388 |
if (pItem) { |
+ QString("%1: %2.").arg(sParam).arg(sValue)); |
|
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]); |
|
|
} |
|
389 |
} |
} |
390 |
} |
} |
391 |
|
|
392 |
// Done. |
// Done. |
393 |
m_iDirtySetup--; |
m_iDirtySetup--; |
394 |
// stabilizeForm(); |
stabilizeForm(); |
395 |
} |
// Main session should be dirtier... |
396 |
|
m_pMainForm->sessionDirty(); |
|
// Device selection slot. |
|
|
void qsamplerDeviceForm::selectDevice ( QListViewItem *pItem ) |
|
|
{ |
|
|
if (pItem == NULL) |
|
|
return; |
|
|
if (pItem->rtti() != QSAMPLER_DEVICE_ITEM) |
|
|
return; |
|
|
|
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::selectDevice(" + pItem->text(0) + ")"); |
|
|
|
|
|
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
|
|
DeviceParamTable->setDevice(m_pClient, |
|
|
device.deviceType(), device.deviceID()); |
|
397 |
} |
} |
398 |
|
|
399 |
|
|
400 |
// Stabilize current form state. |
// Stabilize current form state. |
401 |
void qsamplerDeviceForm::stabilizeForm (void) |
void qsamplerDeviceForm::stabilizeForm (void) |
402 |
{ |
{ |
403 |
// Update the main caption... |
QListViewItem *pItem = DeviceListView->selectedItem(); |
404 |
QString sDevicesName = devicesName(m_sFilename); |
bool bEnabled = (pItem != NULL); |
405 |
if (m_iDirtyCount > 0) |
DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice); |
406 |
sDevicesName += '*'; |
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
407 |
setCaption(tr("Devices - [%1]").arg(sDevicesName)); |
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
408 |
|
DeviceParamTable->setEnabled(bEnabled); |
409 |
// |
CreateDevicePushButton->setEnabled(bEnabled || m_bNewDevice); |
410 |
// TODO: Enable/disable available command buttons. |
DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); |
|
// |
|
|
m_pMainForm->appendMessages("qsamplerDeviceForm::stabilizeForm()"); |
|
|
|
|
|
SaveDevicesPushButton->setEnabled(m_iDirtyCount > 0); |
|
|
|
|
|
CreateDevicePushButton->setEnabled(m_iDirtyCount > 0); |
|
|
UpdateDevicePushButton->setEnabled(m_iDirtyCount > 0); |
|
|
DeleteDevicePushButton->setEnabled(m_iDirtyCount > 0); |
|
411 |
} |
} |
412 |
|
|
413 |
|
|
414 |
// end of qsamplerDeviceForm.ui.h |
// end of qsamplerDeviceForm.ui.h |
|
|
|