--- qsampler/trunk/src/qsamplerMainForm.ui.h 2004/11/17 11:51:49 296 +++ qsampler/trunk/src/qsamplerMainForm.ui.h 2005/02/11 15:36:06 371 @@ -2,7 +2,7 @@ // // ui.h extension file, included from the uic-generated form implementation. /**************************************************************************** - Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -44,6 +44,9 @@ #include "config.h" +#ifdef HAVE_SIGNAL_H +#include +#endif // Timer constant stuff. #define QSAMPLER_TIMER_MSECS 200 @@ -116,6 +119,11 @@ m_iTimerSlot = 0; +#ifdef HAVE_SIGNAL_H + // Set to ignore any fatal "Broken pipe" signals. + ::signal(SIGPIPE, SIG_IGN); +#endif + // Make it an MDI workspace. m_pWorkspace = new QWorkspace(this); m_pWorkspace->setScrollBarsEnabled(true); @@ -544,19 +552,19 @@ appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename)); // Now we'll try to create the whole GUI session. - int iChannels = ::lscp_get_channels(m_pClient); - if (iChannels < 0) { - appendMessagesClient("lscp_get_channels"); - appendMessagesError(tr("Could not get current number of channels.\n\nSorry.")); - } - - // Try to (re)create each channel. - m_pWorkspace->setUpdatesEnabled(false); - for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) { - createChannelStrip(iChannelID); - QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); - } - m_pWorkspace->setUpdatesEnabled(true); + int *piChannelIDs = ::lscp_list_channels(m_pClient); + if (piChannelIDs == NULL) { + appendMessagesClient("lscp_list_channels"); + appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); + } else { + // Try to (re)create each channel. + m_pWorkspace->setUpdatesEnabled(false); + for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { + createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); + QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); + } + m_pWorkspace->setUpdatesEnabled(true); + } // Save as default session directory. if (m_pOptions) @@ -567,6 +575,9 @@ m_sFilename = sFilename; updateRecentFiles(sFilename); appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); + + // Make that an overall update. + m_iChangeCount++; stabilizeForm(); return true; } @@ -611,10 +622,10 @@ ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; - if (pChannel->midiChannel() > 0) - ts << pChannel->midiChannel(); - else + if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) ts << "ALL"; + else + ts << pChannel->midiChannel(); ts << endl; ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl; @@ -768,9 +779,28 @@ if (m_pClient == NULL) return; - // Just create the channel strip, - // by giving an invalid channel id. - createChannelStrip(-1); + // Just create the channel instance... + qsamplerChannel *pChannel = new qsamplerChannel(this); + if (pChannel == NULL) + return; + + // Before we show it up, may be we'll + // better ask for some initial values? + if (!pChannel->channelSetup(this)) { + delete pChannel; + return; + } + + // And give it to the strip (will own the channel instance, if successful). + if (!createChannelStrip(pChannel)) { + delete pChannel; + return; + } + + // Make that an overall update. + m_iDirtyCount++; + m_iChangeCount++; + stabilizeForm(); } @@ -848,8 +878,8 @@ // Reset the existing sampler channel. pChannel->resetChannel(); - // Refresh channel strip info. - pChannelStrip->updateChannelInfo(); + // And force a deferred update. + m_iChangeCount++; } @@ -929,6 +959,7 @@ int bOldMessagesLimit = m_pOptions->bMessagesLimit; int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; bool bOldCompletePath = m_pOptions->bCompletePath; + bool bOldInstrumentNames = m_pOptions->bInstrumentNames; int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; // Load the current setup settings. pOptionsForm->setup(m_pOptions); @@ -947,6 +978,9 @@ (!bOldCompletePath && m_pOptions->bCompletePath) || (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) updateRecentFilesMenu(); + if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) || + (!bOldInstrumentNames && m_pOptions->bInstrumentNames)) + updateInstrumentNames(); if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || (!bOldDisplayEffect && m_pOptions->bDisplayEffect)) updateDisplayEffect(); @@ -1190,6 +1224,24 @@ } +// Force update of the channels instrument names mode. +void qsamplerMainForm::updateInstrumentNames (void) +{ + // Full channel list update... + QWidgetList wlist = m_pWorkspace->windowList(); + if (wlist.isEmpty()) + return; + + m_pWorkspace->setUpdatesEnabled(false); + for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { + qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); + if (pChannelStrip) + pChannelStrip->updateInstrumentName(true); + } + m_pWorkspace->setUpdatesEnabled(true); +} + + // Force update of the channels display font. void qsamplerMainForm::updateDisplayFont (void) { @@ -1355,9 +1407,9 @@ // qsamplerMainForm -- MDI channel strip management. // The channel strip creation executive. -qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( int iChannelID ) +qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel ) { - if (m_pClient == NULL) + if (m_pClient == NULL || pChannel == NULL) return NULL; // Prepare for auto-arrange? @@ -1375,17 +1427,12 @@ // Add a new channel itema... WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder; pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); - // Actual channel setup. - pChannelStrip->setup(this, iChannelID); - QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); - // Before we show it up, may be we'll - // better ask for some initial values? - if (iChannelID < 0 && !pChannelStrip->channelSetup()) { - // No luck, bail out... - delete pChannelStrip; + if (pChannelStrip == NULL) return NULL; - } - + + // Actual channel strip setup... + pChannelStrip->setup(pChannel); + QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); // Set some initial aesthetic options... if (m_pOptions) { // Background display effect... @@ -1507,8 +1554,11 @@ QWidgetList wlist = m_pWorkspace->windowList(); for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); - if (pChannelStrip && pChannelStrip->isVisible()) - pChannelStrip->updateChannelUsage(); + if (pChannelStrip && pChannelStrip->isVisible()) { + // If we can't make it clean, try next time. + if (!pChannelStrip->updateChannelUsage()) + m_iChangeCount++; + } } } }