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

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

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

revision 263 by capela, Wed Sep 29 09:01:35 2004 UTC revision 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 103  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 114  void qsamplerMainForm::init (void) Line 119  void qsamplerMainForm::init (void)
119    
120      m_iTimerSlot = 0;      m_iTimerSlot = 0;
121    
122    #ifdef HAVE_SIGNAL_H
123            // Set to ignore any fatal "Broken pipe" signals.
124            ::signal(SIGPIPE, SIG_IGN);
125    #endif
126    
127      // Make it an MDI workspace.      // Make it an MDI workspace.
128      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
129      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
# Line 195  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 483  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 539  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 562  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 595  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 << " ";                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
625          if (pChannel->midiChannel() > 0)                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
626              ts << pChannel->midiChannel();                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
627           else                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
628              ts << "ALL";                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
629          ts << endl;                      ts << "ALL";
630          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  else
631          ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                      ts << pChannel->midiChannel();
632          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  ts << endl;
633          ts << endl;                  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 758  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;
     }  
   
     // Log this happening.  
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
789    
790      // Just create the channel strip with given id.      // Before we show it up, may be we'll
791      createChannel(iChannelID, true);      // better ask for some initial values?
792        if (!pChannel->channelSetup(this)) {
793            delete pChannel;
794            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 785  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 795  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 828  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->showChannelSetup(false);      pChannelStrip->channelSetup();
864  }  }
865    
866    
# Line 843  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 919  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 931  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 938  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 951  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 997  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 1095  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);
# Line 1121  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 1140  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 1214  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 1234  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 1334  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->showChannelSetup(true);          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 1407  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 1419  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 1462  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      }      }

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

  ViewVC Help
Powered by ViewVC