1 |
// qsamplerInstrumentForm.cpp |
// qsamplerInstrumentForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2009, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2010, 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 |
27 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
28 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
29 |
|
|
|
#include <QFileDialog> |
|
30 |
#include <QMessageBox> |
#include <QMessageBox> |
31 |
|
#include <QPushButton> |
32 |
|
#include <QFileDialog> |
33 |
|
|
34 |
// Needed for lroundf() |
// Needed for lroundf() |
35 |
#include <math.h> |
#include <math.h> |
51 |
// QSampler::InstrumentForm -- Instrument map item form implementation. |
// QSampler::InstrumentForm -- Instrument map item form implementation. |
52 |
// |
// |
53 |
|
|
54 |
InstrumentForm::InstrumentForm ( QWidget* pParent ) |
InstrumentForm::InstrumentForm ( QWidget *pParent ) |
55 |
: QDialog(pParent) |
: QDialog(pParent) |
56 |
{ |
{ |
57 |
m_ui.setupUi(this); |
m_ui.setupUi(this); |
97 |
QObject::connect(m_ui.LoadModeComboBox, |
QObject::connect(m_ui.LoadModeComboBox, |
98 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
99 |
SLOT(changed())); |
SLOT(changed())); |
100 |
QObject::connect(m_ui.OkPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
101 |
SIGNAL(clicked()), |
SIGNAL(accepted()), |
102 |
SLOT(accept())); |
SLOT(accept())); |
103 |
QObject::connect(m_ui.CancelPushButton, |
QObject::connect(m_ui.DialogButtonBox, |
104 |
SIGNAL(clicked()), |
SIGNAL(rejected()), |
105 |
SLOT(reject())); |
SLOT(reject())); |
106 |
} |
} |
107 |
|
|
231 |
// Done. |
// Done. |
232 |
m_iDirtySetup--; |
m_iDirtySetup--; |
233 |
stabilizeForm(); |
stabilizeForm(); |
|
|
|
|
// Done. |
|
|
m_iDirtySetup--; |
|
|
stabilizeForm(); |
|
234 |
} |
} |
235 |
|
|
236 |
|
|
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 |
|
const QString& sEngineName = m_ui.EngineNameComboBox->currentText().toUpper(); |
262 |
|
QStringList filters; |
263 |
|
if (sEngineName.contains("GIG")) |
264 |
|
filters << tr("GIG Instrument files") + " (*.gig *.dls)"; |
265 |
|
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, |
QString sInstrumentFile = QFileDialog::getOpenFileName(this, |
272 |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. |
273 |
pOptions->sInstrumentDir, // Start here. |
pOptions->sInstrumentDir, // Start here. |
274 |
tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) |
filter // File filter. |
275 |
); |
); |
276 |
|
|
277 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
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 && m_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" |
409 |
// Stabilize current form state. |
// Stabilize current form state. |
410 |
void InstrumentForm::stabilizeForm (void) |
void InstrumentForm::stabilizeForm (void) |
411 |
{ |
{ |
412 |
bool bValid = |
bool bValid = !m_ui.NameLineEdit->text().isEmpty() |
413 |
!m_ui.NameLineEdit->text().isEmpty() && |
&& m_ui.EngineNameComboBox->currentIndex() >= 0 |
414 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
&& m_ui.EngineNameComboBox->currentText() != Channel::noEngineName(); |
|
m_ui.EngineNameComboBox->currentText() != |
|
|
Channel::noEngineName(); |
|
415 |
|
|
416 |
const QString& sPath = m_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 |
m_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 |