/[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 2113 by capela, Thu Jul 22 08:12:12 2010 UTC revision 2441 by capela, Wed Apr 10 09:11:37 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);
# Line 96  static WSADATA _wsaData; Line 102  static WSADATA _wsaData;
102  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
103  // LADISH Level 1 support stuff.  // LADISH Level 1 support stuff.
104    
105  #ifdef HAVE_SIGNAL_H  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
106    
107  #include <QSocketNotifier>  #include <QSocketNotifier>
108    
# Line 202  MainForm::MainForm ( QWidget *pParent ) Line 208  MainForm::MainForm ( QWidget *pParent )
208    
209          m_iTimerSlot = 0;          m_iTimerSlot = 0;
210    
211  #ifdef HAVE_SIGNAL_H  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
212    
213          // Set to ignore any fatal "Broken pipe" signals.          // Set to ignore any fatal "Broken pipe" signals.
214          ::signal(SIGPIPE, SIG_IGN);          ::signal(SIGPIPE, SIG_IGN);
# Line 221  MainForm::MainForm ( QWidget *pParent ) Line 227  MainForm::MainForm ( QWidget *pParent )
227          // Install SIGUSR1 signal handler.          // Install SIGUSR1 signal handler.
228      struct sigaction usr1;      struct sigaction usr1;
229      usr1.sa_handler = qsampler_sigusr1_handler;      usr1.sa_handler = qsampler_sigusr1_handler;
230      ::sigemptyset(&usr1.sa_mask);      sigemptyset(&usr1.sa_mask);
231      usr1.sa_flags = 0;      usr1.sa_flags = 0;
232      usr1.sa_flags |= SA_RESTART;      usr1.sa_flags |= SA_RESTART;
233      ::sigaction(SIGUSR1, &usr1, NULL);      ::sigaction(SIGUSR1, &usr1, NULL);
# Line 269  MainForm::MainForm ( QWidget *pParent ) Line 275  MainForm::MainForm ( QWidget *pParent )
275  #endif  #endif
276    
277          // Make it an MDI workspace.          // Make it an MDI workspace.
278          m_pWorkspace = new QWorkspace(this);          m_pWorkspace = new QMdiArea(this);
279          m_pWorkspace->setScrollBarsEnabled(true);          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
280            m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
281          // Set the activation connection.          // Set the activation connection.
282          QObject::connect(m_pWorkspace,          QObject::connect(m_pWorkspace,
283                  SIGNAL(windowActivated(QWidget *)),                  SIGNAL(subWindowActivated(QMdiSubWindow *)),
284                  SLOT(activateStrip(QWidget *)));                  SLOT(activateStrip(QMdiSubWindow *)));
285          // Make it shine :-)          // Make it shine :-)
286          setCentralWidget(m_pWorkspace);          setCentralWidget(m_pWorkspace);
287    
# Line 403  MainForm::~MainForm() Line 410  MainForm::~MainForm()
410          WSACleanup();          WSACleanup();
411  #endif  #endif
412    
413  #ifdef HAVE_SIGNAL_H  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
414          if (m_pUsr1Notifier)          if (m_pUsr1Notifier)
415                  delete m_pUsr1Notifier;                  delete m_pUsr1Notifier;
416  #endif  #endif
# Line 691  void MainForm::customEvent ( QEvent* pEv Line 698  void MainForm::customEvent ( QEvent* pEv
698  // LADISH Level 1 -- SIGUSR1 signal handler.  // LADISH Level 1 -- SIGUSR1 signal handler.
699  void MainForm::handle_sigusr1 (void)  void MainForm::handle_sigusr1 (void)
700  {  {
701  #ifdef HAVE_SIGNAL_H  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
702    
703          char c;          char c;
704    
# Line 890  bool MainForm::closeSession ( bool bForc Line 897  bool MainForm::closeSession ( bool bForc
897          if (bClose) {          if (bClose) {
898                  // Remove all channel strips from sight...                  // Remove all channel strips from sight...
899                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
900                  QWidgetList wlist = m_pWorkspace->windowList();                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
901                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
902                          ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                          ChannelStrip *pChannelStrip = NULL;
903                            QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
904                            if (pMdiSubWindow)
905                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
906                          if (pChannelStrip) {                          if (pChannelStrip) {
907                                  Channel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
908                                  if (bForce && pChannel)                                  if (bForce && pChannel)
909                                          pChannel->removeChannel();                                          pChannel->removeChannel();
910                                  delete pChannelStrip;                                  delete pChannelStrip;
911                          }                          }
912                            if (pMdiSubWindow)
913                                    delete pMdiSubWindow;
914                  }                  }
915                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
916                  // We're now clean, for sure.                  // We're now clean, for sure.
# Line 1189  bool MainForm::saveSessionFile ( const Q Line 1201  bool MainForm::saveSessionFile ( const Q
1201  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1202    
1203          // Sampler channel mapping.          // Sampler channel mapping.
1204          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1205          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1206                  ChannelStrip* pChannelStrip                  ChannelStrip *pChannelStrip = NULL;
1207                          = static_cast<ChannelStrip *> (wlist.at(iChannel));                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1208                    if (pMdiSubWindow)
1209                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1210                  if (pChannelStrip) {                  if (pChannelStrip) {
1211                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1212                          if (pChannel) {                          if (pChannel) {
# Line 1240  bool MainForm::saveSessionFile ( const Q Line 1254  bool MainForm::saveSessionFile ( const Q
1254                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
1255                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1256                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
1257  #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1258                                  if (pChannel->midiMap() >= 0) {                                  if (pChannel->midiMap() >= 0) {
1259                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
1260                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
1261                                  }                                  }
1262  #endif                          #endif
1263  #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
1264                                  int iChannelID = pChannel->channelID();                                  int iChannelID = pChannel->channelID();
1265                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);
1266                                  for (int iFxSend = 0;                                  for (int iFxSend = 0;
# Line 1270  bool MainForm::saveSessionFile ( const Q Line 1284  bool MainForm::saveSessionFile ( const Q
1284                                                                  << " " << iAudioSrc                                                                  << " " << iAudioSrc
1285                                                                  << " " << piRouting[iAudioSrc] << endl;                                                                  << " " << piRouting[iAudioSrc] << endl;
1286                                                  }                                                  }
1287  #ifdef CONFIG_FXSEND_LEVEL                                          #ifdef CONFIG_FXSEND_LEVEL
1288                                                  ts << "SET FX_SEND LEVEL " << iChannel                                                  ts << "SET FX_SEND LEVEL " << iChannel
1289                                                          << " " << iFxSend                                                          << " " << iFxSend
1290                                                          << " " << pFxSendInfo->level << endl;                                                          << " " << pFxSendInfo->level << endl;
1291  #endif                                          #endif
1292                                          }       // Check for errors...                                          }       // Check for errors...
1293                                          else if (::lscp_client_get_errno(m_pClient)) {                                          else if (::lscp_client_get_errno(m_pClient)) {
1294                                                  appendMessagesClient("lscp_get_fxsend_info");                                                  appendMessagesClient("lscp_get_fxsend_info");
1295                                                  iErrors++;                                                  iErrors++;
1296                                          }                                          }
1297                                  }                                  }
1298  #endif                          #endif
1299                                  ts << endl;                                  ts << endl;
1300                          }                          }
1301                  }                  }
# Line 1506  void MainForm::editRemoveChannel (void) Line 1520  void MainForm::editRemoveChannel (void)
1520          if (m_pClient == NULL)          if (m_pClient == NULL)
1521                  return;                  return;
1522    
1523          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1524          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1525                  return;                  return;
1526    
# Line 1531  void MainForm::editRemoveChannel (void) Line 1545  void MainForm::editRemoveChannel (void)
1545          if (!pChannel->removeChannel())          if (!pChannel->removeChannel())
1546                  return;                  return;
1547    
         // Just delete the channel strip.  
         delete pChannelStrip;  
   
         // Do we auto-arrange?  
         if (m_pOptions && m_pOptions->bAutoArrange)  
                 channelsArrange();  
   
1548          // We'll be dirty, for sure...          // We'll be dirty, for sure...
1549          m_iDirtyCount++;          m_iDirtyCount++;
1550          stabilizeForm();  
1551            // Just delete the channel strip.
1552            destroyChannelStrip(pChannelStrip);
1553  }  }
1554    
1555    
# Line 1550  void MainForm::editSetupChannel (void) Line 1559  void MainForm::editSetupChannel (void)
1559          if (m_pClient == NULL)          if (m_pClient == NULL)
1560                  return;                  return;
1561    
1562          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1563          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1564                  return;                  return;
1565    
# Line 1565  void MainForm::editEditChannel (void) Line 1574  void MainForm::editEditChannel (void)
1574          if (m_pClient == NULL)          if (m_pClient == NULL)
1575                  return;                  return;
1576    
1577          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1578          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1579                  return;                  return;
1580    
# Line 1580  void MainForm::editResetChannel (void) Line 1589  void MainForm::editResetChannel (void)
1589          if (m_pClient == NULL)          if (m_pClient == NULL)
1590                  return;                  return;
1591    
1592          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1593          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1594                  return;                  return;
1595    
# Line 1598  void MainForm::editResetAllChannels (voi Line 1607  void MainForm::editResetAllChannels (voi
1607          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
1608          // for all channels out there...          // for all channels out there...
1609          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1610          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1611          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1612                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
1613                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1614                    if (pMdiSubWindow)
1615                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1616                  if (pChannelStrip)                  if (pChannelStrip)
1617                          pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1618          }          }
# Line 1703  void MainForm::viewOptions (void) Line 1715  void MainForm::viewOptions (void)
1715          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
1716          if (pOptionsForm) {          if (pOptionsForm) {
1717                  // Check out some initial nullities(tm)...                  // Check out some initial nullities(tm)...
1718                  ChannelStrip* pChannelStrip = activeChannelStrip();                  ChannelStrip *pChannelStrip = activeChannelStrip();
1719                  if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)                  if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
1720                          m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();                          m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
1721                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
# Line 1796  void MainForm::viewOptions (void) Line 1808  void MainForm::viewOptions (void)
1808  void MainForm::channelsArrange (void)  void MainForm::channelsArrange (void)
1809  {  {
1810          // Full width vertical tiling          // Full width vertical tiling
1811          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1812          if (wlist.isEmpty())          if (wlist.isEmpty())
1813                  return;                  return;
1814    
1815          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1816          int y = 0;          int y = 0;
1817          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1818                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
1819          /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1820                          // Prevent flicker...                  if (pMdiSubWindow)
1821                          pChannelStrip->hide();                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1822                          pChannelStrip->showNormal();                  if (pChannelStrip) {
1823                  }   */                  /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1824                  pChannelStrip->adjustSize();                                  // Prevent flicker...
1825                  int iWidth  = m_pWorkspace->width();                                  pChannelStrip->hide();
1826                  if (iWidth < pChannelStrip->width())                                  pChannelStrip->showNormal();
1827                          iWidth = pChannelStrip->width();                          }   */
1828          //  int iHeight = pChannelStrip->height()                          pChannelStrip->adjustSize();
1829          //              + pChannelStrip->parentWidget()->baseSize().height();                          int iWidth  = m_pWorkspace->width();
1830                  int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();                          if (iWidth < pChannelStrip->width())
1831                  pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);                                  iWidth = pChannelStrip->width();
1832                  y += iHeight;                  //  int iHeight = pChannelStrip->height()
1833                    //              + pChannelStrip->parentWidget()->baseSize().height();
1834                            int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1835                            pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1836                            y += iHeight;
1837                    }
1838          }          }
1839          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1840    
# Line 1962  void MainForm::stabilizeForm (void) Line 1979  void MainForm::stabilizeForm (void)
1979          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1980          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);
1981          bool bHasChannel = (bHasClient && pChannelStrip != NULL);          bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1982          bool bHasChannels = (bHasClient && m_pWorkspace->windowList().count() > 0);          bool bHasChannels = (bHasClient && m_pWorkspace->subWindowList().count() > 0);
1983          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
1984          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
1985          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
# Line 2058  void MainForm::volumeChanged ( int iVolu Line 2075  void MainForm::volumeChanged ( int iVolu
2075    
2076    
2077  // Channel change receiver slot.  // Channel change receiver slot.
2078  void MainForm::channelStripChanged(ChannelStrip* pChannelStrip)  void MainForm::channelStripChanged ( ChannelStrip *pChannelStrip )
2079  {  {
2080          // Add this strip to the changed list...          // Add this strip to the changed list...
2081          if (!m_changedStrips.contains(pChannelStrip)) {          if (!m_changedStrips.contains(pChannelStrip)) {
# Line 2109  void MainForm::updateSession (void) Line 2126  void MainForm::updateSession (void)
2126                  m_pDeviceForm->refreshDevices();                  m_pDeviceForm->refreshDevices();
2127  }  }
2128    
2129  void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) {  
2130    void MainForm::updateAllChannelStrips ( bool bRemoveDeadStrips )
2131    {
2132          // Retrieve the current channel list.          // Retrieve the current channel list.
2133          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2134          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 2121  void MainForm::updateAllChannelStrips(bo Line 2140  void MainForm::updateAllChannelStrips(bo
2140          } else {          } else {
2141                  // Try to (re)create each channel.                  // Try to (re)create each channel.
2142                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
2143                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2144                          // Check if theres already a channel strip for this one...                          // Check if theres already a channel strip for this one...
2145                          if (!channelStrip(piChannelIDs[iChannel]))                          if (!channelStrip(piChannelIDs[iChannel]))
2146                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2147                  }                  }
   
2148                  // Do we auto-arrange?                  // Do we auto-arrange?
2149                  if (m_pOptions && m_pOptions->bAutoArrange)                  if (m_pOptions && m_pOptions->bAutoArrange)
2150                          channelsArrange();                          channelsArrange();
   
                 stabilizeForm();  
   
2151                  // remove dead channel strips                  // remove dead channel strips
2152                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2153                          for (int i = 0; channelStripAt(i); ++i) {                          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2154                                  ChannelStrip* pChannelStrip = channelStripAt(i);                          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2155                                  bool bExists = false;                                  ChannelStrip *pChannelStrip = NULL;
2156                                  for (int j = 0; piChannelIDs[j] >= 0; ++j) {                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2157                                          if (!pChannelStrip->channel()) break;                                  if (pMdiSubWindow)
2158                                          if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2159                                                  // strip exists, don't touch it                                  if (pChannelStrip) {
2160                                                  bExists = true;                                          bool bExists = false;
2161                                                  break;                                          for (int j = 0; piChannelIDs[j] >= 0; ++j) {
2162                                                    if (!pChannelStrip->channel())
2163                                                            break;
2164                                                    if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {
2165                                                            // strip exists, don't touch it
2166                                                            bExists = true;
2167                                                            break;
2168                                                    }
2169                                          }                                          }
2170                                            if (!bExists)
2171                                                    destroyChannelStrip(pChannelStrip);
2172                                  }                                  }
                                 if (!bExists) destroyChannelStrip(pChannelStrip);  
2173                          }                          }
2174                  }                  }
2175                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
2176          }          }
2177    
2178            stabilizeForm();
2179  }  }
2180    
2181    
2182  // Update the recent files list and menu.  // Update the recent files list and menu.
2183  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2184  {  {
# Line 2199  void MainForm::updateRecentFilesMenu (vo Line 2225  void MainForm::updateRecentFilesMenu (vo
2225  void MainForm::updateInstrumentNames (void)  void MainForm::updateInstrumentNames (void)
2226  {  {
2227          // Full channel list update...          // Full channel list update...
2228          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2229          if (wlist.isEmpty())          if (wlist.isEmpty())
2230                  return;                  return;
2231    
2232          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2233          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2234                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);
2235                  if (pChannelStrip)                  if (pChannelStrip)
2236                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
# Line 2228  void MainForm::updateDisplayFont (void) Line 2254  void MainForm::updateDisplayFont (void)
2254                  return;                  return;
2255    
2256          // Full channel list update...          // Full channel list update...
2257          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2258          if (wlist.isEmpty())          if (wlist.isEmpty())
2259                  return;                  return;
2260    
2261          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2262          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2263                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2264                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2265                    if (pMdiSubWindow)
2266                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2267                  if (pChannelStrip)                  if (pChannelStrip)
2268                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2269          }          }
# Line 2246  void MainForm::updateDisplayFont (void) Line 2275  void MainForm::updateDisplayFont (void)
2275  void MainForm::updateDisplayEffect (void)  void MainForm::updateDisplayEffect (void)
2276  {  {
2277          // Full channel list update...          // Full channel list update...
2278          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2279          if (wlist.isEmpty())          if (wlist.isEmpty())
2280                  return;                  return;
2281    
2282          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2283          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2284                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2285                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2286                    if (pMdiSubWindow)
2287                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2288                  if (pChannelStrip)                  if (pChannelStrip)
2289                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2290          }          }
# Line 2274  void MainForm::updateMaxVolume (void) Line 2306  void MainForm::updateMaxVolume (void)
2306  #endif  #endif
2307    
2308          // Full channel list update...          // Full channel list update...
2309          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2310          if (wlist.isEmpty())          if (wlist.isEmpty())
2311                  return;                  return;
2312    
2313          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2314          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2315                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2316                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2317                    if (pMdiSubWindow)
2318                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2319                  if (pChannelStrip)                  if (pChannelStrip)
2320                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
2321          }          }
# Line 2388  void MainForm::updateMessagesCapture (vo Line 2423  void MainForm::updateMessagesCapture (vo
2423  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
2424    
2425  // The channel strip creation executive.  // The channel strip creation executive.
2426  ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2427  {  {
2428          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == NULL || pChannel == NULL)
2429                  return NULL;                  return NULL;
# Line 2411  ChannelStrip* MainForm::createChannelStr Line 2446  ChannelStrip* MainForm::createChannelStr
2446          }          }
2447    
2448          // Add it to workspace...          // Add it to workspace...
2449          m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint);          m_pWorkspace->addSubWindow(pChannelStrip,
2450                    Qt::SubWindow | Qt::FramelessWindowHint);
2451    
2452          // Actual channel strip setup...          // Actual channel strip setup...
2453          pChannelStrip->setup(pChannel);          pChannelStrip->setup(pChannel);
2454    
2455          QObject::connect(pChannelStrip,          QObject::connect(pChannelStrip,
2456                  SIGNAL(channelChanged(ChannelStrip*)),                  SIGNAL(channelChanged(ChannelStrip *)),
2457                  SLOT(channelStripChanged(ChannelStrip*)));                  SLOT(channelStripChanged(ChannelStrip *)));
2458    
2459          // Now we show up us to the world.          // Now we show up us to the world.
2460          pChannelStrip->show();          pChannelStrip->show();
# Line 2430  ChannelStrip* MainForm::createChannelStr Line 2466  ChannelStrip* MainForm::createChannelStr
2466          return pChannelStrip;          return pChannelStrip;
2467  }  }
2468    
2469  void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) {  
2470    void MainForm::destroyChannelStrip ( ChannelStrip *pChannelStrip )
2471    {
2472            QMdiSubWindow *pMdiSubWindow
2473                    = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2474            if (pMdiSubWindow == NULL)
2475                    return;
2476    
2477          // Just delete the channel strip.          // Just delete the channel strip.
2478          delete pChannelStrip;          delete pChannelStrip;
2479            delete pMdiSubWindow;
2480    
2481          // Do we auto-arrange?          // Do we auto-arrange?
2482          if (m_pOptions && m_pOptions->bAutoArrange)          if (m_pOptions && m_pOptions->bAutoArrange)
# Line 2441  void MainForm::destroyChannelStrip(Chann Line 2485  void MainForm::destroyChannelStrip(Chann
2485          stabilizeForm();          stabilizeForm();
2486  }  }
2487    
2488    
2489  // Retrieve the active channel strip.  // Retrieve the active channel strip.
2490  ChannelStrip* MainForm::activeChannelStrip (void)  ChannelStrip *MainForm::activeChannelStrip (void)
2491  {  {
2492          return static_cast<ChannelStrip *> (m_pWorkspace->activeWindow());          QMdiSubWindow *pMdiSubWindow = m_pWorkspace->activeSubWindow();
2493            if (pMdiSubWindow)
2494                    return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2495            else
2496                    return NULL;
2497  }  }
2498    
2499    
2500  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2501  ChannelStrip* MainForm::channelStripAt ( int iChannel )  ChannelStrip *MainForm::channelStripAt ( int iChannel )
2502  {  {
2503          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return NULL;
2504    
2505          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2506          if (wlist.isEmpty())          if (wlist.isEmpty())
2507                  return NULL;                  return NULL;
2508    
2509          if (iChannel < 0 || iChannel >= wlist.size())          if (iChannel < 0 || iChannel >= wlist.size())
2510                  return NULL;                  return NULL;
2511    
2512          return dynamic_cast<ChannelStrip *> (wlist.at(iChannel));          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2513            if (pMdiSubWindow)
2514                    return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2515            else
2516                    return NULL;
2517  }  }
2518    
2519    
2520  // Retrieve a channel strip by sampler channel id.  // Retrieve a channel strip by sampler channel id.
2521  ChannelStrip* MainForm::channelStrip ( int iChannelID )  ChannelStrip *MainForm::channelStrip ( int iChannelID )
2522  {  {
2523          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2524          if (wlist.isEmpty())          if (wlist.isEmpty())
2525                  return NULL;                  return NULL;
2526    
2527          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2528                  ChannelStrip* pChannelStrip                  ChannelStrip *pChannelStrip = NULL;
2529                          = static_cast<ChannelStrip*> (wlist.at(iChannel));                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2530                    if (pMdiSubWindow)
2531                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2532                  if (pChannelStrip) {                  if (pChannelStrip) {
2533                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2534                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2493  void MainForm::channelsMenuAboutToShow ( Line 2548  void MainForm::channelsMenuAboutToShow (
2548          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);
2549          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);
2550    
2551          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2552          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2553                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2554                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2555                          ChannelStrip* pChannelStrip                          ChannelStrip *pChannelStrip = NULL;
2556                                  = static_cast<ChannelStrip*> (wlist.at(iChannel));                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2557                            if (pMdiSubWindow)
2558                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2559                          if (pChannelStrip) {                          if (pChannelStrip) {
2560                                  QAction *pAction = m_ui.channelsMenu->addAction(                                  QAction *pAction = m_ui.channelsMenu->addAction(
2561                                          pChannelStrip->windowTitle(),                                          pChannelStrip->windowTitle(),
# Line 2520  void MainForm::channelsMenuActivated (vo Line 2577  void MainForm::channelsMenuActivated (vo
2577          if (pAction == NULL)          if (pAction == NULL)
2578                  return;                  return;
2579    
2580          ChannelStrip* pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
2581          if (pChannelStrip) {          if (pChannelStrip) {
2582                  pChannelStrip->showNormal();                  pChannelStrip->showNormal();
2583                  pChannelStrip->setFocus();                  pChannelStrip->setFocus();
# Line 2581  void MainForm::timerSlot (void) Line 2638  void MainForm::timerSlot (void)
2638                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {
2639                                  m_iTimerSlot = 0;                                  m_iTimerSlot = 0;
2640                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2641                                  QWidgetList wlist = m_pWorkspace->windowList();                                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2642                                  for (int iChannel = 0;                                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2643                                                  iChannel < (int) wlist.count(); iChannel++) {                                          ChannelStrip *pChannelStrip = NULL;
2644                                          ChannelStrip* pChannelStrip                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2645                                                  = (ChannelStrip*) wlist.at(iChannel);                                          if (pMdiSubWindow)
2646                                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2647                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
2648                                                  pChannelStrip->updateChannelUsage();                                                  pChannelStrip->updateChannelUsage();
2649                                  }                                  }
# Line 2637  void MainForm::startServer (void) Line 2695  void MainForm::startServer (void)
2695    
2696          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2697  //      if (m_pOptions->bStdoutCapture) {  //      if (m_pOptions->bStdoutCapture) {
2698  #if QT_VERSION >= 0x040200          #if QT_VERSION >= 0x040200
2699                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
2700  #endif          #endif
2701                  QObject::connect(m_pServer,                  QObject::connect(m_pServer,
2702                          SIGNAL(readyReadStandardOutput()),                          SIGNAL(readyReadStandardOutput()),
2703                          SLOT(readServerStdout()));                          SLOT(readServerStdout()));
# Line 2704  void MainForm::stopServer (bool bInterac Line 2762  void MainForm::stopServer (bool bInterac
2762          if (m_pServer && bForceServerStop) {          if (m_pServer && bForceServerStop) {
2763                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2764                  if (m_pServer->state() == QProcess::Running) {                  if (m_pServer->state() == QProcess::Running) {
2765  #if defined(WIN32)                  #if defined(WIN32)
2766                          // Try harder...                          // Try harder...
2767                          m_pServer->kill();                          m_pServer->kill();
2768  #else                  #else
2769                          // Try softly...                          // Try softly...
2770                          m_pServer->terminate();                          m_pServer->terminate();
2771  #endif                  #endif
2772                  }                  }
2773          }       // Do final processing anyway.          }       // Do final processing anyway.
2774          else processServerExit();          else processServerExit();
# Line 2939  void MainForm::stopClient (void) Line 2997  void MainForm::stopClient (void)
2997    
2998    
2999  // Channel strip activation/selection.  // Channel strip activation/selection.
3000  void MainForm::activateStrip ( QWidget *pWidget )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3001  {  {
3002          ChannelStrip *pChannelStrip          ChannelStrip *pChannelStrip = NULL;
3003                  = static_cast<ChannelStrip *> (pWidget);          if (pMdiSubWindow)
3004                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3005          if (pChannelStrip)          if (pChannelStrip)
3006                  pChannelStrip->setSelected(true);                  pChannelStrip->setSelected(true);
3007    

Legend:
Removed from v.2113  
changed lines
  Added in v.2441

  ViewVC Help
Powered by ViewVC