/[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 263 by capela, Wed Sep 29 09:01:35 2004 UTC revision 400 by capela, Mon Feb 21 15:02:58 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 103  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 114  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 284  void qsamplerMainForm::closeEvent ( QClo Line 294  void qsamplerMainForm::closeEvent ( QClo
294  }  }
295    
296    
297  // Window drag-n-drop event handlers.  // Drag'n'drop file handler.
298  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files )
299  {  {
300      bool bAccept = false;      bool bDecode = false;
301    
302      if (QTextDrag::canDecode(pDragEnterEvent)) {      if (QTextDrag::canDecode(pEvent)) {
303          QString sUrl;          QString sText;
304          if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient)          bDecode = QTextDrag::decode(pEvent, sText);
305              bAccept = QFileInfo(QUrl(sUrl).path()).exists();          if (bDecode) {
306                files = QStringList::split('\n', sText);
307                for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++)
308                    *iter = (*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null);
309            }
310      }      }
311    
312      pDragEnterEvent->accept(bAccept);      return bDecode;
313    }
314    
315    
316    // Window drag-n-drop event handlers.
317    void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
318    {
319            QStringList files;
320            pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));
321  }  }
322    
323    
324  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )
325  {  {
326      if (QTextDrag::canDecode(pDropEvent)) {      QStringList files;
327          QString sUrl;  
328          if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true))      if (!decodeDragFiles(pDropEvent, files))
329              loadSessionFile(QUrl(sUrl).path());          return;
330      }  
331        for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
332                    const QString& sPath = QUrl(*iter).path();
333                    if (qsamplerChannel::isInstrumentFile(sPath)) {
334                            // Try to create a new channel from instrument file...
335                        qsamplerChannel *pChannel = new qsamplerChannel(this);
336                        if (pChannel == NULL)
337                            return;
338                            // Start setting the instrument filename...
339                            pChannel->setInstrument(sPath, 0);
340                        // Before we show it up, may be we'll
341                        // better ask for some initial values?
342                        if (!pChannel->channelSetup(this)) {
343                            delete pChannel;
344                            return;
345                        }
346                        // Finally, give it to a new channel strip...
347                            if (!createChannelStrip(pChannel)) {
348                            delete pChannel;
349                            return;
350                            }
351                        // Make that an overall update.
352                        m_iDirtyCount++;
353                        stabilizeForm();
354                    }   // Otherwise, load an usual session file (LSCP script)...
355                    else if (closeSession(true))
356                            loadSessionFile(sPath);
357                    // Make it look responsive...:)
358                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
359            }
360  }  }
361    
362    
# Line 370  bool qsamplerMainForm::newSession (void) Line 421  bool qsamplerMainForm::newSession (void)
421      if (!closeSession(true))      if (!closeSession(true))
422          return false;          return false;
423    
424            // Give us what the server has, right now...
425            updateSession();
426    
427      // Ok increment untitled count.      // Ok increment untitled count.
428      m_iUntitled++;      m_iUntitled++;
429    
# Line 483  bool qsamplerMainForm::closeSession ( bo Line 537  bool qsamplerMainForm::closeSession ( bo
537          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
538          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
539          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
540              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
541              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
542                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
543              delete pChannel;                  if (bForce && pChannel)
544                        pChannel->removeChannel();
545                    delete pChannelStrip;
546                }
547          }          }
548          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
549          // We're now clean, for sure.          // We're now clean, for sure.
# Line 525  bool qsamplerMainForm::loadSessionFile ( Line 582  bool qsamplerMainForm::loadSessionFile (
582              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
583                  appendMessagesClient("lscp_client_query");                  appendMessagesClient("lscp_client_query");
584                  iErrors++;                  iErrors++;
585                    break;
586              }              }
587          }          }
588          // Try to make it snappy :)          // Try to make it snappy :)
# Line 536  bool qsamplerMainForm::loadSessionFile ( Line 594  bool qsamplerMainForm::loadSessionFile (
594    
595      // Have we any errors?      // Have we any errors?
596      if (iErrors > 0)      if (iErrors > 0)
597          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));
598    
599      // Now we'll try to create the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
600      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);  
601    
602      // Save as default session directory.      // Save as default session directory.
603      if (m_pOptions)      if (m_pOptions)
# Line 562  bool qsamplerMainForm::loadSessionFile ( Line 608  bool qsamplerMainForm::loadSessionFile (
608      m_sFilename = sFilename;      m_sFilename = sFilename;
609      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
610      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
611        
612        // Make that an overall update.
613      stabilizeForm();      stabilizeForm();
614      return true;      return true;
615  }  }
# Line 595  bool qsamplerMainForm::saveSessionFile ( Line 643  bool qsamplerMainForm::saveSessionFile (
643      ts << endl;      ts << endl;
644      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
645      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
646          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
647          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
648          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
649          ts << "ADD CHANNEL" << endl;              if (pChannel) {
650          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  int iChannelID = pChannel->channelID();
651          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "# " << pChannelStrip->caption() << endl;
652          ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "ADD CHANNEL" << endl;
653          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
654          if (pChannel->midiChannel() > 0)                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
655              ts << pChannel->midiChannel();                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
656           else                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
657              ts << "ALL";                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
658          ts << endl;                      ts << "ALL";
659          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  else
660          ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                      ts << pChannel->midiChannel();
661          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  ts << endl;
662          ts << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
663                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
664                    ts << "SET CHANNEL VOLUME " << iChannelID << " " << 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 708  void qsamplerMainForm::fileReset (void) Line 761  void qsamplerMainForm::fileReset (void)
761    
762      // Log this.      // Log this.
763      appendMessages(tr("Sampler reset."));      appendMessages(tr("Sampler reset."));
764    
765            // Make it a new session...
766            newSession();
767  }  }
768    
769    
# Line 758  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 785  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 795  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 828  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->showChannelSetup(false);      pChannelStrip->channelSetup();
895  }  }
896    
897    
# Line 843  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();
         appendMessagesClient("lscp_reset_channel");  
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
         return;  
     }  
   
     // Log this.  
     appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));  
   
     // Refresh channel strip info.  
     pChannel->updateChannelInfo();  
910  }  }
911    
912    
# Line 919  void qsamplerMainForm::viewOptions (void Line 967  void qsamplerMainForm::viewOptions (void
967      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
968      if (pOptionsForm) {      if (pOptionsForm) {
969          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
970          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
971          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
972              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
973          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
974              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
975          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 931  void qsamplerMainForm::viewOptions (void Line 979  void qsamplerMainForm::viewOptions (void
979          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
980          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
981          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
982            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
983          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
984          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
985          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
986          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
987          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
988          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
989            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
990          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
991          // Load the current setup settings.          // Load the current setup settings.
992          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 955  void qsamplerMainForm::viewOptions (void Line 1005  void qsamplerMainForm::viewOptions (void
1005                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1006                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
1007                  updateRecentFilesMenu();                  updateRecentFilesMenu();
1008                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
1009                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
1010                    updateInstrumentNames();
1011                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
1012                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
1013                    updateDisplayEffect();
1014              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
1015                  updateDisplayFont();                  updateDisplayFont();
1016              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 997  void qsamplerMainForm::channelsArrange ( Line 1053  void qsamplerMainForm::channelsArrange (
1053      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1054      int y = 0;      int y = 0;
1055      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1056          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1057      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1058              // Prevent flicker...              // Prevent flicker...
1059              pChannel->hide();              pChannelStrip->hide();
1060              pChannel->showNormal();              pChannelStrip->showNormal();
1061          }   */          }   */
1062          pChannel->adjustSize();          pChannelStrip->adjustSize();
1063          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1064          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1065              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1066      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1067          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1068          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1069          y += iHeight;          y += iHeight;
1070      }      }
1071      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 1062  void qsamplerMainForm::helpAbout (void) Line 1118  void qsamplerMainForm::helpAbout (void)
1118      sText += tr("GIG (libgig) file support disabled.");      sText += tr("GIG (libgig) file support disabled.");
1119      sText += "</font></small><br />";      sText += "</font></small><br />";
1120  #endif  #endif
1121    #ifndef CONFIG_INSTRUMENT_NAME
1122        sText += "<small><font color=\"red\">";
1123        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1124        sText += "</font></small><br />";
1125    #endif
1126      sText += "<br />\n";      sText += "<br />\n";
1127      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1128      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1095  void qsamplerMainForm::stabilizeForm (vo Line 1156  void qsamplerMainForm::stabilizeForm (vo
1156      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));
1157    
1158      // Update the main menu state...      // Update the main menu state...
1159      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1160      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1161      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1162      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1163      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1164      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
# Line 1121  void qsamplerMainForm::stabilizeForm (vo Line 1182  void qsamplerMainForm::stabilizeForm (vo
1182      }      }
1183      // Channel status...      // Channel status...
1184      if (bHasChannel)      if (bHasChannel)
1185          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1186      else      else
1187          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_status[QSAMPLER_STATUS_CHANNEL]->clear();
1188      // Session status...      // Session status...
# Line 1140  void qsamplerMainForm::stabilizeForm (vo Line 1201  void qsamplerMainForm::stabilizeForm (vo
1201    
1202    
1203  // Channel change receiver slot.  // Channel change receiver slot.
1204  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )
1205  {  {
1206            // Add this strip to the changed list...
1207            if (m_changedStrips.containsRef(pChannelStrip) == 0)
1208                    m_changedStrips.append(pChannelStrip);
1209    
1210      // Just mark the dirty form.      // Just mark the dirty form.
1211      m_iDirtyCount++;      m_iDirtyCount++;
1212      // and update the form status...      // and update the form status...
# Line 1149  void qsamplerMainForm::channelChanged( q Line 1214  void qsamplerMainForm::channelChanged( q
1214  }  }
1215    
1216    
1217    // Grab and restore current sampler channels session.
1218    void qsamplerMainForm::updateSession (void)
1219    {
1220            // Retrieve the current channel list.
1221            int *piChannelIDs = ::lscp_list_channels(m_pClient);
1222            if (piChannelIDs == NULL) {
1223                    if (::lscp_client_get_errno(m_pClient)) {
1224                            appendMessagesClient("lscp_list_channels");
1225                            appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1226                    }
1227                    return;
1228            }
1229    
1230            // Try to (re)create each channel.
1231            m_pWorkspace->setUpdatesEnabled(false);
1232            for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1233                    // Check if theres already a channel strip for this one...
1234                    if (!channelStrip(piChannelIDs[iChannel]))
1235                            createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
1236                    // Make it visibly responsive...
1237                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1238            }
1239            m_pWorkspace->setUpdatesEnabled(true);
1240    }
1241    
1242    
1243  // Update the recent files list and menu.  // Update the recent files list and menu.
1244  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )
1245  {  {
# Line 1193  void qsamplerMainForm::updateRecentFiles Line 1284  void qsamplerMainForm::updateRecentFiles
1284  }  }
1285    
1286    
1287    // Force update of the channels instrument names mode.
1288    void qsamplerMainForm::updateInstrumentNames (void)
1289    {
1290        // Full channel list update...
1291        QWidgetList wlist = m_pWorkspace->windowList();
1292        if (wlist.isEmpty())
1293            return;
1294    
1295        m_pWorkspace->setUpdatesEnabled(false);
1296        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1297            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1298            if (pChannelStrip)
1299                pChannelStrip->updateInstrumentName(true);
1300        }
1301        m_pWorkspace->setUpdatesEnabled(true);
1302    }
1303    
1304    
1305  // Force update of the channels display font.  // Force update of the channels display font.
1306  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1307  {  {
# Line 1214  void qsamplerMainForm::updateDisplayFont Line 1323  void qsamplerMainForm::updateDisplayFont
1323    
1324      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1325      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1326          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1327          pChannel->setDisplayFont(font);          if (pChannelStrip)
1328                pChannelStrip->setDisplayFont(font);
1329        }
1330        m_pWorkspace->setUpdatesEnabled(true);
1331    }
1332    
1333    
1334    // Update channel strips background effect.
1335    void qsamplerMainForm::updateDisplayEffect (void)
1336    {
1337       QPixmap pm;
1338        if (m_pOptions->bDisplayEffect)
1339            pm = QPixmap::fromMimeSource("displaybg1.png");
1340    
1341        // Full channel list update...
1342        QWidgetList wlist = m_pWorkspace->windowList();
1343        if (wlist.isEmpty())
1344            return;
1345    
1346        m_pWorkspace->setUpdatesEnabled(false);
1347        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1348            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1349            if (pChannelStrip)
1350                pChannelStrip->setDisplayBackground(pm);
1351      }      }
1352      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1353  }  }
# Line 1234  void qsamplerMainForm::updateMaxVolume ( Line 1366  void qsamplerMainForm::updateMaxVolume (
1366    
1367      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1368      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1369          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1370          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1371                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1372      }      }
1373      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1374  }  }
# Line 1334  void qsamplerMainForm::updateMessagesCap Line 1467  void qsamplerMainForm::updateMessagesCap
1467  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1468    
1469  // The channel strip creation executive.  // The channel strip creation executive.
1470  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1471  {  {
1472      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1473          return;          return NULL;
1474    
1475      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1476      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1477      int y = 0;      int y = 0;
1478      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1479          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1480          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1481              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1482          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();                          if (pChannelStrip) {
1483              y += pChannel->parentWidget()->frameGeometry().height();                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1484                                    y += pChannelStrip->parentWidget()->frameGeometry().height();
1485                            }
1486          }          }
1487      }      }
1488    
1489      // Add a new channel itema...      // Add a new channel itema...
1490      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;
1491      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1492      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1493      pChannel->setup(this, iChannelID);          return NULL;
1494      // We'll need a display font.          
1495      QFont font;      // Actual channel strip setup...
1496      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1497          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1498      // Track channel setup changes.      // Set some initial aesthetic options...
1499      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1500      // Before we show it up, may be we'll          // Background display effect...
1501      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1502      if (bPrompt)          // We'll need a display font.
1503          pChannel->showChannelSetup(true);          QFont font;
1504            if (font.fromString(m_pOptions->sDisplayFont))
1505                pChannelStrip->setDisplayFont(font);
1506            // Maximum allowed volume setting.
1507            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1508        }
1509    
1510      // Now we show up us to the world.      // Now we show up us to the world.
1511      pChannel->show();      pChannelStrip->show();
1512      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1513      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1514          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1515      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1516          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1517          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1518      }      }
1519    
1520            // This is pretty new, so we'll watch for it closely.
1521            channelStripChanged(pChannelStrip);
1522    
1523        // Return our successful reference...
1524        return pChannelStrip;
1525  }  }
1526    
1527    
1528  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1529  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1530  {  {
1531      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1532  }  }
1533    
1534    
1535  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1536  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1537  {  {
1538      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1539      if (wlist.isEmpty())      if (wlist.isEmpty())
1540          return 0;          return NULL;
1541    
1542      return (qsamplerChannelStrip *) wlist.at(iChannel);      return (qsamplerChannelStrip *) wlist.at(iChannel);
1543  }  }
1544    
1545    
1546    // Retrieve a channel strip by sampler channel id.
1547    qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID )
1548    {
1549            QWidgetList wlist = m_pWorkspace->windowList();
1550            if (wlist.isEmpty())
1551                    return NULL;
1552            
1553            for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1554                    qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1555                    if (pChannelStrip) {
1556                            qsamplerChannel *pChannel = pChannelStrip->channel();
1557                            if (pChannel && pChannel->channelID() == iChannelID)
1558                                    return pChannelStrip;
1559                    }
1560            }
1561    
1562            // Not found.
1563            return NULL;
1564    }
1565    
1566    
1567  // Construct the windows menu.  // Construct the windows menu.
1568  void qsamplerMainForm::channelsMenuAboutToShow (void)  void qsamplerMainForm::channelsMenuAboutToShow (void)
1569  {  {
# Line 1407  void qsamplerMainForm::channelsMenuAbout Line 1575  void qsamplerMainForm::channelsMenuAbout
1575      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1576          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1577          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1578              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1579              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1580              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1581              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1582                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1583                }
1584          }          }
1585      }      }
1586  }  }
# Line 1419  void qsamplerMainForm::channelsMenuAbout Line 1589  void qsamplerMainForm::channelsMenuAbout
1589  // Windows menu activation slot  // Windows menu activation slot
1590  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1591  {  {
1592      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1593      if (pChannel)      if (pChannelStrip)
1594          pChannel->showNormal();          pChannelStrip->showNormal();
1595      pChannel->setFocus();      pChannelStrip->setFocus();
1596  }  }
1597    
1598    
# Line 1462  void qsamplerMainForm::timerSlot (void) Line 1632  void qsamplerMainForm::timerSlot (void)
1632      }      }
1633            
1634          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1635      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) {
1636          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1637          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1638              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1639                // Update the channel information for each pending strip...
1640                for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();
1641                        pChannelStrip;
1642                                                    pChannelStrip = m_changedStrips.next()) {
1643                                    // If successfull, remove from pending list...
1644                                    if (pChannelStrip->updateChannelInfo())
1645                        m_changedStrips.remove(pChannelStrip);
1646                            }
1647                // Update the channel stream usage for each strip...
1648              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1649              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1650                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1651                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible())
1652                      pChannel->updateChannelUsage();                      pChannelStrip->updateChannelUsage();
1653              }              }
1654          }          }
1655      }      }

Legend:
Removed from v.263  
changed lines
  Added in v.400

  ViewVC Help
Powered by ViewVC