--- qsampler/trunk/src/qsamplerInstrumentForm.cpp 2007/12/06 09:35:33 1558 +++ qsampler/trunk/src/qsamplerInstrumentForm.cpp 2010/07/15 17:01:35 2109 @@ -1,7 +1,7 @@ // qsamplerInstrumentForm.cpp // /**************************************************************************** - Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2003-2010, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2007, Christian Schoenebeck This program is free software; you can redistribute it and/or @@ -27,8 +27,9 @@ #include "qsamplerChannel.h" #include "qsamplerMainForm.h" -#include #include +#include +#include // Needed for lroundf() #include @@ -50,7 +51,7 @@ // QSampler::InstrumentForm -- Instrument map item form implementation. // -InstrumentForm::InstrumentForm ( QWidget* pParent ) +InstrumentForm::InstrumentForm ( QWidget *pParent ) : QDialog(pParent) { m_ui.setupUi(this); @@ -96,11 +97,11 @@ QObject::connect(m_ui.LoadModeComboBox, SIGNAL(activated(int)), SLOT(changed())); - QObject::connect(m_ui.OkPushButton, - SIGNAL(clicked()), + QObject::connect(m_ui.DialogButtonBox, + SIGNAL(accepted()), SLOT(accept())); - QObject::connect(m_ui.CancelPushButton, - SIGNAL(clicked()), + QObject::connect(m_ui.DialogButtonBox, + SIGNAL(rejected()), SLOT(reject())); } @@ -230,10 +231,6 @@ // Done. m_iDirtySetup--; stabilizeForm(); - - // Done. - m_iDirtySetup--; - stabilizeForm(); } @@ -261,10 +258,17 @@ // FIXME: the instrument file filters should be restricted, // depending on the current engine. + QStringList filters; + filters << tr("GIG Instrument files") + " (*.gig *.dls)"; + filters << tr("SFZ Instrument files") + " (*.sfz)"; + filters << tr("SF2 Instrument files") + " (*.sf2)"; + filters << tr("All files") + " (*.*)"; + const QString& filter = filters.join(";;"); + QString sInstrumentFile = QFileDialog::getOpenFileName(this, QSAMPLER_TITLE ": " + tr("Instrument files"), // Caption. - pOptions->sInstrumentDir, // Start here. - tr("Instrument files") + " (*.gig *.dls)" // Filter (GIG and DLS files) + pOptions->sInstrumentDir, // Start here. + filter // File filter. ); if (sInstrumentFile.isEmpty()) @@ -364,16 +368,18 @@ bool bReject = true; // Check if there's any pending changes... - if (m_iDirtyCount > 0 && m_ui.OkPushButton->isEnabled()) { + if (m_iDirtyCount > 0) { switch (QMessageBox::warning(this, QSAMPLER_TITLE ": " + tr("Warning"), tr("Some channel settings have been changed.\n\n" "Do you want to apply the changes?"), - tr("Apply"), tr("Discard"), tr("Cancel"))) { - case 0: // Apply... + QMessageBox::Apply | + QMessageBox::Discard | + QMessageBox::Cancel)) { + case QMessageBox::Apply: accept(); return; - case 1: // Discard + case QMessageBox::Discard: break; default: // Cancel. bReject = false; @@ -400,16 +406,15 @@ // Stabilize current form state. void InstrumentForm::stabilizeForm (void) { - bool bValid = - !m_ui.NameLineEdit->text().isEmpty() && - m_ui.EngineNameComboBox->currentIndex() >= 0 && - m_ui.EngineNameComboBox->currentText() != - Channel::noEngineName(); + bool bValid = !m_ui.NameLineEdit->text().isEmpty() + && m_ui.EngineNameComboBox->currentIndex() >= 0 + && m_ui.EngineNameComboBox->currentText() != Channel::noEngineName(); const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); - m_ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid); + m_ui.DialogButtonBox->button( + QDialogButtonBox::Ok)->setEnabled(m_iDirtyCount > 0 && bValid); } } // namespace QSampler