/[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 267 by capela, Wed Oct 6 15:42:59 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 44  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 104  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 115  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 196  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 487  bool qsamplerMainForm::closeSession ( bo Line 499  bool qsamplerMainForm::closeSession ( bo
499              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
500              if (pChannelStrip) {              if (pChannelStrip) {
501                  qsamplerChannel *pChannel = pChannelStrip->channel();                  qsamplerChannel *pChannel = pChannelStrip->channel();
502                  if (bForce && pChannel && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)                  if (bForce && pChannel)
503                      appendMessagesClient("lscp_remove_channel");                      pChannel->removeChannel();
504                  delete pChannelStrip;                  delete pChannelStrip;
505              }              }
506          }          }
# Line 543  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 566  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 610  bool qsamplerMainForm::saveSessionFile ( Line 625  bool qsamplerMainForm::saveSessionFile (
625                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
626                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
627                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
628                  if (pChannel->midiChannel() > 0)                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
                     ts << pChannel->midiChannel();  
                  else  
629                      ts << "ALL";                      ts << "ALL";
630                    else
631                        ts << pChannel->midiChannel();
632                  ts << endl;                  ts << endl;
633                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
634                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
# Line 767  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)
788          appendMessagesClient("lscp_add_channel");          return;
789          appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
790        // Before we show it up, may be we'll
791        // 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;          return;
801      }      }
802    
803      // Log this happening.      // Make that an overall update.
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
   
     // Just create the channel strip with given id.  
     createChannel(iChannelID, true);  
   
     // We'll be dirty, for sure...  
804      m_iDirtyCount++;      m_iDirtyCount++;
805      // Stabilize form anyway.      m_iChangeCount++;
806      stabilizeForm();      stabilizeForm();
807  }  }
808    
# Line 814  void qsamplerMainForm::editRemoveChannel Line 833  void qsamplerMainForm::editRemoveChannel
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 pChannelStrip;      delete pChannelStrip;
841            
# Line 847  void qsamplerMainForm::editSetupChannel Line 860  void qsamplerMainForm::editSetupChannel
860          return;          return;
861    
862      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
863      pChannelStrip->showChannelSetup(false);      pChannelStrip->channelSetup();
864  }  }
865    
866    
# Line 865  void qsamplerMainForm::editResetChannel Line 878  void qsamplerMainForm::editResetChannel
878      if (pChannel == NULL)      if (pChannel == NULL)
879          return;          return;
880    
881      // Remove the existing sampler channel.      // Reset the existing sampler channel.
882      if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      pChannel->resetChannel();
         appendMessagesClient("lscp_reset_channel");  
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
         return;  
     }  
   
     // Log this.  
     appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));  
883    
884      // Refresh channel strip info.      // And force a deferred update.
885      pChannelStrip->updateChannelInfo();      m_iChangeCount++;
886  }  }
887    
888    
# Line 957  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 970  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))
# Line 1164  void qsamplerMainForm::stabilizeForm (vo Line 1174  void qsamplerMainForm::stabilizeForm (vo
1174  // Channel change receiver slot.  // Channel change receiver slot.
1175  void qsamplerMainForm::channelStripChanged( 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 1380  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 *pChannelStrip = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
# Line 1400  void qsamplerMainForm::createChannel ( i Line 1412  void qsamplerMainForm::createChannel ( i
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      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1415        if (pChannelStrip == NULL)
1416            return NULL;
1417            
1418        // Actual channel strip setup...
1419        pChannelStrip->setup(pChannel);
1420        QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1421      // Set some initial aesthetic options...      // Set some initial aesthetic options...
1422      if (m_pOptions) {      if (m_pOptions) {
1423          // Background display effect...          // Background display effect...
# Line 1411  void qsamplerMainForm::createChannel ( i Line 1429  void qsamplerMainForm::createChannel ( i
1429          // Maximum allowed volume setting.          // Maximum allowed volume setting.
1430          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1431      }      }
1432      // Actual channel setup.  
     pChannelStrip->setup(this, iChannelID);  
     QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));  
     // Before we show it up, may be we'll  
     // better ask for some initial values?  
     if (bPrompt)  
         pChannelStrip->showChannelSetup(true);  
1433      // Now we show up us to the world.      // Now we show up us to the world.
1434      pChannelStrip->show();      pChannelStrip->show();
1435      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
# Line 1427  void qsamplerMainForm::createChannel ( i Line 1439  void qsamplerMainForm::createChannel ( i
1439          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1440          pChannelStrip->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    
# Line 1516  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 *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1542                  if (pChannelStrip && pChannelStrip->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible()) {
1543                      pChannelStrip->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.267  
changed lines
  Added in v.341

  ViewVC Help
Powered by ViewVC