1 |
capela |
1464 |
// qsamplerChannelForm.cpp |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
2387 |
Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
schoenebeck |
1710 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
capela |
1464 |
|
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 along |
18 |
|
|
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
|
21 |
|
|
*****************************************************************************/ |
22 |
|
|
|
23 |
schoenebeck |
1461 |
#include "qsamplerChannelForm.h" |
24 |
|
|
|
25 |
|
|
#include "qsamplerAbout.h" |
26 |
|
|
#include "qsamplerDeviceForm.h" |
27 |
|
|
|
28 |
|
|
#include "qsamplerMainForm.h" |
29 |
|
|
#include "qsamplerInstrument.h" |
30 |
|
|
|
31 |
capela |
1499 |
#include <QValidator> |
32 |
|
|
#include <QMessageBox> |
33 |
|
|
#include <QFileDialog> |
34 |
|
|
#include <QFileInfo> |
35 |
schoenebeck |
1461 |
|
36 |
capela |
1499 |
#include <QHeaderView> |
37 |
|
|
|
38 |
|
|
|
39 |
schoenebeck |
1461 |
namespace QSampler { |
40 |
|
|
|
41 |
capela |
1558 |
//------------------------------------------------------------------------- |
42 |
|
|
// QSampler::Channelform -- Channel form implementation. |
43 |
|
|
// |
44 |
|
|
|
45 |
capela |
1509 |
ChannelForm::ChannelForm ( QWidget* pParent ) |
46 |
|
|
: QDialog(pParent) |
47 |
|
|
{ |
48 |
capela |
1510 |
m_ui.setupUi(this); |
49 |
schoenebeck |
1461 |
|
50 |
|
|
// Initialize locals. |
51 |
|
|
m_pChannel = NULL; |
52 |
|
|
|
53 |
|
|
m_iDirtySetup = 0; |
54 |
|
|
m_iDirtyCount = 0; |
55 |
|
|
|
56 |
capela |
1499 |
// m_midiDevices.setAutoDelete(true); |
57 |
|
|
// m_audioDevices.setAutoDelete(true); |
58 |
schoenebeck |
1461 |
|
59 |
|
|
m_pDeviceForm = NULL; |
60 |
|
|
|
61 |
capela |
1519 |
int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4; |
62 |
|
|
m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight); |
63 |
|
|
m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
64 |
|
|
|
65 |
capela |
1509 |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
66 |
|
|
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
67 |
capela |
2388 |
#if QT_VERSION >= 0x050000 |
68 |
|
|
m_ui.AudioRoutingTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); |
69 |
|
|
else |
70 |
capela |
1509 |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
71 |
capela |
2387 |
#endif |
72 |
capela |
1509 |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
73 |
|
|
|
74 |
|
|
// This goes initially hidden, and will be shown |
75 |
capela |
1510 |
// on setup() for currently existing channels... |
76 |
capela |
1509 |
m_ui.AudioRoutingTable->hide(); |
77 |
|
|
|
78 |
schoenebeck |
1461 |
// Try to restore normal window positioning. |
79 |
|
|
adjustSize(); |
80 |
capela |
1466 |
|
81 |
capela |
1509 |
QObject::connect(m_ui.EngineNameComboBox, |
82 |
capela |
1466 |
SIGNAL(activated(int)), |
83 |
|
|
SLOT(optionsChanged())); |
84 |
capela |
1509 |
QObject::connect(m_ui.InstrumentFileComboBox, |
85 |
schoenebeck |
1474 |
SIGNAL(activated(const QString&)), |
86 |
capela |
1466 |
SLOT(updateInstrumentName())); |
87 |
capela |
1509 |
QObject::connect(m_ui.InstrumentFileToolButton, |
88 |
capela |
1466 |
SIGNAL(clicked()), |
89 |
|
|
SLOT(openInstrumentFile())); |
90 |
capela |
1509 |
QObject::connect(m_ui.InstrumentNrComboBox, |
91 |
capela |
1466 |
SIGNAL(activated(int)), |
92 |
|
|
SLOT(optionsChanged())); |
93 |
capela |
1509 |
QObject::connect(m_ui.MidiDriverComboBox, |
94 |
schoenebeck |
1474 |
SIGNAL(activated(const QString&)), |
95 |
|
|
SLOT(selectMidiDriver(const QString&))); |
96 |
capela |
1509 |
QObject::connect(m_ui.MidiDeviceComboBox, |
97 |
capela |
1466 |
SIGNAL(activated(int)), |
98 |
|
|
SLOT(selectMidiDevice(int))); |
99 |
capela |
1509 |
QObject::connect(m_ui.MidiPortSpinBox, |
100 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
101 |
|
|
SLOT(optionsChanged())); |
102 |
capela |
1509 |
QObject::connect(m_ui.MidiChannelComboBox, |
103 |
capela |
1466 |
SIGNAL(activated(int)), |
104 |
|
|
SLOT(optionsChanged())); |
105 |
capela |
1509 |
QObject::connect(m_ui.MidiMapComboBox, |
106 |
capela |
1466 |
SIGNAL(activated(int)), |
107 |
|
|
SLOT(optionsChanged())); |
108 |
capela |
1509 |
QObject::connect(m_ui.AudioDriverComboBox, |
109 |
schoenebeck |
1474 |
SIGNAL(activated(const QString&)), |
110 |
|
|
SLOT(selectAudioDriver(const QString&))); |
111 |
capela |
1509 |
QObject::connect(m_ui.AudioDeviceComboBox, |
112 |
capela |
1466 |
SIGNAL(activated(int)), |
113 |
|
|
SLOT(selectAudioDevice(int))); |
114 |
capela |
2107 |
QObject::connect(m_ui.DialogButtonBox, |
115 |
|
|
SIGNAL(accepted()), |
116 |
capela |
1466 |
SLOT(accept())); |
117 |
capela |
2107 |
QObject::connect(m_ui.DialogButtonBox, |
118 |
|
|
SIGNAL(rejected()), |
119 |
capela |
1466 |
SLOT(reject())); |
120 |
capela |
1509 |
QObject::connect(m_ui.MidiDeviceToolButton, |
121 |
capela |
1466 |
SIGNAL(clicked()), |
122 |
|
|
SLOT(setupMidiDevice())); |
123 |
capela |
1509 |
QObject::connect(m_ui.AudioDeviceToolButton, |
124 |
capela |
1466 |
SIGNAL(clicked()), |
125 |
|
|
SLOT(setupAudioDevice())); |
126 |
capela |
1509 |
QObject::connect(&m_routingModel, |
127 |
schoenebeck |
1489 |
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
128 |
|
|
SLOT(optionsChanged())); |
129 |
capela |
1509 |
QObject::connect(&m_routingModel, |
130 |
schoenebeck |
1489 |
SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
131 |
|
|
SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&))); |
132 |
capela |
1509 |
QObject::connect(&m_routingModel, |
133 |
schoenebeck |
1489 |
SIGNAL(modelReset()), |
134 |
|
|
SLOT(updateTableCellRenderers())); |
135 |
schoenebeck |
1461 |
} |
136 |
|
|
|
137 |
capela |
1499 |
ChannelForm::~ChannelForm() |
138 |
|
|
{ |
139 |
schoenebeck |
1461 |
if (m_pDeviceForm) |
140 |
|
|
delete m_pDeviceForm; |
141 |
|
|
m_pDeviceForm = NULL; |
142 |
capela |
1499 |
|
143 |
|
|
qDeleteAll(m_midiDevices); |
144 |
|
|
m_midiDevices.clear(); |
145 |
|
|
|
146 |
|
|
qDeleteAll(m_audioDevices); |
147 |
|
|
m_audioDevices.clear(); |
148 |
schoenebeck |
1461 |
} |
149 |
|
|
|
150 |
|
|
|
151 |
|
|
// Channel dialog setup formal initializer. |
152 |
capela |
1558 |
void ChannelForm::setup ( Channel *pChannel ) |
153 |
schoenebeck |
1461 |
{ |
154 |
|
|
m_pChannel = pChannel; |
155 |
|
|
|
156 |
|
|
m_iDirtySetup = 0; |
157 |
|
|
m_iDirtyCount = 0; |
158 |
|
|
|
159 |
|
|
if (m_pChannel == NULL) |
160 |
|
|
return; |
161 |
|
|
|
162 |
|
|
// It can be a brand new channel, remember? |
163 |
schoenebeck |
1710 |
const bool bNew = (m_pChannel->channelID() < 0); |
164 |
capela |
1499 |
setWindowTitle(QSAMPLER_TITLE ": " + m_pChannel->channelName()); |
165 |
schoenebeck |
1461 |
|
166 |
|
|
// Check if we're up and connected. |
167 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
168 |
|
|
if (pMainForm == NULL) |
169 |
|
|
return; |
170 |
|
|
if (pMainForm->client() == NULL) |
171 |
|
|
return; |
172 |
|
|
|
173 |
capela |
1558 |
Options *pOptions = pMainForm->options(); |
174 |
schoenebeck |
1461 |
if (pOptions == NULL) |
175 |
|
|
return; |
176 |
|
|
|
177 |
|
|
// Avoid nested changes. |
178 |
|
|
m_iDirtySetup++; |
179 |
|
|
|
180 |
|
|
// Load combo box history... |
181 |
capela |
1509 |
pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox); |
182 |
schoenebeck |
1461 |
|
183 |
|
|
// Populate Engines list. |
184 |
|
|
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
185 |
|
|
if (ppszEngines) { |
186 |
capela |
1509 |
m_ui.EngineNameComboBox->clear(); |
187 |
schoenebeck |
1461 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
188 |
capela |
1509 |
m_ui.EngineNameComboBox->addItem(QString(ppszEngines[iEngine])); |
189 |
schoenebeck |
1461 |
} |
190 |
|
|
else m_pChannel->appendMessagesClient("lscp_list_available_engines"); |
191 |
|
|
|
192 |
|
|
// Populate Audio output type list. |
193 |
capela |
1509 |
m_ui.AudioDriverComboBox->clear(); |
194 |
|
|
m_ui.AudioDriverComboBox->insertItems(0, |
195 |
capela |
1558 |
Device::getDrivers(pMainForm->client(), Device::Audio)); |
196 |
schoenebeck |
1461 |
|
197 |
|
|
// Populate MIDI input type list. |
198 |
capela |
1509 |
m_ui.MidiDriverComboBox->clear(); |
199 |
|
|
m_ui.MidiDriverComboBox->insertItems(0, |
200 |
capela |
1558 |
Device::getDrivers(pMainForm->client(), Device::Midi)); |
201 |
schoenebeck |
1461 |
|
202 |
|
|
// Populate Maps list. |
203 |
capela |
1509 |
m_ui.MidiMapComboBox->clear(); |
204 |
|
|
m_ui.MidiMapComboBox->insertItems(0, |
205 |
capela |
1558 |
Instrument::getMapNames()); |
206 |
schoenebeck |
1461 |
|
207 |
|
|
// Read proper channel information, |
208 |
|
|
// and populate the channel form fields. |
209 |
|
|
|
210 |
|
|
// Engine name... |
211 |
|
|
QString sEngineName = pChannel->engineName(); |
212 |
|
|
if (sEngineName.isEmpty() || bNew) |
213 |
|
|
sEngineName = pOptions->sEngineName; |
214 |
|
|
if (sEngineName.isEmpty()) |
215 |
capela |
1558 |
sEngineName = Channel::noEngineName(); |
216 |
capela |
1509 |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
217 |
schoenebeck |
1474 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
218 |
capela |
1509 |
m_ui.EngineNameComboBox->addItem(sEngineName); |
219 |
schoenebeck |
1461 |
} |
220 |
capela |
1509 |
m_ui.EngineNameComboBox->setCurrentIndex( |
221 |
|
|
m_ui.EngineNameComboBox->findText(sEngineName, |
222 |
schoenebeck |
1474 |
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
223 |
capela |
1504 |
|
224 |
schoenebeck |
1461 |
// Instrument filename and index... |
225 |
|
|
QString sInstrumentFile = pChannel->instrumentFile(); |
226 |
|
|
if (sInstrumentFile.isEmpty()) |
227 |
capela |
1558 |
sInstrumentFile = Channel::noInstrumentName(); |
228 |
capela |
1509 |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
229 |
|
|
m_ui.InstrumentNrComboBox->clear(); |
230 |
|
|
m_ui.InstrumentNrComboBox->insertItems(0, |
231 |
capela |
1558 |
Channel::getInstrumentList(sInstrumentFile, |
232 |
schoenebeck |
1461 |
pOptions->bInstrumentNames)); |
233 |
capela |
1510 |
int iInstrumentNr = pChannel->instrumentNr(); |
234 |
|
|
if (iInstrumentNr < 0) |
235 |
|
|
iInstrumentNr = 0; |
236 |
|
|
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
237 |
schoenebeck |
1461 |
|
238 |
|
|
// MIDI input device... |
239 |
capela |
1558 |
Device midiDevice(Device::Midi, m_pChannel->midiDevice()); |
240 |
schoenebeck |
1461 |
// MIDI input driver... |
241 |
|
|
QString sMidiDriver = midiDevice.driverName(); |
242 |
|
|
if (sMidiDriver.isEmpty() || bNew) |
243 |
capela |
1499 |
sMidiDriver = pOptions->sMidiDriver.toUpper(); |
244 |
schoenebeck |
1461 |
if (!sMidiDriver.isEmpty()) { |
245 |
capela |
1509 |
if (m_ui.MidiDriverComboBox->findText(sMidiDriver, |
246 |
schoenebeck |
1474 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
247 |
capela |
1509 |
m_ui.MidiDriverComboBox->insertItem(0, sMidiDriver); |
248 |
schoenebeck |
1461 |
} |
249 |
schoenebeck |
1710 |
m_ui.MidiDriverComboBox->setCurrentIndex( |
250 |
|
|
m_ui.MidiDriverComboBox->findText(sMidiDriver, |
251 |
|
|
Qt::MatchExactly | Qt::MatchCaseSensitive) |
252 |
|
|
); |
253 |
schoenebeck |
1461 |
} |
254 |
|
|
selectMidiDriverItem(sMidiDriver); |
255 |
capela |
1499 |
if (!bNew) { |
256 |
capela |
1509 |
m_ui.MidiDeviceComboBox->setItemText( |
257 |
|
|
m_ui.MidiDeviceComboBox->currentIndex(), |
258 |
capela |
1499 |
midiDevice.deviceName()); |
259 |
|
|
} |
260 |
capela |
1509 |
selectMidiDeviceItem(m_ui.MidiDeviceComboBox->currentIndex()); |
261 |
schoenebeck |
1461 |
// MIDI input port... |
262 |
capela |
1509 |
m_ui.MidiPortSpinBox->setValue(pChannel->midiPort()); |
263 |
schoenebeck |
1461 |
// MIDI input channel... |
264 |
|
|
int iMidiChannel = pChannel->midiChannel(); |
265 |
|
|
// When new, try to suggest a sensible MIDI channel... |
266 |
|
|
if (iMidiChannel < 0) |
267 |
|
|
iMidiChannel = (::lscp_get_channels(pMainForm->client()) % 16); |
268 |
capela |
1509 |
m_ui.MidiChannelComboBox->setCurrentIndex(iMidiChannel); |
269 |
schoenebeck |
1461 |
// MIDI instrument map... |
270 |
|
|
int iMidiMap = (bNew ? pOptions->iMidiMap : pChannel->midiMap()); |
271 |
|
|
// When new, try to suggest a sensible MIDI map... |
272 |
|
|
if (iMidiMap < 0) |
273 |
|
|
iMidiMap = 0; |
274 |
capela |
1558 |
const QString& sMapName = Instrument::getMapName(iMidiMap); |
275 |
capela |
1499 |
if (!sMapName.isEmpty()) { |
276 |
capela |
1509 |
m_ui.MidiMapComboBox->setItemText( |
277 |
|
|
m_ui.MidiMapComboBox->currentIndex(), |
278 |
capela |
1499 |
sMapName); |
279 |
|
|
} |
280 |
schoenebeck |
1461 |
// It might be no maps around... |
281 |
capela |
1509 |
bool bMidiMapEnabled = (m_ui.MidiMapComboBox->count() > 0); |
282 |
|
|
m_ui.MidiMapTextLabel->setEnabled(bMidiMapEnabled); |
283 |
|
|
m_ui.MidiMapComboBox->setEnabled(bMidiMapEnabled); |
284 |
schoenebeck |
1461 |
|
285 |
|
|
// Audio output device... |
286 |
capela |
1558 |
Device audioDevice(Device::Audio, m_pChannel->audioDevice()); |
287 |
schoenebeck |
1461 |
// Audio output driver... |
288 |
|
|
QString sAudioDriver = audioDevice.driverName(); |
289 |
|
|
if (sAudioDriver.isEmpty() || bNew) |
290 |
capela |
1499 |
sAudioDriver = pOptions->sAudioDriver.toUpper(); |
291 |
schoenebeck |
1461 |
if (!sAudioDriver.isEmpty()) { |
292 |
capela |
1509 |
if (m_ui.AudioDriverComboBox->findText(sAudioDriver, |
293 |
schoenebeck |
1474 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
294 |
capela |
1509 |
m_ui.AudioDriverComboBox->insertItem(0, sAudioDriver); |
295 |
schoenebeck |
1461 |
} |
296 |
schoenebeck |
1710 |
m_ui.AudioDriverComboBox->setCurrentIndex( |
297 |
|
|
m_ui.AudioDriverComboBox->findText(sAudioDriver, |
298 |
|
|
Qt::MatchExactly | Qt::MatchCaseSensitive) |
299 |
|
|
); |
300 |
schoenebeck |
1461 |
} |
301 |
|
|
selectAudioDriverItem(sAudioDriver); |
302 |
capela |
1499 |
if (!bNew) { |
303 |
capela |
1509 |
m_ui.AudioDeviceComboBox->setItemText( |
304 |
|
|
m_ui.AudioDeviceComboBox->currentIndex(), |
305 |
capela |
1499 |
audioDevice.deviceName()); |
306 |
|
|
} |
307 |
capela |
1509 |
selectAudioDeviceItem(m_ui.AudioDeviceComboBox->currentIndex()); |
308 |
schoenebeck |
1461 |
|
309 |
capela |
1509 |
// Let the audio routing table see the light, |
310 |
|
|
// if we're editing an existing sampler channel... |
311 |
|
|
m_ui.AudioRoutingTable->setVisible(!bNew); |
312 |
|
|
|
313 |
schoenebeck |
1527 |
const QString sInstrumentNrToolTip = |
314 |
|
|
(pOptions->bInstrumentNames) ? |
315 |
|
|
"Select an instrument of the file" : |
316 |
|
|
"You might want to enable instrument name retrieval in the " |
317 |
|
|
"settings dialog"; |
318 |
|
|
m_ui.InstrumentNrComboBox->setToolTip( |
319 |
|
|
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
320 |
|
|
); |
321 |
|
|
|
322 |
schoenebeck |
1461 |
// As convenient, make it ready on stabilizeForm() for |
323 |
|
|
// prompt acceptance, if we got the minimum required... |
324 |
capela |
1558 |
/* if (sEngineName != Channel::noEngineName() && |
325 |
|
|
sInstrumentFile != Channel::noInstrumentName()) |
326 |
schoenebeck |
1461 |
m_iDirtyCount++; */ |
327 |
|
|
// Done. |
328 |
|
|
m_iDirtySetup--; |
329 |
|
|
stabilizeForm(); |
330 |
|
|
} |
331 |
|
|
|
332 |
|
|
|
333 |
|
|
// Accept settings (OK button slot). |
334 |
|
|
void ChannelForm::accept (void) |
335 |
|
|
{ |
336 |
|
|
if (m_pChannel == NULL) |
337 |
|
|
return; |
338 |
|
|
|
339 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
340 |
|
|
if (pMainForm == NULL) |
341 |
|
|
return; |
342 |
|
|
if (pMainForm->client() == NULL) |
343 |
|
|
return; |
344 |
|
|
|
345 |
capela |
1558 |
Options *pOptions = pMainForm->options(); |
346 |
schoenebeck |
1461 |
if (pOptions == NULL) |
347 |
|
|
return; |
348 |
|
|
|
349 |
|
|
// Flush any pending editing... |
350 |
capela |
1509 |
//m_ui.AudioRoutingTable->flush(); |
351 |
schoenebeck |
1461 |
|
352 |
|
|
// We'll go for it! |
353 |
|
|
if (m_iDirtyCount > 0) { |
354 |
|
|
int iErrors = 0; |
355 |
|
|
// Are we a new channel? |
356 |
|
|
if (!m_pChannel->addChannel()) |
357 |
|
|
iErrors++; |
358 |
|
|
// Accept Audio driver or device selection... |
359 |
|
|
if (m_audioDevices.isEmpty()) { |
360 |
capela |
1509 |
if (!m_pChannel->setAudioDriver(m_ui.AudioDriverComboBox->currentText())) |
361 |
schoenebeck |
1461 |
iErrors++; |
362 |
|
|
} else { |
363 |
capela |
1558 |
Device *pDevice = NULL; |
364 |
capela |
1509 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
365 |
capela |
1504 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
366 |
|
|
pDevice = m_audioDevices.at(iAudioItem); |
367 |
capela |
1558 |
ChannelRoutingMap routingMap = m_routingModel.routingMap(); |
368 |
schoenebeck |
1461 |
if (pDevice == NULL) |
369 |
|
|
iErrors++; |
370 |
|
|
else if (!m_pChannel->setAudioDevice(pDevice->deviceID())) |
371 |
|
|
iErrors++; |
372 |
schoenebeck |
1489 |
else if (!routingMap.isEmpty()) { |
373 |
schoenebeck |
1461 |
// Set the audio route changes... |
374 |
capela |
1558 |
ChannelRoutingMap::ConstIterator iter; |
375 |
schoenebeck |
1489 |
for (iter = routingMap.begin(); |
376 |
|
|
iter != routingMap.end(); ++iter) { |
377 |
capela |
1499 |
if (!m_pChannel->setAudioChannel(iter.key(), iter.value())) |
378 |
schoenebeck |
1461 |
iErrors++; |
379 |
|
|
} |
380 |
|
|
} |
381 |
|
|
} |
382 |
|
|
// Accept MIDI driver or device selection... |
383 |
|
|
if (m_midiDevices.isEmpty()) { |
384 |
capela |
1509 |
if (!m_pChannel->setMidiDriver(m_ui.MidiDriverComboBox->currentText())) |
385 |
schoenebeck |
1461 |
iErrors++; |
386 |
|
|
} else { |
387 |
capela |
1558 |
Device *pDevice = NULL; |
388 |
capela |
1509 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
389 |
capela |
1504 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
390 |
|
|
pDevice = m_midiDevices.at(iMidiItem); |
391 |
schoenebeck |
1461 |
if (pDevice == NULL) |
392 |
|
|
iErrors++; |
393 |
|
|
else if (!m_pChannel->setMidiDevice(pDevice->deviceID())) |
394 |
|
|
iErrors++; |
395 |
|
|
} |
396 |
|
|
// MIDI input port number... |
397 |
capela |
1509 |
if (!m_pChannel->setMidiPort(m_ui.MidiPortSpinBox->value())) |
398 |
schoenebeck |
1461 |
iErrors++; |
399 |
|
|
// MIDI input channel... |
400 |
capela |
1509 |
if (!m_pChannel->setMidiChannel(m_ui.MidiChannelComboBox->currentIndex())) |
401 |
schoenebeck |
1461 |
iErrors++; |
402 |
|
|
// Engine name... |
403 |
capela |
1509 |
if (!m_pChannel->loadEngine(m_ui.EngineNameComboBox->currentText())) |
404 |
schoenebeck |
1461 |
iErrors++; |
405 |
|
|
// Instrument file and index... |
406 |
capela |
1509 |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
407 |
schoenebeck |
1461 |
if (!sPath.isEmpty() && QFileInfo(sPath).exists()) { |
408 |
capela |
1509 |
if (!m_pChannel->loadInstrument(sPath, m_ui.InstrumentNrComboBox->currentIndex())) |
409 |
schoenebeck |
1461 |
iErrors++; |
410 |
|
|
} |
411 |
|
|
// MIDI intrument map... |
412 |
capela |
1509 |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
413 |
schoenebeck |
1461 |
iErrors++; |
414 |
|
|
// Show error messages? |
415 |
capela |
1510 |
if (iErrors > 0) { |
416 |
|
|
m_pChannel->appendMessagesError( |
417 |
|
|
tr("Some channel settings could not be set.\n\nSorry.")); |
418 |
|
|
} |
419 |
schoenebeck |
1461 |
} |
420 |
|
|
|
421 |
|
|
// Save default engine name, instrument directory and history... |
422 |
capela |
1499 |
pOptions->sInstrumentDir = QFileInfo( |
423 |
capela |
1509 |
m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath(); |
424 |
|
|
pOptions->sEngineName = m_ui.EngineNameComboBox->currentText(); |
425 |
|
|
pOptions->sAudioDriver = m_ui.AudioDriverComboBox->currentText(); |
426 |
|
|
pOptions->sMidiDriver = m_ui.MidiDriverComboBox->currentText(); |
427 |
|
|
pOptions->iMidiMap = m_ui.MidiMapComboBox->currentIndex(); |
428 |
|
|
pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox); |
429 |
schoenebeck |
1461 |
|
430 |
|
|
// Just go with dialog acceptance. |
431 |
|
|
QDialog::accept(); |
432 |
|
|
} |
433 |
|
|
|
434 |
|
|
|
435 |
|
|
// Reject settings (Cancel button slot). |
436 |
|
|
void ChannelForm::reject (void) |
437 |
|
|
{ |
438 |
|
|
bool bReject = true; |
439 |
|
|
|
440 |
|
|
// Check if there's any pending changes... |
441 |
capela |
2107 |
if (m_iDirtyCount > 0) { |
442 |
schoenebeck |
1461 |
switch (QMessageBox::warning(this, |
443 |
|
|
QSAMPLER_TITLE ": " + tr("Warning"), |
444 |
|
|
tr("Some channel settings have been changed.\n\n" |
445 |
|
|
"Do you want to apply the changes?"), |
446 |
capela |
1840 |
QMessageBox::Apply | |
447 |
|
|
QMessageBox::Discard | |
448 |
|
|
QMessageBox::Cancel)) { |
449 |
|
|
case QMessageBox::Apply: |
450 |
schoenebeck |
1461 |
accept(); |
451 |
|
|
return; |
452 |
capela |
1840 |
case QMessageBox::Discard: |
453 |
schoenebeck |
1461 |
break; |
454 |
|
|
default: // Cancel. |
455 |
|
|
bReject = false; |
456 |
|
|
break; |
457 |
|
|
} |
458 |
|
|
} |
459 |
|
|
|
460 |
|
|
if (bReject) |
461 |
|
|
QDialog::reject(); |
462 |
|
|
} |
463 |
|
|
|
464 |
|
|
|
465 |
|
|
// Browse and open an instrument file. |
466 |
|
|
void ChannelForm::openInstrumentFile (void) |
467 |
|
|
{ |
468 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
469 |
|
|
if (pMainForm == NULL) |
470 |
|
|
return; |
471 |
|
|
if (pMainForm->client() == NULL) |
472 |
|
|
return; |
473 |
|
|
|
474 |
capela |
1558 |
Options *pOptions = pMainForm->options(); |
475 |
schoenebeck |
1461 |
if (pOptions == NULL) |
476 |
|
|
return; |
477 |
|
|
|
478 |
|
|
// FIXME: the instrument file filters should be restricted, |
479 |
|
|
// depending on the current engine. |
480 |
capela |
2108 |
QStringList filters; |
481 |
capela |
2110 |
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
482 |
|
|
if (sEngineName.contains("GIG")) |
483 |
|
|
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
484 |
|
|
if (sEngineName.contains("SFZ")) |
485 |
|
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
486 |
|
|
if (sEngineName.contains("SF2")) |
487 |
|
|
filters << tr("SF2 Instrument files") + " (*.sf2)"; |
488 |
capela |
2108 |
filters << tr("All files") + " (*.*)"; |
489 |
|
|
const QString& filter = filters.join(";;"); |
490 |
|
|
|
491 |
capela |
1499 |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
492 |
|
|
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
493 |
capela |
2108 |
pOptions->sInstrumentDir, // Start here. |
494 |
|
|
filter // File filter. |
495 |
schoenebeck |
1461 |
); |
496 |
|
|
|
497 |
|
|
if (sInstrumentFile.isEmpty()) |
498 |
|
|
return; |
499 |
|
|
|
500 |
capela |
1509 |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
501 |
schoenebeck |
1461 |
updateInstrumentName(); |
502 |
|
|
} |
503 |
|
|
|
504 |
|
|
|
505 |
|
|
// Refresh the actual instrument name. |
506 |
|
|
void ChannelForm::updateInstrumentName (void) |
507 |
|
|
{ |
508 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
509 |
|
|
if (pMainForm == NULL) |
510 |
|
|
return; |
511 |
|
|
if (pMainForm->client() == NULL) |
512 |
|
|
return; |
513 |
|
|
|
514 |
capela |
1558 |
Options *pOptions = pMainForm->options(); |
515 |
schoenebeck |
1461 |
if (pOptions == NULL) |
516 |
|
|
return; |
517 |
|
|
|
518 |
|
|
// Finally this better idea would be to use libgig |
519 |
|
|
// to retrieve the REAL instrument names. |
520 |
capela |
1509 |
m_ui.InstrumentNrComboBox->clear(); |
521 |
|
|
m_ui.InstrumentNrComboBox->insertItems(0, |
522 |
capela |
1558 |
Channel::getInstrumentList( |
523 |
capela |
1509 |
m_ui.InstrumentFileComboBox->currentText(), |
524 |
schoenebeck |
1461 |
pOptions->bInstrumentNames) |
525 |
|
|
); |
526 |
|
|
|
527 |
|
|
optionsChanged(); |
528 |
|
|
} |
529 |
|
|
|
530 |
|
|
|
531 |
|
|
// Show device options dialog. |
532 |
capela |
1558 |
void ChannelForm::setupDevice ( Device *pDevice, |
533 |
|
|
Device::DeviceType deviceTypeMode, |
534 |
schoenebeck |
1461 |
const QString& sDriverName ) |
535 |
|
|
{ |
536 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
537 |
|
|
if (pMainForm == NULL) |
538 |
|
|
return; |
539 |
|
|
if (pMainForm->client() == NULL) |
540 |
|
|
return; |
541 |
|
|
|
542 |
|
|
// Create the device form if not already... |
543 |
|
|
if (m_pDeviceForm == NULL) { |
544 |
|
|
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
545 |
capela |
1510 |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
546 |
schoenebeck |
1461 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
547 |
|
|
this, SLOT(updateDevices())); |
548 |
|
|
} |
549 |
|
|
|
550 |
|
|
// Refresh the device form with selected data. |
551 |
|
|
if (m_pDeviceForm) { |
552 |
|
|
m_pDeviceForm->setDeviceTypeMode(deviceTypeMode); |
553 |
|
|
m_pDeviceForm->refreshDevices(); |
554 |
|
|
m_pDeviceForm->setDevice(pDevice); |
555 |
|
|
m_pDeviceForm->setDriverName(sDriverName); |
556 |
|
|
m_pDeviceForm->show(); |
557 |
|
|
} |
558 |
|
|
} |
559 |
|
|
|
560 |
|
|
|
561 |
|
|
// Refresh MIDI driver item devices. |
562 |
|
|
void ChannelForm::selectMidiDriverItem ( const QString& sMidiDriver ) |
563 |
|
|
{ |
564 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
565 |
|
|
if (pMainForm == NULL) |
566 |
|
|
return; |
567 |
|
|
if (pMainForm->client() == NULL) |
568 |
|
|
return; |
569 |
|
|
|
570 |
capela |
1499 |
const QString sDriverName = sMidiDriver.toUpper(); |
571 |
schoenebeck |
1461 |
|
572 |
|
|
// Save current device id. |
573 |
capela |
1504 |
// Save current device id. |
574 |
schoenebeck |
1461 |
int iDeviceID = 0; |
575 |
capela |
1558 |
Device *pDevice = NULL; |
576 |
capela |
1509 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
577 |
capela |
1504 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
578 |
|
|
pDevice = m_midiDevices.at(iMidiItem); |
579 |
schoenebeck |
1461 |
if (pDevice) |
580 |
|
|
iDeviceID = pDevice->deviceID(); |
581 |
|
|
|
582 |
|
|
// Clean maplist. |
583 |
capela |
1509 |
m_ui.MidiDeviceComboBox->clear(); |
584 |
capela |
1499 |
qDeleteAll(m_midiDevices); |
585 |
schoenebeck |
1461 |
m_midiDevices.clear(); |
586 |
|
|
|
587 |
|
|
// Populate with the current ones... |
588 |
capela |
2074 |
const QPixmap midiPixmap(":/images/midi2.png"); |
589 |
capela |
1558 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
590 |
|
|
Device::Midi); |
591 |
schoenebeck |
1461 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
592 |
capela |
1558 |
pDevice = new Device(Device::Midi, piDeviceIDs[i]); |
593 |
capela |
1499 |
if (pDevice->driverName().toUpper() == sDriverName) { |
594 |
capela |
1510 |
m_ui.MidiDeviceComboBox->insertItem(0, |
595 |
|
|
midiPixmap, pDevice->deviceName()); |
596 |
schoenebeck |
1461 |
m_midiDevices.append(pDevice); |
597 |
|
|
} else { |
598 |
|
|
delete pDevice; |
599 |
|
|
} |
600 |
|
|
} |
601 |
|
|
|
602 |
|
|
// Do proper enabling... |
603 |
|
|
bool bEnabled = !m_midiDevices.isEmpty(); |
604 |
|
|
if (bEnabled) { |
605 |
|
|
// Select the previous current device... |
606 |
capela |
1504 |
iMidiItem = 0; |
607 |
capela |
1558 |
QListIterator<Device *> iter(m_midiDevices); |
608 |
capela |
1499 |
while (iter.hasNext()) { |
609 |
|
|
pDevice = iter.next(); |
610 |
schoenebeck |
1461 |
if (pDevice->deviceID() == iDeviceID) { |
611 |
capela |
1509 |
m_ui.MidiDeviceComboBox->setCurrentIndex(iMidiItem); |
612 |
schoenebeck |
1461 |
selectMidiDeviceItem(iMidiItem); |
613 |
|
|
break; |
614 |
|
|
} |
615 |
|
|
iMidiItem++; |
616 |
|
|
} |
617 |
|
|
} else { |
618 |
capela |
1509 |
m_ui.MidiDeviceComboBox->insertItem(0, |
619 |
schoenebeck |
1461 |
tr("(New MIDI %1 device)").arg(sMidiDriver)); |
620 |
|
|
} |
621 |
capela |
1509 |
m_ui.MidiDeviceTextLabel->setEnabled(bEnabled); |
622 |
|
|
m_ui.MidiDeviceComboBox->setEnabled(bEnabled); |
623 |
schoenebeck |
1461 |
} |
624 |
|
|
|
625 |
|
|
|
626 |
|
|
// Refresh MIDI device options slot. |
627 |
|
|
void ChannelForm::selectMidiDriver ( const QString& sMidiDriver ) |
628 |
|
|
{ |
629 |
|
|
if (m_iDirtySetup > 0) |
630 |
|
|
return; |
631 |
|
|
|
632 |
|
|
selectMidiDriverItem(sMidiDriver); |
633 |
|
|
optionsChanged(); |
634 |
|
|
} |
635 |
|
|
|
636 |
|
|
|
637 |
|
|
// Select MIDI device item. |
638 |
|
|
void ChannelForm::selectMidiDeviceItem ( int iMidiItem ) |
639 |
|
|
{ |
640 |
capela |
1558 |
Device *pDevice = NULL; |
641 |
capela |
1504 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
642 |
|
|
pDevice = m_midiDevices.at(iMidiItem); |
643 |
schoenebeck |
1461 |
if (pDevice) { |
644 |
capela |
1558 |
const DeviceParamMap& params = pDevice->params(); |
645 |
schoenebeck |
1461 |
int iPorts = params["PORTS"].value.toInt(); |
646 |
capela |
1509 |
m_ui.MidiPortTextLabel->setEnabled(iPorts > 0); |
647 |
|
|
m_ui.MidiPortSpinBox->setEnabled(iPorts > 0); |
648 |
schoenebeck |
1461 |
if (iPorts > 0) |
649 |
capela |
1509 |
m_ui.MidiPortSpinBox->setMaximum(iPorts - 1); |
650 |
schoenebeck |
1461 |
} |
651 |
|
|
} |
652 |
|
|
|
653 |
|
|
|
654 |
|
|
// Select MIDI device options slot. |
655 |
|
|
void ChannelForm::selectMidiDevice ( int iMidiItem ) |
656 |
|
|
{ |
657 |
|
|
if (m_iDirtySetup > 0) |
658 |
|
|
return; |
659 |
|
|
|
660 |
|
|
selectMidiDeviceItem(iMidiItem); |
661 |
|
|
optionsChanged(); |
662 |
|
|
} |
663 |
|
|
|
664 |
|
|
|
665 |
|
|
// MIDI device options. |
666 |
|
|
void ChannelForm::setupMidiDevice (void) |
667 |
|
|
{ |
668 |
capela |
1558 |
Device *pDevice = NULL; |
669 |
capela |
1509 |
int iMidiItem = m_ui.MidiDeviceComboBox->currentIndex(); |
670 |
capela |
1504 |
if (iMidiItem >= 0 && iMidiItem < m_midiDevices.count()) |
671 |
|
|
pDevice = m_midiDevices.at(iMidiItem); |
672 |
|
|
setupDevice(pDevice, |
673 |
capela |
1558 |
Device::Midi, m_ui.MidiDriverComboBox->currentText()); |
674 |
schoenebeck |
1461 |
} |
675 |
|
|
|
676 |
|
|
|
677 |
|
|
// Refresh Audio driver item devices. |
678 |
|
|
void ChannelForm::selectAudioDriverItem ( const QString& sAudioDriver ) |
679 |
|
|
{ |
680 |
|
|
MainForm *pMainForm = MainForm::getInstance(); |
681 |
|
|
if (pMainForm == NULL) |
682 |
|
|
return; |
683 |
|
|
if (pMainForm->client() == NULL) |
684 |
|
|
return; |
685 |
|
|
|
686 |
capela |
1499 |
const QString sDriverName = sAudioDriver.toUpper(); |
687 |
schoenebeck |
1461 |
|
688 |
|
|
// Save current device id. |
689 |
|
|
int iDeviceID = 0; |
690 |
capela |
1558 |
Device *pDevice = NULL; |
691 |
capela |
1509 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
692 |
capela |
1504 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
693 |
|
|
pDevice = m_audioDevices.at(iAudioItem); |
694 |
schoenebeck |
1461 |
if (pDevice) |
695 |
|
|
iDeviceID = pDevice->deviceID(); |
696 |
|
|
|
697 |
|
|
// Clean maplist. |
698 |
capela |
1509 |
m_ui.AudioDeviceComboBox->clear(); |
699 |
capela |
1499 |
qDeleteAll(m_audioDevices); |
700 |
schoenebeck |
1461 |
m_audioDevices.clear(); |
701 |
|
|
|
702 |
|
|
// Populate with the current ones... |
703 |
capela |
2074 |
const QPixmap audioPixmap(":/images/audio2.png"); |
704 |
capela |
1558 |
int *piDeviceIDs = Device::getDevices(pMainForm->client(), |
705 |
|
|
Device::Audio); |
706 |
schoenebeck |
1461 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
707 |
capela |
1558 |
pDevice = new Device(Device::Audio, piDeviceIDs[i]); |
708 |
capela |
1499 |
if (pDevice->driverName().toUpper() == sDriverName) { |
709 |
capela |
1510 |
m_ui.AudioDeviceComboBox->insertItem(0, |
710 |
|
|
audioPixmap, pDevice->deviceName()); |
711 |
schoenebeck |
1461 |
m_audioDevices.append(pDevice); |
712 |
|
|
} else { |
713 |
|
|
delete pDevice; |
714 |
|
|
} |
715 |
|
|
} |
716 |
|
|
|
717 |
|
|
// Do proper enabling... |
718 |
|
|
bool bEnabled = !m_audioDevices.isEmpty(); |
719 |
|
|
if (bEnabled) { |
720 |
|
|
// Select the previous current device... |
721 |
capela |
1504 |
iAudioItem = 0; |
722 |
capela |
1558 |
QListIterator<Device *> iter(m_audioDevices); |
723 |
capela |
1499 |
while (iter.hasNext()) { |
724 |
|
|
pDevice = iter.next(); |
725 |
schoenebeck |
1461 |
if (pDevice->deviceID() == iDeviceID) { |
726 |
capela |
1509 |
m_ui.AudioDeviceComboBox->setCurrentIndex(iAudioItem); |
727 |
schoenebeck |
1461 |
selectAudioDeviceItem(iAudioItem); |
728 |
|
|
break; |
729 |
|
|
} |
730 |
|
|
iAudioItem++; |
731 |
|
|
} |
732 |
|
|
} else { |
733 |
capela |
1509 |
m_ui.AudioDeviceComboBox->insertItem(0, |
734 |
schoenebeck |
1461 |
tr("(New Audio %1 device)").arg(sAudioDriver)); |
735 |
capela |
1509 |
//m_ui.AudioRoutingTable->setNumRows(0); |
736 |
schoenebeck |
1461 |
} |
737 |
capela |
1509 |
m_ui.AudioDeviceTextLabel->setEnabled(bEnabled); |
738 |
|
|
m_ui.AudioDeviceComboBox->setEnabled(bEnabled); |
739 |
|
|
m_ui.AudioRoutingTable->setEnabled(bEnabled); |
740 |
schoenebeck |
1461 |
} |
741 |
|
|
|
742 |
|
|
|
743 |
|
|
// Refresh Audio device options slot. |
744 |
|
|
void ChannelForm::selectAudioDriver ( const QString& sAudioDriver ) |
745 |
|
|
{ |
746 |
|
|
if (m_iDirtySetup > 0) |
747 |
|
|
return; |
748 |
|
|
|
749 |
|
|
selectAudioDriverItem(sAudioDriver); |
750 |
|
|
optionsChanged(); |
751 |
|
|
} |
752 |
|
|
|
753 |
|
|
|
754 |
|
|
// Select Audio device item. |
755 |
|
|
void ChannelForm::selectAudioDeviceItem ( int iAudioItem ) |
756 |
|
|
{ |
757 |
capela |
1558 |
Device *pDevice = NULL; |
758 |
capela |
1504 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
759 |
|
|
pDevice = m_audioDevices.at(iAudioItem); |
760 |
schoenebeck |
1461 |
if (pDevice) { |
761 |
|
|
// Refresh the audio routing table. |
762 |
capela |
1509 |
m_routingModel.refresh(pDevice, m_pChannel->audioRouting()); |
763 |
schoenebeck |
1461 |
// Reset routing change map. |
764 |
capela |
1509 |
m_routingModel.clear(); |
765 |
schoenebeck |
1461 |
} |
766 |
|
|
} |
767 |
|
|
|
768 |
|
|
|
769 |
|
|
// Select Audio device options slot. |
770 |
|
|
void ChannelForm::selectAudioDevice ( int iAudioItem ) |
771 |
|
|
{ |
772 |
|
|
if (m_iDirtySetup > 0) |
773 |
|
|
return; |
774 |
|
|
|
775 |
|
|
selectAudioDeviceItem(iAudioItem); |
776 |
|
|
optionsChanged(); |
777 |
|
|
} |
778 |
|
|
|
779 |
|
|
|
780 |
|
|
// Audio device options. |
781 |
|
|
void ChannelForm::setupAudioDevice (void) |
782 |
|
|
{ |
783 |
capela |
1558 |
Device *pDevice = NULL; |
784 |
capela |
1509 |
int iAudioItem = m_ui.AudioDeviceComboBox->currentIndex(); |
785 |
capela |
1504 |
if (iAudioItem >= 0 && iAudioItem < m_audioDevices.count()) |
786 |
|
|
pDevice = m_audioDevices.at(iAudioItem); |
787 |
|
|
setupDevice(pDevice, |
788 |
capela |
1558 |
Device::Audio, m_ui.AudioDriverComboBox->currentText()); |
789 |
schoenebeck |
1461 |
} |
790 |
|
|
|
791 |
|
|
// UPdate all device lists slot. |
792 |
|
|
void ChannelForm::updateDevices (void) |
793 |
|
|
{ |
794 |
|
|
if (m_iDirtySetup > 0) |
795 |
|
|
return; |
796 |
|
|
|
797 |
capela |
1509 |
selectMidiDriverItem(m_ui.MidiDriverComboBox->currentText()); |
798 |
|
|
selectAudioDriverItem(m_ui.AudioDriverComboBox->currentText()); |
799 |
schoenebeck |
1461 |
optionsChanged(); |
800 |
|
|
} |
801 |
|
|
|
802 |
|
|
|
803 |
|
|
// Dirty up settings. |
804 |
|
|
void ChannelForm::optionsChanged (void) |
805 |
|
|
{ |
806 |
|
|
if (m_iDirtySetup > 0) |
807 |
|
|
return; |
808 |
|
|
|
809 |
|
|
m_iDirtyCount++; |
810 |
|
|
stabilizeForm(); |
811 |
|
|
} |
812 |
|
|
|
813 |
|
|
|
814 |
|
|
// Stabilize current form state. |
815 |
|
|
void ChannelForm::stabilizeForm (void) |
816 |
|
|
{ |
817 |
schoenebeck |
1506 |
const bool bValid = |
818 |
capela |
1509 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
819 |
capela |
1510 |
m_ui.EngineNameComboBox->currentText() |
820 |
capela |
1558 |
!= Channel::noEngineName(); |
821 |
schoenebeck |
1461 |
#if 0 |
822 |
|
|
const QString& sPath = InstrumentFileComboBox->currentText(); |
823 |
|
|
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
824 |
|
|
#endif |
825 |
capela |
2107 |
m_ui.DialogButtonBox->button( |
826 |
|
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
827 |
schoenebeck |
1461 |
} |
828 |
|
|
|
829 |
capela |
1509 |
|
830 |
|
|
void ChannelForm::updateTableCellRenderers (void) |
831 |
|
|
{ |
832 |
capela |
1510 |
const int rows = m_routingModel.rowCount(); |
833 |
|
|
const int cols = m_routingModel.columnCount(); |
834 |
|
|
updateTableCellRenderers( |
835 |
capela |
1509 |
m_routingModel.index(0, 0), |
836 |
|
|
m_routingModel.index(rows - 1, cols - 1)); |
837 |
schoenebeck |
1489 |
} |
838 |
schoenebeck |
1461 |
|
839 |
capela |
1509 |
|
840 |
|
|
void ChannelForm::updateTableCellRenderers ( |
841 |
|
|
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
842 |
|
|
{ |
843 |
capela |
1510 |
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
844 |
|
|
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
845 |
|
|
const QModelIndex index = m_routingModel.index(r, c); |
846 |
|
|
m_ui.AudioRoutingTable->openPersistentEditor(index); |
847 |
|
|
} |
848 |
|
|
} |
849 |
schoenebeck |
1489 |
} |
850 |
|
|
|
851 |
schoenebeck |
1461 |
} // namespace QSampler |
852 |
capela |
1464 |
|
853 |
|
|
|
854 |
|
|
// end of qsamplerChannelForm.cpp |