/[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 2144 by persson, Wed Oct 6 18:49:54 2010 UTC revision 2459 by capela, Mon Jul 8 10:06:57 2013 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2013, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007, 2008 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 35  Line 35 
35  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
36  #include "qsamplerDeviceStatusForm.h"  #include "qsamplerDeviceStatusForm.h"
37    
38    #include <QMdiArea>
39    #include <QMdiSubWindow>
40    
41  #include <QApplication>  #include <QApplication>
 #include <QWorkspace>  
42  #include <QProcess>  #include <QProcess>
43  #include <QMessageBox>  #include <QMessageBox>
44    
# Line 56  Line 58 
58  #include <QTimer>  #include <QTimer>
59  #include <QDateTime>  #include <QDateTime>
60    
61    #if QT_VERSION >= 0x050000
62    #include <QMimeData>
63    #endif
64    
65  #if QT_VERSION < 0x040500  #if QT_VERSION < 0x040500
66  namespace Qt {  namespace Qt {
67  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
 #if QT_VERSION < 0x040200  
 const WindowFlags CustomizeWindowHint   = WindowFlags(0x02000000);  
 #endif  
68  }  }
69  #endif  #endif
70    
# Line 221  MainForm::MainForm ( QWidget *pParent ) Line 224  MainForm::MainForm ( QWidget *pParent )
224          // Install SIGUSR1 signal handler.          // Install SIGUSR1 signal handler.
225      struct sigaction usr1;      struct sigaction usr1;
226      usr1.sa_handler = qsampler_sigusr1_handler;      usr1.sa_handler = qsampler_sigusr1_handler;
227      ::sigemptyset(&usr1.sa_mask);      sigemptyset(&usr1.sa_mask);
228      usr1.sa_flags = 0;      usr1.sa_flags = 0;
229      usr1.sa_flags |= SA_RESTART;      usr1.sa_flags |= SA_RESTART;
230      ::sigaction(SIGUSR1, &usr1, NULL);      ::sigaction(SIGUSR1, &usr1, NULL);
# Line 269  MainForm::MainForm ( QWidget *pParent ) Line 272  MainForm::MainForm ( QWidget *pParent )
272  #endif  #endif
273    
274          // Make it an MDI workspace.          // Make it an MDI workspace.
275          m_pWorkspace = new QWorkspace(this);          m_pWorkspace = new QMdiArea(this);
276          m_pWorkspace->setScrollBarsEnabled(true);          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
277            m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
278          // Set the activation connection.          // Set the activation connection.
279          QObject::connect(m_pWorkspace,          QObject::connect(m_pWorkspace,
280                  SIGNAL(windowActivated(QWidget *)),                  SIGNAL(subWindowActivated(QMdiSubWindow *)),
281                  SLOT(activateStrip(QWidget *)));                  SLOT(activateStrip(QMdiSubWindow *)));
282          // Make it shine :-)          // Make it shine :-)
283          setCentralWidget(m_pWorkspace);          setCentralWidget(m_pWorkspace);
284    
# Line 890  bool MainForm::closeSession ( bool bForc Line 894  bool MainForm::closeSession ( bool bForc
894          if (bClose) {          if (bClose) {
895                  // Remove all channel strips from sight...                  // Remove all channel strips from sight...
896                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
897                  QWidgetList wlist = m_pWorkspace->windowList();                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
898                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
899                          ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                          ChannelStrip *pChannelStrip = NULL;
900                            QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
901                            if (pMdiSubWindow)
902                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
903                          if (pChannelStrip) {                          if (pChannelStrip) {
904                                  Channel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
905                                  if (bForce && pChannel)                                  if (bForce && pChannel)
906                                          pChannel->removeChannel();                                          pChannel->removeChannel();
907                                  delete pChannelStrip;                                  delete pChannelStrip;
908                          }                          }
909                            if (pMdiSubWindow)
910                                    delete pMdiSubWindow;
911                  }                  }
912                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
913                  // We're now clean, for sure.                  // We're now clean, for sure.
# Line 1189  bool MainForm::saveSessionFile ( const Q Line 1198  bool MainForm::saveSessionFile ( const Q
1198  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1199    
1200          // Sampler channel mapping.          // Sampler channel mapping.
1201          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1202          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1203                  ChannelStrip* pChannelStrip                  ChannelStrip *pChannelStrip = NULL;
1204                          = static_cast<ChannelStrip *> (wlist.at(iChannel));                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1205                    if (pMdiSubWindow)
1206                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1207                  if (pChannelStrip) {                  if (pChannelStrip) {
1208                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1209                          if (pChannel) {                          if (pChannel) {
# Line 1240  bool MainForm::saveSessionFile ( const Q Line 1251  bool MainForm::saveSessionFile ( const Q
1251                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
1252                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1253                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
1254  #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1255                                  if (pChannel->midiMap() >= 0) {                                  if (pChannel->midiMap() >= 0) {
1256                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
1257                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
1258                                  }                                  }
1259  #endif                          #endif
1260  #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
1261                                  int iChannelID = pChannel->channelID();                                  int iChannelID = pChannel->channelID();
1262                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);
1263                                  for (int iFxSend = 0;                                  for (int iFxSend = 0;
# Line 1270  bool MainForm::saveSessionFile ( const Q Line 1281  bool MainForm::saveSessionFile ( const Q
1281                                                                  << " " << iAudioSrc                                                                  << " " << iAudioSrc
1282                                                                  << " " << piRouting[iAudioSrc] << endl;                                                                  << " " << piRouting[iAudioSrc] << endl;
1283                                                  }                                                  }
1284  #ifdef CONFIG_FXSEND_LEVEL                                          #ifdef CONFIG_FXSEND_LEVEL
1285                                                  ts << "SET FX_SEND LEVEL " << iChannel                                                  ts << "SET FX_SEND LEVEL " << iChannel
1286                                                          << " " << iFxSend                                                          << " " << iFxSend
1287                                                          << " " << pFxSendInfo->level << endl;                                                          << " " << pFxSendInfo->level << endl;
1288  #endif                                          #endif
1289                                          }       // Check for errors...                                          }       // Check for errors...
1290                                          else if (::lscp_client_get_errno(m_pClient)) {                                          else if (::lscp_client_get_errno(m_pClient)) {
1291                                                  appendMessagesClient("lscp_get_fxsend_info");                                                  appendMessagesClient("lscp_get_fxsend_info");
1292                                                  iErrors++;                                                  iErrors++;
1293                                          }                                          }
1294                                  }                                  }
1295  #endif                          #endif
1296                                  ts << endl;                                  ts << endl;
1297                          }                          }
1298                  }                  }
# Line 1506  void MainForm::editRemoveChannel (void) Line 1517  void MainForm::editRemoveChannel (void)
1517          if (m_pClient == NULL)          if (m_pClient == NULL)
1518                  return;                  return;
1519    
1520          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1521          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1522                  return;                  return;
1523    
# Line 1531  void MainForm::editRemoveChannel (void) Line 1542  void MainForm::editRemoveChannel (void)
1542          if (!pChannel->removeChannel())          if (!pChannel->removeChannel())
1543                  return;                  return;
1544    
         // Just delete the channel strip.  
         delete pChannelStrip;  
   
         // Do we auto-arrange?  
         if (m_pOptions && m_pOptions->bAutoArrange)  
                 channelsArrange();  
   
1545          // We'll be dirty, for sure...          // We'll be dirty, for sure...
1546          m_iDirtyCount++;          m_iDirtyCount++;
1547          stabilizeForm();  
1548            // Just delete the channel strip.
1549            destroyChannelStrip(pChannelStrip);
1550  }  }
1551    
1552    
# Line 1550  void MainForm::editSetupChannel (void) Line 1556  void MainForm::editSetupChannel (void)
1556          if (m_pClient == NULL)          if (m_pClient == NULL)
1557                  return;                  return;
1558    
1559          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1560          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1561                  return;                  return;
1562    
# Line 1565  void MainForm::editEditChannel (void) Line 1571  void MainForm::editEditChannel (void)
1571          if (m_pClient == NULL)          if (m_pClient == NULL)
1572                  return;                  return;
1573    
1574          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1575          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1576                  return;                  return;
1577    
# Line 1580  void MainForm::editResetChannel (void) Line 1586  void MainForm::editResetChannel (void)
1586          if (m_pClient == NULL)          if (m_pClient == NULL)
1587                  return;                  return;
1588    
1589          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1590          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1591                  return;                  return;
1592    
# Line 1598  void MainForm::editResetAllChannels (voi Line 1604  void MainForm::editResetAllChannels (voi
1604          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
1605          // for all channels out there...          // for all channels out there...
1606          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1607          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1608          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1609                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
1610                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1611                    if (pMdiSubWindow)
1612                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1613                  if (pChannelStrip)                  if (pChannelStrip)
1614                          pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1615          }          }
# Line 1703  void MainForm::viewOptions (void) Line 1712  void MainForm::viewOptions (void)
1712          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
1713          if (pOptionsForm) {          if (pOptionsForm) {
1714                  // Check out some initial nullities(tm)...                  // Check out some initial nullities(tm)...
1715                  ChannelStrip* pChannelStrip = activeChannelStrip();                  ChannelStrip *pChannelStrip = activeChannelStrip();
1716                  if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)                  if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
1717                          m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();                          m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
1718                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
# Line 1796  void MainForm::viewOptions (void) Line 1805  void MainForm::viewOptions (void)
1805  void MainForm::channelsArrange (void)  void MainForm::channelsArrange (void)
1806  {  {
1807          // Full width vertical tiling          // Full width vertical tiling
1808          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1809          if (wlist.isEmpty())          if (wlist.isEmpty())
1810                  return;                  return;
1811    
1812          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1813          int y = 0;          int y = 0;
1814          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1815                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
1816          /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1817                          // Prevent flicker...                  if (pMdiSubWindow)
1818                          pChannelStrip->hide();                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1819                          pChannelStrip->showNormal();                  if (pChannelStrip) {
1820                  }   */                  /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1821                  pChannelStrip->adjustSize();                                  // Prevent flicker...
1822                  int iWidth  = m_pWorkspace->width();                                  pChannelStrip->hide();
1823                  if (iWidth < pChannelStrip->width())                                  pChannelStrip->showNormal();
1824                          iWidth = pChannelStrip->width();                          }   */
1825          //  int iHeight = pChannelStrip->height()                          pChannelStrip->adjustSize();
1826          //              + pChannelStrip->parentWidget()->baseSize().height();                          int iWidth  = m_pWorkspace->width();
1827                  int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();                          if (iWidth < pChannelStrip->width())
1828                  pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);                                  iWidth = pChannelStrip->width();
1829                  y += iHeight;                  //  int iHeight = pChannelStrip->height()
1830                    //              + pChannelStrip->parentWidget()->baseSize().height();
1831                            int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1832                            pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1833                            y += iHeight;
1834                    }
1835          }          }
1836          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1837    
# Line 1962  void MainForm::stabilizeForm (void) Line 1976  void MainForm::stabilizeForm (void)
1976          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1977          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);
1978          bool bHasChannel = (bHasClient && pChannelStrip != NULL);          bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1979          bool bHasChannels = (bHasClient && m_pWorkspace->windowList().count() > 0);          bool bHasChannels = (bHasClient && m_pWorkspace->subWindowList().count() > 0);
1980          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
1981          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
1982          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
# Line 2058  void MainForm::volumeChanged ( int iVolu Line 2072  void MainForm::volumeChanged ( int iVolu
2072    
2073    
2074  // Channel change receiver slot.  // Channel change receiver slot.
2075  void MainForm::channelStripChanged(ChannelStrip* pChannelStrip)  void MainForm::channelStripChanged ( ChannelStrip *pChannelStrip )
2076  {  {
2077          // Add this strip to the changed list...          // Add this strip to the changed list...
2078          if (!m_changedStrips.contains(pChannelStrip)) {          if (!m_changedStrips.contains(pChannelStrip)) {
# Line 2109  void MainForm::updateSession (void) Line 2123  void MainForm::updateSession (void)
2123                  m_pDeviceForm->refreshDevices();                  m_pDeviceForm->refreshDevices();
2124  }  }
2125    
2126  void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) {  
2127    void MainForm::updateAllChannelStrips ( bool bRemoveDeadStrips )
2128    {
2129          // Retrieve the current channel list.          // Retrieve the current channel list.
2130          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2131          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 2121  void MainForm::updateAllChannelStrips(bo Line 2137  void MainForm::updateAllChannelStrips(bo
2137          } else {          } else {
2138                  // Try to (re)create each channel.                  // Try to (re)create each channel.
2139                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
2140                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2141                          // Check if theres already a channel strip for this one...                          // Check if theres already a channel strip for this one...
2142                          if (!channelStrip(piChannelIDs[iChannel]))                          if (!channelStrip(piChannelIDs[iChannel]))
2143                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2144                  }                  }
   
2145                  // Do we auto-arrange?                  // Do we auto-arrange?
2146                  if (m_pOptions && m_pOptions->bAutoArrange)                  if (m_pOptions && m_pOptions->bAutoArrange)
2147                          channelsArrange();                          channelsArrange();
   
                 stabilizeForm();  
   
2148                  // remove dead channel strips                  // remove dead channel strips
2149                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2150                          for (int i = 0; channelStripAt(i); ++i) {                          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2151                                  ChannelStrip* pChannelStrip = channelStripAt(i);                          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2152                                  bool bExists = false;                                  ChannelStrip *pChannelStrip = NULL;
2153                                  for (int j = 0; piChannelIDs[j] >= 0; ++j) {                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2154                                          if (!pChannelStrip->channel()) break;                                  if (pMdiSubWindow)
2155                                          if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2156                                                  // strip exists, don't touch it                                  if (pChannelStrip) {
2157                                                  bExists = true;                                          bool bExists = false;
2158                                                  break;                                          for (int j = 0; piChannelIDs[j] >= 0; ++j) {
2159                                                    if (!pChannelStrip->channel())
2160                                                            break;
2161                                                    if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {
2162                                                            // strip exists, don't touch it
2163                                                            bExists = true;
2164                                                            break;
2165                                                    }
2166                                          }                                          }
2167                                            if (!bExists)
2168                                                    destroyChannelStrip(pChannelStrip);
2169                                  }                                  }
                                 if (!bExists) destroyChannelStrip(pChannelStrip);  
2170                          }                          }
2171                  }                  }
2172                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
2173          }          }
2174    
2175            stabilizeForm();
2176  }  }
2177    
2178    
2179  // Update the recent files list and menu.  // Update the recent files list and menu.
2180  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2181  {  {
# Line 2199  void MainForm::updateRecentFilesMenu (vo Line 2222  void MainForm::updateRecentFilesMenu (vo
2222  void MainForm::updateInstrumentNames (void)  void MainForm::updateInstrumentNames (void)
2223  {  {
2224          // Full channel list update...          // Full channel list update...
2225          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2226          if (wlist.isEmpty())          if (wlist.isEmpty())
2227                  return;                  return;
2228    
2229          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2230          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2231                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);
2232                  if (pChannelStrip)                  if (pChannelStrip)
2233                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
# Line 2228  void MainForm::updateDisplayFont (void) Line 2251  void MainForm::updateDisplayFont (void)
2251                  return;                  return;
2252    
2253          // Full channel list update...          // Full channel list update...
2254          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2255          if (wlist.isEmpty())          if (wlist.isEmpty())
2256                  return;                  return;
2257    
2258          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2259          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2260                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2261                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2262                    if (pMdiSubWindow)
2263                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2264                  if (pChannelStrip)                  if (pChannelStrip)
2265                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2266          }          }
# Line 2246  void MainForm::updateDisplayFont (void) Line 2272  void MainForm::updateDisplayFont (void)
2272  void MainForm::updateDisplayEffect (void)  void MainForm::updateDisplayEffect (void)
2273  {  {
2274          // Full channel list update...          // Full channel list update...
2275          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2276          if (wlist.isEmpty())          if (wlist.isEmpty())
2277                  return;                  return;
2278    
2279          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2280          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2281                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2282                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2283                    if (pMdiSubWindow)
2284                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2285                  if (pChannelStrip)                  if (pChannelStrip)
2286                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2287          }          }
# Line 2274  void MainForm::updateMaxVolume (void) Line 2303  void MainForm::updateMaxVolume (void)
2303  #endif  #endif
2304    
2305          // Full channel list update...          // Full channel list update...
2306          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = 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++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2312                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2313                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2314                    if (pMdiSubWindow)
2315                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2316                  if (pChannelStrip)                  if (pChannelStrip)
2317                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
2318          }          }
# Line 2388  void MainForm::updateMessagesCapture (vo Line 2420  void MainForm::updateMessagesCapture (vo
2420  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
2421    
2422  // The channel strip creation executive.  // The channel strip creation executive.
2423  ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2424  {  {
2425          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == NULL || pChannel == NULL)
2426                  return NULL;                  return NULL;
# Line 2411  ChannelStrip* MainForm::createChannelStr Line 2443  ChannelStrip* MainForm::createChannelStr
2443          }          }
2444    
2445          // Add it to workspace...          // Add it to workspace...
2446          m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint);          m_pWorkspace->addSubWindow(pChannelStrip,
2447                    Qt::SubWindow | Qt::FramelessWindowHint);
2448    
2449          // Actual channel strip setup...          // Actual channel strip setup...
2450          pChannelStrip->setup(pChannel);          pChannelStrip->setup(pChannel);
2451    
2452          QObject::connect(pChannelStrip,          QObject::connect(pChannelStrip,
2453                  SIGNAL(channelChanged(ChannelStrip*)),                  SIGNAL(channelChanged(ChannelStrip *)),
2454                  SLOT(channelStripChanged(ChannelStrip*)));                  SLOT(channelStripChanged(ChannelStrip *)));
2455    
2456          // Now we show up us to the world.          // Now we show up us to the world.
2457          pChannelStrip->show();          pChannelStrip->show();
# Line 2430  ChannelStrip* MainForm::createChannelStr Line 2463  ChannelStrip* MainForm::createChannelStr
2463          return pChannelStrip;          return pChannelStrip;
2464  }  }
2465    
2466  void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) {  
2467    void MainForm::destroyChannelStrip ( ChannelStrip *pChannelStrip )
2468    {
2469            QMdiSubWindow *pMdiSubWindow
2470                    = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2471            if (pMdiSubWindow == NULL)
2472                    return;
2473    
2474          // Just delete the channel strip.          // Just delete the channel strip.
2475          delete pChannelStrip;          delete pChannelStrip;
2476            delete pMdiSubWindow;
2477    
2478          // Do we auto-arrange?          // Do we auto-arrange?
2479          if (m_pOptions && m_pOptions->bAutoArrange)          if (m_pOptions && m_pOptions->bAutoArrange)
# Line 2441  void MainForm::destroyChannelStrip(Chann Line 2482  void MainForm::destroyChannelStrip(Chann
2482          stabilizeForm();          stabilizeForm();
2483  }  }
2484    
2485    
2486  // Retrieve the active channel strip.  // Retrieve the active channel strip.
2487  ChannelStrip* MainForm::activeChannelStrip (void)  ChannelStrip *MainForm::activeChannelStrip (void)
2488  {  {
2489          return static_cast<ChannelStrip *> (m_pWorkspace->activeWindow());          QMdiSubWindow *pMdiSubWindow = m_pWorkspace->activeSubWindow();
2490            if (pMdiSubWindow)
2491                    return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2492            else
2493                    return NULL;
2494  }  }
2495    
2496    
2497  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2498  ChannelStrip* MainForm::channelStripAt ( int iChannel )  ChannelStrip *MainForm::channelStripAt ( int iChannel )
2499  {  {
2500          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return NULL;
2501    
2502          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2503          if (wlist.isEmpty())          if (wlist.isEmpty())
2504                  return NULL;                  return NULL;
2505    
2506          if (iChannel < 0 || iChannel >= wlist.size())          if (iChannel < 0 || iChannel >= wlist.size())
2507                  return NULL;                  return NULL;
2508    
2509          return dynamic_cast<ChannelStrip *> (wlist.at(iChannel));          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2510            if (pMdiSubWindow)
2511                    return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2512            else
2513                    return NULL;
2514  }  }
2515    
2516    
2517  // Retrieve a channel strip by sampler channel id.  // Retrieve a channel strip by sampler channel id.
2518  ChannelStrip* MainForm::channelStrip ( int iChannelID )  ChannelStrip *MainForm::channelStrip ( int iChannelID )
2519  {  {
2520          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2521          if (wlist.isEmpty())          if (wlist.isEmpty())
2522                  return NULL;                  return NULL;
2523    
2524          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2525                  ChannelStrip* pChannelStrip                  ChannelStrip *pChannelStrip = NULL;
2526                          = static_cast<ChannelStrip*> (wlist.at(iChannel));                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2527                    if (pMdiSubWindow)
2528                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2529                  if (pChannelStrip) {                  if (pChannelStrip) {
2530                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2531                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2493  void MainForm::channelsMenuAboutToShow ( Line 2545  void MainForm::channelsMenuAboutToShow (
2545          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);
2546          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);
2547    
2548          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2549          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2550                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2551                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2552                          ChannelStrip* pChannelStrip                          ChannelStrip *pChannelStrip = NULL;
2553                                  = static_cast<ChannelStrip*> (wlist.at(iChannel));                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2554                            if (pMdiSubWindow)
2555                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2556                          if (pChannelStrip) {                          if (pChannelStrip) {
2557                                  QAction *pAction = m_ui.channelsMenu->addAction(                                  QAction *pAction = m_ui.channelsMenu->addAction(
2558                                          pChannelStrip->windowTitle(),                                          pChannelStrip->windowTitle(),
# Line 2520  void MainForm::channelsMenuActivated (vo Line 2574  void MainForm::channelsMenuActivated (vo
2574          if (pAction == NULL)          if (pAction == NULL)
2575                  return;                  return;
2576    
2577          ChannelStrip* pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
2578          if (pChannelStrip) {          if (pChannelStrip) {
2579                  pChannelStrip->showNormal();                  pChannelStrip->showNormal();
2580                  pChannelStrip->setFocus();                  pChannelStrip->setFocus();
# Line 2581  void MainForm::timerSlot (void) Line 2635  void MainForm::timerSlot (void)
2635                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {
2636                                  m_iTimerSlot = 0;                                  m_iTimerSlot = 0;
2637                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2638                                  QWidgetList wlist = m_pWorkspace->windowList();                                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2639                                  for (int iChannel = 0;                                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2640                                                  iChannel < (int) wlist.count(); iChannel++) {                                          ChannelStrip *pChannelStrip = NULL;
2641                                          ChannelStrip* pChannelStrip                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2642                                                  = (ChannelStrip*) wlist.at(iChannel);                                          if (pMdiSubWindow)
2643                                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2644                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
2645                                                  pChannelStrip->updateChannelUsage();                                                  pChannelStrip->updateChannelUsage();
2646                                  }                                  }
# Line 2637  void MainForm::startServer (void) Line 2692  void MainForm::startServer (void)
2692    
2693          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2694  //      if (m_pOptions->bStdoutCapture) {  //      if (m_pOptions->bStdoutCapture) {
 #if QT_VERSION >= 0x040200  
2695                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
 #endif  
2696                  QObject::connect(m_pServer,                  QObject::connect(m_pServer,
2697                          SIGNAL(readyReadStandardOutput()),                          SIGNAL(readyReadStandardOutput()),
2698                          SLOT(readServerStdout()));                          SLOT(readServerStdout()));
# Line 2704  void MainForm::stopServer (bool bInterac Line 2757  void MainForm::stopServer (bool bInterac
2757          if (m_pServer && bForceServerStop) {          if (m_pServer && bForceServerStop) {
2758                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2759                  if (m_pServer->state() == QProcess::Running) {                  if (m_pServer->state() == QProcess::Running) {
2760  #if defined(WIN32)                  #if defined(WIN32)
2761                          // Try harder...                          // Try harder...
2762                          m_pServer->kill();                          m_pServer->kill();
2763  #else                  #else
2764                          // Try softly...                          // Try softly...
2765                          m_pServer->terminate();                          m_pServer->terminate();
2766  #endif                  #endif
2767                  }                  }
2768          }       // Do final processing anyway.          }       // Do final processing anyway.
2769          else processServerExit();          else processServerExit();
# Line 2939  void MainForm::stopClient (void) Line 2992  void MainForm::stopClient (void)
2992    
2993    
2994  // Channel strip activation/selection.  // Channel strip activation/selection.
2995  void MainForm::activateStrip ( QWidget *pWidget )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
2996  {  {
2997          ChannelStrip *pChannelStrip          ChannelStrip *pChannelStrip = NULL;
2998                  = static_cast<ChannelStrip *> (pWidget);          if (pMdiSubWindow)
2999                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3000          if (pChannelStrip)          if (pChannelStrip)
3001                  pChannelStrip->setSelected(true);                  pChannelStrip->setSelected(true);
3002    

Legend:
Removed from v.2144  
changed lines
  Added in v.2459

  ViewVC Help
Powered by ViewVC