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-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, 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 |
404 |
m_iDirtyCount++; |
m_iDirtyCount++; |
405 |
stabilizeForm(); |
stabilizeForm(); |
406 |
} // Otherwise, load an usual session file (LSCP script)... |
} // Otherwise, load an usual session file (LSCP script)... |
407 |
else if (closeSession(true)) |
else if (closeSession(true)) { |
408 |
loadSessionFile(sPath); |
loadSessionFile(sPath); |
409 |
|
break; |
410 |
|
} |
411 |
// Make it look responsive...:) |
// Make it look responsive...:) |
412 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
413 |
} |
} |
638 |
return false; |
return false; |
639 |
} |
} |
640 |
|
|
641 |
|
// Tell the world we'll take some time... |
642 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
643 |
|
|
644 |
// Read the file. |
// Read the file. |
645 |
|
int iLine = 0; |
646 |
int iErrors = 0; |
int iErrors = 0; |
647 |
QTextStream ts(&file); |
QTextStream ts(&file); |
648 |
while (!ts.atEnd()) { |
while (!ts.atEnd()) { |
649 |
// Read the line. |
// Read the line. |
650 |
QString sCommand = ts.readLine().stripWhiteSpace(); |
QString sCommand = ts.readLine().stripWhiteSpace(); |
651 |
|
iLine++; |
652 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
653 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
654 |
appendMessagesColor(sCommand, "#996633"); |
// Remember that, no matter what, |
655 |
// Remember that, no matter what, |
// all LSCP commands are CR/LF terminated. |
656 |
// all LSCP commands are CR/LF terminated. |
sCommand += "\r\n"; |
657 |
sCommand += "\r\n"; |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
658 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
appendMessagesColor(QString("%1(%2): %3") |
659 |
appendMessagesClient("lscp_client_query"); |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
660 |
iErrors++; |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
661 |
} |
appendMessagesClient("lscp_client_query"); |
662 |
|
iErrors++; |
663 |
|
} |
664 |
} |
} |
665 |
// Try to make it snappy :) |
// Try to make it snappy :) |
666 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
672 |
// Now we'll try to create (update) the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
673 |
updateSession(); |
updateSession(); |
674 |
|
|
675 |
|
// We're fornerly done. |
676 |
|
QApplication::restoreOverrideCursor(); |
677 |
|
|
678 |
// Have we any errors? |
// Have we any errors? |
679 |
if (iErrors > 0) |
if (iErrors > 0) |
680 |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
714 |
return false; |
return false; |
715 |
} |
} |
716 |
|
|
717 |
|
// Tell the world we'll take some time... |
718 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
719 |
|
|
720 |
// Write the file. |
// Write the file. |
721 |
int iErrors = 0; |
int iErrors = 0; |
722 |
QTextStream ts(&file); |
QTextStream ts(&file); |
870 |
if (pInstrInfo->name) |
if (pInstrInfo->name) |
871 |
ts << " '" << pInstrInfo->name << "'"; |
ts << " '" << pInstrInfo->name << "'"; |
872 |
ts << endl; |
ts << endl; |
873 |
|
} // Check for errors... |
874 |
|
else if (::lscp_client_get_errno(m_pClient)) { |
875 |
|
appendMessagesClient("lscp_get_midi_instrument_info"); |
876 |
|
iErrors++; |
877 |
} |
} |
|
// MIDI device index/id mapping. |
|
|
midiInstrumentMap[iMidiMap] = iMap; |
|
878 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
879 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
880 |
} |
} |
881 |
if (pInstrs) |
ts << endl; |
882 |
ts << endl; |
// Check for errors... |
883 |
|
if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) { |
884 |
|
appendMessagesClient("lscp_list_midi_instruments"); |
885 |
|
iErrors++; |
886 |
|
} |
887 |
|
// MIDI strument index/id mapping. |
888 |
|
midiInstrumentMap[iMidiMap] = iMap; |
889 |
|
} |
890 |
|
// Check for errors... |
891 |
|
if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) { |
892 |
|
appendMessagesClient("lscp_list_midi_instrument_maps"); |
893 |
|
iErrors++; |
894 |
} |
} |
895 |
#endif // CONFIG_MIDI_INSTRUMENT |
#endif // CONFIG_MIDI_INSTRUMENT |
896 |
|
|
897 |
// Sampler channel mapping. |
// Sampler channel mapping. |
898 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
959 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |
960 |
file.close(); |
file.close(); |
961 |
|
|
962 |
|
// We're fornerly done. |
963 |
|
QApplication::restoreOverrideCursor(); |
964 |
|
|
965 |
// Have we any errors? |
// Have we any errors? |
966 |
if (iErrors > 0) |
if (iErrors > 0) |
967 |
appendMessagesError(tr("Some settings could not be saved\nto \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Some settings could not be saved\nto \"%1\" session file.\n\nSorry.").arg(sFilename)); |
1053 |
tr("Reset"), tr("Cancel")) > 0) |
tr("Reset"), tr("Cancel")) > 0) |
1054 |
return; |
return; |
1055 |
|
|
1056 |
|
// Trye closing the current session, first... |
1057 |
|
if (!closeSession(true)) |
1058 |
|
return; |
1059 |
|
|
1060 |
// Just do the reset, after closing down current session... |
// Just do the reset, after closing down current session... |
1061 |
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
// Do the actual sampler reset... |
1062 |
appendMessagesClient("lscp_reset_sampler"); |
if (::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
1063 |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
appendMessagesClient("lscp_reset_sampler"); |
1064 |
return; |
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
1065 |
} |
return; |
1066 |
|
} |
1067 |
|
|
1068 |
// Log this. |
// Log this. |
1069 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
1614 |
void qsamplerMainForm::updateSession (void) |
void qsamplerMainForm::updateSession (void) |
1615 |
{ |
{ |
1616 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1617 |
// FIXME Make some room for default instrument maps... |
// FIXME: Make some room for default instrument maps... |
1618 |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1619 |
if (iMaps < 0) |
if (iMaps < 0) |
1620 |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
1631 |
appendMessagesClient("lscp_list_channels"); |
appendMessagesClient("lscp_list_channels"); |
1632 |
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1633 |
} |
} |
1634 |
return; |
} else { |
1635 |
|
// Try to (re)create each channel. |
1636 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1637 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1638 |
|
// Check if theres already a channel strip for this one... |
1639 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1640 |
|
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
1641 |
|
} |
1642 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1643 |
} |
} |
1644 |
|
|
1645 |
// Try to (re)create each channel. |
// Do we auto-arrange? |
1646 |
m_pWorkspace->setUpdatesEnabled(false); |
if (m_pOptions && m_pOptions->bAutoArrange) |
1647 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
channelsArrange(); |
|
// Check if theres already a channel strip for this one... |
|
|
if (!channelStrip(piChannelIDs[iChannel])) |
|
|
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
|
|
// Make it visibly responsive... |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
m_pWorkspace->setUpdatesEnabled(true); |
|
1648 |
|
|
1649 |
// Remember to refresh devices and instruments... |
// Remember to refresh devices and instruments... |
1650 |
if (m_pInstrumentListForm) |
if (m_pInstrumentListForm) |
1821 |
|
|
1822 |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000"); |
1823 |
|
|
1824 |
|
// Make it look responsive...:) |
1825 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1826 |
|
|
1827 |
QMessageBox::critical(this, |
QMessageBox::critical(this, |
1828 |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
1829 |
} |
} |
1838 |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
appendMessagesColor(s + QString(": %1 (errno=%2)") |
1839 |
.arg(::lscp_client_get_result(m_pClient)) |
.arg(::lscp_client_get_result(m_pClient)) |
1840 |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
1841 |
|
|
1842 |
|
// Make it look responsive...:) |
1843 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1844 |
} |
} |
1845 |
|
|
1846 |
|
|