/[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 341 by capela, Tue Jan 18 11:29:01 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 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 163  void qsamplerMainForm::setup ( qsamplerO Line 205  void qsamplerMainForm::setup ( qsamplerO
205      // We got options?      // We got options?
206      m_pOptions = pOptions;      m_pOptions = pOptions;
207    
208            // Set initial instrument name display mode.
209        qsamplerChannel::setInstrumentNames(m_pOptions->bInstrumentNames);
210    
211      // Some child forms are to be created right now.      // Some child forms are to be created right now.
212      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
213      // Set message defaults...      // Set message defaults...
# Line 252  void qsamplerMainForm::closeEvent ( QClo Line 297  void qsamplerMainForm::closeEvent ( QClo
297  }  }
298    
299    
300    // Window drag-n-drop event handlers.
301  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
302  {  {
303      bool bAccept = false;      bool bAccept = false;
# Line 276  void qsamplerMainForm::dropEvent ( QDrop Line 322  void qsamplerMainForm::dropEvent ( QDrop
322  }  }
323    
324    
325    // Custome event handler.
326    void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent )
327    {
328        // For the time being, just pump it to messages.
329        if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
330            qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
331            appendMessagesColor(tr("Notify event: %1 data: %2")
332                .arg(::lscp_event_to_text(pEvent->event()))
333                .arg(pEvent->data()), "#996699");
334        }
335    }
336    
337    
338    // Context menu event handler.
339    void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
340    {
341        stabilizeForm();
342        
343        editMenu->exec(pEvent->globalPos());
344    }
345    
346    
347  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
348  // qsamplerMainForm -- Brainless public property accessors.  // qsamplerMainForm -- Brainless public property accessors.
349    
# Line 428  bool qsamplerMainForm::closeSession ( bo Line 496  bool qsamplerMainForm::closeSession ( bo
496          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
497          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
498          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
499              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
500              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
501                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
502              delete pChannel;                  if (bForce && pChannel)
503                        pChannel->removeChannel();
504                    delete pChannelStrip;
505                }
506          }          }
507          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
508          // We're now clean, for sure.          // We're now clean, for sure.
# Line 484  bool qsamplerMainForm::loadSessionFile ( Line 555  bool qsamplerMainForm::loadSessionFile (
555          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));
556    
557      // Now we'll try to create the whole GUI session.      // Now we'll try to create the whole GUI session.
558      int iChannels = ::lscp_get_channels(m_pClient);      int *piChannelIDs = ::lscp_list_channels(m_pClient);
559      if (iChannels < 0) {      if (piChannelIDs == NULL) {
560          appendMessagesClient("lscp_get_channels");          appendMessagesClient("lscp_list_channels");
561          appendMessagesError(tr("Could not get current number of channels.\n\nSorry."));          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
562      }      }
563            
564      // Try to (re)create each channel.      // Try to (re)create each channel.
565      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
566      for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) {      for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
567          createChannel(iChannelID, false);          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
568          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
569      }      }
570      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 507  bool qsamplerMainForm::loadSessionFile ( Line 578  bool qsamplerMainForm::loadSessionFile (
578      m_sFilename = sFilename;      m_sFilename = sFilename;
579      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
580      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
581        
582        // Make that an overall update.
583        m_iChangeCount++;
584      stabilizeForm();      stabilizeForm();
585      return true;      return true;
586  }  }
# Line 540  bool qsamplerMainForm::saveSessionFile ( Line 614  bool qsamplerMainForm::saveSessionFile (
614      ts << endl;      ts << endl;
615      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
616      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
617          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
618          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
619          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
620          ts << "ADD CHANNEL" << endl;              if (pChannel) {
621          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  int iChannelID = pChannel->channelID();
622          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "# " << pChannelStrip->caption() << endl;
623      //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "ADD CHANNEL" << endl;
624          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
625          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
626          ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
627          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
628          ts << endl;                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
629                        ts << "ALL";
630                    else
631                        ts << pChannel->midiChannel();
632                    ts << endl;
633                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
634                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
635                    ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;
636                    ts << endl;
637                }
638            }
639          // Try to keep it snappy :)          // Try to keep it snappy :)
640          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
641      }      }
# Line 623  void qsamplerMainForm::fileSaveAs (void) Line 707  void qsamplerMainForm::fileSaveAs (void)
707  }  }
708    
709    
710    // Reset the sampler instance.
711    void qsamplerMainForm::fileReset (void)
712    {
713        if (m_pClient == NULL)
714            return;
715    
716        // Ask user whether he/she want's an internal sampler reset...
717        if (QMessageBox::warning(this, tr("Warning"),
718            tr("Resetting the sampler instance will close\n"
719               "all device and channel configurations.\n\n"
720               "Please note that this operation may cause\n"
721               "temporary MIDI and Audio disruption\n\n"
722               "Do you want to reset the sampler engine now?"),
723            tr("Reset"), tr("Cancel")) > 0)
724            return;
725    
726        // Just do the reset, after closing down current session...
727        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
728            appendMessagesClient("lscp_reset_sampler");
729            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
730            return;
731        }
732    
733        // Log this.
734        appendMessages(tr("Sampler reset."));
735    }
736    
737    
738  // Restart the client/server instance.  // Restart the client/server instance.
739  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
740  {  {
# Line 670  void qsamplerMainForm::editAddChannel (v Line 782  void qsamplerMainForm::editAddChannel (v
782      if (m_pClient == NULL)      if (m_pClient == NULL)
783          return;          return;
784    
785      // Create the new sampler channel.      // Just create the channel instance...
786      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
787      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
788          return;          return;
     }  
789    
790      // Log this happening.      // Before we show it up, may be we'll
791      appendMessages(tr("Channel %1 created.").arg(iChannelID));      // better ask for some initial values?
792        if (!pChannel->channelSetup(this)) {
793      // Just create the channel strip with given id.          delete pChannel;
794      createChannel(iChannelID, true);          return;
795        }
796        
797        // And give it to the strip (will own the channel instance, if successful).
798        if (!createChannelStrip(pChannel)) {
799            delete pChannel;
800            return;
801        }
802    
803      // We'll be dirty, for sure...      // Make that an overall update.
804      m_iDirtyCount++;      m_iDirtyCount++;
805      // Stabilize form anyway.      m_iChangeCount++;
806      stabilizeForm();      stabilizeForm();
807  }  }
808    
# Line 697  void qsamplerMainForm::editRemoveChannel Line 813  void qsamplerMainForm::editRemoveChannel
813      if (m_pClient == NULL)      if (m_pClient == NULL)
814          return;          return;
815    
816      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
817        if (pChannelStrip == NULL)
818            return;
819            
820        qsamplerChannel *pChannel = pChannelStrip->channel();
821      if (pChannel == NULL)      if (pChannel == NULL)
822          return;          return;
823    
# Line 707  void qsamplerMainForm::editRemoveChannel Line 827  void qsamplerMainForm::editRemoveChannel
827              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
828                 "%1\n\n"                 "%1\n\n"
829                 "Are you sure?")                 "Are you sure?")
830                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
831              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
832              return;              return;
833      }      }
834    
835      // Remove the existing sampler channel.      // Remove the existing sampler channel.
836      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."));  
837          return;          return;
     }  
838    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
839      // Just delete the channel strip.      // Just delete the channel strip.
840      delete pChannel;      delete pChannelStrip;
841        
842      // Do we auto-arrange?      // Do we auto-arrange?
843      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
844          channelsArrange();          channelsArrange();
# Line 740  void qsamplerMainForm::editSetupChannel Line 855  void qsamplerMainForm::editSetupChannel
855      if (m_pClient == NULL)      if (m_pClient == NULL)
856          return;          return;
857    
858      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
859      if (pChannel == NULL)      if (pChannelStrip == NULL)
860          return;          return;
861    
862      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
863      pChannel->channelSetup();      pChannelStrip->channelSetup();
864  }  }
865    
866    
# Line 755  void qsamplerMainForm::editResetChannel Line 870  void qsamplerMainForm::editResetChannel
870      if (m_pClient == NULL)      if (m_pClient == NULL)
871          return;          return;
872    
873      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
874      if (pChannel == NULL)      if (pChannelStrip == NULL)
875          return;          return;
876    
877      // Remove the existing sampler channel.      qsamplerChannel *pChannel = pChannelStrip->channel();
878      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."));  
879          return;          return;
     }  
880    
881      // Log this.      // Reset the existing sampler channel.
882      appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));      pChannel->resetChannel();
883    
884      // Refresh channel strip info.      // And force a deferred update.
885      pChannel->updateChannelInfo();      m_iChangeCount++;
886  }  }
887    
888    
# Line 831  void qsamplerMainForm::viewOptions (void Line 943  void qsamplerMainForm::viewOptions (void
943      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
944      if (pOptionsForm) {      if (pOptionsForm) {
945          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
946          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
947          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
948              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
949          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
950              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
951          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 843  void qsamplerMainForm::viewOptions (void Line 955  void qsamplerMainForm::viewOptions (void
955          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
956          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
957          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
958            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
959          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
960          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
961          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
# Line 850  void qsamplerMainForm::viewOptions (void Line 963  void qsamplerMainForm::viewOptions (void
963          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
964          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
965          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
966            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
967          // Load the current setup settings.          // Load the current setup settings.
968          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
969          // Show the setup dialog...          // Show the setup dialog...
# Line 863  void qsamplerMainForm::viewOptions (void Line 977  void qsamplerMainForm::viewOptions (void
977                  updateMessagesCapture();                  updateMessagesCapture();
978              }              }
979              // Check wheather something immediate has changed.              // Check wheather something immediate has changed.
980                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
981                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
982                    qsamplerChannel::setInstrumentNames(m_pOptions->bInstrumentNames);
983              if (( bOldCompletePath && !m_pOptions->bCompletePath) ||              if (( bOldCompletePath && !m_pOptions->bCompletePath) ||
984                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
985                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
986                  updateRecentFilesMenu();                  updateRecentFilesMenu();
987                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
988                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
989                    updateDisplayEffect();
990              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
991                  updateDisplayFont();                  updateDisplayFont();
992              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 909  void qsamplerMainForm::channelsArrange ( Line 1029  void qsamplerMainForm::channelsArrange (
1029      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1030      int y = 0;      int y = 0;
1031      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1032          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1033      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1034              // Prevent flicker...              // Prevent flicker...
1035              pChannel->hide();              pChannelStrip->hide();
1036              pChannel->showNormal();              pChannelStrip->showNormal();
1037          }   */          }   */
1038          pChannel->adjustSize();          pChannelStrip->adjustSize();
1039          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1040          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1041              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1042      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1043          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1044          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1045          y += iHeight;          y += iHeight;
1046      }      }
1047      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 969  void qsamplerMainForm::helpAbout (void) Line 1089  void qsamplerMainForm::helpAbout (void)
1089      sText += tr("Debugging option enabled.");      sText += tr("Debugging option enabled.");
1090      sText += "</font></small><br />";      sText += "</font></small><br />";
1091  #endif  #endif
1092    #ifndef CONFIG_LIBGIG
1093        sText += "<small><font color=\"red\">";
1094        sText += tr("GIG (libgig) file support disabled.");
1095        sText += "</font></small><br />";
1096    #endif
1097      sText += "<br />\n";      sText += "<br />\n";
1098      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1099      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1002  void qsamplerMainForm::stabilizeForm (vo Line 1127  void qsamplerMainForm::stabilizeForm (vo
1127      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));
1128    
1129      // Update the main menu state...      // Update the main menu state...
1130      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1131      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1132      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1133      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1134      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1135      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1136      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1137        fileResetAction->setEnabled(bHasClient);
1138      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1139      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1140      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
# Line 1027  void qsamplerMainForm::stabilizeForm (vo Line 1153  void qsamplerMainForm::stabilizeForm (vo
1153      }      }
1154      // Channel status...      // Channel status...
1155      if (bHasChannel)      if (bHasChannel)
1156          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1157      else      else
1158          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_status[QSAMPLER_STATUS_CHANNEL]->clear();
1159      // Session status...      // Session status...
# Line 1046  void qsamplerMainForm::stabilizeForm (vo Line 1172  void qsamplerMainForm::stabilizeForm (vo
1172    
1173    
1174  // Channel change receiver slot.  // Channel change receiver slot.
1175  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )
1176  {  {
1177        // Flag that we're update those channel strips.
1178        m_iChangeCount++;
1179      // Just mark the dirty form.      // Just mark the dirty form.
1180      m_iDirtyCount++;      m_iDirtyCount++;
1181      // and update the form status...      // and update the form status...
# Line 1120  void qsamplerMainForm::updateDisplayFont Line 1248  void qsamplerMainForm::updateDisplayFont
1248    
1249      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1250      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1251          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1252          pChannel->setDisplayFont(font);          if (pChannelStrip)
1253                pChannelStrip->setDisplayFont(font);
1254        }
1255        m_pWorkspace->setUpdatesEnabled(true);
1256    }
1257    
1258    
1259    // Update channel strips background effect.
1260    void qsamplerMainForm::updateDisplayEffect (void)
1261    {
1262       QPixmap pm;
1263        if (m_pOptions->bDisplayEffect)
1264            pm = QPixmap::fromMimeSource("displaybg1.png");
1265    
1266        // Full channel list update...
1267        QWidgetList wlist = m_pWorkspace->windowList();
1268        if (wlist.isEmpty())
1269            return;
1270    
1271        m_pWorkspace->setUpdatesEnabled(false);
1272        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1273            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1274            if (pChannelStrip)
1275                pChannelStrip->setDisplayBackground(pm);
1276      }      }
1277      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1278  }  }
# Line 1140  void qsamplerMainForm::updateMaxVolume ( Line 1291  void qsamplerMainForm::updateMaxVolume (
1291    
1292      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1293      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1294          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1295          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1296                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1297      }      }
1298      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1299  }  }
# Line 1240  void qsamplerMainForm::updateMessagesCap Line 1392  void qsamplerMainForm::updateMessagesCap
1392  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1393    
1394  // The channel strip creation executive.  // The channel strip creation executive.
1395  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1396  {  {
1397      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1398          return;          return NULL;
1399    
1400      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1401      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1402      int y = 0;      int y = 0;
1403      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1404          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1405          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1406              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1407          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1408              y += pChannel->parentWidget()->frameGeometry().height();              y += pChannelStrip->parentWidget()->frameGeometry().height();
1409          }          }
1410      }      }
1411    
1412      // Add a new channel itema...      // Add a new channel itema...
1413      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;
1414      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1415      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1416      pChannel->setup(this, iChannelID);          return NULL;
1417      // We'll need a display font.          
1418      QFont font;      // Actual channel strip setup...
1419      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1420          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1421      // Track channel setup changes.      // Set some initial aesthetic options...
1422      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1423      // Before we show it up, may be we'll          // Background display effect...
1424      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1425      if (bPrompt)          // We'll need a display font.
1426          pChannel->channelSetup();                QFont font;
1427            if (font.fromString(m_pOptions->sDisplayFont))
1428                pChannelStrip->setDisplayFont(font);
1429            // Maximum allowed volume setting.
1430            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1431        }
1432    
1433      // Now we show up us to the world.      // Now we show up us to the world.
1434      pChannel->show();      pChannelStrip->show();
1435      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1436      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1437          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1438      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1439          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1440          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1441      }      }
1442        
1443        // Return our successful reference...
1444        return pChannelStrip;
1445  }  }
1446    
1447    
1448  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1449  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1450  {  {
1451      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1452  }  }
1453    
1454    
1455  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1456  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1457  {  {
1458      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1459      if (wlist.isEmpty())      if (wlist.isEmpty())
# Line 1313  void qsamplerMainForm::channelsMenuAbout Line 1474  void qsamplerMainForm::channelsMenuAbout
1474      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1475          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1476          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1477              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1478              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1479              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1480              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1481                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1482                }
1483          }          }
1484      }      }
1485  }  }
# Line 1325  void qsamplerMainForm::channelsMenuAbout Line 1488  void qsamplerMainForm::channelsMenuAbout
1488  // Windows menu activation slot  // Windows menu activation slot
1489  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1490  {  {
1491      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1492      if (pChannel)      if (pChannelStrip)
1493          pChannel->showNormal();          pChannelStrip->showNormal();
1494      pChannel->setFocus();      pChannelStrip->setFocus();
1495  }  }
1496    
1497    
# Line 1368  void qsamplerMainForm::timerSlot (void) Line 1531  void qsamplerMainForm::timerSlot (void)
1531      }      }
1532            
1533          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1534      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) {
1535          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1536          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1537              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1538                m_iChangeCount = 0;
1539              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1540              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1541                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1542                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible()) {
1543                      pChannel->updateChannelUsage();                      // If we can't make it clean, try next time.
1544                        if (!pChannelStrip->updateChannelUsage())
1545                            m_iChangeCount++;
1546                    }
1547              }              }
1548          }          }
1549      }      }
# Line 1513  void qsamplerMainForm::processServerExit Line 1680  void qsamplerMainForm::processServerExit
1680  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1681  // qsamplerMainForm -- Client stuff.  // qsamplerMainForm -- Client stuff.
1682    
   
1683  // The LSCP client callback procedure.  // The LSCP client callback procedure.
1684  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 )
1685  {  {
1686      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;
1687      if (pMainForm == NULL)      if (pMainForm == NULL)
1688          return LSCP_FAILED;          return LSCP_FAILED;
1689    
1690      char *pszBuffer = (char *) malloc(cchBuffer + 1);      // ATTN: DO NOT EVER call any GUI code here,
1691      if (pszBuffer == NULL)      // as this is run under some other thread context.
1692          return LSCP_FAILED;      // A custom event must be posted here...
1693        QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData));
     memcpy(pszBuffer, pchBuffer, cchBuffer);  
     pszBuffer[cchBuffer] = (char) 0;  
     pMainForm->appendMessagesColor(pszBuffer, "#996699");  
     free(pszBuffer);  
1694    
1695      return LSCP_OK;      return LSCP_OK;
1696  }  }

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

  ViewVC Help
Powered by ViewVC