/[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 119 by capela, Wed Jun 9 20:24:48 2004 UTC revision 303 by capela, Fri Nov 19 10:18:59 2004 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 54  Line 55 
55  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
56    
57    
58    // All winsock apps needs this.
59  #if defined(WIN32)  #if defined(WIN32)
60  static WSADATA _wsaData;  static WSADATA _wsaData;
61  #endif  #endif
62    
63    
64    //-------------------------------------------------------------------------
65    // qsamplerCustomEvent -- specialty for callback comunication.
66    
67    #define QSAMPLER_CUSTOM_EVENT   1000
68    
69    class qsamplerCustomEvent : public QCustomEvent
70    {
71    public:
72    
73        // Constructor.
74        qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData)
75            : QCustomEvent(QSAMPLER_CUSTOM_EVENT)
76        {
77            m_event = event;
78            m_data.setLatin1(pchData, cchData);
79        }
80    
81        // Accessors.
82        lscp_event_t event() { return m_event; }
83        QString&     data()  { return m_data;  }
84    
85    private:
86    
87        // The proper event type.
88        lscp_event_t m_event;
89        // The event data as a string.
90        QString      m_data;
91    };
92    
93    
94  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
95  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
96    
# Line 71  void qsamplerMainForm::init (void) Line 104  void qsamplerMainForm::init (void)
104      m_pMessages = NULL;      m_pMessages = NULL;
105    
106      // We'll start clean.      // We'll start clean.
107      m_iUntitled = 0;      m_iUntitled    = 0;
108      m_iDirtyCount = 0;      m_iDirtyCount  = 0;
109        m_iChangeCount = 0;
110    
111      m_pServer = NULL;      m_pServer = NULL;
112      m_pClient = NULL;      m_pClient = NULL;
# Line 252  void qsamplerMainForm::closeEvent ( QClo Line 286  void qsamplerMainForm::closeEvent ( QClo
286  }  }
287    
288    
289    // Window drag-n-drop event handlers.
290  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
291  {  {
292      bool bAccept = false;      bool bAccept = false;
# Line 276  void qsamplerMainForm::dropEvent ( QDrop Line 311  void qsamplerMainForm::dropEvent ( QDrop
311  }  }
312    
313    
314    // Custome event handler.
315    void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent )
316    {
317        // For the time being, just pump it to messages.
318        if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
319            qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
320            appendMessagesColor(tr("Notify event: %1 data: %2")
321                .arg(::lscp_event_to_text(pEvent->event()))
322                .arg(pEvent->data()), "#996699");
323        }
324    }
325    
326    
327    // Context menu event handler.
328    void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
329    {
330        stabilizeForm();
331        
332        editMenu->exec(pEvent->globalPos());
333    }
334    
335    
336  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
337  // qsamplerMainForm -- Brainless public property accessors.  // qsamplerMainForm -- Brainless public property accessors.
338    
# Line 428  bool qsamplerMainForm::closeSession ( bo Line 485  bool qsamplerMainForm::closeSession ( bo
485          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
486          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
487          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
488              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
489              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
490                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
491              delete pChannel;                  if (bForce && pChannel)
492                        pChannel->removeChannel();
493                    delete pChannelStrip;
494                }
495          }          }
496          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
497          // We're now clean, for sure.          // We're now clean, for sure.
# Line 484  bool qsamplerMainForm::loadSessionFile ( Line 544  bool qsamplerMainForm::loadSessionFile (
544          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));
545    
546      // Now we'll try to create the whole GUI session.      // Now we'll try to create the whole GUI session.
547      int iChannels = ::lscp_get_channels(m_pClient);      int *piChannelIDs = ::lscp_list_channels(m_pClient);
548      if (iChannels < 0) {      if (piChannelIDs == NULL) {
549          appendMessagesClient("lscp_get_channels");          appendMessagesClient("lscp_list_channels");
550          appendMessagesError(tr("Could not get current number of channels.\n\nSorry."));          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
551      }      }
552            
553      // Try to (re)create each channel.      // Try to (re)create each channel.
554      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
555      for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) {      for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
556          createChannel(iChannelID, false);          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
557          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
558      }      }
559      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 507  bool qsamplerMainForm::loadSessionFile ( Line 567  bool qsamplerMainForm::loadSessionFile (
567      m_sFilename = sFilename;      m_sFilename = sFilename;
568      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
569      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
570        
571        // Make that an overall update.
572        m_iChangeCount++;
573      stabilizeForm();      stabilizeForm();
574      return true;      return true;
575  }  }
# Line 540  bool qsamplerMainForm::saveSessionFile ( Line 603  bool qsamplerMainForm::saveSessionFile (
603      ts << endl;      ts << endl;
604      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
605      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
606          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
607          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
608          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
609          ts << "ADD CHANNEL" << endl;              if (pChannel) {
610          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  int iChannelID = pChannel->channelID();
611          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "# " << pChannelStrip->caption() << endl;
612      //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "ADD CHANNEL" << endl;
613          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
614          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
615          ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
616          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
617          ts << endl;                  if (pChannel->midiChannel() > 0)
618                        ts << pChannel->midiChannel();
619                     else
620                        ts << "ALL";
621                    ts << endl;
622                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
623                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
624                    ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;
625                    ts << endl;
626                }
627            }
628          // Try to keep it snappy :)          // Try to keep it snappy :)
629          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
630      }      }
# Line 623  void qsamplerMainForm::fileSaveAs (void) Line 696  void qsamplerMainForm::fileSaveAs (void)
696  }  }
697    
698    
699    // Reset the sampler instance.
700    void qsamplerMainForm::fileReset (void)
701    {
702        if (m_pClient == NULL)
703            return;
704    
705        // Ask user whether he/she want's an internal sampler reset...
706        if (QMessageBox::warning(this, tr("Warning"),
707            tr("Resetting the sampler instance will close\n"
708               "all device and channel configurations.\n\n"
709               "Please note that this operation may cause\n"
710               "temporary MIDI and Audio disruption\n\n"
711               "Do you want to reset the sampler engine now?"),
712            tr("Reset"), tr("Cancel")) > 0)
713            return;
714    
715        // Just do the reset, after closing down current session...
716        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
717            appendMessagesClient("lscp_reset_sampler");
718            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
719            return;
720        }
721    
722        // Log this.
723        appendMessages(tr("Sampler reset."));
724    }
725    
726    
727  // Restart the client/server instance.  // Restart the client/server instance.
728  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
729  {  {
# Line 670  void qsamplerMainForm::editAddChannel (v Line 771  void qsamplerMainForm::editAddChannel (v
771      if (m_pClient == NULL)      if (m_pClient == NULL)
772          return;          return;
773    
774      // Create the new sampler channel.      // Just create the channel instance...
775      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
776      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
777          return;          return;
     }  
   
     // Log this happening.  
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
778    
779      // Just create the channel strip with given id.      // Before we show it up, may be we'll
780      createChannel(iChannelID, true);      // better ask for some initial values?
781        if (!pChannel->channelSetup(this)) {
782            delete pChannel;
783            return;
784        }
785        
786        // And give it to the strip (will own the channel instance, if successful).
787        if (!createChannelStrip(pChannel)) {
788            delete pChannel;
789            return;
790        }
791    
792      // We'll be dirty, for sure...      // Make that an overall update.
793      m_iDirtyCount++;      m_iDirtyCount++;
794      // Stabilize form anyway.      m_iChangeCount++;
795      stabilizeForm();      stabilizeForm();
796  }  }
797    
# Line 697  void qsamplerMainForm::editRemoveChannel Line 802  void qsamplerMainForm::editRemoveChannel
802      if (m_pClient == NULL)      if (m_pClient == NULL)
803          return;          return;
804    
805      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
806        if (pChannelStrip == NULL)
807            return;
808            
809        qsamplerChannel *pChannel = pChannelStrip->channel();
810      if (pChannel == NULL)      if (pChannel == NULL)
811          return;          return;
812    
# Line 707  void qsamplerMainForm::editRemoveChannel Line 816  void qsamplerMainForm::editRemoveChannel
816              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
817                 "%1\n\n"                 "%1\n\n"
818                 "Are you sure?")                 "Are you sure?")
819                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
820              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
821              return;              return;
822      }      }
823    
824      // Remove the existing sampler channel.      // Remove the existing sampler channel.
825      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."));  
826          return;          return;
     }  
827    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
828      // Just delete the channel strip.      // Just delete the channel strip.
829      delete pChannel;      delete pChannelStrip;
830        
831      // Do we auto-arrange?      // Do we auto-arrange?
832      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
833          channelsArrange();          channelsArrange();
# Line 740  void qsamplerMainForm::editSetupChannel Line 844  void qsamplerMainForm::editSetupChannel
844      if (m_pClient == NULL)      if (m_pClient == NULL)
845          return;          return;
846    
847      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
848      if (pChannel == NULL)      if (pChannelStrip == NULL)
849          return;          return;
850    
851      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
852      pChannel->channelSetup();      pChannelStrip->channelSetup();
853  }  }
854    
855    
# Line 755  void qsamplerMainForm::editResetChannel Line 859  void qsamplerMainForm::editResetChannel
859      if (m_pClient == NULL)      if (m_pClient == NULL)
860          return;          return;
861    
862      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
863      if (pChannel == NULL)      if (pChannelStrip == NULL)
864          return;          return;
865    
866      // Remove the existing sampler channel.      qsamplerChannel *pChannel = pChannelStrip->channel();
867      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."));  
868          return;          return;
     }  
869    
870      // Log this.      // Reset the existing sampler channel.
871      appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));      pChannel->resetChannel();
872    
873      // Refresh channel strip info.      // And force a deferred update.
874      pChannel->updateChannelInfo();      m_iChangeCount++;
875  }  }
876    
877    
# Line 831  void qsamplerMainForm::viewOptions (void Line 932  void qsamplerMainForm::viewOptions (void
932      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
933      if (pOptionsForm) {      if (pOptionsForm) {
934          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
935          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
936          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
937              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
938          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
939              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
940          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 843  void qsamplerMainForm::viewOptions (void Line 944  void qsamplerMainForm::viewOptions (void
944          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
945          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
946          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
947            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
948          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
949          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
950          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
# Line 867  void qsamplerMainForm::viewOptions (void Line 969  void qsamplerMainForm::viewOptions (void
969                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
970                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
971                  updateRecentFilesMenu();                  updateRecentFilesMenu();
972                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
973                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
974                    updateDisplayEffect();
975              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
976                  updateDisplayFont();                  updateDisplayFont();
977              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 909  void qsamplerMainForm::channelsArrange ( Line 1014  void qsamplerMainForm::channelsArrange (
1014      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1015      int y = 0;      int y = 0;
1016      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1017          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1018      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1019              // Prevent flicker...              // Prevent flicker...
1020              pChannel->hide();              pChannelStrip->hide();
1021              pChannel->showNormal();              pChannelStrip->showNormal();
1022          }   */          }   */
1023          pChannel->adjustSize();          pChannelStrip->adjustSize();
1024          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1025          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1026              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1027      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1028          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1029          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1030          y += iHeight;          y += iHeight;
1031      }      }
1032      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 969  void qsamplerMainForm::helpAbout (void) Line 1074  void qsamplerMainForm::helpAbout (void)
1074      sText += tr("Debugging option enabled.");      sText += tr("Debugging option enabled.");
1075      sText += "</font></small><br />";      sText += "</font></small><br />";
1076  #endif  #endif
1077    #ifndef CONFIG_LIBGIG
1078        sText += "<small><font color=\"red\">";
1079        sText += tr("GIG (libgig) file support disabled.");
1080        sText += "</font></small><br />";
1081    #endif
1082      sText += "<br />\n";      sText += "<br />\n";
1083      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1084      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1002  void qsamplerMainForm::stabilizeForm (vo Line 1112  void qsamplerMainForm::stabilizeForm (vo
1112      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));
1113    
1114      // Update the main menu state...      // Update the main menu state...
1115      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1116      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1117      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1118      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1119      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1120      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1121      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1122        fileResetAction->setEnabled(bHasClient);
1123      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1124      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1125      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
# Line 1027  void qsamplerMainForm::stabilizeForm (vo Line 1138  void qsamplerMainForm::stabilizeForm (vo
1138      }      }
1139      // Channel status...      // Channel status...
1140      if (bHasChannel)      if (bHasChannel)
1141          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1142      else      else
1143          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_status[QSAMPLER_STATUS_CHANNEL]->clear();
1144      // Session status...      // Session status...
# Line 1046  void qsamplerMainForm::stabilizeForm (vo Line 1157  void qsamplerMainForm::stabilizeForm (vo
1157    
1158    
1159  // Channel change receiver slot.  // Channel change receiver slot.
1160  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )
1161  {  {
1162        // Flag that we're update those channel strips.
1163        m_iChangeCount++;
1164      // Just mark the dirty form.      // Just mark the dirty form.
1165      m_iDirtyCount++;      m_iDirtyCount++;
1166      // and update the form status...      // and update the form status...
# Line 1120  void qsamplerMainForm::updateDisplayFont Line 1233  void qsamplerMainForm::updateDisplayFont
1233    
1234      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1235      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1236          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1237          pChannel->setDisplayFont(font);          if (pChannelStrip)
1238                pChannelStrip->setDisplayFont(font);
1239        }
1240        m_pWorkspace->setUpdatesEnabled(true);
1241    }
1242    
1243    
1244    // Update channel strips background effect.
1245    void qsamplerMainForm::updateDisplayEffect (void)
1246    {
1247       QPixmap pm;
1248        if (m_pOptions->bDisplayEffect)
1249            pm = QPixmap::fromMimeSource("displaybg1.png");
1250    
1251        // Full channel list update...
1252        QWidgetList wlist = m_pWorkspace->windowList();
1253        if (wlist.isEmpty())
1254            return;
1255    
1256        m_pWorkspace->setUpdatesEnabled(false);
1257        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1258            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1259            if (pChannelStrip)
1260                pChannelStrip->setDisplayBackground(pm);
1261      }      }
1262      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1263  }  }
# Line 1140  void qsamplerMainForm::updateMaxVolume ( Line 1276  void qsamplerMainForm::updateMaxVolume (
1276    
1277      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1278      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1279          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1280          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1281                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1282      }      }
1283      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1284  }  }
# Line 1240  void qsamplerMainForm::updateMessagesCap Line 1377  void qsamplerMainForm::updateMessagesCap
1377  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1378    
1379  // The channel strip creation executive.  // The channel strip creation executive.
1380  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1381  {  {
1382      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1383          return;          return NULL;
1384    
1385      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1386      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1387      int y = 0;      int y = 0;
1388      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1389          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1390          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1391              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1392          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1393              y += pChannel->parentWidget()->frameGeometry().height();              y += pChannelStrip->parentWidget()->frameGeometry().height();
1394          }          }
1395      }      }
1396    
1397      // Add a new channel itema...      // Add a new channel itema...
1398      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;
1399      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1400      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1401      pChannel->setup(this, iChannelID);          return NULL;
1402      // We'll need a display font.          
1403      QFont font;      // Actual channel strip setup...
1404      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1405          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1406      // Track channel setup changes.      // Set some initial aesthetic options...
1407      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1408      // Before we show it up, may be we'll          // Background display effect...
1409      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1410      if (bPrompt)          // We'll need a display font.
1411          pChannel->channelSetup();                QFont font;
1412            if (font.fromString(m_pOptions->sDisplayFont))
1413                pChannelStrip->setDisplayFont(font);
1414            // Maximum allowed volume setting.
1415            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1416        }
1417    
1418      // Now we show up us to the world.      // Now we show up us to the world.
1419      pChannel->show();      pChannelStrip->show();
1420      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1421      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1422          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1423      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1424          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1425          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1426      }      }
1427        
1428        // Return our successful reference...
1429        return pChannelStrip;
1430  }  }
1431    
1432    
1433  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1434  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1435  {  {
1436      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1437  }  }
1438    
1439    
1440  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1441  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1442  {  {
1443      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1444      if (wlist.isEmpty())      if (wlist.isEmpty())
# Line 1313  void qsamplerMainForm::channelsMenuAbout Line 1459  void qsamplerMainForm::channelsMenuAbout
1459      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1460          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1461          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1462              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1463              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1464              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1465              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1466                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1467                }
1468          }          }
1469      }      }
1470  }  }
# Line 1325  void qsamplerMainForm::channelsMenuAbout Line 1473  void qsamplerMainForm::channelsMenuAbout
1473  // Windows menu activation slot  // Windows menu activation slot
1474  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1475  {  {
1476      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1477      if (pChannel)      if (pChannelStrip)
1478          pChannel->showNormal();          pChannelStrip->showNormal();
1479      pChannel->setFocus();      pChannelStrip->setFocus();
1480  }  }
1481    
1482    
# Line 1368  void qsamplerMainForm::timerSlot (void) Line 1516  void qsamplerMainForm::timerSlot (void)
1516      }      }
1517            
1518          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1519      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) {
1520          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1521          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1522              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1523                m_iChangeCount = 0;
1524              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1525              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1526                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1527                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible()) {
1528                      pChannel->updateChannelUsage();                      // If we can't make it clean, try next time.
1529                        if (!pChannelStrip->updateChannelUsage())
1530                            m_iChangeCount++;
1531                    }
1532              }              }
1533          }          }
1534      }      }
# Line 1462  void qsamplerMainForm::stopServer (void) Line 1614  void qsamplerMainForm::stopServer (void)
1614      // And try to stop server.      // And try to stop server.
1615      if (m_pServer) {      if (m_pServer) {
1616          appendMessages(tr("Server is stopping..."));          appendMessages(tr("Server is stopping..."));
1617          if (m_pServer->isRunning()) {          if (m_pServer->isRunning())
1618              m_pServer->tryTerminate();              m_pServer->tryTerminate();
             return;  
         }  
1619       }       }
1620    
1621        // Give it some time to terminate gracefully and stabilize...
1622        QTime t;
1623        t.start();
1624        while (t.elapsed() < QSAMPLER_TIMER_MSECS)
1625            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1626    
1627       // Do final processing anyway.       // Do final processing anyway.
1628       processServerExit();       processServerExit();
1629  }  }
# Line 1509  void qsamplerMainForm::processServerExit Line 1665  void qsamplerMainForm::processServerExit
1665  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1666  // qsamplerMainForm -- Client stuff.  // qsamplerMainForm -- Client stuff.
1667    
   
1668  // The LSCP client callback procedure.  // The LSCP client callback procedure.
1669  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 )
1670  {  {
1671      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;
1672      if (pMainForm == NULL)      if (pMainForm == NULL)
1673          return LSCP_FAILED;          return LSCP_FAILED;
1674    
1675      char *pszBuffer = (char *) malloc(cchBuffer + 1);      // ATTN: DO NOT EVER call any GUI code here,
1676      if (pszBuffer == NULL)      // as this is run under some other thread context.
1677          return LSCP_FAILED;      // A custom event must be posted here...
1678        QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData));
     memcpy(pszBuffer, pchBuffer, cchBuffer);  
     pszBuffer[cchBuffer] = (char) 0;  
     pMainForm->appendMessagesColor(pszBuffer, "#996699");  
     free(pszBuffer);  
1679    
1680      return LSCP_OK;      return LSCP_OK;
1681  }  }

Legend:
Removed from v.119  
changed lines
  Added in v.303

  ViewVC Help
Powered by ViewVC