/[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 122 by capela, Sat Jun 12 13:21:35 2004 UTC revision 340 by capela, Fri Jan 14 10:40:47 2005 UTC
# Line 36  Line 36 
36    
37  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
38  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
39    #include "qsamplerChannel.h"
40  #include "qsamplerMessages.h"  #include "qsamplerMessages.h"
41    
42  #include "qsamplerChannelStrip.h"  #include "qsamplerChannelStrip.h"
# Line 43  Line 44 
44    
45  #include "config.h"  #include "config.h"
46    
47    #ifdef HAVE_SIGNAL_H
48    #include <signal.h>
49    #endif
50    
51  // Timer constant stuff.  // Timer constant stuff.
52  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
# Line 54  Line 58 
58  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
59    
60    
61    // All winsock apps needs this.
62  #if defined(WIN32)  #if defined(WIN32)
63  static WSADATA _wsaData;  static WSADATA _wsaData;
64  #endif  #endif
65    
66    
67    //-------------------------------------------------------------------------
68    // qsamplerCustomEvent -- specialty for callback comunication.
69    
70    #define QSAMPLER_CUSTOM_EVENT   1000
71    
72    class qsamplerCustomEvent : public QCustomEvent
73    {
74    public:
75    
76        // Constructor.
77        qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData)
78            : QCustomEvent(QSAMPLER_CUSTOM_EVENT)
79        {
80            m_event = event;
81            m_data.setLatin1(pchData, cchData);
82        }
83    
84        // Accessors.
85        lscp_event_t event() { return m_event; }
86        QString&     data()  { return m_data;  }
87    
88    private:
89    
90        // The proper event type.
91        lscp_event_t m_event;
92        // The event data as a string.
93        QString      m_data;
94    };
95    
96    
97  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
98  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
99    
# Line 71  void qsamplerMainForm::init (void) Line 107  void qsamplerMainForm::init (void)
107      m_pMessages = NULL;      m_pMessages = NULL;
108    
109      // We'll start clean.      // We'll start clean.
110      m_iUntitled = 0;      m_iUntitled    = 0;
111      m_iDirtyCount = 0;      m_iDirtyCount  = 0;
112        m_iChangeCount = 0;
113    
114      m_pServer = NULL;      m_pServer = NULL;
115      m_pClient = NULL;      m_pClient = 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 252  void qsamplerMainForm::closeEvent ( QClo Line 294  void qsamplerMainForm::closeEvent ( QClo
294  }  }
295    
296    
297    // Window drag-n-drop event handlers.
298  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
299  {  {
300      bool bAccept = false;      bool bAccept = false;
# Line 276  void qsamplerMainForm::dropEvent ( QDrop Line 319  void qsamplerMainForm::dropEvent ( QDrop
319  }  }
320    
321    
322    // Custome event handler.
323    void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent )
324    {
325        // For the time being, just pump it to messages.
326        if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
327            qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
328            appendMessagesColor(tr("Notify event: %1 data: %2")
329                .arg(::lscp_event_to_text(pEvent->event()))
330                .arg(pEvent->data()), "#996699");
331        }
332    }
333    
334    
335    // Context menu event handler.
336    void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
337    {
338        stabilizeForm();
339        
340        editMenu->exec(pEvent->globalPos());
341    }
342    
343    
344  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
345  // qsamplerMainForm -- Brainless public property accessors.  // qsamplerMainForm -- Brainless public property accessors.
346    
# Line 428  bool qsamplerMainForm::closeSession ( bo Line 493  bool qsamplerMainForm::closeSession ( bo
493          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
494          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
495          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
496              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
497              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
498                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
499              delete pChannel;                  if (bForce && pChannel)
500                        pChannel->removeChannel();
501                    delete pChannelStrip;
502                }
503          }          }
504          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
505          // We're now clean, for sure.          // We're now clean, for sure.
# Line 484  bool qsamplerMainForm::loadSessionFile ( Line 552  bool qsamplerMainForm::loadSessionFile (
552          appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));
553    
554      // Now we'll try to create the whole GUI session.      // Now we'll try to create the whole GUI session.
555      int iChannels = ::lscp_get_channels(m_pClient);      int *piChannelIDs = ::lscp_list_channels(m_pClient);
556      if (iChannels < 0) {      if (piChannelIDs == NULL) {
557          appendMessagesClient("lscp_get_channels");          appendMessagesClient("lscp_list_channels");
558          appendMessagesError(tr("Could not get current number of channels.\n\nSorry."));          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
559      }      }
560            
561      // Try to (re)create each channel.      // Try to (re)create each channel.
562      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
563      for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) {      for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
564          createChannel(iChannelID, false);          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
565          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
566      }      }
567      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 507  bool qsamplerMainForm::loadSessionFile ( Line 575  bool qsamplerMainForm::loadSessionFile (
575      m_sFilename = sFilename;      m_sFilename = sFilename;
576      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
577      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
578        
579        // Make that an overall update.
580        m_iChangeCount++;
581      stabilizeForm();      stabilizeForm();
582      return true;      return true;
583  }  }
# Line 540  bool qsamplerMainForm::saveSessionFile ( Line 611  bool qsamplerMainForm::saveSessionFile (
611      ts << endl;      ts << endl;
612      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
613      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
614          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
615          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
616          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
617          ts << "ADD CHANNEL" << endl;              if (pChannel) {
618          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  int iChannelID = pChannel->channelID();
619          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "# " << pChannelStrip->caption() << endl;
620      //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "ADD CHANNEL" << endl;
621          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
622          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
623          ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
624          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
625          ts << endl;                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
626                        ts << "ALL";
627                    else
628                        ts << pChannel->midiChannel();
629                    ts << endl;
630                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
631                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
632                    ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;
633                    ts << endl;
634                }
635            }
636          // Try to keep it snappy :)          // Try to keep it snappy :)
637          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
638      }      }
# Line 623  void qsamplerMainForm::fileSaveAs (void) Line 704  void qsamplerMainForm::fileSaveAs (void)
704  }  }
705    
706    
707    // Reset the sampler instance.
708    void qsamplerMainForm::fileReset (void)
709    {
710        if (m_pClient == NULL)
711            return;
712    
713        // Ask user whether he/she want's an internal sampler reset...
714        if (QMessageBox::warning(this, tr("Warning"),
715            tr("Resetting the sampler instance will close\n"
716               "all device and channel configurations.\n\n"
717               "Please note that this operation may cause\n"
718               "temporary MIDI and Audio disruption\n\n"
719               "Do you want to reset the sampler engine now?"),
720            tr("Reset"), tr("Cancel")) > 0)
721            return;
722    
723        // Just do the reset, after closing down current session...
724        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
725            appendMessagesClient("lscp_reset_sampler");
726            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
727            return;
728        }
729    
730        // Log this.
731        appendMessages(tr("Sampler reset."));
732    }
733    
734    
735  // Restart the client/server instance.  // Restart the client/server instance.
736  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
737  {  {
# Line 670  void qsamplerMainForm::editAddChannel (v Line 779  void qsamplerMainForm::editAddChannel (v
779      if (m_pClient == NULL)      if (m_pClient == NULL)
780          return;          return;
781    
782      // Create the new sampler channel.      // Just create the channel instance...
783      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
784      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
785          return;          return;
     }  
   
     // Log this happening.  
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
786    
787      // Just create the channel strip with given id.      // Before we show it up, may be we'll
788      createChannel(iChannelID, true);      // better ask for some initial values?
789        if (!pChannel->channelSetup(this)) {
790            delete pChannel;
791            return;
792        }
793        
794        // And give it to the strip (will own the channel instance, if successful).
795        if (!createChannelStrip(pChannel)) {
796            delete pChannel;
797            return;
798        }
799    
800      // We'll be dirty, for sure...      // Make that an overall update.
801      m_iDirtyCount++;      m_iDirtyCount++;
802      // Stabilize form anyway.      m_iChangeCount++;
803      stabilizeForm();      stabilizeForm();
804  }  }
805    
# Line 697  void qsamplerMainForm::editRemoveChannel Line 810  void qsamplerMainForm::editRemoveChannel
810      if (m_pClient == NULL)      if (m_pClient == NULL)
811          return;          return;
812    
813      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
814        if (pChannelStrip == NULL)
815            return;
816            
817        qsamplerChannel *pChannel = pChannelStrip->channel();
818      if (pChannel == NULL)      if (pChannel == NULL)
819          return;          return;
820    
# Line 707  void qsamplerMainForm::editRemoveChannel Line 824  void qsamplerMainForm::editRemoveChannel
824              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
825                 "%1\n\n"                 "%1\n\n"
826                 "Are you sure?")                 "Are you sure?")
827                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
828              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
829              return;              return;
830      }      }
831    
832      // Remove the existing sampler channel.      // Remove the existing sampler channel.
833      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."));  
834          return;          return;
     }  
835    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
836      // Just delete the channel strip.      // Just delete the channel strip.
837      delete pChannel;      delete pChannelStrip;
838        
839      // Do we auto-arrange?      // Do we auto-arrange?
840      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
841          channelsArrange();          channelsArrange();
# Line 740  void qsamplerMainForm::editSetupChannel Line 852  void qsamplerMainForm::editSetupChannel
852      if (m_pClient == NULL)      if (m_pClient == NULL)
853          return;          return;
854    
855      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
856      if (pChannel == NULL)      if (pChannelStrip == NULL)
857          return;          return;
858    
859      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
860      pChannel->channelSetup();      pChannelStrip->channelSetup();
861  }  }
862    
863    
# Line 755  void qsamplerMainForm::editResetChannel Line 867  void qsamplerMainForm::editResetChannel
867      if (m_pClient == NULL)      if (m_pClient == NULL)
868          return;          return;
869    
870      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
871      if (pChannel == NULL)      if (pChannelStrip == NULL)
872          return;          return;
873    
874      // Remove the existing sampler channel.      qsamplerChannel *pChannel = pChannelStrip->channel();
875      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."));  
876          return;          return;
     }  
877    
878      // Log this.      // Reset the existing sampler channel.
879      appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));      pChannel->resetChannel();
880    
881      // Refresh channel strip info.      // And force a deferred update.
882      pChannel->updateChannelInfo();      m_iChangeCount++;
883  }  }
884    
885    
# Line 831  void qsamplerMainForm::viewOptions (void Line 940  void qsamplerMainForm::viewOptions (void
940      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
941      if (pOptionsForm) {      if (pOptionsForm) {
942          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
943          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
944          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
945              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
946          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
947              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
948          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 843  void qsamplerMainForm::viewOptions (void Line 952  void qsamplerMainForm::viewOptions (void
952          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
953          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
954          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
955            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
956          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
957          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
958          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
# Line 867  void qsamplerMainForm::viewOptions (void Line 977  void qsamplerMainForm::viewOptions (void
977                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
978                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
979                  updateRecentFilesMenu();                  updateRecentFilesMenu();
980                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
981                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
982                    updateDisplayEffect();
983              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
984                  updateDisplayFont();                  updateDisplayFont();
985              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 909  void qsamplerMainForm::channelsArrange ( Line 1022  void qsamplerMainForm::channelsArrange (
1022      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1023      int y = 0;      int y = 0;
1024      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1025          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1026      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1027              // Prevent flicker...              // Prevent flicker...
1028              pChannel->hide();              pChannelStrip->hide();
1029              pChannel->showNormal();              pChannelStrip->showNormal();
1030          }   */          }   */
1031          pChannel->adjustSize();          pChannelStrip->adjustSize();
1032          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1033          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1034              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1035      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1036          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1037          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1038          y += iHeight;          y += iHeight;
1039      }      }
1040      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 969  void qsamplerMainForm::helpAbout (void) Line 1082  void qsamplerMainForm::helpAbout (void)
1082      sText += tr("Debugging option enabled.");      sText += tr("Debugging option enabled.");
1083      sText += "</font></small><br />";      sText += "</font></small><br />";
1084  #endif  #endif
1085    #ifndef CONFIG_LIBGIG
1086        sText += "<small><font color=\"red\">";
1087        sText += tr("GIG (libgig) file support disabled.");
1088        sText += "</font></small><br />";
1089    #endif
1090      sText += "<br />\n";      sText += "<br />\n";
1091      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1092      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1002  void qsamplerMainForm::stabilizeForm (vo Line 1120  void qsamplerMainForm::stabilizeForm (vo
1120      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));
1121    
1122      // Update the main menu state...      // Update the main menu state...
1123      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1124      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1125      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1126      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1127      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1128      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1129      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1130        fileResetAction->setEnabled(bHasClient);
1131      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1132      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1133      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
# Line 1027  void qsamplerMainForm::stabilizeForm (vo Line 1146  void qsamplerMainForm::stabilizeForm (vo
1146      }      }
1147      // Channel status...      // Channel status...
1148      if (bHasChannel)      if (bHasChannel)
1149          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1150      else      else
1151          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_status[QSAMPLER_STATUS_CHANNEL]->clear();
1152      // Session status...      // Session status...
# Line 1046  void qsamplerMainForm::stabilizeForm (vo Line 1165  void qsamplerMainForm::stabilizeForm (vo
1165    
1166    
1167  // Channel change receiver slot.  // Channel change receiver slot.
1168  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )
1169  {  {
1170        // Flag that we're update those channel strips.
1171        m_iChangeCount++;
1172      // Just mark the dirty form.      // Just mark the dirty form.
1173      m_iDirtyCount++;      m_iDirtyCount++;
1174      // and update the form status...      // and update the form status...
# Line 1120  void qsamplerMainForm::updateDisplayFont Line 1241  void qsamplerMainForm::updateDisplayFont
1241    
1242      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1243      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1244          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1245          pChannel->setDisplayFont(font);          if (pChannelStrip)
1246                pChannelStrip->setDisplayFont(font);
1247        }
1248        m_pWorkspace->setUpdatesEnabled(true);
1249    }
1250    
1251    
1252    // Update channel strips background effect.
1253    void qsamplerMainForm::updateDisplayEffect (void)
1254    {
1255       QPixmap pm;
1256        if (m_pOptions->bDisplayEffect)
1257            pm = QPixmap::fromMimeSource("displaybg1.png");
1258    
1259        // Full channel list update...
1260        QWidgetList wlist = m_pWorkspace->windowList();
1261        if (wlist.isEmpty())
1262            return;
1263    
1264        m_pWorkspace->setUpdatesEnabled(false);
1265        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1266            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1267            if (pChannelStrip)
1268                pChannelStrip->setDisplayBackground(pm);
1269      }      }
1270      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1271  }  }
# Line 1140  void qsamplerMainForm::updateMaxVolume ( Line 1284  void qsamplerMainForm::updateMaxVolume (
1284    
1285      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1286      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1287          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1288          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1289                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1290      }      }
1291      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1292  }  }
# Line 1240  void qsamplerMainForm::updateMessagesCap Line 1385  void qsamplerMainForm::updateMessagesCap
1385  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1386    
1387  // The channel strip creation executive.  // The channel strip creation executive.
1388  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1389  {  {
1390      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1391          return;          return NULL;
1392    
1393      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1394      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1395      int y = 0;      int y = 0;
1396      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1397          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1398          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1399              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1400          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1401              y += pChannel->parentWidget()->frameGeometry().height();              y += pChannelStrip->parentWidget()->frameGeometry().height();
1402          }          }
1403      }      }
1404    
1405      // Add a new channel itema...      // Add a new channel itema...
1406      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;
1407      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1408      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1409      pChannel->setup(this, iChannelID);          return NULL;
1410      // We'll need a display font.          
1411      QFont font;      // Actual channel strip setup...
1412      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1413          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1414      // Track channel setup changes.      // Set some initial aesthetic options...
1415      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1416      // Before we show it up, may be we'll          // Background display effect...
1417      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1418      if (bPrompt)          // We'll need a display font.
1419          pChannel->channelSetup();                QFont font;
1420            if (font.fromString(m_pOptions->sDisplayFont))
1421                pChannelStrip->setDisplayFont(font);
1422            // Maximum allowed volume setting.
1423            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1424        }
1425    
1426      // Now we show up us to the world.      // Now we show up us to the world.
1427      pChannel->show();      pChannelStrip->show();
1428      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1429      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1430          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1431      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1432          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1433          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1434      }      }
1435        
1436        // Return our successful reference...
1437        return pChannelStrip;
1438  }  }
1439    
1440    
1441  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1442  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1443  {  {
1444      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1445  }  }
1446    
1447    
1448  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1449  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1450  {  {
1451      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1452      if (wlist.isEmpty())      if (wlist.isEmpty())
# Line 1313  void qsamplerMainForm::channelsMenuAbout Line 1467  void qsamplerMainForm::channelsMenuAbout
1467      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1468          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1469          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1470              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1471              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1472              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1473              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1474                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1475                }
1476          }          }
1477      }      }
1478  }  }
# Line 1325  void qsamplerMainForm::channelsMenuAbout Line 1481  void qsamplerMainForm::channelsMenuAbout
1481  // Windows menu activation slot  // Windows menu activation slot
1482  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1483  {  {
1484      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1485      if (pChannel)      if (pChannelStrip)
1486          pChannel->showNormal();          pChannelStrip->showNormal();
1487      pChannel->setFocus();      pChannelStrip->setFocus();
1488  }  }
1489    
1490    
# Line 1368  void qsamplerMainForm::timerSlot (void) Line 1524  void qsamplerMainForm::timerSlot (void)
1524      }      }
1525            
1526          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1527      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) {
1528          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1529          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1530              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1531                m_iChangeCount = 0;
1532              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1533              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1534                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1535                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible()) {
1536                      pChannel->updateChannelUsage();                      // If we can't make it clean, try next time.
1537                        if (!pChannelStrip->updateChannelUsage())
1538                            m_iChangeCount++;
1539                    }
1540              }              }
1541          }          }
1542      }      }
# Line 1513  void qsamplerMainForm::processServerExit Line 1673  void qsamplerMainForm::processServerExit
1673  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1674  // qsamplerMainForm -- Client stuff.  // qsamplerMainForm -- Client stuff.
1675    
   
1676  // The LSCP client callback procedure.  // The LSCP client callback procedure.
1677  lscp_status_t qsampler_client_callback ( lscp_client_t *pClient, 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 )
1678  {  {
1679      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;
1680      if (pMainForm == NULL)      if (pMainForm == NULL)
1681          return LSCP_FAILED;          return LSCP_FAILED;
1682    
1683      char *pszBuffer = (char *) malloc(cchBuffer + 1);      // ATTN: DO NOT EVER call any GUI code here,
1684      if (pszBuffer == NULL)      // as this is run under some other thread context.
1685          return LSCP_FAILED;      // A custom event must be posted here...
1686        QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData));
     memcpy(pszBuffer, pchBuffer, cchBuffer);  
     pszBuffer[cchBuffer] = (char) 0;  
     pMainForm->appendMessagesColor(pszBuffer, "#996699");  
     free(pszBuffer);  
1687    
1688      return LSCP_OK;      return LSCP_OK;
1689  }  }

Legend:
Removed from v.122  
changed lines
  Added in v.340

  ViewVC Help
Powered by ViewVC