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

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

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

revision 176 by capela, Tue Jul 6 10:54:45 2004 UTC revision 388 by capela, Thu Feb 17 17:27:59 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        m_iChangeCount = 0;
114    
115      m_pServer = NULL;      m_pServer = NULL;
116      m_pClient = NULL;      m_pClient = NULL;
# Line 114  void qsamplerMainForm::init (void) Line 120  void qsamplerMainForm::init (void)
120    
121      m_iTimerSlot = 0;      m_iTimerSlot = 0;
122    
123    #ifdef HAVE_SIGNAL_H
124            // Set to ignore any fatal "Broken pipe" signals.
125            ::signal(SIGPIPE, SIG_IGN);
126    #endif
127    
128      // Make it an MDI workspace.      // Make it an MDI workspace.
129      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
130      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
# Line 284  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 = (*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null);
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    
322        pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));
323  }  }
324    
325    
326  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )
327  {  {
328      if (QTextDrag::canDecode(pDropEvent)) {      QStringList files;
329          QString sUrl;      if (decodeDragFiles(pDropEvent, files)) {
330          if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true))          for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
331              loadSessionFile(QUrl(sUrl).path());                          const QString& sPath = QUrl(*iter).path();
332                            if (qsamplerChannel::isInstrumentFile(sPath)) {
333                                    // Try to create a new channel from instrument file...
334                                qsamplerChannel *pChannel = new qsamplerChannel(this);
335                                if (pChannel == NULL)
336                                    return;
337                                    // Start setting the instrument filename...
338                                    pChannel->setInstrument(sPath, 0);
339                                // Before we show it up, may be we'll
340                                // better ask for some initial values?
341                                if (!pChannel->channelSetup(this)) {
342                                    delete pChannel;
343                                    return;
344                                }
345                                // Make that an overall update.
346                                m_iDirtyCount++;
347                                m_iChangeCount++;
348                                stabilizeForm();
349                    }   // Otherwise, load an usual session file (LSCP script)...
350                            else if (closeSession(true))
351                                    loadSessionFile(sPath);
352                    }
353      }      }
354  }  }
355    
# Line 483  bool qsamplerMainForm::closeSession ( bo Line 528  bool qsamplerMainForm::closeSession ( bo
528          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
529          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
530          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
531              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
532              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
533                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
534              delete pChannel;                  if (bForce && pChannel)
535                        pChannel->removeChannel();
536                    delete pChannelStrip;
537                }
538          }          }
539          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
540          // We're now clean, for sure.          // We're now clean, for sure.
# Line 525  bool qsamplerMainForm::loadSessionFile ( Line 573  bool qsamplerMainForm::loadSessionFile (
573              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
574                  appendMessagesClient("lscp_client_query");                  appendMessagesClient("lscp_client_query");
575                  iErrors++;                  iErrors++;
576                    break;
577              }              }
578          }          }
579          // Try to make it snappy :)          // Try to make it snappy :)
# Line 536  bool qsamplerMainForm::loadSessionFile ( Line 585  bool qsamplerMainForm::loadSessionFile (
585    
586      // Have we any errors?      // Have we any errors?
587      if (iErrors > 0)      if (iErrors > 0)
588          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));
589    
590      // Now we'll try to create the whole GUI session.      // Now we'll try to create the whole GUI session.
591      int iChannels = ::lscp_get_channels(m_pClient);      int *piChannelIDs = ::lscp_list_channels(m_pClient);
592      if (iChannels < 0) {      if (piChannelIDs == NULL) {
593          appendMessagesClient("lscp_get_channels");          appendMessagesClient("lscp_list_channels");
594          appendMessagesError(tr("Could not get current number of channels.\n\nSorry."));          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
595      }      } else {
596                        // Try to (re)create each channel.
597      // Try to (re)create each channel.                  m_pWorkspace->setUpdatesEnabled(false);
598      m_pWorkspace->setUpdatesEnabled(false);                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
599      for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) {                          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
600          createChannel(iChannelID, false);                          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
601          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  }
602      }                  m_pWorkspace->setUpdatesEnabled(true);
603      m_pWorkspace->setUpdatesEnabled(true);          }
604    
605      // Save as default session directory.      // Save as default session directory.
606      if (m_pOptions)      if (m_pOptions)
# Line 562  bool qsamplerMainForm::loadSessionFile ( Line 611  bool qsamplerMainForm::loadSessionFile (
611      m_sFilename = sFilename;      m_sFilename = sFilename;
612      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
613      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
614        
615        // Make that an overall update.
616        m_iChangeCount++;
617      stabilizeForm();      stabilizeForm();
618      return true;      return true;
619  }  }
# Line 595  bool qsamplerMainForm::saveSessionFile ( Line 647  bool qsamplerMainForm::saveSessionFile (
647      ts << endl;      ts << endl;
648      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
649      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
650          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
651          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
652          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
653          ts << "ADD CHANNEL" << endl;              if (pChannel) {
654          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  int iChannelID = pChannel->channelID();
655          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "# " << pChannelStrip->caption() << endl;
656          ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "ADD CHANNEL" << endl;
657          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
658          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
659          ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
660          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
661          ts << endl;                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
662                        ts << "ALL";
663                    else
664                        ts << pChannel->midiChannel();
665                    ts << endl;
666                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
667                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
668                    ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;
669                    ts << endl;
670                }
671            }
672          // Try to keep it snappy :)          // Try to keep it snappy :)
673          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
674      }      }
# Line 678  void qsamplerMainForm::fileSaveAs (void) Line 740  void qsamplerMainForm::fileSaveAs (void)
740  }  }
741    
742    
743    // Reset the sampler instance.
744    void qsamplerMainForm::fileReset (void)
745    {
746        if (m_pClient == NULL)
747            return;
748    
749        // Ask user whether he/she want's an internal sampler reset...
750        if (QMessageBox::warning(this, tr("Warning"),
751            tr("Resetting the sampler instance will close\n"
752               "all device and channel configurations.\n\n"
753               "Please note that this operation may cause\n"
754               "temporary MIDI and Audio disruption\n\n"
755               "Do you want to reset the sampler engine now?"),
756            tr("Reset"), tr("Cancel")) > 0)
757            return;
758    
759        // Just do the reset, after closing down current session...
760        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
761            appendMessagesClient("lscp_reset_sampler");
762            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
763            return;
764        }
765    
766        // Log this.
767        appendMessages(tr("Sampler reset."));
768    }
769    
770    
771  // Restart the client/server instance.  // Restart the client/server instance.
772  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
773  {  {
# Line 725  void qsamplerMainForm::editAddChannel (v Line 815  void qsamplerMainForm::editAddChannel (v
815      if (m_pClient == NULL)      if (m_pClient == NULL)
816          return;          return;
817    
818      // Create the new sampler channel.      // Just create the channel instance...
819      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
820      if (iChannelID < 0) {      if (pChannel == NULL)
821          appendMessagesClient("lscp_add_channel");          return;
822          appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
823        // Before we show it up, may be we'll
824        // better ask for some initial values?
825        if (!pChannel->channelSetup(this)) {
826            delete pChannel;
827            return;
828        }
829        
830        // And give it to the strip (will own the channel instance, if successful).
831        if (!createChannelStrip(pChannel)) {
832            delete pChannel;
833          return;          return;
834      }      }
835    
836      // Log this happening.      // Make that an overall update.
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
   
     // Just create the channel strip with given id.  
     createChannel(iChannelID, true);  
   
     // We'll be dirty, for sure...  
837      m_iDirtyCount++;      m_iDirtyCount++;
838      // Stabilize form anyway.      m_iChangeCount++;
839      stabilizeForm();      stabilizeForm();
840  }  }
841    
# Line 752  void qsamplerMainForm::editRemoveChannel Line 846  void qsamplerMainForm::editRemoveChannel
846      if (m_pClient == NULL)      if (m_pClient == NULL)
847          return;          return;
848    
849      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
850        if (pChannelStrip == NULL)
851            return;
852            
853        qsamplerChannel *pChannel = pChannelStrip->channel();
854      if (pChannel == NULL)      if (pChannel == NULL)
855          return;          return;
856    
# Line 762  void qsamplerMainForm::editRemoveChannel Line 860  void qsamplerMainForm::editRemoveChannel
860              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
861                 "%1\n\n"                 "%1\n\n"
862                 "Are you sure?")                 "Are you sure?")
863                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
864              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
865              return;              return;
866      }      }
867    
868      // Remove the existing sampler channel.      // Remove the existing sampler channel.
869      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."));  
870          return;          return;
     }  
871    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
872      // Just delete the channel strip.      // Just delete the channel strip.
873      delete pChannel;      delete pChannelStrip;
874        
875      // Do we auto-arrange?      // Do we auto-arrange?
876      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
877          channelsArrange();          channelsArrange();
# Line 795  void qsamplerMainForm::editSetupChannel Line 888  void qsamplerMainForm::editSetupChannel
888      if (m_pClient == NULL)      if (m_pClient == NULL)
889          return;          return;
890    
891      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
892      if (pChannel == NULL)      if (pChannelStrip == NULL)
893          return;          return;
894    
895      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
896      pChannel->channelSetup(false);      pChannelStrip->channelSetup();
897  }  }
898    
899    
# Line 810  void qsamplerMainForm::editResetChannel Line 903  void qsamplerMainForm::editResetChannel
903      if (m_pClient == NULL)      if (m_pClient == NULL)
904          return;          return;
905    
906      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
907      if (pChannel == NULL)      if (pChannelStrip == NULL)
908          return;          return;
909    
910      // Remove the existing sampler channel.      qsamplerChannel *pChannel = pChannelStrip->channel();
911      if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      if (pChannel == NULL)
         appendMessagesClient("lscp_reset_channel");  
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
912          return;          return;
     }  
913    
914      // Log this.      // Reset the existing sampler channel.
915      appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));      pChannel->resetChannel();
916    
917      // Refresh channel strip info.      // And force a deferred update.
918      pChannel->updateChannelInfo();      m_iChangeCount++;
919  }  }
920    
921    
# Line 886  void qsamplerMainForm::viewOptions (void Line 976  void qsamplerMainForm::viewOptions (void
976      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
977      if (pOptionsForm) {      if (pOptionsForm) {
978          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
979          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
980          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
981              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
982          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
983              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
984          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 898  void qsamplerMainForm::viewOptions (void Line 988  void qsamplerMainForm::viewOptions (void
988          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
989          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
990          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
991            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
992          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
993          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
994          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
995          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
996          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
997          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
998            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
999          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1000          // Load the current setup settings.          // Load the current setup settings.
1001          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 922  void qsamplerMainForm::viewOptions (void Line 1014  void qsamplerMainForm::viewOptions (void
1014                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1015                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
1016                  updateRecentFilesMenu();                  updateRecentFilesMenu();
1017                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
1018                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
1019                    updateInstrumentNames();
1020                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
1021                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
1022                    updateDisplayEffect();
1023              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
1024                  updateDisplayFont();                  updateDisplayFont();
1025              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 964  void qsamplerMainForm::channelsArrange ( Line 1062  void qsamplerMainForm::channelsArrange (
1062      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1063      int y = 0;      int y = 0;
1064      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1065          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1066      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1067              // Prevent flicker...              // Prevent flicker...
1068              pChannel->hide();              pChannelStrip->hide();
1069              pChannel->showNormal();              pChannelStrip->showNormal();
1070          }   */          }   */
1071          pChannel->adjustSize();          pChannelStrip->adjustSize();
1072          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1073          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1074              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1075      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1076          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1077          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1078          y += iHeight;          y += iHeight;
1079      }      }
1080      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 1029  void qsamplerMainForm::helpAbout (void) Line 1127  void qsamplerMainForm::helpAbout (void)
1127      sText += tr("GIG (libgig) file support disabled.");      sText += tr("GIG (libgig) file support disabled.");
1128      sText += "</font></small><br />";      sText += "</font></small><br />";
1129  #endif  #endif
1130    #ifndef CONFIG_INSTRUMENT_NAME
1131        sText += "<small><font color=\"red\">";
1132        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1133        sText += "</font></small><br />";
1134    #endif
1135      sText += "<br />\n";      sText += "<br />\n";
1136      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1137      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1062  void qsamplerMainForm::stabilizeForm (vo Line 1165  void qsamplerMainForm::stabilizeForm (vo
1165      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));
1166    
1167      // Update the main menu state...      // Update the main menu state...
1168      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1169      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1170      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1171      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1172      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1173      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1174      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1175        fileResetAction->setEnabled(bHasClient);
1176      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1177      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1178      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
# Line 1087  void qsamplerMainForm::stabilizeForm (vo Line 1191  void qsamplerMainForm::stabilizeForm (vo
1191      }      }
1192      // Channel status...      // Channel status...
1193      if (bHasChannel)      if (bHasChannel)
1194          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1195      else      else
1196          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_status[QSAMPLER_STATUS_CHANNEL]->clear();
1197      // Session status...      // Session status...
# Line 1106  void qsamplerMainForm::stabilizeForm (vo Line 1210  void qsamplerMainForm::stabilizeForm (vo
1210    
1211    
1212  // Channel change receiver slot.  // Channel change receiver slot.
1213  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )
1214  {  {
1215        // Flag that we're update those channel strips.
1216        m_iChangeCount++;
1217      // Just mark the dirty form.      // Just mark the dirty form.
1218      m_iDirtyCount++;      m_iDirtyCount++;
1219      // and update the form status...      // and update the form status...
# Line 1159  void qsamplerMainForm::updateRecentFiles Line 1265  void qsamplerMainForm::updateRecentFiles
1265  }  }
1266    
1267    
1268    // Force update of the channels instrument names mode.
1269    void qsamplerMainForm::updateInstrumentNames (void)
1270    {
1271        // Full channel list update...
1272        QWidgetList wlist = m_pWorkspace->windowList();
1273        if (wlist.isEmpty())
1274            return;
1275    
1276        m_pWorkspace->setUpdatesEnabled(false);
1277        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1278            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1279            if (pChannelStrip)
1280                pChannelStrip->updateInstrumentName(true);
1281        }
1282        m_pWorkspace->setUpdatesEnabled(true);
1283    }
1284    
1285    
1286  // Force update of the channels display font.  // Force update of the channels display font.
1287  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1288  {  {
# Line 1180  void qsamplerMainForm::updateDisplayFont Line 1304  void qsamplerMainForm::updateDisplayFont
1304    
1305      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1306      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1307          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1308          pChannel->setDisplayFont(font);          if (pChannelStrip)
1309                pChannelStrip->setDisplayFont(font);
1310        }
1311        m_pWorkspace->setUpdatesEnabled(true);
1312    }
1313    
1314    
1315    // Update channel strips background effect.
1316    void qsamplerMainForm::updateDisplayEffect (void)
1317    {
1318       QPixmap pm;
1319        if (m_pOptions->bDisplayEffect)
1320            pm = QPixmap::fromMimeSource("displaybg1.png");
1321    
1322        // Full channel list update...
1323        QWidgetList wlist = m_pWorkspace->windowList();
1324        if (wlist.isEmpty())
1325            return;
1326    
1327        m_pWorkspace->setUpdatesEnabled(false);
1328        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1329            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1330            if (pChannelStrip)
1331                pChannelStrip->setDisplayBackground(pm);
1332      }      }
1333      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1334  }  }
# Line 1200  void qsamplerMainForm::updateMaxVolume ( Line 1347  void qsamplerMainForm::updateMaxVolume (
1347    
1348      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1349      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1350          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1351          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1352                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1353      }      }
1354      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1355  }  }
# Line 1300  void qsamplerMainForm::updateMessagesCap Line 1448  void qsamplerMainForm::updateMessagesCap
1448  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1449    
1450  // The channel strip creation executive.  // The channel strip creation executive.
1451  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1452  {  {
1453      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1454          return;          return NULL;
1455    
1456      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1457      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1458      int y = 0;      int y = 0;
1459      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1460          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1461          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1462              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1463          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1464              y += pChannel->parentWidget()->frameGeometry().height();              y += pChannelStrip->parentWidget()->frameGeometry().height();
1465          }          }
1466      }      }
1467    
1468      // Add a new channel itema...      // Add a new channel itema...
1469      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;
1470      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1471      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1472      pChannel->setup(this, iChannelID);          return NULL;
1473      // We'll need a display font.          
1474      QFont font;      // Actual channel strip setup...
1475      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1476          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1477      // Track channel setup changes.      // Set some initial aesthetic options...
1478      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1479      // Before we show it up, may be we'll          // Background display effect...
1480      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1481      if (bPrompt)          // We'll need a display font.
1482          pChannel->channelSetup(true);          QFont font;
1483            if (font.fromString(m_pOptions->sDisplayFont))
1484                pChannelStrip->setDisplayFont(font);
1485            // Maximum allowed volume setting.
1486            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1487        }
1488    
1489      // Now we show up us to the world.      // Now we show up us to the world.
1490      pChannel->show();      pChannelStrip->show();
1491      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1492      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1493          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1494      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1495          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1496          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1497      }      }
1498        
1499        // Return our successful reference...
1500        return pChannelStrip;
1501  }  }
1502    
1503    
1504  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1505  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1506  {  {
1507      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1508  }  }
1509    
1510    
1511  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1512  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1513  {  {
1514      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1515      if (wlist.isEmpty())      if (wlist.isEmpty())
# Line 1373  void qsamplerMainForm::channelsMenuAbout Line 1530  void qsamplerMainForm::channelsMenuAbout
1530      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1531          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1532          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1533              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1534              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1535              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1536              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1537                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1538                }
1539          }          }
1540      }      }
1541  }  }
# Line 1385  void qsamplerMainForm::channelsMenuAbout Line 1544  void qsamplerMainForm::channelsMenuAbout
1544  // Windows menu activation slot  // Windows menu activation slot
1545  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1546  {  {
1547      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1548      if (pChannel)      if (pChannelStrip)
1549          pChannel->showNormal();          pChannelStrip->showNormal();
1550      pChannel->setFocus();      pChannelStrip->setFocus();
1551  }  }
1552    
1553    
# Line 1428  void qsamplerMainForm::timerSlot (void) Line 1587  void qsamplerMainForm::timerSlot (void)
1587      }      }
1588            
1589          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1590      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) {
1591          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1592          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1593              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1594                m_iChangeCount = 0;
1595              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1596              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1597                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1598                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible()) {
1599                      pChannel->updateChannelUsage();                      // If we can't make it clean, try next time.
1600                        if (!pChannelStrip->updateChannelUsage())
1601                            m_iChangeCount++;
1602                    }
1603              }              }
1604          }          }
1605      }      }

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

  ViewVC Help
Powered by ViewVC