/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

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

revision 2722 by capela, Tue Mar 3 17:41:04 2015 UTC revision 3049 by capela, Sat Dec 3 09:47:38 2016 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007,2008,2015 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 123  static void qsampler_sigusr1_handler ( i Line 123  static void qsampler_sigusr1_handler ( i
123    
124    
125  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
126  // qsampler -- namespace  // QSampler -- namespace
127    
128    
129  namespace QSampler {  namespace QSampler {
# Line 143  namespace QSampler { Line 143  namespace QSampler {
143    
144    
145  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
146  // LscpEvent -- specialty for LSCP callback comunication.  // QSampler::LscpEvent -- specialty for LSCP callback comunication.
   
147    
148  class LscpEvent : public QEvent  class LscpEvent : public QEvent
149  {  {
# Line 159  public: Line 158  public:
158          }          }
159    
160          // Accessors.          // Accessors.
161          lscp_event_t event() { return m_event; }          lscp_event_t  event() { return m_event; }
162          QString&     data()  { return m_data;  }          const QString& data() { return m_data;  }
163    
164  private:  private:
165    
# Line 172  private: Line 171  private:
171    
172    
173  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
174  // qsamplerMainForm -- Main window form implementation.  // QSampler::Workspace -- Main window workspace (MDI Area) decl.
175    
176    class Workspace : public QMdiArea
177    {
178    public:
179    
180            Workspace(MainForm *pMainForm) : QMdiArea(pMainForm) {}
181    
182    protected:
183    
184            void resizeEvent(QResizeEvent *)
185            {
186                    MainForm *pMainForm = static_cast<MainForm *> (parentWidget());
187                    if (pMainForm)
188                            pMainForm->channelsArrangeAuto();
189            }
190    };
191    
192    
193    //-------------------------------------------------------------------------
194    // QSampler::MainForm -- Main window form implementation.
195    
196  // Kind of singleton reference.  // Kind of singleton reference.
197  MainForm* MainForm::g_pMainForm = NULL;  MainForm *MainForm::g_pMainForm = NULL;
198    
199  MainForm::MainForm ( QWidget *pParent )  MainForm::MainForm ( QWidget *pParent )
200          : QMainWindow(pParent)          : QMainWindow(pParent)
# Line 195  MainForm::MainForm ( QWidget *pParent ) Line 214  MainForm::MainForm ( QWidget *pParent )
214    
215          // We'll start clean.          // We'll start clean.
216          m_iUntitled   = 0;          m_iUntitled   = 0;
217            m_iDirtySetup = 0;
218          m_iDirtyCount = 0;          m_iDirtyCount = 0;
219    
220          m_pServer = NULL;          m_pServer = NULL;
# Line 269  MainForm::MainForm ( QWidget *pParent ) Line 289  MainForm::MainForm ( QWidget *pParent )
289  #endif  #endif
290    
291          // Make it an MDI workspace.          // Make it an MDI workspace.
292          m_pWorkspace = new QMdiArea(this);          m_pWorkspace = new Workspace(this);
293          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
294          m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);          m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
295          // Set the activation connection.          // Set the activation connection.
# Line 478  void MainForm::setup ( Options *pOptions Line 498  void MainForm::setup ( Options *pOptions
498          updateMessagesFont();          updateMessagesFont();
499          updateMessagesLimit();          updateMessagesLimit();
500          updateMessagesCapture();          updateMessagesCapture();
501    
502          // Set the visibility signal.          // Set the visibility signal.
503          QObject::connect(m_pMessages,          QObject::connect(m_pMessages,
504                  SIGNAL(visibilityChanged(bool)),                  SIGNAL(visibilityChanged(bool)),
# Line 543  bool MainForm::queryClose (void) Line 564  bool MainForm::queryClose (void)
564                                  || m_ui.channelsToolbar->isVisible());                                  || m_ui.channelsToolbar->isVisible());
565                          m_pOptions->bStatusbar = statusBar()->isVisible();                          m_pOptions->bStatusbar = statusBar()->isVisible();
566                          // Save the dock windows state.                          // Save the dock windows state.
                         const QString sDockables = saveState().toBase64().data();  
567                          m_pOptions->settings().setValue("/Layout/DockWindows", saveState());                          m_pOptions->settings().setValue("/Layout/DockWindows", saveState());
568                          // And the children, and the main windows state,.                          // And the children, and the main windows state,.
569                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
# Line 586  void MainForm::dragEnterEvent ( QDragEnt Line 606  void MainForm::dragEnterEvent ( QDragEnt
606  }  }
607    
608    
609  void MainForm::dropEvent ( QDropEvent* pDropEvent )  void MainForm::dropEvent ( QDropEvent *pDropEvent )
610  {  {
611          // Accept externally originated drops only...          // Accept externally originated drops only...
612          if (pDropEvent->source())          if (pDropEvent->source())
# Line 642  void MainForm::customEvent ( QEvent* pEv Line 662  void MainForm::customEvent ( QEvent* pEv
662                                  updateAllChannelStrips(true);                                  updateAllChannelStrips(true);
663                                  break;                                  break;
664                          case LSCP_EVENT_CHANNEL_INFO: {                          case LSCP_EVENT_CHANNEL_INFO: {
665                                  int iChannelID = pLscpEvent->data().toInt();                                  const int iChannelID = pLscpEvent->data().toInt();
666                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
667                                  if (pChannelStrip)                                  if (pChannelStrip)
668                                          channelStripChanged(pChannelStrip);                                          channelStripChanged(pChannelStrip);
# Line 733  void MainForm::contextMenuEvent( QContex Line 753  void MainForm::contextMenuEvent( QContex
753    
754    
755  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
756  // qsamplerMainForm -- Brainless public property accessors.  // QSampler::MainForm -- Brainless public property accessors.
757    
758  // The global options settings property.  // The global options settings property.
759  Options *MainForm::options (void) const  Options *MainForm::options (void) const
# Line 757  MainForm *MainForm::getInstance (void) Line 777  MainForm *MainForm::getInstance (void)
777    
778    
779  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
780  // qsamplerMainForm -- Session file stuff.  // QSampler::MainForm -- Session file stuff.
781    
782  // Format the displayable session filename.  // Format the displayable session filename.
783  QString MainForm::sessionName ( const QString& sFilename )  QString MainForm::sessionName ( const QString& sFilename )
784  {  {
785          bool bCompletePath = (m_pOptions && m_pOptions->bCompletePath);          const bool bCompletePath = (m_pOptions && m_pOptions->bCompletePath);
786          QString sSessionName = sFilename;          QString sSessionName = sFilename;
787          if (sSessionName.isEmpty())          if (sSessionName.isEmpty())
788                  sSessionName = tr("Untitled") + QString::number(m_iUntitled);                  sSessionName = tr("Untitled") + QString::number(m_iUntitled);
# Line 896  bool MainForm::closeSession ( bool bForc Line 916  bool MainForm::closeSession ( bool bForc
916          if (bClose) {          if (bClose) {
917                  // Remove all channel strips from sight...                  // Remove all channel strips from sight...
918                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
919                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();                  const QList<QMdiSubWindow *>& wlist
920                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {                          = m_pWorkspace->subWindowList();
921                    const int iStripCount = wlist.count();
922                    for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
923                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip = NULL;
924                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
925                          if (pMdiSubWindow)                          if (pMdiSubWindow)
926                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
927                          if (pChannelStrip) {                          if (pChannelStrip) {
# Line 1021  bool MainForm::saveSessionFile ( const Q Line 1043  bool MainForm::saveSessionFile ( const Q
1043          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));          QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1044    
1045          // Write the file.          // Write the file.
1046          int  iErrors = 0;          int iErrors = 0;
1047          QTextStream ts(&file);          QTextStream ts(&file);
1048          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
1049          ts << "# " << tr("Version")          ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl;
1050          << ": " QSAMPLER_VERSION << endl;  //      ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl;
         ts << "# " << tr("Build")  
         << ": " __DATE__ " " __TIME__ << endl;  
1051          ts << "#"  << endl;          ts << "#"  << endl;
1052          ts << "# " << tr("File")          ts << "# " << tr("File")
1053          << ": " << QFileInfo(sFilename).fileName() << endl;          << ": " << QFileInfo(sFilename).fileName() << endl;
# Line 1133  bool MainForm::saveSessionFile ( const Q Line 1153  bool MainForm::saveSessionFile ( const Q
1153          QMap<int, int> midiInstrumentMap;          QMap<int, int> midiInstrumentMap;
1154          int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);          int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
1155          for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {          for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {
1156                  int iMidiMap = piMaps[iMap];                  const int iMidiMap = piMaps[iMap];
1157                  const char *pszMapName                  const char *pszMapName
1158                          = ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap);                          = ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap);
1159                  ts << "# " << tr("MIDI instrument map") << " " << iMap;                  ts << "# " << tr("MIDI instrument map") << " " << iMap;
# Line 1200  bool MainForm::saveSessionFile ( const Q Line 1220  bool MainForm::saveSessionFile ( const Q
1220  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1221    
1222          // Sampler channel mapping.          // Sampler channel mapping.
1223          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
1224          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {                  = m_pWorkspace->subWindowList();
1225            const int iStripCount = wlist.count();
1226            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
1227                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = NULL;
1228                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
1229                  if (pMdiSubWindow)                  if (pMdiSubWindow)
1230                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1231                  if (pChannelStrip) {                  if (pChannelStrip) {
1232                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1233                          if (pChannel) {                          if (pChannel) {
1234                                  ts << "# " << tr("Channel") << " " << iChannel << endl;                                  const int iChannelID = pChannel->channelID();
1235                                    ts << "# " << tr("Channel") << " " << iChannelID << endl;
1236                                  ts << "ADD CHANNEL" << endl;                                  ts << "ADD CHANNEL" << endl;
1237                                  if (audioDeviceMap.isEmpty()) {                                  if (audioDeviceMap.isEmpty()) {
1238                                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel                                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID
1239                                                  << " " << pChannel->audioDriver() << endl;                                                  << " " << pChannel->audioDriver() << endl;
1240                                  } else {                                  } else {
1241                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID
1242                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;
1243                                  }                                  }
1244                                  if (midiDeviceMap.isEmpty()) {                                  if (midiDeviceMap.isEmpty()) {
1245                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID
1246                                                  << " " << pChannel->midiDriver() << endl;                                                  << " " << pChannel->midiDriver() << endl;
1247                                  } else {                                  } else {
1248                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID
1249                                                  << " " << midiDeviceMap[pChannel->midiDevice()] << endl;                                                  << " " << midiDeviceMap[pChannel->midiDevice()] << endl;
1250                                  }                                  }
1251                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID
1252                                          << " " << pChannel->midiPort() << endl;                                          << " " << pChannel->midiPort() << endl;
1253                                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";                                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
1254                                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)                                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
1255                                          ts << "ALL";                                          ts << "ALL";
1256                                  else                                  else
1257                                          ts << pChannel->midiChannel();                                          ts << pChannel->midiChannel();
1258                                  ts << endl;                                  ts << endl;
1259                                  ts << "LOAD ENGINE " << pChannel->engineName()                                  ts << "LOAD ENGINE " << pChannel->engineName()
1260                                          << " " << iChannel << endl;                                          << " " << iChannelID << endl;
1261                                  if (pChannel->instrumentStatus() < 100) ts << "# ";                                  if (pChannel->instrumentStatus() < 100) ts << "# ";
1262                                  ts << "LOAD INSTRUMENT NON_MODAL '"                                  ts << "LOAD INSTRUMENT NON_MODAL '"
1263                                          << pChannel->instrumentFile() << "' "                                          << pChannel->instrumentFile() << "' "
1264                                          << pChannel->instrumentNr() << " " << iChannel << endl;                                          << pChannel->instrumentNr() << " " << iChannelID << endl;
1265                                  ChannelRoutingMap::ConstIterator audioRoute;                                  ChannelRoutingMap::ConstIterator audioRoute;
1266                                  for (audioRoute = pChannel->audioRouting().begin();                                  for (audioRoute = pChannel->audioRouting().begin();
1267                                                  audioRoute != pChannel->audioRouting().end();                                                  audioRoute != pChannel->audioRouting().end();
1268                                                          ++audioRoute) {                                                          ++audioRoute) {
1269                                          ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel                                          ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID
1270                                                  << " " << audioRoute.key()                                                  << " " << audioRoute.key()
1271                                                  << " " << audioRoute.value() << endl;                                                  << " " << audioRoute.value() << endl;
1272                                  }                                  }
1273                                  ts << "SET CHANNEL VOLUME " << iChannel                                  ts << "SET CHANNEL VOLUME " << iChannelID
1274                                          << " " << pChannel->volume() << endl;                                          << " " << pChannel->volume() << endl;
1275                                  if (pChannel->channelMute())                                  if (pChannel->channelMute())
1276                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL MUTE " << iChannelID << " 1" << endl;
1277                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1278                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;
1279                          #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1280                                  if (pChannel->midiMap() >= 0) {                                  if (pChannel->midiMap() >= 0) {
1281                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID
1282                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
1283                                  }                                  }
1284                          #endif                          #endif
1285                          #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
                                 int iChannelID = pChannel->channelID();  
1286                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);
1287                                  for (int iFxSend = 0;                                  for (int iFxSend = 0;
1288                                                  piFxSends && piFxSends[iFxSend] >= 0;                                                  piFxSends && piFxSends[iFxSend] >= 0;
# Line 1268  bool MainForm::saveSessionFile ( const Q Line 1290  bool MainForm::saveSessionFile ( const Q
1290                                          lscp_fxsend_info_t *pFxSendInfo = ::lscp_get_fxsend_info(                                          lscp_fxsend_info_t *pFxSendInfo = ::lscp_get_fxsend_info(
1291                                                  m_pClient, iChannelID, piFxSends[iFxSend]);                                                  m_pClient, iChannelID, piFxSends[iFxSend]);
1292                                          if (pFxSendInfo) {                                          if (pFxSendInfo) {
1293                                                  ts << "CREATE FX_SEND " << iChannel                                                  ts << "CREATE FX_SEND " << iChannelID
1294                                                          << " " << pFxSendInfo->midi_controller;                                                          << " " << pFxSendInfo->midi_controller;
1295                                                  if (pFxSendInfo->name)                                                  if (pFxSendInfo->name)
1296                                                          ts << " '" << pFxSendInfo->name << "'";                                                          ts << " '" << pFxSendInfo->name << "'";
# Line 1278  bool MainForm::saveSessionFile ( const Q Line 1300  bool MainForm::saveSessionFile ( const Q
1300                                                                  piRouting && piRouting[iAudioSrc] >= 0;                                                                  piRouting && piRouting[iAudioSrc] >= 0;
1301                                                                          iAudioSrc++) {                                                                          iAudioSrc++) {
1302                                                          ts << "SET FX_SEND AUDIO_OUTPUT_CHANNEL "                                                          ts << "SET FX_SEND AUDIO_OUTPUT_CHANNEL "
1303                                                                  << iChannel                                                                  << iChannelID
1304                                                                  << " " << iFxSend                                                                  << " " << iFxSend
1305                                                                  << " " << iAudioSrc                                                                  << " " << iAudioSrc
1306                                                                  << " " << piRouting[iAudioSrc] << endl;                                                                  << " " << piRouting[iAudioSrc] << endl;
1307                                                  }                                                  }
1308                                          #ifdef CONFIG_FXSEND_LEVEL                                          #ifdef CONFIG_FXSEND_LEVEL
1309                                                  ts << "SET FX_SEND LEVEL " << iChannel                                                  ts << "SET FX_SEND LEVEL " << iChannelID
1310                                                          << " " << iFxSend                                                          << " " << iFxSend
1311                                                          << " " << pFxSendInfo->level << endl;                                                          << " " << pFxSendInfo->level << endl;
1312                                          #endif                                          #endif
# Line 1347  void MainForm::sessionDirty (void) Line 1369  void MainForm::sessionDirty (void)
1369    
1370    
1371  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1372  // qsamplerMainForm -- File Action slots.  // QSampler::MainForm -- File Action slots.
1373    
1374  // Create a new sampler session.  // Create a new sampler session.
1375  void MainForm::fileNew (void)  void MainForm::fileNew (void)
# Line 1371  void MainForm::fileOpenRecent (void) Line 1393  void MainForm::fileOpenRecent (void)
1393          // Retrive filename index from action data...          // Retrive filename index from action data...
1394          QAction *pAction = qobject_cast<QAction *> (sender());          QAction *pAction = qobject_cast<QAction *> (sender());
1395          if (pAction && m_pOptions) {          if (pAction && m_pOptions) {
1396                  int iIndex = pAction->data().toInt();                  const int iIndex = pAction->data().toInt();
1397                  if (iIndex >= 0 && iIndex < m_pOptions->recentFiles.count()) {                  if (iIndex >= 0 && iIndex < m_pOptions->recentFiles.count()) {
1398                          QString sFilename = m_pOptions->recentFiles[iIndex];                          QString sFilename = m_pOptions->recentFiles[iIndex];
1399                          // Check if we can safely close the current session...                          // Check if we can safely close the current session...
# Line 1513  void MainForm::fileExit (void) Line 1535  void MainForm::fileExit (void)
1535    
1536    
1537  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1538  // qsamplerMainForm -- Edit Action slots.  // QSampler::MainForm -- Edit Action slots.
1539    
1540  // Add a new sampler channel.  // Add a new sampler channel.
1541  void MainForm::editAddChannel (void)  void MainForm::editAddChannel (void)
1542  {  {
1543            ++m_iDirtySetup;
1544            addChannelStrip();
1545            --m_iDirtySetup;
1546    }
1547    
1548    void MainForm::addChannelStrip (void)
1549    {
1550          if (m_pClient == NULL)          if (m_pClient == NULL)
1551                  return;                  return;
1552    
# Line 1541  void MainForm::editAddChannel (void) Line 1570  void MainForm::editAddChannel (void)
1570          }          }
1571    
1572          // Do we auto-arrange?          // Do we auto-arrange?
1573          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
1574    
1575          // Make that an overall update.          // Make that an overall update.
1576          m_iDirtyCount++;          m_iDirtyCount++;
# Line 1553  void MainForm::editAddChannel (void) Line 1581  void MainForm::editAddChannel (void)
1581  // Remove current sampler channel.  // Remove current sampler channel.
1582  void MainForm::editRemoveChannel (void)  void MainForm::editRemoveChannel (void)
1583  {  {
1584            ++m_iDirtySetup;
1585            removeChannelStrip();
1586            --m_iDirtySetup;
1587    }
1588    
1589    void MainForm::removeChannelStrip (void)
1590    {
1591          if (m_pClient == NULL)          if (m_pClient == NULL)
1592                  return;                  return;
1593    
# Line 1597  void MainForm::editRemoveChannel (void) Line 1632  void MainForm::editRemoveChannel (void)
1632          if (!pChannel->removeChannel())          if (!pChannel->removeChannel())
1633                  return;                  return;
1634    
         // We'll be dirty, for sure...  
         m_iDirtyCount++;  
   
1635          // Just delete the channel strip.          // Just delete the channel strip.
1636          destroyChannelStrip(pChannelStrip);          destroyChannelStrip(pChannelStrip);
1637    
1638            // We'll be dirty, for sure...
1639            m_iDirtyCount++;
1640            stabilizeForm();
1641  }  }
1642    
1643    
# Line 1659  void MainForm::editResetAllChannels (voi Line 1695  void MainForm::editResetAllChannels (voi
1695          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
1696          // for all channels out there...          // for all channels out there...
1697          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1698          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
1699          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {                  = m_pWorkspace->subWindowList();
1700            const int iStripCount = wlist.count();
1701            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
1702                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = NULL;
1703                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
1704                  if (pMdiSubWindow)                  if (pMdiSubWindow)
1705                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1706                  if (pChannelStrip)                  if (pChannelStrip)
# Line 1673  void MainForm::editResetAllChannels (voi Line 1711  void MainForm::editResetAllChannels (voi
1711    
1712    
1713  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1714  // qsamplerMainForm -- View Action slots.  // QSampler::MainForm -- View Action slots.
1715    
1716  // Show/hide the main program window menubar.  // Show/hide the main program window menubar.
1717  void MainForm::viewMenubar ( bool bOn )  void MainForm::viewMenubar ( bool bOn )
# Line 1773  void MainForm::viewOptions (void) Line 1811  void MainForm::viewOptions (void)
1811                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
1812                          m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();                          m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
1813                  // To track down deferred or immediate changes.                  // To track down deferred or immediate changes.
1814                  QString sOldServerHost      = m_pOptions->sServerHost;                  const QString sOldServerHost      = m_pOptions->sServerHost;
1815                  int     iOldServerPort      = m_pOptions->iServerPort;                  const int     iOldServerPort      = m_pOptions->iServerPort;
1816                  int     iOldServerTimeout   = m_pOptions->iServerTimeout;                  const int     iOldServerTimeout   = m_pOptions->iServerTimeout;
1817                  bool    bOldServerStart     = m_pOptions->bServerStart;                  const bool    bOldServerStart     = m_pOptions->bServerStart;
1818                  QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;                  const QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
1819                  bool    bOldMessagesLog     = m_pOptions->bMessagesLog;                  const bool    bOldMessagesLog     = m_pOptions->bMessagesLog;
1820                  QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath;                  const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath;
1821                  QString sOldDisplayFont     = m_pOptions->sDisplayFont;                  const QString sOldDisplayFont     = m_pOptions->sDisplayFont;
1822                  bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;                  const bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1823                  int     iOldMaxVolume       = m_pOptions->iMaxVolume;                  const int     iOldMaxVolume       = m_pOptions->iMaxVolume;
1824                  QString sOldMessagesFont    = m_pOptions->sMessagesFont;                  const QString sOldMessagesFont    = m_pOptions->sMessagesFont;
1825                  bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;                  const bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;
1826                  bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;                  const bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
1827                  int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;                  const int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
1828                  int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;                  const int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1829                  bool    bOldCompletePath    = m_pOptions->bCompletePath;                  const bool    bOldCompletePath    = m_pOptions->bCompletePath;
1830                  bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;                  const bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
1831                  int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;                  const int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1832                  int     iOldBaseFontSize    = m_pOptions->iBaseFontSize;                  const int     iOldBaseFontSize    = m_pOptions->iBaseFontSize;
1833                  // Load the current setup settings.                  // Load the current setup settings.
1834                  pOptionsForm->setup(m_pOptions);                  pOptionsForm->setup(m_pOptions);
1835                  // Show the setup dialog...                  // Show the setup dialog...
# Line 1854  void MainForm::viewOptions (void) Line 1892  void MainForm::viewOptions (void)
1892    
1893    
1894  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1895  // qsamplerMainForm -- Channels action slots.  // QSampler::MainForm -- Channels action slots.
1896    
1897  // Arrange channel strips.  // Arrange channel strips.
1898  void MainForm::channelsArrange (void)  void MainForm::channelsArrange (void)
1899  {  {
1900          // Full width vertical tiling          // Full width vertical tiling
1901          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
1902                    = m_pWorkspace->subWindowList();
1903          if (wlist.isEmpty())          if (wlist.isEmpty())
1904                  return;                  return;
1905    
1906          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1907          int y = 0;          int y = 0;
1908          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {          const int iStripCount = wlist.count();
1909                  ChannelStrip *pChannelStrip = NULL;          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
1910                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
1911                  if (pMdiSubWindow)                  if (pMdiSubWindow) {
1912                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pMdiSubWindow->adjustSize();
1913                  if (pChannelStrip) {                          int iWidth = m_pWorkspace->width();
1914                  /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {                          if (iWidth < pMdiSubWindow->width())
1915                                  // Prevent flicker...                                  iWidth = pMdiSubWindow->width();
1916                                  pChannelStrip->hide();                          const int iHeight = pMdiSubWindow->frameGeometry().height();
1917                                  pChannelStrip->showNormal();                          pMdiSubWindow->setGeometry(0, y, iWidth, iHeight);
                         }   */  
                         pChannelStrip->adjustSize();  
                         int iWidth  = m_pWorkspace->width();  
                         if (iWidth < pChannelStrip->width())  
                                 iWidth = pChannelStrip->width();  
                 //  int iHeight = pChannelStrip->height()  
                 //              + pChannelStrip->parentWidget()->baseSize().height();  
                         int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();  
                         pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);  
1918                          y += iHeight;                          y += iHeight;
1919                  }                  }
1920          }          }
# Line 1904  void MainForm::channelsAutoArrange ( boo Line 1934  void MainForm::channelsAutoArrange ( boo
1934          m_pOptions->bAutoArrange = bOn;          m_pOptions->bAutoArrange = bOn;
1935    
1936          // If on, update whole workspace...          // If on, update whole workspace...
1937          if (m_pOptions->bAutoArrange)          channelsArrangeAuto();
1938    }
1939    
1940    
1941    void MainForm::channelsArrangeAuto (void)
1942    {
1943            if (m_pOptions && m_pOptions->bAutoArrange)
1944                  channelsArrange();                  channelsArrange();
1945  }  }
1946    
1947    
1948  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1949  // qsamplerMainForm -- Help Action slots.  // QSampler::MainForm -- Help Action slots.
1950    
1951  // Show information about the Qt toolkit.  // Show information about the Qt toolkit.
1952  void MainForm::helpAboutQt (void)  void MainForm::helpAboutQt (void)
# Line 1922  void MainForm::helpAboutQt (void) Line 1958  void MainForm::helpAboutQt (void)
1958  // Show information about application program.  // Show information about application program.
1959  void MainForm::helpAbout (void)  void MainForm::helpAbout (void)
1960  {  {
1961          // Stuff the about box text...          QStringList list;
         QString sText = "<p>\n";  
         sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";  
         sText += "<br />\n";  
         sText += tr("Version") + ": <b>" QSAMPLER_VERSION "</b><br />\n";  
         sText += "<small>" + tr("Build") + ": " __DATE__ " " __TIME__ "</small><br />\n";  
1962  #ifdef CONFIG_DEBUG  #ifdef CONFIG_DEBUG
1963          sText += "<small><font color=\"red\">";          list << tr("Debugging option enabled.");
         sText += tr("Debugging option enabled.");  
         sText += "</font></small><br />";  
1964  #endif  #endif
1965  #ifndef CONFIG_LIBGIG  #ifndef CONFIG_LIBGIG
1966          sText += "<small><font color=\"red\">";          list << tr("GIG (libgig) file support disabled.");
         sText += tr("GIG (libgig) file support disabled.");  
         sText += "</font></small><br />";  
1967  #endif  #endif
1968  #ifndef CONFIG_INSTRUMENT_NAME  #ifndef CONFIG_INSTRUMENT_NAME
1969          sText += "<small><font color=\"red\">";          list << tr("LSCP (liblscp) instrument_name support disabled.");
         sText += tr("LSCP (liblscp) instrument_name support disabled.");  
         sText += "</font></small><br />";  
1970  #endif  #endif
1971  #ifndef CONFIG_MUTE_SOLO  #ifndef CONFIG_MUTE_SOLO
1972          sText += "<small><font color=\"red\">";          list << tr("Sampler channel Mute/Solo support disabled.");
         sText += tr("Sampler channel Mute/Solo support disabled.");  
         sText += "</font></small><br />";  
1973  #endif  #endif
1974  #ifndef CONFIG_AUDIO_ROUTING  #ifndef CONFIG_AUDIO_ROUTING
1975          sText += "<small><font color=\"red\">";          list << tr("LSCP (liblscp) audio_routing support disabled.");
         sText += tr("LSCP (liblscp) audio_routing support disabled.");  
         sText += "</font></small><br />";  
1976  #endif  #endif
1977  #ifndef CONFIG_FXSEND  #ifndef CONFIG_FXSEND
1978          sText += "<small><font color=\"red\">";          list << tr("Sampler channel Effect Sends support disabled.");
         sText += tr("Sampler channel Effect Sends support disabled.");  
         sText += "</font></small><br />";  
1979  #endif  #endif
1980  #ifndef CONFIG_VOLUME  #ifndef CONFIG_VOLUME
1981          sText += "<small><font color=\"red\">";          list << tr("Global volume support disabled.");
         sText += tr("Global volume support disabled.");  
         sText += "</font></small><br />";  
1982  #endif  #endif
1983  #ifndef CONFIG_MIDI_INSTRUMENT  #ifndef CONFIG_MIDI_INSTRUMENT
1984          sText += "<small><font color=\"red\">";          list << tr("MIDI instrument mapping support disabled.");
         sText += tr("MIDI instrument mapping support disabled.");  
         sText += "</font></small><br />";  
1985  #endif  #endif
1986  #ifndef CONFIG_EDIT_INSTRUMENT  #ifndef CONFIG_EDIT_INSTRUMENT
1987          sText += "<small><font color=\"red\">";          list << tr("Instrument editing support disabled.");
         sText += tr("Instrument editing support disabled.");  
         sText += "</font></small><br />";  
1988  #endif  #endif
1989  #ifndef CONFIG_EVENT_CHANNEL_MIDI  #ifndef CONFIG_EVENT_CHANNEL_MIDI
1990          sText += "<small><font color=\"red\">";          list << tr("Channel MIDI event support disabled.");
         sText += tr("Channel MIDI event support disabled.");  
         sText += "</font></small><br />";  
1991  #endif  #endif
1992  #ifndef CONFIG_EVENT_DEVICE_MIDI  #ifndef CONFIG_EVENT_DEVICE_MIDI
1993          sText += "<small><font color=\"red\">";          list << tr("Device MIDI event support disabled.");
         sText += tr("Device MIDI event support disabled.");  
         sText += "</font></small><br />";  
1994  #endif  #endif
1995  #ifndef CONFIG_MAX_VOICES  #ifndef CONFIG_MAX_VOICES
1996          sText += "<small><font color=\"red\">";          list << tr("Runtime max. voices / disk streams support disabled.");
         sText += tr("Runtime max. voices / disk streams support disabled.");  
         sText += "</font></small><br />";  
1997  #endif  #endif
1998    
1999            // Stuff the about box text...
2000            QString sText = "<p>\n";
2001            sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";
2002            sText += "<br />\n";
2003            sText += tr("Version") + ": <b>" CONFIG_BUILD_VERSION "</b><br />\n";
2004    //      sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n";
2005            if (!list.isEmpty()) {
2006                    sText += "<small><font color=\"red\">";
2007                    sText += list.join("<br />\n");
2008                    sText += "</font></small>";
2009            }
2010          sText += "<br />\n";          sText += "<br />\n";
2011          sText += tr("Using") + ": ";          sText += tr("Using") + ": ";
2012          sText += ::lscp_client_package();          sText += ::lscp_client_package();
# Line 2017  void MainForm::helpAbout (void) Line 2036  void MainForm::helpAbout (void)
2036    
2037    
2038  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2039  // qsamplerMainForm -- Main window stabilization.  // QSampler::MainForm -- Main window stabilization.
2040    
2041  void MainForm::stabilizeForm (void)  void MainForm::stabilizeForm (void)
2042  {  {
# Line 2029  void MainForm::stabilizeForm (void) Line 2048  void MainForm::stabilizeForm (void)
2048    
2049          // Update the main menu state...          // Update the main menu state...
2050          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
2051          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();
2052          bool bHasChannel = (bHasClient && pChannelStrip != NULL);          const bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);
2053          bool bHasChannels = (bHasClient && m_pWorkspace->subWindowList().count() > 0);          const bool bHasChannel = (bHasClient && pChannelStrip != NULL);
2054            const bool bHasChannels = (bHasClient && wlist.count() > 0);
2055          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
2056          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
2057          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
# Line 2111  void MainForm::volumeChanged ( int iVolu Line 2131  void MainForm::volumeChanged ( int iVolu
2131                  m_pVolumeSpinBox->setValue(iVolume);                  m_pVolumeSpinBox->setValue(iVolume);
2132    
2133          // Do it as commanded...          // Do it as commanded...
2134          float fVolume = 0.01f * float(iVolume);          const float fVolume = 0.01f * float(iVolume);
2135          if (::lscp_set_volume(m_pClient, fVolume) == LSCP_OK)          if (::lscp_set_volume(m_pClient, fVolume) == LSCP_OK)
2136                  appendMessages(QObject::tr("Volume: %1.").arg(fVolume));                  appendMessages(QObject::tr("Volume: %1.").arg(fVolume));
2137          else          else
# Line 2146  void MainForm::channelStripChanged ( Cha Line 2166  void MainForm::channelStripChanged ( Cha
2166  void MainForm::updateSession (void)  void MainForm::updateSession (void)
2167  {  {
2168  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
2169          int iVolume = ::lroundf(100.0f * ::lscp_get_volume(m_pClient));          const int iVolume = ::lroundf(100.0f * ::lscp_get_volume(m_pClient));
2170          m_iVolumeChanging++;          m_iVolumeChanging++;
2171          m_pVolumeSlider->setValue(iVolume);          m_pVolumeSlider->setValue(iVolume);
2172          m_pVolumeSpinBox->setValue(iVolume);          m_pVolumeSpinBox->setValue(iVolume);
# Line 2154  void MainForm::updateSession (void) Line 2174  void MainForm::updateSession (void)
2174  #endif  #endif
2175  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
2176          // FIXME: Make some room for default instrument maps...          // FIXME: Make some room for default instrument maps...
2177          int iMaps = ::lscp_get_midi_instrument_maps(m_pClient);          const int iMaps = ::lscp_get_midi_instrument_maps(m_pClient);
2178          if (iMaps < 0)          if (iMaps < 0)
2179                  appendMessagesClient("lscp_get_midi_instrument_maps");                  appendMessagesClient("lscp_get_midi_instrument_maps");
2180          else if (iMaps < 1) {          else if (iMaps < 1) {
# Line 2168  void MainForm::updateSession (void) Line 2188  void MainForm::updateSession (void)
2188          updateAllChannelStrips(false);          updateAllChannelStrips(false);
2189    
2190          // Do we auto-arrange?          // Do we auto-arrange?
2191          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
2192    
2193          // Remember to refresh devices and instruments...          // Remember to refresh devices and instruments...
2194          if (m_pInstrumentListForm)          if (m_pInstrumentListForm)
# Line 2181  void MainForm::updateSession (void) Line 2200  void MainForm::updateSession (void)
2200    
2201  void MainForm::updateAllChannelStrips ( bool bRemoveDeadStrips )  void MainForm::updateAllChannelStrips ( bool bRemoveDeadStrips )
2202  {  {
2203            // Skip if setting up a new channel strip...
2204            if (m_iDirtySetup > 0)
2205                    return;
2206    
2207          // Retrieve the current channel list.          // Retrieve the current channel list.
2208          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2209          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 2198  void MainForm::updateAllChannelStrips ( Line 2221  void MainForm::updateAllChannelStrips (
2221                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2222                  }                  }
2223                  // Do we auto-arrange?                  // Do we auto-arrange?
2224                  if (m_pOptions && m_pOptions->bAutoArrange)                  channelsArrangeAuto();
                         channelsArrange();  
2225                  // remove dead channel strips                  // remove dead channel strips
2226                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2227                          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();                          const QList<QMdiSubWindow *>& wlist
2228                          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {                                  = m_pWorkspace->subWindowList();
2229                            const int iStripCount = wlist.count();
2230                            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2231                                  ChannelStrip *pChannelStrip = NULL;                                  ChannelStrip *pChannelStrip = NULL;
2232                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2233                                  if (pMdiSubWindow)                                  if (pMdiSubWindow)
2234                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2235                                  if (pChannelStrip) {                                  if (pChannelStrip) {
2236                                          bool bExists = false;                                          bool bExists = false;
2237                                          for (int j = 0; piChannelIDs[j] >= 0; ++j) {                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2238                                                  if (!pChannelStrip->channel())                                                  Channel *pChannel = pChannelStrip->channel();
2239                                                    if (pChannel == NULL)
2240                                                          break;                                                          break;
2241                                                  if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {
2242                                                          // strip exists, don't touch it                                                          // strip exists, don't touch it
2243                                                          bExists = true;                                                          bExists = true;
2244                                                          break;                                                          break;
# Line 2238  void MainForm::updateRecentFiles ( const Line 2263  void MainForm::updateRecentFiles ( const
2263                  return;                  return;
2264    
2265          // Remove from list if already there (avoid duplicates)          // Remove from list if already there (avoid duplicates)
2266          int iIndex = m_pOptions->recentFiles.indexOf(sFilename);          const int iIndex = m_pOptions->recentFiles.indexOf(sFilename);
2267          if (iIndex >= 0)          if (iIndex >= 0)
2268                  m_pOptions->recentFiles.removeAt(iIndex);                  m_pOptions->recentFiles.removeAt(iIndex);
2269          // Put it to front...          // Put it to front...
# Line 2277  void MainForm::updateRecentFilesMenu (vo Line 2302  void MainForm::updateRecentFilesMenu (vo
2302  void MainForm::updateInstrumentNames (void)  void MainForm::updateInstrumentNames (void)
2303  {  {
2304          // Full channel list update...          // Full channel list update...
2305          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2306                    = m_pWorkspace->subWindowList();
2307          if (wlist.isEmpty())          if (wlist.isEmpty())
2308                  return;                  return;
2309    
2310          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2311          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {          const int iStripCount = wlist.count();
2312                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2313                    ChannelStrip *pChannelStrip = NULL;
2314                    QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2315                    if (pMdiSubWindow)
2316                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2317                  if (pChannelStrip)                  if (pChannelStrip)
2318                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
2319          }          }
# Line 2300  void MainForm::updateDisplayFont (void) Line 2330  void MainForm::updateDisplayFont (void)
2330          // Check if display font is legal.          // Check if display font is legal.
2331          if (m_pOptions->sDisplayFont.isEmpty())          if (m_pOptions->sDisplayFont.isEmpty())
2332                  return;                  return;
2333    
2334          // Realize it.          // Realize it.
2335          QFont font;          QFont font;
2336          if (!font.fromString(m_pOptions->sDisplayFont))          if (!font.fromString(m_pOptions->sDisplayFont))
2337                  return;                  return;
2338    
2339          // Full channel list update...          // Full channel list update...
2340          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2341                    = m_pWorkspace->subWindowList();
2342          if (wlist.isEmpty())          if (wlist.isEmpty())
2343                  return;                  return;
2344    
2345          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2346          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {          const int iStripCount = wlist.count();
2347            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2348                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = NULL;
2349                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2350                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2351                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2352                  if (pChannelStrip)                  if (pChannelStrip)
# Line 2327  void MainForm::updateDisplayFont (void) Line 2360  void MainForm::updateDisplayFont (void)
2360  void MainForm::updateDisplayEffect (void)  void MainForm::updateDisplayEffect (void)
2361  {  {
2362          // Full channel list update...          // Full channel list update...
2363          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2364                    = m_pWorkspace->subWindowList();
2365          if (wlist.isEmpty())          if (wlist.isEmpty())
2366                  return;                  return;
2367    
2368          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2369          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {          const int iStripCount = wlist.count();
2370            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2371                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = NULL;
2372                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2373                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2374                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2375                  if (pChannelStrip)                  if (pChannelStrip)
# Line 2358  void MainForm::updateMaxVolume (void) Line 2393  void MainForm::updateMaxVolume (void)
2393  #endif  #endif
2394    
2395          // Full channel list update...          // Full channel list update...
2396          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2397                    = m_pWorkspace->subWindowList();
2398          if (wlist.isEmpty())          if (wlist.isEmpty())
2399                  return;                  return;
2400    
2401          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2402          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {          const int iStripCount = wlist.count();
2403            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2404                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = NULL;
2405                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2406                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2407                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2408                  if (pChannelStrip)                  if (pChannelStrip)
# Line 2376  void MainForm::updateMaxVolume (void) Line 2413  void MainForm::updateMaxVolume (void)
2413    
2414    
2415  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2416  // qsamplerMainForm -- Messages window form handlers.  // QSampler::MainForm -- Messages window form handlers.
2417    
2418  // Messages output methods.  // Messages output methods.
2419  void MainForm::appendMessages( const QString& s )  void MainForm::appendMessages( const QString& s )
# Line 2488  void MainForm::updateMessagesCapture (vo Line 2525  void MainForm::updateMessagesCapture (vo
2525    
2526    
2527  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2528  // qsamplerMainForm -- MDI channel strip management.  // QSampler::MainForm -- MDI channel strip management.
2529    
2530  // The channel strip creation executive.  // The channel strip creation executive.
2531  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
# Line 2507  ChannelStrip *MainForm::createChannelStr Line 2544  ChannelStrip *MainForm::createChannelStr
2544                  pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                  pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2545                  // We'll need a display font.                  // We'll need a display font.
2546                  QFont font;                  QFont font;
2547                  if (font.fromString(m_pOptions->sDisplayFont))                  if (!m_pOptions->sDisplayFont.isEmpty() &&
2548                            font.fromString(m_pOptions->sDisplayFont))
2549                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2550                  // Maximum allowed volume setting.                  // Maximum allowed volume setting.
2551                  pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                  pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
# Line 2547  void MainForm::destroyChannelStrip ( Cha Line 2585  void MainForm::destroyChannelStrip ( Cha
2585          delete pMdiSubWindow;          delete pMdiSubWindow;
2586    
2587          // Do we auto-arrange?          // Do we auto-arrange?
2588          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
   
         stabilizeForm();  
2589  }  }
2590    
2591    
# Line 2566  ChannelStrip *MainForm::activeChannelStr Line 2601  ChannelStrip *MainForm::activeChannelStr
2601    
2602    
2603  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2604  ChannelStrip *MainForm::channelStripAt ( int iChannel )  ChannelStrip *MainForm::channelStripAt ( int iStrip )
2605  {  {
2606          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return NULL;
2607    
2608          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2609                    = m_pWorkspace->subWindowList();
2610          if (wlist.isEmpty())          if (wlist.isEmpty())
2611                  return NULL;                  return NULL;
2612    
2613          if (iChannel < 0 || iChannel >= wlist.size())          if (iStrip < 0 || iStrip >= wlist.count())
2614                  return NULL;                  return NULL;
2615    
2616          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2617          if (pMdiSubWindow)          if (pMdiSubWindow)
2618                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2619          else          else
# Line 2588  ChannelStrip *MainForm::channelStripAt ( Line 2624  ChannelStrip *MainForm::channelStripAt (
2624  // Retrieve a channel strip by sampler channel id.  // Retrieve a channel strip by sampler channel id.
2625  ChannelStrip *MainForm::channelStrip ( int iChannelID )  ChannelStrip *MainForm::channelStrip ( int iChannelID )
2626  {  {
2627          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2628                    = m_pWorkspace->subWindowList();
2629          if (wlist.isEmpty())          if (wlist.isEmpty())
2630                  return NULL;                  return NULL;
2631    
2632          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {          const int iStripCount = wlist.count();
2633            for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2634                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = NULL;
2635                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2636                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2637                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2638                  if (pChannelStrip) {                  if (pChannelStrip) {
# Line 2616  void MainForm::channelsMenuAboutToShow ( Line 2654  void MainForm::channelsMenuAboutToShow (
2654          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);
2655          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);
2656    
2657          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist
2658                    = m_pWorkspace->subWindowList();
2659          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2660                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2661                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {                  const int iStripCount = wlist.count();
2662                    for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2663                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip = NULL;
2664                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2665                          if (pMdiSubWindow)                          if (pMdiSubWindow)
2666                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2667                          if (pChannelStrip) {                          if (pChannelStrip) {
# Line 2630  void MainForm::channelsMenuAboutToShow ( Line 2670  void MainForm::channelsMenuAboutToShow (
2670                                          this, SLOT(channelsMenuActivated()));                                          this, SLOT(channelsMenuActivated()));
2671                                  pAction->setCheckable(true);                                  pAction->setCheckable(true);
2672                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);
2673                                  pAction->setData(iChannel);                                  pAction->setData(iStrip);
2674                          }                          }
2675                  }                  }
2676          }          }
# Line 2654  void MainForm::channelsMenuActivated (vo Line 2694  void MainForm::channelsMenuActivated (vo
2694    
2695    
2696  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2697  // qsamplerMainForm -- Timer stuff.  // QSampler::MainForm -- Timer stuff.
2698    
2699  // Set the pseudo-timer delay schedule.  // Set the pseudo-timer delay schedule.
2700  void MainForm::startSchedule ( int iStartDelay )  void MainForm::startSchedule ( int iStartDelay )
# Line 2695  void MainForm::timerSlot (void) Line 2735  void MainForm::timerSlot (void)
2735                          ChannelStrip *pChannelStrip = iter.next();                          ChannelStrip *pChannelStrip = iter.next();
2736                          // If successfull, remove from pending list...                          // If successfull, remove from pending list...
2737                          if (pChannelStrip->updateChannelInfo()) {                          if (pChannelStrip->updateChannelInfo()) {
2738                                  int iChannelStrip = m_changedStrips.indexOf(pChannelStrip);                                  const int iChannelStrip = m_changedStrips.indexOf(pChannelStrip);
2739                                  if (iChannelStrip >= 0)                                  if (iChannelStrip >= 0)
2740                                          m_changedStrips.removeAt(iChannelStrip);                                          m_changedStrips.removeAt(iChannelStrip);
2741                          }                          }
# Line 2706  void MainForm::timerSlot (void) Line 2746  void MainForm::timerSlot (void)
2746                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {
2747                                  m_iTimerSlot = 0;                                  m_iTimerSlot = 0;
2748                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2749                                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();                                  const QList<QMdiSubWindow *>& wlist
2750                                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {                                          = m_pWorkspace->subWindowList();
2751                                    const int iStripCount = wlist.count();
2752                                    for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2753                                          ChannelStrip *pChannelStrip = NULL;                                          ChannelStrip *pChannelStrip = NULL;
2754                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2755                                          if (pMdiSubWindow)                                          if (pMdiSubWindow)
2756                                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2757                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
# Line 2725  void MainForm::timerSlot (void) Line 2767  void MainForm::timerSlot (void)
2767    
2768    
2769  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2770  // qsamplerMainForm -- Server stuff.  // QSampler::MainForm -- Server stuff.
2771    
2772  // Start linuxsampler server...  // Start linuxsampler server...
2773  void MainForm::startServer (void)  void MainForm::startServer (void)
# Line 2762  void MainForm::startServer (void) Line 2804  void MainForm::startServer (void)
2804          bForceServerStop = true;          bForceServerStop = true;
2805    
2806          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2807  //      if (m_pOptions->bStdoutCapture) {          m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
2808                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);          QObject::connect(m_pServer,
2809                  QObject::connect(m_pServer,                  SIGNAL(readyReadStandardOutput()),
2810                          SIGNAL(readyReadStandardOutput()),                  SLOT(readServerStdout()));
2811                          SLOT(readServerStdout()));          QObject::connect(m_pServer,
2812                  QObject::connect(m_pServer,                  SIGNAL(readyReadStandardError()),
2813                          SIGNAL(readyReadStandardError()),                  SLOT(readServerStdout()));
                         SLOT(readServerStdout()));  
 //      }  
2814    
2815          // The unforgiveable signal communication...          // The unforgiveable signal communication...
2816          QObject::connect(m_pServer,          QObject::connect(m_pServer,
# Line 2891  void MainForm::processServerExit (void) Line 2931  void MainForm::processServerExit (void)
2931    
2932    
2933  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2934  // qsamplerMainForm -- Client stuff.  // QSampler::MainForm -- Client stuff.
2935    
2936  // The LSCP client callback procedure.  // The LSCP client callback procedure.
2937  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/,  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/,

Legend:
Removed from v.2722  
changed lines
  Added in v.3049

  ViewVC Help
Powered by ViewVC