1 |
// qsamplerInstrumentForm.cpp |
// qsamplerInstrumentForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerAbout.h" |
24 |
#include "qsamplerInstrumentForm.h" |
#include "qsamplerInstrumentForm.h" |
25 |
|
|
26 |
#include "qsamplerAbout.h" |
#include "qsamplerOptions.h" |
27 |
|
#include "qsamplerChannel.h" |
28 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
29 |
|
|
30 |
|
#include <QMessageBox> |
31 |
|
#include <QPushButton> |
32 |
|
#include <QFileDialog> |
33 |
|
|
34 |
// Needed for lroundf() |
// Needed for lroundf() |
35 |
#include <math.h> |
#include <math.h> |
36 |
|
|
|
namespace QSampler { |
|
|
|
|
37 |
#ifndef CONFIG_ROUND |
#ifndef CONFIG_ROUND |
38 |
static inline long lroundf ( float x ) |
static inline long lroundf ( float x ) |
39 |
{ |
{ |
44 |
} |
} |
45 |
#endif |
#endif |
46 |
|
|
47 |
InstrumentForm::InstrumentForm(QWidget* parent) : QDialog(parent) { |
|
48 |
ui.setupUi(this); |
namespace QSampler { |
49 |
|
|
50 |
|
//------------------------------------------------------------------------- |
51 |
|
// QSampler::InstrumentForm -- Instrument map item form implementation. |
52 |
|
// |
53 |
|
|
54 |
|
InstrumentForm::InstrumentForm ( QWidget *pParent ) |
55 |
|
: QDialog(pParent) |
56 |
|
{ |
57 |
|
m_ui.setupUi(this); |
58 |
|
|
59 |
// Initialize locals. |
// Initialize locals. |
60 |
m_pInstrument = NULL; |
m_pInstrument = nullptr; |
61 |
|
|
62 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
63 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
67 |
adjustSize(); |
adjustSize(); |
68 |
|
|
69 |
|
|
70 |
QObject::connect(ui.MapComboBox, |
QObject::connect(m_ui.MapComboBox, |
71 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
72 |
SLOT(changed())); |
SLOT(changed())); |
73 |
QObject::connect(ui.BankSpinBox, |
QObject::connect(m_ui.BankSpinBox, |
74 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
75 |
SLOT(changed())); |
SLOT(changed())); |
76 |
QObject::connect(ui.ProgSpinBox, |
QObject::connect(m_ui.ProgSpinBox, |
77 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
78 |
SLOT(changed())); |
SLOT(changed())); |
79 |
QObject::connect(ui.NameLineEdit, |
QObject::connect(m_ui.NameLineEdit, |
80 |
SIGNAL(textChanged(const QString&)), |
SIGNAL(textChanged(const QString&)), |
81 |
SLOT(nameChanged(const QString&))); |
SLOT(nameChanged(const QString&))); |
82 |
QObject::connect(ui.EngineNameComboBox, |
QObject::connect(m_ui.EngineNameComboBox, |
83 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
84 |
SLOT(changed())); |
SLOT(changed())); |
85 |
QObject::connect(ui.InstrumentFileComboBox, |
QObject::connect(m_ui.InstrumentFileComboBox, |
86 |
SIGNAL(activated(const QString&)), |
SIGNAL(activated(const QString&)), |
87 |
SLOT(updateInstrumentName())); |
SLOT(updateInstrumentName())); |
88 |
QObject::connect(ui.InstrumentFileToolButton, |
QObject::connect(m_ui.InstrumentFileToolButton, |
89 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
90 |
SLOT(openInstrumentFile())); |
SLOT(openInstrumentFile())); |
91 |
QObject::connect(ui.InstrumentNrComboBox, |
QObject::connect(m_ui.InstrumentNrComboBox, |
92 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
93 |
SLOT(instrumentNrChanged())); |
SLOT(instrumentNrChanged())); |
94 |
QObject::connect(ui.VolumeSpinBox, |
QObject::connect(m_ui.VolumeSpinBox, |
95 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
96 |
SLOT(changed())); |
SLOT(changed())); |
97 |
QObject::connect(ui.LoadModeComboBox, |
QObject::connect(m_ui.LoadModeComboBox, |
98 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
99 |
SLOT(changed())); |
SLOT(changed())); |
100 |
QObject::connect(ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
101 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
102 |
SLOT(accept())); |
SLOT(accept())); |
103 |
QObject::connect(ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
104 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
105 |
SLOT(reject())); |
SLOT(reject())); |
106 |
} |
} |
107 |
|
|
108 |
InstrumentForm::~InstrumentForm() { |
|
109 |
|
InstrumentForm::~InstrumentForm (void) |
110 |
|
{ |
111 |
} |
} |
112 |
|
|
113 |
|
|
114 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
115 |
void InstrumentForm::setup ( qsamplerInstrument *pInstrument ) |
void InstrumentForm::setup ( Instrument *pInstrument ) |
116 |
{ |
{ |
117 |
m_pInstrument = pInstrument; |
m_pInstrument = pInstrument; |
118 |
|
|
120 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
121 |
m_iDirtyName = 0; |
m_iDirtyName = 0; |
122 |
|
|
123 |
if (m_pInstrument == NULL) |
if (m_pInstrument == nullptr) |
124 |
return; |
return; |
125 |
|
|
126 |
// Check if we're up and connected. |
// Check if we're up and connected. |
127 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
128 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
129 |
return; |
return; |
130 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == nullptr) |
131 |
return; |
return; |
132 |
|
|
133 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
134 |
if (pOptions == NULL) |
if (pOptions == nullptr) |
135 |
return; |
return; |
136 |
|
|
137 |
// It can be a brand new channel, remember? |
// It can be a brand new channel, remember? |
145 |
m_iDirtySetup++; |
m_iDirtySetup++; |
146 |
|
|
147 |
// Load combo box history... |
// Load combo box history... |
148 |
pOptions->loadComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox); |
149 |
|
|
150 |
// Populate maps list. |
// Populate maps list. |
151 |
ui.MapComboBox->clear(); |
m_ui.MapComboBox->clear(); |
152 |
ui.MapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
m_ui.MapComboBox->insertItems(0, Instrument::getMapNames()); |
153 |
|
|
154 |
// Populate Engines list. |
// Populate Engines list. |
155 |
const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client()); |
const char **ppszEngines |
156 |
|
= ::lscp_list_available_engines(pMainForm->client()); |
157 |
if (ppszEngines) { |
if (ppszEngines) { |
158 |
ui.EngineNameComboBox->clear(); |
m_ui.EngineNameComboBox->clear(); |
159 |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
for (int iEngine = 0; ppszEngines[iEngine]; iEngine++) |
160 |
ui.EngineNameComboBox->insertItem(ppszEngines[iEngine]); |
m_ui.EngineNameComboBox->addItem(ppszEngines[iEngine]); |
161 |
} |
} |
162 |
else pMainForm->appendMessagesClient("lscp_list_available_engines"); |
else pMainForm->appendMessagesClient("lscp_list_available_engines"); |
163 |
|
|
168 |
int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map()); |
int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map()); |
169 |
if (iMap < 0) |
if (iMap < 0) |
170 |
iMap = 0; |
iMap = 0; |
171 |
const QString& sMapName = qsamplerInstrument::getMapName(iMap); |
const QString& sMapName = Instrument::getMapName(iMap); |
172 |
if (!sMapName.isEmpty()) |
if (!sMapName.isEmpty()) { |
173 |
ui.MapComboBox->setCurrentText(sMapName); |
m_ui.MapComboBox->setCurrentIndex( |
174 |
|
m_ui.MapComboBox->findText(sMapName, |
175 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
176 |
|
} |
177 |
|
|
178 |
// It might be no maps around... |
// It might be no maps around... |
179 |
bool bMapEnabled = (ui.MapComboBox->count() > 0); |
bool bMapEnabled = (m_ui.MapComboBox->count() > 0); |
180 |
ui.MapTextLabel->setEnabled(bMapEnabled); |
m_ui.MapTextLabel->setEnabled(bMapEnabled); |
181 |
ui.MapComboBox->setEnabled(bMapEnabled); |
m_ui.MapComboBox->setEnabled(bMapEnabled); |
182 |
|
|
183 |
// Instrument bank/program... |
// Instrument bank/program... |
184 |
int iBank = (bNew ? pOptions->iMidiBank : m_pInstrument->bank()); |
int iBank = (bNew ? pOptions->iMidiBank : m_pInstrument->bank()); |
187 |
iProg = 1; |
iProg = 1; |
188 |
iBank++; |
iBank++; |
189 |
} |
} |
190 |
ui.BankSpinBox->setValue(iBank); |
m_ui.BankSpinBox->setValue(iBank); |
191 |
ui.ProgSpinBox->setValue(iProg); |
m_ui.ProgSpinBox->setValue(iProg); |
192 |
|
|
193 |
// Instrument name... |
// Instrument name... |
194 |
ui.NameLineEdit->setText(m_pInstrument->name()); |
m_ui.NameLineEdit->setText(m_pInstrument->name()); |
195 |
|
|
196 |
// Engine name... |
// Engine name... |
197 |
QString sEngineName = m_pInstrument->engineName(); |
QString sEngineName = m_pInstrument->engineName(); |
198 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
199 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
200 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
201 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
202 |
if (ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
203 |
Qt::MatchExactly | Qt::MatchCaseSensitive) == 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
204 |
ui.EngineNameComboBox->insertItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
205 |
} |
} |
206 |
ui.EngineNameComboBox->setCurrentText(sEngineName); |
m_ui.EngineNameComboBox->setCurrentIndex( |
207 |
|
m_ui.EngineNameComboBox->findText(sEngineName, |
208 |
|
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
209 |
|
|
210 |
// Instrument filename and index... |
// Instrument filename and index... |
211 |
QString sInstrumentFile = m_pInstrument->instrumentFile(); |
QString sInstrumentFile = m_pInstrument->instrumentFile(); |
212 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
213 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
214 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
215 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
216 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
217 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
218 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
219 |
ui.InstrumentNrComboBox->setCurrentItem(m_pInstrument->instrumentNr()); |
m_ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr()); |
220 |
|
|
221 |
// Instrument volume.... |
// Instrument volume.... |
222 |
int iVolume = (bNew ? pOptions->iVolume : |
int iVolume = (bNew ? pOptions->iVolume : |
223 |
::lroundf(100.0f * m_pInstrument->volume())); |
::lroundf(100.0f * m_pInstrument->volume())); |
224 |
ui.VolumeSpinBox->setValue(iVolume); |
m_ui.VolumeSpinBox->setValue(iVolume); |
225 |
|
|
226 |
// Instrument load mode... |
// Instrument load mode... |
227 |
int iLoadMode = (bNew ? pOptions->iLoadMode : |
int iLoadMode = (bNew ? pOptions->iLoadMode : |
228 |
m_pInstrument->loadMode()); |
m_pInstrument->loadMode()); |
229 |
ui.LoadModeComboBox->setCurrentItem(iLoadMode); |
m_ui.LoadModeComboBox->setCurrentIndex(iLoadMode); |
|
|
|
|
// Done. |
|
|
m_iDirtySetup--; |
|
|
stabilizeForm(); |
|
230 |
|
|
231 |
// Done. |
// Done. |
232 |
m_iDirtySetup--; |
m_iDirtySetup--; |
249 |
void InstrumentForm::openInstrumentFile (void) |
void InstrumentForm::openInstrumentFile (void) |
250 |
{ |
{ |
251 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
252 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
253 |
return; |
return; |
254 |
|
|
255 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
256 |
if (pOptions == NULL) |
if (pOptions == nullptr) |
257 |
return; |
return; |
258 |
|
|
259 |
// FIXME: the instrument file filters should be restricted, |
// FIXME: the instrument file filters should be restricted, |
260 |
// depending on the current engine. |
// depending on the current engine. |
261 |
QString sInstrumentFile = QFileDialog::getOpenFileName( |
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
262 |
pOptions->sInstrumentDir, // Start here. |
QStringList filters; |
263 |
tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files) |
if (sEngineName.contains("GIG")) |
264 |
this, 0, // Parent and name (none) |
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
265 |
QSAMPLER_TITLE ": " + tr("Instrument files")// Caption. |
if (sEngineName.contains("SFZ")) |
266 |
|
filters << tr("SFZ Instrument files") + " (*.sfz)"; |
267 |
|
if (sEngineName.contains("SF2")) |
268 |
|
filters << tr("SF2 Instrument files") + " (*.sf2)"; |
269 |
|
const QString& filter = filters.join(";;"); |
270 |
|
|
271 |
|
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
272 |
|
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
273 |
|
pOptions->sInstrumentDir, // Start here. |
274 |
|
filter // File filter. |
275 |
); |
); |
276 |
|
|
277 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
278 |
return; |
return; |
279 |
|
|
280 |
ui.InstrumentFileComboBox->setCurrentText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
281 |
updateInstrumentName(); |
updateInstrumentName(); |
282 |
} |
} |
283 |
|
|
286 |
void InstrumentForm::updateInstrumentName (void) |
void InstrumentForm::updateInstrumentName (void) |
287 |
{ |
{ |
288 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
289 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
290 |
return; |
return; |
291 |
|
|
292 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
293 |
if (pOptions == NULL) |
if (pOptions == nullptr) |
294 |
return; |
return; |
295 |
|
|
296 |
// TODO: this better idea would be to use libgig |
// TODO: this better idea would be to use libgig |
297 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
298 |
ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
299 |
ui.InstrumentNrComboBox->insertStringList( |
m_ui.InstrumentNrComboBox->insertItems(0, |
300 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
301 |
ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
302 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
303 |
); |
); |
304 |
|
|
312 |
if (m_iDirtySetup > 0) |
if (m_iDirtySetup > 0) |
313 |
return; |
return; |
314 |
|
|
315 |
if (ui.NameLineEdit->text().isEmpty() || m_iDirtyName == 0) { |
if (m_ui.NameLineEdit->text().isEmpty() || m_iDirtyName == 0) { |
316 |
ui.NameLineEdit->setText(ui.InstrumentNrComboBox->currentText()); |
m_ui.NameLineEdit->setText(m_ui.InstrumentNrComboBox->currentText()); |
317 |
m_iDirtyName = 0; |
m_iDirtyName = 0; |
318 |
} |
} |
319 |
|
|
324 |
// Accept settings (OK button slot). |
// Accept settings (OK button slot). |
325 |
void InstrumentForm::accept (void) |
void InstrumentForm::accept (void) |
326 |
{ |
{ |
327 |
if (m_pInstrument == NULL) |
if (m_pInstrument == nullptr) |
328 |
return; |
return; |
329 |
|
|
330 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
331 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
332 |
return; |
return; |
333 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == nullptr) |
334 |
return; |
return; |
335 |
|
|
336 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
337 |
if (pOptions == NULL) |
if (pOptions == nullptr) |
338 |
return; |
return; |
339 |
|
|
340 |
if (m_iDirtyCount > 0) { |
if (m_iDirtyCount > 0) { |
341 |
m_pInstrument->setMap(ui.MapComboBox->currentItem()); |
m_pInstrument->setMap(m_ui.MapComboBox->currentIndex()); |
342 |
m_pInstrument->setBank(ui.BankSpinBox->value()); |
m_pInstrument->setBank(m_ui.BankSpinBox->value()); |
343 |
m_pInstrument->setProg(ui.ProgSpinBox->value() - 1); |
m_pInstrument->setProg(m_ui.ProgSpinBox->value() - 1); |
344 |
m_pInstrument->setName(ui.NameLineEdit->text()); |
m_pInstrument->setName(m_ui.NameLineEdit->text()); |
345 |
m_pInstrument->setEngineName(ui.EngineNameComboBox->currentText()); |
m_pInstrument->setEngineName(m_ui.EngineNameComboBox->currentText()); |
346 |
m_pInstrument->setInstrumentFile(ui.InstrumentFileComboBox->currentText()); |
m_pInstrument->setInstrumentFile(m_ui.InstrumentFileComboBox->currentText()); |
347 |
m_pInstrument->setInstrumentNr(ui.InstrumentNrComboBox->currentItem()); |
m_pInstrument->setInstrumentNr(m_ui.InstrumentNrComboBox->currentIndex()); |
348 |
m_pInstrument->setVolume(0.01f * float(ui.VolumeSpinBox->value())); |
m_pInstrument->setVolume(0.01f * float(m_ui.VolumeSpinBox->value())); |
349 |
m_pInstrument->setLoadMode(ui.LoadModeComboBox->currentItem()); |
m_pInstrument->setLoadMode(m_ui.LoadModeComboBox->currentIndex()); |
350 |
} |
} |
351 |
|
|
352 |
// Save default engine name, instrument directory and history... |
// Save default engine name, instrument directory and history... |
353 |
pOptions->sInstrumentDir = QFileInfo(ui.InstrumentFileComboBox->currentText()).dirPath(true); |
pOptions->sInstrumentDir = QFileInfo( |
354 |
pOptions->sEngineName = ui.EngineNameComboBox->currentText(); |
m_ui.InstrumentFileComboBox->currentText()).dir().absolutePath(); |
355 |
pOptions->iMidiMap = ui.MapComboBox->currentItem(); |
pOptions->sEngineName = m_ui.EngineNameComboBox->currentText(); |
356 |
pOptions->iMidiBank = ui.BankSpinBox->value(); |
pOptions->iMidiMap = m_ui.MapComboBox->currentIndex(); |
357 |
pOptions->iMidiProg = ui.ProgSpinBox->value(); |
pOptions->iMidiBank = m_ui.BankSpinBox->value(); |
358 |
pOptions->iVolume = ui.VolumeSpinBox->value(); |
pOptions->iMidiProg = m_ui.ProgSpinBox->value(); |
359 |
pOptions->iLoadMode = ui.LoadModeComboBox->currentItem(); |
pOptions->iVolume = m_ui.VolumeSpinBox->value(); |
360 |
pOptions->saveComboBoxHistory(ui.InstrumentFileComboBox); |
pOptions->iLoadMode = m_ui.LoadModeComboBox->currentIndex(); |
361 |
|
pOptions->saveComboBoxHistory(m_ui.InstrumentFileComboBox); |
362 |
|
|
363 |
// Just go with dialog acceptance. |
// Just go with dialog acceptance. |
364 |
QDialog::accept(); |
QDialog::accept(); |
371 |
bool bReject = true; |
bool bReject = true; |
372 |
|
|
373 |
// Check if there's any pending changes... |
// Check if there's any pending changes... |
374 |
if (m_iDirtyCount > 0 && ui.OkPushButton->isEnabled()) { |
if (m_iDirtyCount > 0) { |
375 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
376 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
377 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
378 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
379 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
380 |
case 0: // Apply... |
QMessageBox::Discard | |
381 |
|
QMessageBox::Cancel)) { |
382 |
|
case QMessageBox::Apply: |
383 |
accept(); |
accept(); |
384 |
return; |
return; |
385 |
case 1: // Discard |
case QMessageBox::Discard: |
386 |
break; |
break; |
387 |
default: // Cancel. |
default: // Cancel. |
388 |
bReject = false; |
bReject = false; |
409 |
// Stabilize current form state. |
// Stabilize current form state. |
410 |
void InstrumentForm::stabilizeForm (void) |
void InstrumentForm::stabilizeForm (void) |
411 |
{ |
{ |
412 |
bool bValid = !ui.NameLineEdit->text().isEmpty(); |
bool bValid = !m_ui.NameLineEdit->text().isEmpty() |
413 |
|
&& m_ui.EngineNameComboBox->currentIndex() >= 0 |
414 |
|
&& m_ui.EngineNameComboBox->currentText() != Channel::noEngineName(); |
415 |
|
|
416 |
const QString& sPath = ui.InstrumentFileComboBox->currentText(); |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
417 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
418 |
|
|
419 |
ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); |
m_ui.DialogButtonBox->button( |
420 |
|
QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); |
421 |
} |
} |
422 |
|
|
423 |
} // namespace QSampler |
} // namespace QSampler |