/[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 145 by capela, Thu Jun 24 18:26:57 2004 UTC revision 418 by capela, Wed Mar 2 16:23:10 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"
# Line 43  Line 45 
45    
46  #include "config.h"  #include "config.h"
47    
48    #ifdef HAVE_SIGNAL_H
49    #include <signal.h>
50    #endif
51    
52  // Timer constant stuff.  // Timer constant stuff.
53  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
# Line 54  Line 59 
59  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
60    
61    
62    // All winsock apps needs this.
63  #if defined(WIN32)  #if defined(WIN32)
64  static WSADATA _wsaData;  static WSADATA _wsaData;
65  #endif  #endif
66    
67    
68    //-------------------------------------------------------------------------
69    // qsamplerCustomEvent -- specialty for callback comunication.
70    
71    #define QSAMPLER_CUSTOM_EVENT   1000
72    
73    class qsamplerCustomEvent : public QCustomEvent
74    {
75    public:
76    
77        // Constructor.
78        qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData)
79            : QCustomEvent(QSAMPLER_CUSTOM_EVENT)
80        {
81            m_event = event;
82            m_data.setLatin1(pchData, cchData);
83        }
84    
85        // Accessors.
86        lscp_event_t event() { return m_event; }
87        QString&     data()  { return m_data;  }
88    
89    private:
90    
91        // The proper event type.
92        lscp_event_t m_event;
93        // The event data as a string.
94        QString      m_data;
95    };
96    
97    
98  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
99  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
100    
# Line 71  void qsamplerMainForm::init (void) Line 108  void qsamplerMainForm::init (void)
108      m_pMessages = NULL;      m_pMessages = NULL;
109    
110      // We'll start clean.      // We'll start clean.
111      m_iUntitled = 0;      m_iUntitled   = 0;
112      m_iDirtyCount = 0;      m_iDirtyCount = 0;
113    
114      m_pServer = NULL;      m_pServer = NULL;
# Line 82  void qsamplerMainForm::init (void) Line 119  void qsamplerMainForm::init (void)
119    
120      m_iTimerSlot = 0;      m_iTimerSlot = 0;
121    
122    #ifdef HAVE_SIGNAL_H
123            // Set to ignore any fatal "Broken pipe" signals.
124            ::signal(SIGPIPE, SIG_IGN);
125    #endif
126    
127      // Make it an MDI workspace.      // Make it an MDI workspace.
128      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
129      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
# Line 131  void qsamplerMainForm::destroy (void) Line 173  void qsamplerMainForm::destroy (void)
173  {  {
174      // Do final processing anyway.      // Do final processing anyway.
175      processServerExit();      processServerExit();
176        
177      // Delete recentfiles menu.  #if defined(WIN32)
178      if (m_pRecentFilesMenu)      WSACleanup();
179          delete m_pRecentFilesMenu;  #endif
180    
181        // Finally drop any widgets around...
182        if (m_pMessages)
183            delete m_pMessages;
184        if (m_pWorkspace)
185            delete m_pWorkspace;
186    
187      // Delete status item labels one by one.      // Delete status item labels one by one.
188      if (m_status[QSAMPLER_STATUS_CLIENT])      if (m_status[QSAMPLER_STATUS_CLIENT])
189          delete m_status[QSAMPLER_STATUS_CLIENT];          delete m_status[QSAMPLER_STATUS_CLIENT];
# Line 145  void qsamplerMainForm::destroy (void) Line 194  void qsamplerMainForm::destroy (void)
194      if (m_status[QSAMPLER_STATUS_SESSION])      if (m_status[QSAMPLER_STATUS_SESSION])
195          delete m_status[QSAMPLER_STATUS_SESSION];          delete m_status[QSAMPLER_STATUS_SESSION];
196    
197      // Finally drop any widgets around...      // Delete recentfiles menu.
198      if (m_pMessages)      if (m_pRecentFilesMenu)
199          delete m_pMessages;          delete m_pRecentFilesMenu;
     if (m_pWorkspace)  
         delete m_pWorkspace;  
   
 #if defined(WIN32)  
     WSACleanup();  
 #endif  
200  }  }
201    
202    
# Line 252  void qsamplerMainForm::closeEvent ( QClo Line 295  void qsamplerMainForm::closeEvent ( QClo
295  }  }
296    
297    
298  // Window drag-n-drop event handlers.  // Drag'n'drop file handler.
299  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files )
300  {  {
301      bool bAccept = false;      bool bDecode = false;
302    
303      if (QTextDrag::canDecode(pDragEnterEvent)) {      if (QTextDrag::canDecode(pEvent)) {
304          QString sUrl;          QString sText;
305          if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient)          bDecode = QTextDrag::decode(pEvent, sText);
306              bAccept = QFileInfo(QUrl(sUrl).path()).exists();          if (bDecode) {
307                files = QStringList::split('\n', sText);
308                for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++)
309                    *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();
310            }
311      }      }
312    
313      pDragEnterEvent->accept(bAccept);      return bDecode;
314    }
315    
316    
317    // Window drag-n-drop event handlers.
318    void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
319    {
320            QStringList files;
321            pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));
322  }  }
323    
324    
325  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )
326  {  {
327      if (QTextDrag::canDecode(pDropEvent)) {      QStringList files;
328          QString sUrl;  
329          if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true))      if (!decodeDragFiles(pDropEvent, files))
330              loadSessionFile(QUrl(sUrl).path());          return;
331    
332        for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
333                    const QString& sPath = *iter;
334                    if (qsamplerChannel::isInstrumentFile(sPath)) {
335                            // Try to create a new channel from instrument file...
336                        qsamplerChannel *pChannel = new qsamplerChannel(this);
337                        if (pChannel == NULL)
338                            return;
339                            // Start setting the instrument filename...
340                            pChannel->setInstrument(sPath, 0);
341                        // Before we show it up, may be we'll
342                        // better ask for some initial values?
343                        if (!pChannel->channelSetup(this)) {
344                            delete pChannel;
345                            return;
346                        }
347                        // Finally, give it to a new channel strip...
348                            if (!createChannelStrip(pChannel)) {
349                            delete pChannel;
350                            return;
351                            }
352                        // Make that an overall update.
353                        m_iDirtyCount++;
354                        stabilizeForm();
355                    }   // Otherwise, load an usual session file (LSCP script)...
356                    else if (closeSession(true))
357                            loadSessionFile(sPath);
358                    // Make it look responsive...:)
359                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
360            }
361    }
362    
363    
364    // Custome event handler.
365    void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent )
366    {
367        // For the time being, just pump it to messages.
368        if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
369            qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
370            appendMessagesColor(tr("Notify event: %1 data: %2")
371                .arg(::lscp_event_to_text(pEvent->event()))
372                .arg(pEvent->data()), "#996699");
373      }      }
374  }  }
375    
# Line 325  bool qsamplerMainForm::newSession (void) Line 422  bool qsamplerMainForm::newSession (void)
422      if (!closeSession(true))      if (!closeSession(true))
423          return false;          return false;
424    
425            // Give us what the server has, right now...
426            updateSession();
427    
428      // Ok increment untitled count.      // Ok increment untitled count.
429      m_iUntitled++;      m_iUntitled++;
430    
# Line 438  bool qsamplerMainForm::closeSession ( bo Line 538  bool qsamplerMainForm::closeSession ( bo
538          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
539          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
540          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
541              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
542              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
543                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
544              delete pChannel;                  if (bForce && pChannel)
545                        pChannel->removeChannel();
546                    delete pChannelStrip;
547                }
548          }          }
549          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
550          // We're now clean, for sure.          // We're now clean, for sure.
# Line 480  bool qsamplerMainForm::loadSessionFile ( Line 583  bool qsamplerMainForm::loadSessionFile (
583              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
584                  appendMessagesClient("lscp_client_query");                  appendMessagesClient("lscp_client_query");
585                  iErrors++;                  iErrors++;
586                    break;
587              }              }
588          }          }
589          // Try to make it snappy :)          // Try to make it snappy :)
# Line 491  bool qsamplerMainForm::loadSessionFile ( Line 595  bool qsamplerMainForm::loadSessionFile (
595    
596      // Have we any errors?      // Have we any errors?
597      if (iErrors > 0)      if (iErrors > 0)
598          appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename));
599    
600      // Now we'll try to create the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
601      int iChannels = ::lscp_get_channels(m_pClient);          updateSession();
     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++) {  
         createChannel(iChannelID, false);  
         QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
     }  
     m_pWorkspace->setUpdatesEnabled(true);  
602    
603      // Save as default session directory.      // Save as default session directory.
604      if (m_pOptions)      if (m_pOptions)
# Line 517  bool qsamplerMainForm::loadSessionFile ( Line 609  bool qsamplerMainForm::loadSessionFile (
609      m_sFilename = sFilename;      m_sFilename = sFilename;
610      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
611      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
612        
613        // Make that an overall update.
614      stabilizeForm();      stabilizeForm();
615      return true;      return true;
616  }  }
# Line 550  bool qsamplerMainForm::saveSessionFile ( Line 644  bool qsamplerMainForm::saveSessionFile (
644      ts << endl;      ts << endl;
645      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
646      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
647          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
648          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
649          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
650          ts << "ADD CHANNEL" << endl;              if (pChannel) {
651          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  ts << "# Channel " << iChannel << endl;
652          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "ADD CHANNEL" << endl;
653      //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl;
654          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl;
655          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;              //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl;
656          ts << "LOAD INSTRUMENT NON_MODAL " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";
657          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
658          ts << endl;                      ts << "ALL";
659                    else
660                        ts << pChannel->midiChannel();
661                    ts << endl;
662                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
663                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;
664                    ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;
665                    ts << endl;
666                }
667            }
668          // Try to keep it snappy :)          // Try to keep it snappy :)
669          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
670      }      }
# Line 633  void qsamplerMainForm::fileSaveAs (void) Line 736  void qsamplerMainForm::fileSaveAs (void)
736  }  }
737    
738    
739    // Reset the sampler instance.
740    void qsamplerMainForm::fileReset (void)
741    {
742        if (m_pClient == NULL)
743            return;
744    
745        // Ask user whether he/she want's an internal sampler reset...
746        if (QMessageBox::warning(this, tr("Warning"),
747            tr("Resetting the sampler instance will close\n"
748               "all device and channel configurations.\n\n"
749               "Please note that this operation may cause\n"
750               "temporary MIDI and Audio disruption\n\n"
751               "Do you want to reset the sampler engine now?"),
752            tr("Reset"), tr("Cancel")) > 0)
753            return;
754    
755        // Just do the reset, after closing down current session...
756        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
757            appendMessagesClient("lscp_reset_sampler");
758            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
759            return;
760        }
761    
762        // Log this.
763        appendMessages(tr("Sampler reset."));
764    
765            // Make it a new session...
766            newSession();
767    }
768    
769    
770  // Restart the client/server instance.  // Restart the client/server instance.
771  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
772  {  {
# Line 680  void qsamplerMainForm::editAddChannel (v Line 814  void qsamplerMainForm::editAddChannel (v
814      if (m_pClient == NULL)      if (m_pClient == NULL)
815          return;          return;
816    
817      // Create the new sampler channel.      // Just create the channel instance...
818      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
819      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
820          return;          return;
     }  
   
     // Log this happening.  
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
821    
822      // Just create the channel strip with given id.      // Before we show it up, may be we'll
823      createChannel(iChannelID, true);      // better ask for some initial values?
824        if (!pChannel->channelSetup(this)) {
825            delete pChannel;
826            return;
827        }
828        
829        // And give it to the strip (will own the channel instance, if successful).
830        if (!createChannelStrip(pChannel)) {
831            delete pChannel;
832            return;
833        }
834    
835      // We'll be dirty, for sure...      // Make that an overall update.
836      m_iDirtyCount++;      m_iDirtyCount++;
     // Stabilize form anyway.  
837      stabilizeForm();      stabilizeForm();
838  }  }
839    
# Line 707  void qsamplerMainForm::editRemoveChannel Line 844  void qsamplerMainForm::editRemoveChannel
844      if (m_pClient == NULL)      if (m_pClient == NULL)
845          return;          return;
846    
847      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
848        if (pChannelStrip == NULL)
849            return;
850            
851        qsamplerChannel *pChannel = pChannelStrip->channel();
852      if (pChannel == NULL)      if (pChannel == NULL)
853          return;          return;
854    
# Line 717  void qsamplerMainForm::editRemoveChannel Line 858  void qsamplerMainForm::editRemoveChannel
858              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
859                 "%1\n\n"                 "%1\n\n"
860                 "Are you sure?")                 "Are you sure?")
861                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
862              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
863              return;              return;
864      }      }
865    
866      // Remove the existing sampler channel.      // Remove the existing sampler channel.
867      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."));  
868          return;          return;
     }  
869    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
870      // Just delete the channel strip.      // Just delete the channel strip.
871      delete pChannel;      delete pChannelStrip;
872        
873      // Do we auto-arrange?      // Do we auto-arrange?
874      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
875          channelsArrange();          channelsArrange();
# Line 750  void qsamplerMainForm::editSetupChannel Line 886  void qsamplerMainForm::editSetupChannel
886      if (m_pClient == NULL)      if (m_pClient == NULL)
887          return;          return;
888    
889      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
890      if (pChannel == NULL)      if (pChannelStrip == NULL)
891          return;          return;
892    
893      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
894      pChannel->channelSetup();      pChannelStrip->channelSetup();
895  }  }
896    
897    
# Line 765  void qsamplerMainForm::editResetChannel Line 901  void qsamplerMainForm::editResetChannel
901      if (m_pClient == NULL)      if (m_pClient == NULL)
902          return;          return;
903    
904      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
905      if (pChannel == NULL)      if (pChannelStrip == NULL)
906          return;          return;
907    
908      // Remove the existing sampler channel.      // Just invoque the channel strip procedure.
909      if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      pChannelStrip->channelReset();
910          appendMessagesClient("lscp_reset_channel");  }
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
         return;  
     }  
911    
     // Log this.  
     appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));  
912    
913      // Refresh channel strip info.  // Reset all sampler channels.
914      pChannel->updateChannelInfo();  void qsamplerMainForm::editResetAllChannels (void)
915    {
916        if (m_pClient == NULL)
917            return;
918    
919        // Invoque the channel strip procedure,
920            // for all channels out there...
921        m_pWorkspace->setUpdatesEnabled(false);
922        QWidgetList wlist = m_pWorkspace->windowList();
923        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
924            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
925            if (pChannelStrip)
926                    pChannelStrip->channelReset();
927        }
928        m_pWorkspace->setUpdatesEnabled(true);
929  }  }
930    
931    
# Line 841  void qsamplerMainForm::viewOptions (void Line 986  void qsamplerMainForm::viewOptions (void
986      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
987      if (pOptionsForm) {      if (pOptionsForm) {
988          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
989          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
990          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
991              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
992          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
993              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
994          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 853  void qsamplerMainForm::viewOptions (void Line 998  void qsamplerMainForm::viewOptions (void
998          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
999          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
1000          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
1001            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1002          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
1003          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
1004          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
1005          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
1006          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1007          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
1008            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
1009          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1010          // Load the current setup settings.          // Load the current setup settings.
1011          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 877  void qsamplerMainForm::viewOptions (void Line 1024  void qsamplerMainForm::viewOptions (void
1024                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1025                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
1026                  updateRecentFilesMenu();                  updateRecentFilesMenu();
1027                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
1028                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
1029                    updateInstrumentNames();
1030                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
1031                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
1032                    updateDisplayEffect();
1033              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
1034                  updateDisplayFont();                  updateDisplayFont();
1035              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 919  void qsamplerMainForm::channelsArrange ( Line 1072  void qsamplerMainForm::channelsArrange (
1072      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1073      int y = 0;      int y = 0;
1074      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1075          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1076      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1077              // Prevent flicker...              // Prevent flicker...
1078              pChannel->hide();              pChannelStrip->hide();
1079              pChannel->showNormal();              pChannelStrip->showNormal();
1080          }   */          }   */
1081          pChannel->adjustSize();          pChannelStrip->adjustSize();
1082          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1083          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1084              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1085      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1086          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1087          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1088          y += iHeight;          y += iHeight;
1089      }      }
1090      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 979  void qsamplerMainForm::helpAbout (void) Line 1132  void qsamplerMainForm::helpAbout (void)
1132      sText += tr("Debugging option enabled.");      sText += tr("Debugging option enabled.");
1133      sText += "</font></small><br />";      sText += "</font></small><br />";
1134  #endif  #endif
1135    #ifndef CONFIG_LIBGIG
1136        sText += "<small><font color=\"red\">";
1137        sText += tr("GIG (libgig) file support disabled.");
1138        sText += "</font></small><br />";
1139    #endif
1140    #ifndef CONFIG_INSTRUMENT_NAME
1141        sText += "<small><font color=\"red\">";
1142        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1143        sText += "</font></small><br />";
1144    #endif
1145      sText += "<br />\n";      sText += "<br />\n";
1146      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1147      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1006  void qsamplerMainForm::helpAbout (void) Line 1169  void qsamplerMainForm::helpAbout (void)
1169  void qsamplerMainForm::stabilizeForm (void)  void qsamplerMainForm::stabilizeForm (void)
1170  {  {
1171      // Update the main application caption...      // Update the main application caption...
1172      QString sSessioName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1173      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1174          sSessioName += '*';          sSessionName += '*';
1175      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1176    
1177      // Update the main menu state...      // Update the main menu state...
1178      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1179      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1180      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1181      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1182      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1183      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1184      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1185        fileResetAction->setEnabled(bHasClient);
1186      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1187      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1188      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
1189      editSetupChannelAction->setEnabled(bHasChannel);      editSetupChannelAction->setEnabled(bHasChannel);
1190      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1191        editResetAllChannelsAction->setEnabled(bHasChannel);
1192      channelsArrangeAction->setEnabled(bHasChannel);      channelsArrangeAction->setEnabled(bHasChannel);
1193      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1194    
# Line 1037  void qsamplerMainForm::stabilizeForm (vo Line 1202  void qsamplerMainForm::stabilizeForm (vo
1202      }      }
1203      // Channel status...      // Channel status...
1204      if (bHasChannel)      if (bHasChannel)
1205          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1206      else      else
1207          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_status[QSAMPLER_STATUS_CHANNEL]->clear();
1208      // Session status...      // Session status...
# Line 1056  void qsamplerMainForm::stabilizeForm (vo Line 1221  void qsamplerMainForm::stabilizeForm (vo
1221    
1222    
1223  // Channel change receiver slot.  // Channel change receiver slot.
1224  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )
1225  {  {
1226            // Add this strip to the changed list...
1227            if (m_changedStrips.containsRef(pChannelStrip) == 0)
1228                    m_changedStrips.append(pChannelStrip);
1229    
1230      // Just mark the dirty form.      // Just mark the dirty form.
1231      m_iDirtyCount++;      m_iDirtyCount++;
1232      // and update the form status...      // and update the form status...
# Line 1065  void qsamplerMainForm::channelChanged( q Line 1234  void qsamplerMainForm::channelChanged( q
1234  }  }
1235    
1236    
1237    // Grab and restore current sampler channels session.
1238    void qsamplerMainForm::updateSession (void)
1239    {
1240            // Retrieve the current channel list.
1241            int *piChannelIDs = ::lscp_list_channels(m_pClient);
1242            if (piChannelIDs == NULL) {
1243                    if (::lscp_client_get_errno(m_pClient)) {
1244                            appendMessagesClient("lscp_list_channels");
1245                            appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1246                    }
1247                    return;
1248            }
1249    
1250            // Try to (re)create each channel.
1251            m_pWorkspace->setUpdatesEnabled(false);
1252            for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1253                    // Check if theres already a channel strip for this one...
1254                    if (!channelStrip(piChannelIDs[iChannel]))
1255                            createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
1256                    // Make it visibly responsive...
1257                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1258            }
1259            m_pWorkspace->setUpdatesEnabled(true);
1260    }
1261    
1262    
1263  // Update the recent files list and menu.  // Update the recent files list and menu.
1264  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )
1265  {  {
# Line 1109  void qsamplerMainForm::updateRecentFiles Line 1304  void qsamplerMainForm::updateRecentFiles
1304  }  }
1305    
1306    
1307    // Force update of the channels instrument names mode.
1308    void qsamplerMainForm::updateInstrumentNames (void)
1309    {
1310        // Full channel list update...
1311        QWidgetList wlist = m_pWorkspace->windowList();
1312        if (wlist.isEmpty())
1313            return;
1314    
1315        m_pWorkspace->setUpdatesEnabled(false);
1316        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1317            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1318            if (pChannelStrip)
1319                pChannelStrip->updateInstrumentName(true);
1320        }
1321        m_pWorkspace->setUpdatesEnabled(true);
1322    }
1323    
1324    
1325  // Force update of the channels display font.  // Force update of the channels display font.
1326  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1327  {  {
# Line 1130  void qsamplerMainForm::updateDisplayFont Line 1343  void qsamplerMainForm::updateDisplayFont
1343    
1344      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1345      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1346          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1347          pChannel->setDisplayFont(font);          if (pChannelStrip)
1348                pChannelStrip->setDisplayFont(font);
1349        }
1350        m_pWorkspace->setUpdatesEnabled(true);
1351    }
1352    
1353    
1354    // Update channel strips background effect.
1355    void qsamplerMainForm::updateDisplayEffect (void)
1356    {
1357       QPixmap pm;
1358        if (m_pOptions->bDisplayEffect)
1359            pm = QPixmap::fromMimeSource("displaybg1.png");
1360    
1361        // Full channel list update...
1362        QWidgetList wlist = m_pWorkspace->windowList();
1363        if (wlist.isEmpty())
1364            return;
1365    
1366        m_pWorkspace->setUpdatesEnabled(false);
1367        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1368            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1369            if (pChannelStrip)
1370                pChannelStrip->setDisplayBackground(pm);
1371      }      }
1372      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1373  }  }
# Line 1150  void qsamplerMainForm::updateMaxVolume ( Line 1386  void qsamplerMainForm::updateMaxVolume (
1386    
1387      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1388      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1389          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1390          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1391                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1392      }      }
1393      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1394  }  }
# Line 1250  void qsamplerMainForm::updateMessagesCap Line 1487  void qsamplerMainForm::updateMessagesCap
1487  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1488    
1489  // The channel strip creation executive.  // The channel strip creation executive.
1490  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1491  {  {
1492      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1493          return;          return NULL;
1494    
1495      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1496      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1497      int y = 0;      int y = 0;
1498      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1499          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1500          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1501              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1502          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();                          if (pChannelStrip) {
1503              y += pChannel->parentWidget()->frameGeometry().height();                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1504                                    y += pChannelStrip->parentWidget()->frameGeometry().height();
1505                            }
1506          }          }
1507      }      }
1508    
1509      // Add a new channel itema...      // Add a new channel itema...
1510      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;
1511      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1512      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1513      pChannel->setup(this, iChannelID);          return NULL;
1514      // We'll need a display font.          
1515      QFont font;      // Actual channel strip setup...
1516      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1517          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1518      // Track channel setup changes.      // Set some initial aesthetic options...
1519      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1520      // Before we show it up, may be we'll          // Background display effect...
1521      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1522      if (bPrompt)          // We'll need a display font.
1523          pChannel->channelSetup();                QFont font;
1524            if (font.fromString(m_pOptions->sDisplayFont))
1525                pChannelStrip->setDisplayFont(font);
1526            // Maximum allowed volume setting.
1527            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1528        }
1529    
1530      // Now we show up us to the world.      // Now we show up us to the world.
1531      pChannel->show();      pChannelStrip->show();
1532      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1533      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1534          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1535      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1536          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1537          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1538      }      }
1539    
1540            // This is pretty new, so we'll watch for it closely.
1541            channelStripChanged(pChannelStrip);
1542    
1543        // Return our successful reference...
1544        return pChannelStrip;
1545  }  }
1546    
1547    
1548  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1549  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1550  {  {
1551      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1552  }  }
1553    
1554    
1555  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1556  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1557  {  {
1558      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1559      if (wlist.isEmpty())      if (wlist.isEmpty())
1560          return 0;          return NULL;
1561    
1562      return (qsamplerChannelStrip *) wlist.at(iChannel);      return (qsamplerChannelStrip *) wlist.at(iChannel);
1563  }  }
1564    
1565    
1566    // Retrieve a channel strip by sampler channel id.
1567    qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID )
1568    {
1569            QWidgetList wlist = m_pWorkspace->windowList();
1570            if (wlist.isEmpty())
1571                    return NULL;
1572            
1573            for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1574                    qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1575                    if (pChannelStrip) {
1576                            qsamplerChannel *pChannel = pChannelStrip->channel();
1577                            if (pChannel && pChannel->channelID() == iChannelID)
1578                                    return pChannelStrip;
1579                    }
1580            }
1581    
1582            // Not found.
1583            return NULL;
1584    }
1585    
1586    
1587  // Construct the windows menu.  // Construct the windows menu.
1588  void qsamplerMainForm::channelsMenuAboutToShow (void)  void qsamplerMainForm::channelsMenuAboutToShow (void)
1589  {  {
# Line 1323  void qsamplerMainForm::channelsMenuAbout Line 1595  void qsamplerMainForm::channelsMenuAbout
1595      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1596          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1597          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1598              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1599              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1600              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1601              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1602                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1603                }
1604          }          }
1605      }      }
1606  }  }
# Line 1335  void qsamplerMainForm::channelsMenuAbout Line 1609  void qsamplerMainForm::channelsMenuAbout
1609  // Windows menu activation slot  // Windows menu activation slot
1610  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1611  {  {
1612      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1613      if (pChannel)      if (pChannelStrip)
1614          pChannel->showNormal();          pChannelStrip->showNormal();
1615      pChannel->setFocus();      pChannelStrip->setFocus();
1616  }  }
1617    
1618    
# Line 1378  void qsamplerMainForm::timerSlot (void) Line 1652  void qsamplerMainForm::timerSlot (void)
1652      }      }
1653            
1654          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1655      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) {
1656          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1657          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1658              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1659                // Update the channel information for each pending strip...
1660                for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();
1661                        pChannelStrip;
1662                                                    pChannelStrip = m_changedStrips.next()) {
1663                                    // If successfull, remove from pending list...
1664                                    if (pChannelStrip->updateChannelInfo())
1665                        m_changedStrips.remove(pChannelStrip);
1666                            }
1667                // Update the channel stream usage for each strip...
1668              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1669              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1670                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1671                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible())
1672                      pChannel->updateChannelUsage();                      pChannelStrip->updateChannelUsage();
1673              }              }
1674          }          }
1675      }      }
# Line 1523  void qsamplerMainForm::processServerExit Line 1806  void qsamplerMainForm::processServerExit
1806  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1807  // qsamplerMainForm -- Client stuff.  // qsamplerMainForm -- Client stuff.
1808    
   
1809  // The LSCP client callback procedure.  // The LSCP client callback procedure.
1810  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/, lscp_event_t /*event*/, const char */*pchBuffer*/, int /*cchBuffer*/, void */*pvData*/ )  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/, lscp_event_t event, const char *pchData, int cchData, void *pvData )
1811  {  {
1812      // FIXME: DO NOT EVER call any GUI code here,      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;
1813        if (pMainForm == NULL)
1814            return LSCP_FAILED;
1815    
1816        // ATTN: DO NOT EVER call any GUI code here,
1817      // as this is run under some other thread context.      // as this is run under some other thread context.
1818      // A custom event must be posted here...      // A custom event must be posted here...
1819      //      QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData));
     // QApplication::postEvent((qjackctlMainForm *) pvData, new QCustomEvent(...));  
1820    
1821      return LSCP_OK;      return LSCP_OK;
1822  }  }

Legend:
Removed from v.145  
changed lines
  Added in v.418

  ViewVC Help
Powered by ViewVC