/[svn]/qsampler/trunk/src/qsamplerMainForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 176 by capela, Tue Jul 6 10:54:45 2004 UTC revision 470 by capela, Wed Mar 16 22:07:14 2005 UTC
# Line 2  Line 2 
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, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, 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
# Line 26  Line 26 
26  #include <qprocess.h>  #include <qprocess.h>
27  #include <qmessagebox.h>  #include <qmessagebox.h>
28  #include <qdragobject.h>  #include <qdragobject.h>
29    #include <qregexp.h>
30  #include <qfiledialog.h>  #include <qfiledialog.h>
31  #include <qfileinfo.h>  #include <qfileinfo.h>
32  #include <qfile.h>  #include <qfile.h>
# Line 36  Line 37 
37    
38  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
39  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
40    #include "qsamplerChannel.h"
41  #include "qsamplerMessages.h"  #include "qsamplerMessages.h"
42    
43  #include "qsamplerChannelStrip.h"  #include "qsamplerChannelStrip.h"
44    
45    #include "qsamplerDeviceForm.h"
46  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
47    
48  #include "config.h"  #include "config.h"
49    
50    #ifdef HAVE_SIGNAL_H
51    #include <signal.h>
52    #endif
53    
54  // Timer constant stuff.  // Timer constant stuff.
55  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
# Line 100  void qsamplerMainForm::init (void) Line 107  void qsamplerMainForm::init (void)
107      m_pOptions = NULL;      m_pOptions = NULL;
108    
109      // All child forms are to be created later, not earlier than setup.      // All child forms are to be created later, not earlier than setup.
110      m_pMessages = NULL;      m_pMessages   = NULL;
111        m_pDeviceForm = NULL;
112    
113      // We'll start clean.      // We'll start clean.
114      m_iUntitled = 0;      m_iUntitled   = 0;
115      m_iDirtyCount = 0;      m_iDirtyCount = 0;
116    
117      m_pServer = NULL;      m_pServer = NULL;
# Line 114  void qsamplerMainForm::init (void) Line 122  void qsamplerMainForm::init (void)
122    
123      m_iTimerSlot = 0;      m_iTimerSlot = 0;
124    
125    #ifdef HAVE_SIGNAL_H
126            // Set to ignore any fatal "Broken pipe" signals.
127            ::signal(SIGPIPE, SIG_IGN);
128    #endif
129    
130      // Make it an MDI workspace.      // Make it an MDI workspace.
131      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
132      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
# Line 128  void qsamplerMainForm::init (void) Line 141  void qsamplerMainForm::init (void)
141      pLabel = new QLabel(tr("Connected"), this);      pLabel = new QLabel(tr("Connected"), this);
142      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
143      pLabel->setMinimumSize(pLabel->sizeHint());      pLabel->setMinimumSize(pLabel->sizeHint());
144      m_status[QSAMPLER_STATUS_CLIENT] = pLabel;      m_statusItem[QSAMPLER_STATUS_CLIENT] = pLabel;
145      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
146      // Server address.      // Server address.
147      pLabel = new QLabel(this);      pLabel = new QLabel(this);
148      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
149      m_status[QSAMPLER_STATUS_SERVER] = pLabel;      m_statusItem[QSAMPLER_STATUS_SERVER] = pLabel;
150      statusBar()->addWidget(pLabel, 1);      statusBar()->addWidget(pLabel, 1);
151      // Channel title.      // Channel title.
152      pLabel = new QLabel(this);      pLabel = new QLabel(this);
153      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
154      m_status[QSAMPLER_STATUS_CHANNEL] = pLabel;      m_statusItem[QSAMPLER_STATUS_CHANNEL] = pLabel;
155      statusBar()->addWidget(pLabel, 2);      statusBar()->addWidget(pLabel, 2);
156      // Session modification status.      // Session modification status.
157      pLabel = new QLabel(tr("MOD"), this);      pLabel = new QLabel(tr("MOD"), this);
158      pLabel->setAlignment(Qt::AlignHCenter);      pLabel->setAlignment(Qt::AlignHCenter);
159      pLabel->setMinimumSize(pLabel->sizeHint());      pLabel->setMinimumSize(pLabel->sizeHint());
160      m_status[QSAMPLER_STATUS_SESSION] = pLabel;      m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
161      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
162    
163      // Create the recent files sub-menu.      // Create the recent files sub-menu.
# Line 163  void qsamplerMainForm::destroy (void) Line 176  void qsamplerMainForm::destroy (void)
176  {  {
177      // Do final processing anyway.      // Do final processing anyway.
178      processServerExit();      processServerExit();
179        
180      // Delete recentfiles menu.  #if defined(WIN32)
181      if (m_pRecentFilesMenu)      WSACleanup();
182          delete m_pRecentFilesMenu;  #endif
     // Delete status item labels one by one.  
     if (m_status[QSAMPLER_STATUS_CLIENT])  
         delete m_status[QSAMPLER_STATUS_CLIENT];  
     if (m_status[QSAMPLER_STATUS_SERVER])  
         delete m_status[QSAMPLER_STATUS_SERVER];  
     if (m_status[QSAMPLER_STATUS_CHANNEL])  
         delete m_status[QSAMPLER_STATUS_CHANNEL];  
     if (m_status[QSAMPLER_STATUS_SESSION])  
         delete m_status[QSAMPLER_STATUS_SESSION];  
183    
184      // Finally drop any widgets around...      // Finally drop any widgets around...
185        if (m_pDeviceForm)
186            delete m_pDeviceForm;
187      if (m_pMessages)      if (m_pMessages)
188          delete m_pMessages;          delete m_pMessages;
189      if (m_pWorkspace)      if (m_pWorkspace)
190          delete m_pWorkspace;          delete m_pWorkspace;
191    
192  #if defined(WIN32)      // Delete status item labels one by one.
193      WSACleanup();      if (m_statusItem[QSAMPLER_STATUS_CLIENT])
194  #endif          delete m_statusItem[QSAMPLER_STATUS_CLIENT];
195        if (m_statusItem[QSAMPLER_STATUS_SERVER])
196            delete m_statusItem[QSAMPLER_STATUS_SERVER];
197        if (m_statusItem[QSAMPLER_STATUS_CHANNEL])
198            delete m_statusItem[QSAMPLER_STATUS_CHANNEL];
199        if (m_statusItem[QSAMPLER_STATUS_SESSION])
200            delete m_statusItem[QSAMPLER_STATUS_SESSION];
201    
202        // Delete recentfiles menu.
203        if (m_pRecentFilesMenu)
204            delete m_pRecentFilesMenu;
205  }  }
206    
207    
# Line 195  void qsamplerMainForm::setup ( qsamplerO Line 211  void qsamplerMainForm::setup ( qsamplerO
211      // We got options?      // We got options?
212      m_pOptions = pOptions;      m_pOptions = pOptions;
213    
214        // What style do we create these forms?
215        WFlags wflags = Qt::WType_TopLevel;
216        if (m_pOptions->bKeepOnTop)
217            wflags |= Qt::WStyle_Tool;
218      // Some child forms are to be created right now.      // Some child forms are to be created right now.
219      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
220        m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);
221      // Set message defaults...      // Set message defaults...
222      updateMessagesFont();      updateMessagesFont();
223      updateMessagesLimit();      updateMessagesLimit();
# Line 225  void qsamplerMainForm::setup ( qsamplerO Line 246  void qsamplerMainForm::setup ( qsamplerO
246          QTextIStream istr(&sDockables);          QTextIStream istr(&sDockables);
247          istr >> *this;          istr >> *this;
248      }      }
249      // Try to restore old window positioning.      // Try to restore old window positioning and initial visibility.
250      m_pOptions->loadWidgetGeometry(this);      m_pOptions->loadWidgetGeometry(this);
251        m_pOptions->loadWidgetGeometry(m_pDeviceForm);
252    
253      // Final startup stabilization...      // Final startup stabilization...
254      updateRecentFilesMenu();      updateRecentFilesMenu();
# Line 264  bool qsamplerMainForm::queryClose (void) Line 286  bool qsamplerMainForm::queryClose (void)
286              QTextOStream ostr(&sDockables);              QTextOStream ostr(&sDockables);
287              ostr << *this;              ostr << *this;
288              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);
289              // And the main windows state.              // And the children, and the main windows state,.
290                    m_pOptions->saveWidgetGeometry(m_pDeviceForm);
291              m_pOptions->saveWidgetGeometry(this);              m_pOptions->saveWidgetGeometry(this);
292                    // Close popup widgets.
293                    if (m_pDeviceForm)
294                        m_pDeviceForm->close();
295              // Stop client and/or server, gracefully.              // Stop client and/or server, gracefully.
296              stopServer();              stopServer();
297          }          }
# Line 284  void qsamplerMainForm::closeEvent ( QClo Line 310  void qsamplerMainForm::closeEvent ( QClo
310  }  }
311    
312    
313  // Window drag-n-drop event handlers.  // Drag'n'drop file handler.
314  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files )
315  {  {
316      bool bAccept = false;      bool bDecode = false;
317    
318      if (QTextDrag::canDecode(pDragEnterEvent)) {      if (QTextDrag::canDecode(pEvent)) {
319          QString sUrl;          QString sText;
320          if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient)          bDecode = QTextDrag::decode(pEvent, sText);
321              bAccept = QFileInfo(QUrl(sUrl).path()).exists();          if (bDecode) {
322                files = QStringList::split('\n', sText);
323                for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++)
324                    *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();
325            }
326      }      }
327    
328      pDragEnterEvent->accept(bAccept);      return bDecode;
329    }
330    
331    
332    // Window drag-n-drop event handlers.
333    void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
334    {
335            QStringList files;
336            pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));
337  }  }
338    
339    
340  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )
341  {  {
342      if (QTextDrag::canDecode(pDropEvent)) {      QStringList files;
343          QString sUrl;  
344          if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true))      if (!decodeDragFiles(pDropEvent, files))
345              loadSessionFile(QUrl(sUrl).path());          return;
346      }  
347        for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
348                    const QString& sPath = *iter;
349                    if (qsamplerChannel::isInstrumentFile(sPath)) {
350                            // Try to create a new channel from instrument file...
351                        qsamplerChannel *pChannel = new qsamplerChannel(this);
352                        if (pChannel == NULL)
353                            return;
354                            // Start setting the instrument filename...
355                            pChannel->setInstrument(sPath, 0);
356                        // Before we show it up, may be we'll
357                        // better ask for some initial values?
358                        if (!pChannel->channelSetup(this)) {
359                            delete pChannel;
360                            return;
361                        }
362                        // Finally, give it to a new channel strip...
363                            if (!createChannelStrip(pChannel)) {
364                            delete pChannel;
365                            return;
366                            }
367                        // Make that an overall update.
368                        m_iDirtyCount++;
369                        stabilizeForm();
370                    }   // Otherwise, load an usual session file (LSCP script)...
371                    else if (closeSession(true))
372                            loadSessionFile(sPath);
373                    // Make it look responsive...:)
374                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
375            }
376  }  }
377    
378    
# Line 370  bool qsamplerMainForm::newSession (void) Line 437  bool qsamplerMainForm::newSession (void)
437      if (!closeSession(true))      if (!closeSession(true))
438          return false;          return false;
439    
440            // Give us what the server has, right now...
441            updateSession();
442    
443      // Ok increment untitled count.      // Ok increment untitled count.
444      m_iUntitled++;      m_iUntitled++;
445    
# Line 483  bool qsamplerMainForm::closeSession ( bo Line 553  bool qsamplerMainForm::closeSession ( bo
553          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
554          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
555          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
556              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
557              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
558                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
559              delete pChannel;                  if (bForce && pChannel)
560                        pChannel->removeChannel();
561                    delete pChannelStrip;
562                }
563          }          }
564          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
565          // We're now clean, for sure.          // We're now clean, for sure.
# Line 534  bool qsamplerMainForm::loadSessionFile ( Line 607  bool qsamplerMainForm::loadSessionFile (
607      // Ok. we've read it.      // Ok. we've read it.
608      file.close();      file.close();
609    
610      // Have we any errors?          // Now we'll try to create (update) the whole GUI session.
611      if (iErrors > 0)          updateSession();
         appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));  
612    
613      // Now we'll try to create the whole GUI session.          // Have we any errors?
614      int iChannels = ::lscp_get_channels(m_pClient);          if (iErrors > 0)
615      if (iChannels < 0) {                  appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));
         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++) {  
         createChannel(iChannelID, false);  
         QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
     }  
     m_pWorkspace->setUpdatesEnabled(true);  
616    
617      // Save as default session directory.      // Save as default session directory.
618      if (m_pOptions)      if (m_pOptions)
619          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);
620      // We're not dirty anymore.          // We're not dirty anymore, if loaded without errors,
621      m_iDirtyCount = 0;          m_iDirtyCount = iErrors;
622      // Stabilize form...      // Stabilize form...
623      m_sFilename = sFilename;      m_sFilename = sFilename;
624      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
625      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
626        
627        // Make that an overall update.
628      stabilizeForm();      stabilizeForm();
629      return true;      return true;
630  }  }
# Line 578  bool qsamplerMainForm::saveSessionFile ( Line 641  bool qsamplerMainForm::saveSessionFile (
641      }      }
642    
643      // Write the file.      // Write the file.
644      int iErrors = 0;      int  iErrors = 0;
645      QTextStream ts(&file);      QTextStream ts(&file);
646      ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;      ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
647      ts << "# " << tr("Version")      ts << "# " << tr("Version")
# Line 589  bool qsamplerMainForm::saveSessionFile ( Line 652  bool qsamplerMainForm::saveSessionFile (
652      ts << "# " << tr("File")      ts << "# " << tr("File")
653         << ": " << QFileInfo(sFilename).fileName() << endl;         << ": " << QFileInfo(sFilename).fileName() << endl;
654      ts << "# " << tr("Date")      ts << "# " << tr("Date")
655         << ": " << QDate::currentDate().toString("MMMM dd yyyy")         << ": " << QDate::currentDate().toString("MMM dd yyyy")
656         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
657      ts << "#"  << endl;      ts << "#"  << endl;
658      ts << endl;      ts << endl;
659            // It is assumed that this new kind of device+session file
660            // will be loaded from a complete
661            int *piDeviceIDs;
662            int  iDevice;
663            ts << "RESET" << endl;
664            // Audio device mapping.
665            QMap<int, int> audioDeviceMap;
666            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
667            for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
668                    ts << endl;
669                    qsamplerDevice device(m_pClient, qsamplerDevice::Audio, piDeviceIDs[iDevice]);
670                    // Audio device specification...
671                    ts << "# " << device.deviceTypeName() << " " << device.driverName()
672                       << " " << tr("Device") << " " << iDevice << endl;
673                    ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
674                    qsamplerDeviceParamMap::ConstIterator deviceParam;
675                    for (deviceParam = device.params().begin();
676                                    deviceParam != device.params().end();
677                                            ++deviceParam) {
678                            const qsamplerDeviceParam& param = deviceParam.data();
679                            if (!param.fix && !param.value.isEmpty())
680                                    ts << " " << deviceParam.key() << "='" << param.value << "'";
681                    }
682                    ts << endl;
683                    // Audio channel parameters...
684                    int iPort = 0;
685                    for (qsamplerDevicePort *pPort = device.ports().first();
686                                    pPort;
687                                            pPort = device.ports().next(), ++iPort) {
688                            qsamplerDeviceParamMap::ConstIterator portParam;
689                            for (portParam = pPort->params().begin();
690                                            portParam != pPort->params().end();
691                                                    ++portParam) {
692                                    const qsamplerDeviceParam& param = portParam.data();
693                                    if (!param.fix && !param.value.isEmpty()) {
694                                            ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
695                                               << " " << iPort << " " << portParam.key()
696                                               << "='" << param.value << "'" << endl;
697                                    }
698                            }
699                    }
700                    // Audio device index/id mapping.
701                    audioDeviceMap[device.deviceID()] = iDevice;
702            // Try to keep it snappy :)
703            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
704            }
705            // MIDI device mapping.
706            QMap<int, int> midiDeviceMap;
707            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
708            for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
709                    ts << endl;
710                    qsamplerDevice device(m_pClient, qsamplerDevice::Midi, piDeviceIDs[iDevice]);
711                    // MIDI device specification...
712            ts << "# " << device.deviceTypeName() << " " << device.driverName()
713                       << " " << tr("Device") << " " << iDevice << endl;
714                    ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
715                    qsamplerDeviceParamMap::ConstIterator deviceParam;
716                    for (deviceParam = device.params().begin();
717                                    deviceParam != device.params().end();
718                                            ++deviceParam) {
719                            const qsamplerDeviceParam& param = deviceParam.data();
720                            if (!param.fix && !param.value.isEmpty())
721                                    ts << " " << deviceParam.key() << "='" << param.value << "'";
722                    }
723                    ts << endl;
724                    // MIDI port parameters...
725                    int iPort = 0;
726                    for (qsamplerDevicePort *pPort = device.ports().first();
727                                    pPort;
728                                            pPort = device.ports().next(), ++iPort) {
729                            qsamplerDeviceParamMap::ConstIterator portParam;
730                            for (portParam = pPort->params().begin();
731                                            portParam != pPort->params().end();
732                                                    ++portParam) {
733                                    const qsamplerDeviceParam& param = portParam.data();
734                                    if (!param.fix && !param.value.isEmpty()) {
735                                            ts << "SET MIDI_INPUT_CHANNEL_PARAMETER " << iDevice
736                                               << " " << iPort << " " << portParam.key()
737                                               << "='" << param.value << "'" << endl;
738                                    }
739                            }
740                    }
741                    // MIDI device index/id mapping.
742                    midiDeviceMap[device.deviceID()] = iDevice;
743            // Try to keep it snappy :)
744            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
745            }
746            ts << endl;
747            // Sampler channel mapping.
748      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
749      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
750          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
751          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
752          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
753          ts << "ADD CHANNEL" << endl;              if (pChannel) {
754          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  ts << "# " << tr("Channel") << " " << iChannel << endl;
755          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "ADD CHANNEL" << endl;
756          ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  if (audioDeviceMap.isEmpty()) {
757          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel
758          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                                              << " " << pChannel->audioDriver() << endl;
759          ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                              } else {
760          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel
761          ts << endl;                                             << " " << audioDeviceMap[pChannel->audioDevice()] << endl;
762                                    }
763                    if (midiDeviceMap.isEmpty()) {
764                            ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel
765                                           << " " << pChannel->midiDriver() << endl;
766                                } else {
767                            ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel
768                                               << " " << midiDeviceMap[pChannel->midiDevice()] << endl;
769                                }
770                    ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel
771                                   << " " << pChannel->midiPort() << endl;
772                    ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";
773                    if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
774                        ts << "ALL";
775                    else
776                        ts << pChannel->midiChannel();
777                    ts << endl;
778                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
779                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;
780                    ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;
781                    ts << endl;
782                }
783            }
784          // Try to keep it snappy :)          // Try to keep it snappy :)
785          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
786      }      }
# Line 632  bool qsamplerMainForm::saveSessionFile ( Line 806  bool qsamplerMainForm::saveSessionFile (
806  }  }
807    
808    
809    // Session change receiver slot.
810    void qsamplerMainForm::sessionDirty (void)
811    {
812        // Just mark the dirty form.
813        m_iDirtyCount++;
814        // and update the form status...
815        stabilizeForm();
816    }
817    
818    
819  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
820  // qsamplerMainForm -- File Action slots.  // qsamplerMainForm -- File Action slots.
821    
# Line 678  void qsamplerMainForm::fileSaveAs (void) Line 862  void qsamplerMainForm::fileSaveAs (void)
862  }  }
863    
864    
865    // Reset the sampler instance.
866    void qsamplerMainForm::fileReset (void)
867    {
868        if (m_pClient == NULL)
869            return;
870    
871        // Ask user whether he/she want's an internal sampler reset...
872        if (QMessageBox::warning(this, tr("Warning"),
873            tr("Resetting the sampler instance will close\n"
874               "all device and channel configurations.\n\n"
875               "Please note that this operation may cause\n"
876               "temporary MIDI and Audio disruption\n\n"
877               "Do you want to reset the sampler engine now?"),
878            tr("Reset"), tr("Cancel")) > 0)
879            return;
880    
881        // Just do the reset, after closing down current session...
882        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
883            appendMessagesClient("lscp_reset_sampler");
884            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
885            return;
886        }
887    
888        // Log this.
889        appendMessages(tr("Sampler reset."));
890    
891            // Make it a new session...
892            newSession();
893    }
894    
895    
896  // Restart the client/server instance.  // Restart the client/server instance.
897  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
898  {  {
# Line 725  void qsamplerMainForm::editAddChannel (v Line 940  void qsamplerMainForm::editAddChannel (v
940      if (m_pClient == NULL)      if (m_pClient == NULL)
941          return;          return;
942    
943      // Create the new sampler channel.      // Just create the channel instance...
944      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
945      if (iChannelID < 0) {      if (pChannel == NULL)
946          appendMessagesClient("lscp_add_channel");          return;
947          appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
948        // Before we show it up, may be we'll
949        // better ask for some initial values?
950        if (!pChannel->channelSetup(this)) {
951            delete pChannel;
952            return;
953        }
954        
955        // And give it to the strip (will own the channel instance, if successful).
956        if (!createChannelStrip(pChannel)) {
957            delete pChannel;
958          return;          return;
959      }      }
960    
961      // Log this happening.      // Make that an overall update.
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
   
     // Just create the channel strip with given id.  
     createChannel(iChannelID, true);  
   
     // We'll be dirty, for sure...  
962      m_iDirtyCount++;      m_iDirtyCount++;
     // Stabilize form anyway.  
963      stabilizeForm();      stabilizeForm();
964  }  }
965    
# Line 752  void qsamplerMainForm::editRemoveChannel Line 970  void qsamplerMainForm::editRemoveChannel
970      if (m_pClient == NULL)      if (m_pClient == NULL)
971          return;          return;
972    
973      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
974        if (pChannelStrip == NULL)
975            return;
976            
977        qsamplerChannel *pChannel = pChannelStrip->channel();
978      if (pChannel == NULL)      if (pChannel == NULL)
979          return;          return;
980    
# Line 762  void qsamplerMainForm::editRemoveChannel Line 984  void qsamplerMainForm::editRemoveChannel
984              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
985                 "%1\n\n"                 "%1\n\n"
986                 "Are you sure?")                 "Are you sure?")
987                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
988              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
989              return;              return;
990      }      }
991    
992      // Remove the existing sampler channel.      // Remove the existing sampler channel.
993      if (::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      if (!pChannel->removeChannel())
         appendMessagesClient("lscp_remove_channel");  
         appendMessagesError(tr("Could not remove channel.\n\nSorry."));  
994          return;          return;
     }  
995    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
996      // Just delete the channel strip.      // Just delete the channel strip.
997      delete pChannel;      delete pChannelStrip;
998        
999      // Do we auto-arrange?      // Do we auto-arrange?
1000      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
1001          channelsArrange();          channelsArrange();
# Line 795  void qsamplerMainForm::editSetupChannel Line 1012  void qsamplerMainForm::editSetupChannel
1012      if (m_pClient == NULL)      if (m_pClient == NULL)
1013          return;          return;
1014    
1015      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1016      if (pChannel == NULL)      if (pChannelStrip == NULL)
1017          return;          return;
1018    
1019      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
1020      pChannel->channelSetup(false);      pChannelStrip->channelSetup();
1021  }  }
1022    
1023    
# Line 810  void qsamplerMainForm::editResetChannel Line 1027  void qsamplerMainForm::editResetChannel
1027      if (m_pClient == NULL)      if (m_pClient == NULL)
1028          return;          return;
1029    
1030      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1031      if (pChannel == NULL)      if (pChannelStrip == NULL)
1032          return;          return;
1033    
1034      // Remove the existing sampler channel.      // Just invoque the channel strip procedure.
1035      if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      pChannelStrip->channelReset();
1036          appendMessagesClient("lscp_reset_channel");  }
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
         return;  
     }  
1037    
     // Log this.  
     appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));  
1038    
1039      // Refresh channel strip info.  // Reset all sampler channels.
1040      pChannel->updateChannelInfo();  void qsamplerMainForm::editResetAllChannels (void)
1041    {
1042        if (m_pClient == NULL)
1043            return;
1044    
1045        // Invoque the channel strip procedure,
1046            // for all channels out there...
1047        m_pWorkspace->setUpdatesEnabled(false);
1048        QWidgetList wlist = m_pWorkspace->windowList();
1049        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1050            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1051            if (pChannelStrip)
1052                    pChannelStrip->channelReset();
1053        }
1054        m_pWorkspace->setUpdatesEnabled(true);
1055  }  }
1056    
1057    
# Line 877  void qsamplerMainForm::viewMessages ( bo Line 1103  void qsamplerMainForm::viewMessages ( bo
1103  }  }
1104    
1105    
1106    // Show/hide the device configurator form.
1107    void qsamplerMainForm::viewDevices (void)
1108    {
1109        if (m_pOptions == NULL)
1110            return;
1111    
1112        if (m_pDeviceForm) {
1113            m_pOptions->saveWidgetGeometry(m_pDeviceForm);
1114                    m_pDeviceForm->setClient(m_pClient);
1115            if (m_pDeviceForm->isVisible()) {
1116                m_pDeviceForm->hide();
1117            } else {
1118                m_pDeviceForm->show();
1119                m_pDeviceForm->raise();
1120                m_pDeviceForm->setActiveWindow();
1121            }
1122        }
1123    }
1124    
1125    
1126  // Show options dialog.  // Show options dialog.
1127  void qsamplerMainForm::viewOptions (void)  void qsamplerMainForm::viewOptions (void)
1128  {  {
# Line 886  void qsamplerMainForm::viewOptions (void Line 1132  void qsamplerMainForm::viewOptions (void
1132      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
1133      if (pOptionsForm) {      if (pOptionsForm) {
1134          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
1135          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1136          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
1137              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
1138          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
1139              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
1140          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 898  void qsamplerMainForm::viewOptions (void Line 1144  void qsamplerMainForm::viewOptions (void
1144          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
1145          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
1146          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
1147            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1148          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
1149          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
1150            bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;
1151          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
1152          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
1153          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1154          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
1155            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
1156          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1157          // Load the current setup settings.          // Load the current setup settings.
1158          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 911  void qsamplerMainForm::viewOptions (void Line 1160  void qsamplerMainForm::viewOptions (void
1160          if (pOptionsForm->exec()) {          if (pOptionsForm->exec()) {
1161              // Warn if something will be only effective on next run.              // Warn if something will be only effective on next run.
1162              if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||              if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||
1163                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture)) {                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||
1164                    ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1165                    (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)) {
1166                  QMessageBox::information(this, tr("Information"),                  QMessageBox::information(this, tr("Information"),
1167                      tr("Some settings may be only effective\n"                      tr("Some settings may be only effective\n"
1168                         "next time you start this program."), tr("OK"));                         "next time you start this program."), tr("OK"));
# Line 922  void qsamplerMainForm::viewOptions (void Line 1173  void qsamplerMainForm::viewOptions (void
1173                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1174                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
1175                  updateRecentFilesMenu();                  updateRecentFilesMenu();
1176                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
1177                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
1178                    updateInstrumentNames();
1179                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
1180                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
1181                    updateDisplayEffect();
1182              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
1183                  updateDisplayFont();                  updateDisplayFont();
1184              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 964  void qsamplerMainForm::channelsArrange ( Line 1221  void qsamplerMainForm::channelsArrange (
1221      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1222      int y = 0;      int y = 0;
1223      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1224          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1225      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1226              // Prevent flicker...              // Prevent flicker...
1227              pChannel->hide();              pChannelStrip->hide();
1228              pChannel->showNormal();              pChannelStrip->showNormal();
1229          }   */          }   */
1230          pChannel->adjustSize();          pChannelStrip->adjustSize();
1231          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1232          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1233              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1234      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1235          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1236          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1237          y += iHeight;          y += iHeight;
1238      }      }
1239      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 1029  void qsamplerMainForm::helpAbout (void) Line 1286  void qsamplerMainForm::helpAbout (void)
1286      sText += tr("GIG (libgig) file support disabled.");      sText += tr("GIG (libgig) file support disabled.");
1287      sText += "</font></small><br />";      sText += "</font></small><br />";
1288  #endif  #endif
1289    #ifndef CONFIG_INSTRUMENT_NAME
1290        sText += "<small><font color=\"red\">";
1291        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1292        sText += "</font></small><br />";
1293    #endif
1294      sText += "<br />\n";      sText += "<br />\n";
1295      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1296      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1056  void qsamplerMainForm::helpAbout (void) Line 1318  void qsamplerMainForm::helpAbout (void)
1318  void qsamplerMainForm::stabilizeForm (void)  void qsamplerMainForm::stabilizeForm (void)
1319  {  {
1320      // Update the main application caption...      // Update the main application caption...
1321      QString sSessioName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1322      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1323          sSessioName += '*';          sSessionName += '*';
1324      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1325    
1326      // Update the main menu state...      // Update the main menu state...
1327      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1328      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1329      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1330      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1331      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1332      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1333      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1334        fileResetAction->setEnabled(bHasClient);
1335      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1336      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1337      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
1338      editSetupChannelAction->setEnabled(bHasChannel);      editSetupChannelAction->setEnabled(bHasChannel);
1339      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1340      channelsArrangeAction->setEnabled(bHasChannel);      editResetAllChannelsAction->setEnabled(bHasChannel);
1341      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1342        viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible());
1343        viewDevicesAction->setEnabled(bHasClient);
1344        channelsArrangeAction->setEnabled(bHasChannel);
1345    
1346      // Client/Server status...      // Client/Server status...
1347      if (bHasClient) {      if (bHasClient) {
1348          m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected"));          m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected"));
1349          m_status[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort));          m_statusItem[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort));
1350      } else {      } else {
1351          m_status[QSAMPLER_STATUS_CLIENT]->clear();          m_statusItem[QSAMPLER_STATUS_CLIENT]->clear();
1352          m_status[QSAMPLER_STATUS_SERVER]->clear();          m_statusItem[QSAMPLER_STATUS_SERVER]->clear();
1353      }      }
1354      // Channel status...      // Channel status...
1355      if (bHasChannel)      if (bHasChannel)
1356          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1357      else      else
1358          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear();
1359      // Session status...      // Session status...
1360      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1361          m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD"));          m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD"));
1362      else      else
1363          m_status[QSAMPLER_STATUS_SESSION]->clear();          m_statusItem[QSAMPLER_STATUS_SESSION]->clear();
1364    
1365      // Recent files menu.      // Recent files menu.
1366      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);
# Line 1106  void qsamplerMainForm::stabilizeForm (vo Line 1372  void qsamplerMainForm::stabilizeForm (vo
1372    
1373    
1374  // Channel change receiver slot.  // Channel change receiver slot.
1375  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )
1376  {  {
1377            // Add this strip to the changed list...
1378            if (m_changedStrips.containsRef(pChannelStrip) == 0)
1379                    m_changedStrips.append(pChannelStrip);
1380    
1381      // Just mark the dirty form.      // Just mark the dirty form.
1382      m_iDirtyCount++;      m_iDirtyCount++;
1383      // and update the form status...      // and update the form status...
# Line 1115  void qsamplerMainForm::channelChanged( q Line 1385  void qsamplerMainForm::channelChanged( q
1385  }  }
1386    
1387    
1388    // Grab and restore current sampler channels session.
1389    void qsamplerMainForm::updateSession (void)
1390    {
1391            // Retrieve the current channel list.
1392            int *piChannelIDs = ::lscp_list_channels(m_pClient);
1393            if (piChannelIDs == NULL) {
1394                    if (::lscp_client_get_errno(m_pClient)) {
1395                            appendMessagesClient("lscp_list_channels");
1396                            appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1397                    }
1398                    return;
1399            }
1400    
1401            // Try to (re)create each channel.
1402            m_pWorkspace->setUpdatesEnabled(false);
1403            for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1404                    // Check if theres already a channel strip for this one...
1405                    if (!channelStrip(piChannelIDs[iChannel]))
1406                            createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
1407                    // Make it visibly responsive...
1408                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1409            }
1410            m_pWorkspace->setUpdatesEnabled(true);
1411            
1412            // Remember to refresh devices
1413            if (m_pDeviceForm)
1414                m_pDeviceForm->refreshDevices();
1415    }
1416    
1417    
1418  // Update the recent files list and menu.  // Update the recent files list and menu.
1419  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )
1420  {  {
# Line 1159  void qsamplerMainForm::updateRecentFiles Line 1459  void qsamplerMainForm::updateRecentFiles
1459  }  }
1460    
1461    
1462    // Force update of the channels instrument names mode.
1463    void qsamplerMainForm::updateInstrumentNames (void)
1464    {
1465        // Full channel list update...
1466        QWidgetList wlist = m_pWorkspace->windowList();
1467        if (wlist.isEmpty())
1468            return;
1469    
1470        m_pWorkspace->setUpdatesEnabled(false);
1471        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1472            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1473            if (pChannelStrip)
1474                pChannelStrip->updateInstrumentName(true);
1475        }
1476        m_pWorkspace->setUpdatesEnabled(true);
1477    }
1478    
1479    
1480  // Force update of the channels display font.  // Force update of the channels display font.
1481  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1482  {  {
# Line 1180  void qsamplerMainForm::updateDisplayFont Line 1498  void qsamplerMainForm::updateDisplayFont
1498    
1499      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1500      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1501          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1502          pChannel->setDisplayFont(font);          if (pChannelStrip)
1503                pChannelStrip->setDisplayFont(font);
1504        }
1505        m_pWorkspace->setUpdatesEnabled(true);
1506    }
1507    
1508    
1509    // Update channel strips background effect.
1510    void qsamplerMainForm::updateDisplayEffect (void)
1511    {
1512       QPixmap pm;
1513        if (m_pOptions->bDisplayEffect)
1514            pm = QPixmap::fromMimeSource("displaybg1.png");
1515    
1516        // Full channel list update...
1517        QWidgetList wlist = m_pWorkspace->windowList();
1518        if (wlist.isEmpty())
1519            return;
1520    
1521        m_pWorkspace->setUpdatesEnabled(false);
1522        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1523            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1524            if (pChannelStrip)
1525                pChannelStrip->setDisplayBackground(pm);
1526      }      }
1527      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1528  }  }
# Line 1200  void qsamplerMainForm::updateMaxVolume ( Line 1541  void qsamplerMainForm::updateMaxVolume (
1541    
1542      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1543      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1544          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1545          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1546                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1547      }      }
1548      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1549  }  }
# Line 1300  void qsamplerMainForm::updateMessagesCap Line 1642  void qsamplerMainForm::updateMessagesCap
1642  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1643    
1644  // The channel strip creation executive.  // The channel strip creation executive.
1645  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1646  {  {
1647      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1648          return;          return NULL;
1649    
1650      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1651      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1652      int y = 0;      int y = 0;
1653      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1654          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1655          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1656              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1657          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();                          if (pChannelStrip) {
1658              y += pChannel->parentWidget()->frameGeometry().height();                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1659                                    y += pChannelStrip->parentWidget()->frameGeometry().height();
1660                            }
1661          }          }
1662      }      }
1663    
1664      // Add a new channel itema...      // Add a new channel itema...
1665      WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;      WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;
1666      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1667      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1668      pChannel->setup(this, iChannelID);          return NULL;
1669      // We'll need a display font.          
1670      QFont font;      // Actual channel strip setup...
1671      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1672          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1673      // Track channel setup changes.      // Set some initial aesthetic options...
1674      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1675      // Before we show it up, may be we'll          // Background display effect...
1676      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1677      if (bPrompt)          // We'll need a display font.
1678          pChannel->channelSetup(true);          QFont font;
1679            if (font.fromString(m_pOptions->sDisplayFont))
1680                pChannelStrip->setDisplayFont(font);
1681            // Maximum allowed volume setting.
1682            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1683        }
1684    
1685      // Now we show up us to the world.      // Now we show up us to the world.
1686      pChannel->show();      pChannelStrip->show();
1687      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1688      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1689          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1690      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1691          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1692          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1693      }      }
1694    
1695            // This is pretty new, so we'll watch for it closely.
1696            channelStripChanged(pChannelStrip);
1697    
1698        // Return our successful reference...
1699        return pChannelStrip;
1700  }  }
1701    
1702    
1703  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1704  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1705  {  {
1706      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1707  }  }
1708    
1709    
1710  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1711  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1712  {  {
1713      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1714      if (wlist.isEmpty())      if (wlist.isEmpty())
1715          return 0;          return NULL;
1716    
1717      return (qsamplerChannelStrip *) wlist.at(iChannel);      return (qsamplerChannelStrip *) wlist.at(iChannel);
1718  }  }
1719    
1720    
1721    // Retrieve a channel strip by sampler channel id.
1722    qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID )
1723    {
1724            QWidgetList wlist = m_pWorkspace->windowList();
1725            if (wlist.isEmpty())
1726                    return NULL;
1727            
1728            for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1729                    qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1730                    if (pChannelStrip) {
1731                            qsamplerChannel *pChannel = pChannelStrip->channel();
1732                            if (pChannel && pChannel->channelID() == iChannelID)
1733                                    return pChannelStrip;
1734                    }
1735            }
1736    
1737            // Not found.
1738            return NULL;
1739    }
1740    
1741    
1742  // Construct the windows menu.  // Construct the windows menu.
1743  void qsamplerMainForm::channelsMenuAboutToShow (void)  void qsamplerMainForm::channelsMenuAboutToShow (void)
1744  {  {
# Line 1373  void qsamplerMainForm::channelsMenuAbout Line 1750  void qsamplerMainForm::channelsMenuAbout
1750      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1751          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1752          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1753              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1754              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1755              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1756              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1757                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1758                }
1759          }          }
1760      }      }
1761  }  }
# Line 1385  void qsamplerMainForm::channelsMenuAbout Line 1764  void qsamplerMainForm::channelsMenuAbout
1764  // Windows menu activation slot  // Windows menu activation slot
1765  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1766  {  {
1767      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1768      if (pChannel)      if (pChannelStrip)
1769          pChannel->showNormal();          pChannelStrip->showNormal();
1770      pChannel->setFocus();      pChannelStrip->setFocus();
1771  }  }
1772    
1773    
# Line 1428  void qsamplerMainForm::timerSlot (void) Line 1807  void qsamplerMainForm::timerSlot (void)
1807      }      }
1808            
1809          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1810      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) {
1811          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1812          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1813              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1814                // Update the channel information for each pending strip...
1815                for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();
1816                        pChannelStrip;
1817                                                    pChannelStrip = m_changedStrips.next()) {
1818                                    // If successfull, remove from pending list...
1819                                    if (pChannelStrip->updateChannelInfo())
1820                        m_changedStrips.remove(pChannelStrip);
1821                            }
1822                // Update the channel stream usage for each strip...
1823              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1824              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1825                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1826                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible())
1827                      pChannel->updateChannelUsage();                      pChannelStrip->updateChannelUsage();
1828              }              }
1829          }          }
1830      }      }
# Line 1629  bool qsamplerMainForm::startClient (void Line 2017  bool qsamplerMainForm::startClient (void
2017      // Log success here.      // Log success here.
2018      appendMessages(tr("Client connected."));      appendMessages(tr("Client connected."));
2019    
2020            // Hard-notify device configuration form,
2021            // if visible, that we're ready...
2022            if (m_pDeviceForm && m_pDeviceForm->isVisible())
2023                m_pDeviceForm->setClient(m_pClient);
2024                
2025      // Is any session pending to be loaded?      // Is any session pending to be loaded?
2026      if (!m_pOptions->sSessionFile.isEmpty()) {      if (!m_pOptions->sSessionFile.isEmpty()) {
2027          // Just load the prabably startup session...          // Just load the prabably startup session...
# Line 1649  void qsamplerMainForm::stopClient (void) Line 2042  void qsamplerMainForm::stopClient (void)
2042      if (m_pClient == NULL)      if (m_pClient == NULL)
2043          return;          return;
2044    
2045            // Hard-notify device configuration form,
2046            // if visible, that we're running out...
2047            if (m_pDeviceForm && m_pDeviceForm->isVisible())
2048                m_pDeviceForm->setClient(NULL);
2049    
2050      // Log prepare here.      // Log prepare here.
2051      appendMessages(tr("Client disconnecting..."));      appendMessages(tr("Client disconnecting..."));
2052    

Legend:
Removed from v.176  
changed lines
  Added in v.470

  ViewVC Help
Powered by ViewVC