/[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 265 by capela, Wed Sep 29 16:05:24 2004 UTC revision 382 by capela, Mon Feb 14 15:42:38 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 487  bool qsamplerMainForm::closeSession ( bo Line 496  bool qsamplerMainForm::closeSession ( bo
496              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
497              if (pChannelStrip) {              if (pChannelStrip) {
498                  qsamplerChannel *pChannel = pChannelStrip->channel();                  qsamplerChannel *pChannel = pChannelStrip->channel();
499                  if (bForce && pChannel && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)                  if (bForce && pChannel)
500                      appendMessagesClient("lscp_remove_channel");                      pChannel->removeChannel();
501                  delete pChannelStrip;                  delete pChannelStrip;
502              }              }
503          }          }
# Line 543  bool qsamplerMainForm::loadSessionFile ( Line 552  bool qsamplerMainForm::loadSessionFile (
552          appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));
553    
554      // Now we'll try to create the whole GUI session.      // Now we'll try to create the whole GUI session.
555      int iChannels = ::lscp_get_channels(m_pClient);      int *piChannelIDs = ::lscp_list_channels(m_pClient);
556      if (iChannels < 0) {      if (piChannelIDs == NULL) {
557          appendMessagesClient("lscp_get_channels");          appendMessagesClient("lscp_list_channels");
558          appendMessagesError(tr("Could not get current number of channels.\n\nSorry."));          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
559      }      } else {
560                        // Try to (re)create each channel.
561      // Try to (re)create each channel.                  m_pWorkspace->setUpdatesEnabled(false);
562      m_pWorkspace->setUpdatesEnabled(false);                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
563      for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) {                          createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
564          createChannel(iChannelID, false);                          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
565          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  }
566      }                  m_pWorkspace->setUpdatesEnabled(true);
567      m_pWorkspace->setUpdatesEnabled(true);          }
568    
569      // Save as default session directory.      // Save as default session directory.
570      if (m_pOptions)      if (m_pOptions)
# Line 566  bool qsamplerMainForm::loadSessionFile ( Line 575  bool qsamplerMainForm::loadSessionFile (
575      m_sFilename = sFilename;      m_sFilename = sFilename;
576      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
577      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
578        
579        // Make that an overall update.
580        m_iChangeCount++;
581      stabilizeForm();      stabilizeForm();
582      return true;      return true;
583  }  }
# Line 610  bool qsamplerMainForm::saveSessionFile ( Line 622  bool qsamplerMainForm::saveSessionFile (
622                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
623                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
624                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
625                  if (pChannel->midiChannel() > 0)                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
                     ts << pChannel->midiChannel();  
                  else  
626                      ts << "ALL";                      ts << "ALL";
627                    else
628                        ts << pChannel->midiChannel();
629                  ts << endl;                  ts << endl;
630                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
631                  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 779  void qsamplerMainForm::editAddChannel (v
779      if (m_pClient == NULL)      if (m_pClient == NULL)
780          return;          return;
781    
782      // Create the new sampler channel.      // Just create the channel instance...
783      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
784      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
785          return;          return;
     }  
   
     // Log this happening.  
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
786    
787      // Just create the channel strip with given id.      // Before we show it up, may be we'll
788      createChannel(iChannelID, true);      // better ask for some initial values?
789        if (!pChannel->channelSetup(this)) {
790            delete pChannel;
791            return;
792        }
793        
794        // And give it to the strip (will own the channel instance, if successful).
795        if (!createChannelStrip(pChannel)) {
796            delete pChannel;
797            return;
798        }
799    
800      // We'll be dirty, for sure...      // Make that an overall update.
801      m_iDirtyCount++;      m_iDirtyCount++;
802      // Stabilize form anyway.      m_iChangeCount++;
803      stabilizeForm();      stabilizeForm();
804  }  }
805    
# Line 814  void qsamplerMainForm::editRemoveChannel Line 830  void qsamplerMainForm::editRemoveChannel
830      }      }
831    
832      // Remove the existing sampler channel.      // Remove the existing sampler channel.
833      if (::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      if (!pChannel->removeChannel())
         appendMessagesClient("lscp_remove_channel");  
         appendMessagesError(tr("Could not remove channel.\n\nSorry."));  
834          return;          return;
     }  
835    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
836      // Just delete the channel strip.      // Just delete the channel strip.
837      delete pChannelStrip;      delete pChannelStrip;
838            
# Line 847  void qsamplerMainForm::editSetupChannel Line 857  void qsamplerMainForm::editSetupChannel
857          return;          return;
858    
859      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
860      pChannelStrip->showChannelSetup(false);      pChannelStrip->channelSetup();
861  }  }
862    
863    
# Line 865  void qsamplerMainForm::editResetChannel Line 875  void qsamplerMainForm::editResetChannel
875      if (pChannel == NULL)      if (pChannel == NULL)
876          return;          return;
877    
878      // Remove the existing sampler channel.      // Reset the existing sampler channel.
879      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()));  
880    
881      // Refresh channel strip info.      // And force a deferred update.
882      pChannelStrip->updateChannelInfo();      m_iChangeCount++;
883  }  }
884    
885    
# Line 949  void qsamplerMainForm::viewOptions (void Line 952  void qsamplerMainForm::viewOptions (void
952          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
953          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
954          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
955            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
956          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
957          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
958          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
959          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
960          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
961          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
962            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
963          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
964          // Load the current setup settings.          // Load the current setup settings.
965          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 973  void qsamplerMainForm::viewOptions (void Line 978  void qsamplerMainForm::viewOptions (void
978                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
979                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
980                  updateRecentFilesMenu();                  updateRecentFilesMenu();
981                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
982                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
983                    updateInstrumentNames();
984                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
985                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
986                    updateDisplayEffect();
987              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
988                  updateDisplayFont();                  updateDisplayFont();
989              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 1080  void qsamplerMainForm::helpAbout (void) Line 1091  void qsamplerMainForm::helpAbout (void)
1091      sText += tr("GIG (libgig) file support disabled.");      sText += tr("GIG (libgig) file support disabled.");
1092      sText += "</font></small><br />";      sText += "</font></small><br />";
1093  #endif  #endif
1094    #ifndef CONFIG_INSTRUMENT_NAME
1095        sText += "<small><font color=\"red\">";
1096        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1097        sText += "</font></small><br />";
1098    #endif
1099      sText += "<br />\n";      sText += "<br />\n";
1100      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1101      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1160  void qsamplerMainForm::stabilizeForm (vo Line 1176  void qsamplerMainForm::stabilizeForm (vo
1176  // Channel change receiver slot.  // Channel change receiver slot.
1177  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )
1178  {  {
1179        // Flag that we're update those channel strips.
1180        m_iChangeCount++;
1181      // Just mark the dirty form.      // Just mark the dirty form.
1182      m_iDirtyCount++;      m_iDirtyCount++;
1183      // and update the form status...      // and update the form status...
# Line 1211  void qsamplerMainForm::updateRecentFiles Line 1229  void qsamplerMainForm::updateRecentFiles
1229  }  }
1230    
1231    
1232    // Force update of the channels instrument names mode.
1233    void qsamplerMainForm::updateInstrumentNames (void)
1234    {
1235        // Full channel list update...
1236        QWidgetList wlist = m_pWorkspace->windowList();
1237        if (wlist.isEmpty())
1238            return;
1239    
1240        m_pWorkspace->setUpdatesEnabled(false);
1241        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1242            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1243            if (pChannelStrip)
1244                pChannelStrip->updateInstrumentName(true);
1245        }
1246        m_pWorkspace->setUpdatesEnabled(true);
1247    }
1248    
1249    
1250  // Force update of the channels display font.  // Force update of the channels display font.
1251  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1252  {  {
# Line 1240  void qsamplerMainForm::updateDisplayFont Line 1276  void qsamplerMainForm::updateDisplayFont
1276  }  }
1277    
1278    
1279    // Update channel strips background effect.
1280    void qsamplerMainForm::updateDisplayEffect (void)
1281    {
1282       QPixmap pm;
1283        if (m_pOptions->bDisplayEffect)
1284            pm = QPixmap::fromMimeSource("displaybg1.png");
1285    
1286        // Full channel list update...
1287        QWidgetList wlist = m_pWorkspace->windowList();
1288        if (wlist.isEmpty())
1289            return;
1290    
1291        m_pWorkspace->setUpdatesEnabled(false);
1292        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1293            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1294            if (pChannelStrip)
1295                pChannelStrip->setDisplayBackground(pm);
1296        }
1297        m_pWorkspace->setUpdatesEnabled(true);
1298    }
1299    
1300    
1301  // Force update of the channels maximum volume setting.  // Force update of the channels maximum volume setting.
1302  void qsamplerMainForm::updateMaxVolume (void)  void qsamplerMainForm::updateMaxVolume (void)
1303  {  {
# Line 1354  void qsamplerMainForm::updateMessagesCap Line 1412  void qsamplerMainForm::updateMessagesCap
1412  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1413    
1414  // The channel strip creation executive.  // The channel strip creation executive.
1415  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1416  {  {
1417      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1418          return;          return NULL;
1419    
1420      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1421      qsamplerChannelStrip *pChannelStrip = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
# Line 1374  void qsamplerMainForm::createChannel ( i Line 1432  void qsamplerMainForm::createChannel ( i
1432      // Add a new channel itema...      // Add a new channel itema...
1433      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;
1434      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1435      pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1436      pChannelStrip->setup(this, iChannelID);          return NULL;
1437      // We'll need a display font.          
1438      QFont font;      // Actual channel strip setup...
1439      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
         pChannelStrip->setDisplayFont(font);  
     // Track channel setup changes.  
1440      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1441      // Before we show it up, may be we'll      // Set some initial aesthetic options...
1442      // better ask for some initial values?      if (m_pOptions) {
1443      if (bPrompt)          // Background display effect...
1444          pChannelStrip->showChannelSetup(true);          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1445            // We'll need a display font.
1446            QFont font;
1447            if (font.fromString(m_pOptions->sDisplayFont))
1448                pChannelStrip->setDisplayFont(font);
1449            // Maximum allowed volume setting.
1450            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1451        }
1452    
1453      // Now we show up us to the world.      // Now we show up us to the world.
1454      pChannelStrip->show();      pChannelStrip->show();
1455      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
# Line 1395  void qsamplerMainForm::createChannel ( i Line 1459  void qsamplerMainForm::createChannel ( i
1459          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1460          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1461      }      }
1462        
1463        // Return our successful reference...
1464        return pChannelStrip;
1465  }  }
1466    
1467    
# Line 1484  void qsamplerMainForm::timerSlot (void) Line 1551  void qsamplerMainForm::timerSlot (void)
1551      }      }
1552            
1553          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1554      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) {
1555          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1556          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1557              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1558                m_iChangeCount = 0;
1559              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1560              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1561                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1562                  if (pChannelStrip && pChannelStrip->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible()) {
1563                      pChannelStrip->updateChannelUsage();                      // If we can't make it clean, try next time.
1564                        if (!pChannelStrip->updateChannelUsage())
1565                            m_iChangeCount++;
1566                    }
1567              }              }
1568          }          }
1569      }      }

Legend:
Removed from v.265  
changed lines
  Added in v.382

  ViewVC Help
Powered by ViewVC