/[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 1840 by capela, Thu Feb 19 11:44:57 2009 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-2009, 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
66    namespace Qt {
67    const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
68    #if QT_VERSION < 0x040200
69    const WindowFlags CustomizeWindowHint   = WindowFlags(0x02000000);
70    #endif
71    }
72    #endif
73    
74  #ifdef HAVE_SIGNAL_H  #ifdef HAVE_SIGNAL_H
75  #include <signal.h>  #include <signal.h>
# Line 85  static WSADATA _wsaData; Line 99  static WSADATA _wsaData;
99  #endif  #endif
100    
101    
102    //-------------------------------------------------------------------------
103    // LADISH Level 1 support stuff.
104    
105    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
106    
107    #include <QSocketNotifier>
108    
109    #include <sys/types.h>
110    #include <sys/socket.h>
111    
112    #include <signal.h>
113    
114    // File descriptor for SIGUSR1 notifier.
115    static int g_fdUsr1[2];
116    
117    // Unix SIGUSR1 signal handler.
118    static void qsampler_sigusr1_handler ( int /* signo */ )
119    {
120            char c = 1;
121    
122            (::write(g_fdUsr1[0], &c, sizeof(c)) > 0);
123    }
124    
125    #endif  // HAVE_SIGNAL_H
126    
127    
128    //-------------------------------------------------------------------------
129    // qsampler -- namespace
130    
131    
132  namespace QSampler {  namespace QSampler {
133    
134  // Timer constant stuff.  // Timer constant stuff.
# Line 97  namespace QSampler { Line 141  namespace QSampler {
141  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
142    
143    
144    // Specialties for thread-callback comunication.
145    #define QSAMPLER_LSCP_EVENT   QEvent::Type(QEvent::User + 1)
146    
147    
148  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
149  // CustomEvent -- specialty for callback comunication.  // LscpEvent -- specialty for LSCP callback comunication.
150    
 #define QSAMPLER_CUSTOM_EVENT   QEvent::Type(QEvent::User + 0)  
151    
152  class CustomEvent : public QEvent  class LscpEvent : public QEvent
153  {  {
154  public:  public:
155    
156          // Constructor.          // Constructor.
157          CustomEvent(lscp_event_t event, const char *pchData, int cchData)          LscpEvent(lscp_event_t event, const char *pchData, int cchData)
158                  : QEvent(QSAMPLER_CUSTOM_EVENT)                  : QEvent(QSAMPLER_LSCP_EVENT)
159          {          {
160                  m_event = event;                  m_event = event;
161                  m_data  = QString::fromUtf8(pchData, cchData);                  m_data  = QString::fromUtf8(pchData, cchData);
# Line 161  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);
215  #endif  
216            // LADISH Level 1 suport.
217    
218            // Initialize file descriptors for SIGUSR1 socket notifier.
219            ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1);
220            m_pUsr1Notifier
221                    = new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this);
222    
223            QObject::connect(m_pUsr1Notifier,
224                    SIGNAL(activated(int)),
225                    SLOT(handle_sigusr1()));
226    
227            // Install SIGUSR1 signal handler.
228        struct sigaction usr1;
229        usr1.sa_handler = qsampler_sigusr1_handler;
230        sigemptyset(&usr1.sa_mask);
231        usr1.sa_flags = 0;
232        usr1.sa_flags |= SA_RESTART;
233        ::sigaction(SIGUSR1, &usr1, NULL);
234    
235    #else   // HAVE_SIGNAL_H
236    
237            m_pUsr1Notifier = NULL;
238            
239    #endif  // !HAVE_SIGNAL_H
240    
241  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
242          // Make some extras into the toolbar...          // Make some extras into the toolbar...
# Line 203  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 337  MainForm::~MainForm() Line 410  MainForm::~MainForm()
410          WSACleanup();          WSACleanup();
411  #endif  #endif
412    
413    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
414            if (m_pUsr1Notifier)
415                    delete m_pUsr1Notifier;
416    #endif
417    
418          // Finally drop any widgets around...          // Finally drop any widgets around...
419          if (m_pDeviceForm)          if (m_pDeviceForm)
420                  delete m_pDeviceForm;                  delete m_pDeviceForm;
# Line 375  void MainForm::setup ( Options *pOptions Line 453  void MainForm::setup ( Options *pOptions
453    
454          // What style do we create these forms?          // What style do we create these forms?
455          Qt::WindowFlags wflags = Qt::Window          Qt::WindowFlags wflags = Qt::Window
 #if QT_VERSION >= 0x040200  
456                  | Qt::CustomizeWindowHint                  | Qt::CustomizeWindowHint
 #endif  
457                  | Qt::WindowTitleHint                  | Qt::WindowTitleHint
458                  | Qt::WindowSystemMenuHint                  | Qt::WindowSystemMenuHint
459                  | Qt::WindowMinMaxButtonsHint;                  | Qt::WindowMinMaxButtonsHint
460                    | Qt::WindowCloseButtonHint;
461          if (m_pOptions->bKeepOnTop)          if (m_pOptions->bKeepOnTop)
462                  wflags |= Qt::Tool;                  wflags |= Qt::Tool;
463    
464          // Some child forms are to be created right now.          // Some child forms are to be created right now.
465          m_pMessages = new Messages(this);          m_pMessages = new Messages(this);
466          m_pDeviceForm = new DeviceForm(this, wflags);          m_pDeviceForm = new DeviceForm(this, wflags);
467  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
468          m_pInstrumentListForm = new InstrumentListForm(this, wflags);          m_pInstrumentListForm = new InstrumentListForm(this, wflags);
469  #else  #else
470          viewInstrumentsAction->setEnabled(false);          m_ui.viewInstrumentsAction->setEnabled(false);
471  #endif  #endif
472    
473          // Setup messages logging appropriately...          // Setup messages logging appropriately...
474          m_pMessages->setLogging(          m_pMessages->setLogging(
475                  m_pOptions->bMessagesLog,                  m_pOptions->bMessagesLog,
476                  m_pOptions->sMessagesLogPath);                  m_pOptions->sMessagesLogPath);
477    
478          // Set message defaults...          // Set message defaults...
479          updateMessagesFont();          updateMessagesFont();
480          updateMessagesLimit();          updateMessagesLimit();
# Line 425  void MainForm::setup ( Options *pOptions Line 505  void MainForm::setup ( Options *pOptions
505          }          }
506    
507          // Try to restore old window positioning and initial visibility.          // Try to restore old window positioning and initial visibility.
508          m_pOptions->loadWidgetGeometry(this);          m_pOptions->loadWidgetGeometry(this, true);
509          m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);          m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);
510          m_pOptions->loadWidgetGeometry(m_pDeviceForm);          m_pOptions->loadWidgetGeometry(m_pDeviceForm);
511    
# Line 469  bool MainForm::queryClose (void) Line 549  bool MainForm::queryClose (void)
549                          // And the children, and the main windows state,.                          // And the children, and the main windows state,.
550                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
551                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
552                          m_pOptions->saveWidgetGeometry(this);                          m_pOptions->saveWidgetGeometry(this, true);
553                          // Close popup widgets.                          // Close popup widgets.
554                          if (m_pInstrumentListForm)                          if (m_pInstrumentListForm)
555                                  m_pInstrumentListForm->close();                                  m_pInstrumentListForm->close();
# Line 518  void MainForm::dropEvent ( QDropEvent* p Line 598  void MainForm::dropEvent ( QDropEvent* p
598                  QListIterator<QUrl> iter(pMimeData->urls());                  QListIterator<QUrl> iter(pMimeData->urls());
599                  while (iter.hasNext()) {                  while (iter.hasNext()) {
600                          const QString& sPath = iter.next().toLocalFile();                          const QString& sPath = iter.next().toLocalFile();
601                          if (Channel::isInstrumentFile(sPath)) {                  //      if (Channel::isDlsInstrumentFile(sPath)) {
602                            if (QFileInfo(sPath).exists()) {
603                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
604                                  Channel *pChannel = new Channel();                                  Channel *pChannel = new Channel();
605                                  if (pChannel == NULL)                                  if (pChannel == NULL)
# Line 552  void MainForm::dropEvent ( QDropEvent* p Line 633  void MainForm::dropEvent ( QDropEvent* p
633    
634    
635  // Custome event handler.  // Custome event handler.
636  void MainForm::customEvent(QEvent* pCustomEvent)  void MainForm::customEvent ( QEvent* pEvent )
637  {  {
638          // For the time being, just pump it to messages.          // For the time being, just pump it to messages.
639          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pEvent->type() == QSAMPLER_LSCP_EVENT) {
640                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);                  LscpEvent *pLscpEvent = static_cast<LscpEvent *> (pEvent);
641                  switch (pEvent->event()) {                  switch (pLscpEvent->event()) {
642                          case LSCP_EVENT_CHANNEL_COUNT:                          case LSCP_EVENT_CHANNEL_COUNT:
643                                  updateAllChannelStrips(true);                                  updateAllChannelStrips(true);
644                                  break;                                  break;
645                          case LSCP_EVENT_CHANNEL_INFO: {                          case LSCP_EVENT_CHANNEL_INFO: {
646                                  int iChannelID = pEvent->data().toInt();                                  int iChannelID = pLscpEvent->data().toInt();
647                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
648                                  if (pChannelStrip)                                  if (pChannelStrip)
649                                          channelStripChanged(pChannelStrip);                                          channelStripChanged(pChannelStrip);
# Line 575  void MainForm::customEvent(QEvent* pCust Line 656  void MainForm::customEvent(QEvent* pCust
656                                  break;                                  break;
657                          case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: {                          case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: {
658                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
659                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt();
660                                  DeviceStatusForm::onDeviceChanged(iDeviceID);                                  DeviceStatusForm::onDeviceChanged(iDeviceID);
661                                  break;                                  break;
662                          }                          }
# Line 585  void MainForm::customEvent(QEvent* pCust Line 666  void MainForm::customEvent(QEvent* pCust
666                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:
667                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
668                                  break;                                  break;
669  #if CONFIG_EVENT_CHANNEL_MIDI                  #if CONFIG_EVENT_CHANNEL_MIDI
670                          case LSCP_EVENT_CHANNEL_MIDI: {                          case LSCP_EVENT_CHANNEL_MIDI: {
671                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iChannelID = pLscpEvent->data().section(' ', 0, 0).toInt();
672                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
673                                  if (pChannelStrip)                                  if (pChannelStrip)
674                                          pChannelStrip->midiArrived();                                          pChannelStrip->midiActivityLedOn();
675                                  break;                                  break;
676                          }                          }
677  #endif                  #endif
678  #if CONFIG_EVENT_DEVICE_MIDI                  #if CONFIG_EVENT_DEVICE_MIDI
679                          case LSCP_EVENT_DEVICE_MIDI: {                          case LSCP_EVENT_DEVICE_MIDI: {
680                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt();
681                                  const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();                                  const int iPortID   = pLscpEvent->data().section(' ', 1, 1).toInt();
682                                  DeviceStatusForm* pDeviceStatusForm =                                  DeviceStatusForm *pDeviceStatusForm
683                                          DeviceStatusForm::getInstance(iDeviceID);                                          = DeviceStatusForm::getInstance(iDeviceID);
684                                  if (pDeviceStatusForm)                                  if (pDeviceStatusForm)
685                                          pDeviceStatusForm->midiArrived(iPortID);                                          pDeviceStatusForm->midiArrived(iPortID);
686                                  break;                                  break;
687                          }                          }
688  #endif                  #endif
689                          default:                          default:
690                                  appendMessagesColor(tr("Notify event: %1 data: %2")                                  appendMessagesColor(tr("LSCP Event: %1 data: %2")
691                                          .arg(::lscp_event_to_text(pEvent->event()))                                          .arg(::lscp_event_to_text(pLscpEvent->event()))
692                                          .arg(pEvent->data()), "#996699");                                          .arg(pLscpEvent->data()), "#996699");
693                  }                  }
694          }          }
695  }  }
696    
697  void MainForm::updateViewMidiDeviceStatusMenu() {  
698    // LADISH Level 1 -- SIGUSR1 signal handler.
699    void MainForm::handle_sigusr1 (void)
700    {
701    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
702    
703            char c;
704    
705            if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0)
706                    saveSession(false);
707    
708    #endif
709    }
710    
711    
712    void MainForm::updateViewMidiDeviceStatusMenu (void)
713    {
714          m_ui.viewMidiDeviceStatusMenu->clear();          m_ui.viewMidiDeviceStatusMenu->clear();
715          const std::map<int, DeviceStatusForm*> statusForms =          const std::map<int, DeviceStatusForm *> statusForms
716                  DeviceStatusForm::getInstances();                  = DeviceStatusForm::getInstances();
717          for (          std::map<int, DeviceStatusForm *>::const_iterator iter
718                  std::map<int, DeviceStatusForm*>::const_iterator iter = statusForms.begin();                  = statusForms.begin();
719                  iter != statusForms.end(); ++iter          for ( ; iter != statusForms.end(); ++iter) {
720          ) {                  DeviceStatusForm *pStatusForm = iter->second;
                 DeviceStatusForm* pForm = iter->second;  
721                  m_ui.viewMidiDeviceStatusMenu->addAction(                  m_ui.viewMidiDeviceStatusMenu->addAction(
722                          pForm->visibleAction()                          pStatusForm->visibleAction());
                 );  
723          }          }
724  }  }
725    
726    
727  // Context menu event handler.  // Context menu event handler.
728  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )
729  {  {
# Line 801  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 1100  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 1151  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 1181  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 1417  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 1442  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 1461  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 1476  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 1491  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 1509  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 1614  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 1707  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 1870  void MainForm::stabilizeForm (void) Line 1976  void MainForm::stabilizeForm (void)
1976          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1977    
1978          // Update the main menu state...          // Update the main menu state...
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->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 1888  void MainForm::stabilizeForm (void) Line 1995  void MainForm::stabilizeForm (void)
1995          m_ui.editEditChannelAction->setEnabled(false);          m_ui.editEditChannelAction->setEnabled(false);
1996  #endif  #endif
1997          m_ui.editResetChannelAction->setEnabled(bHasChannel);          m_ui.editResetChannelAction->setEnabled(bHasChannel);
1998          m_ui.editResetAllChannelsAction->setEnabled(bHasChannel);          m_ui.editResetAllChannelsAction->setEnabled(bHasChannels);
1999          m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());          m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());
2000  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
2001          m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm          m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm
# Line 1900  void MainForm::stabilizeForm (void) Line 2007  void MainForm::stabilizeForm (void)
2007          m_ui.viewDevicesAction->setChecked(m_pDeviceForm          m_ui.viewDevicesAction->setChecked(m_pDeviceForm
2008                  && m_pDeviceForm->isVisible());                  && m_pDeviceForm->isVisible());
2009          m_ui.viewDevicesAction->setEnabled(bHasClient);          m_ui.viewDevicesAction->setEnabled(bHasClient);
2010          m_ui.channelsArrangeAction->setEnabled(bHasChannel);          m_ui.viewMidiDeviceStatusMenu->setEnabled(
2011                    DeviceStatusForm::getInstances().size() > 0);
2012            m_ui.channelsArrangeAction->setEnabled(bHasChannels);
2013    
2014  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
2015          // Toolbar widgets are also affected...          // Toolbar widgets are also affected...
# Line 1966  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 2017  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 2029  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 2107  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 2136  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 2154  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 2182  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 2296  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 2319  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 2338  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 2349  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 2401  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 2428  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 2489  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 2545  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 2601  void MainForm::stopServer (bool bInterac Line 2751  void MainForm::stopServer (bool bInterac
2751                          "running in the background. The sampler would continue to work\n"                          "running in the background. The sampler would continue to work\n"
2752                          "according to your current sampler session and you could alter the\n"                          "according to your current sampler session and you could alter the\n"
2753                          "sampler session at any time by relaunching QSampler.\n\n"                          "sampler session at any time by relaunching QSampler.\n\n"
2754                          "Do you want LinuxSampler to stop or to keep running in\n"                          "Do you want LinuxSampler to stop?"),
                         "the background?"),  
2755                          QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)                          QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
2756                  {                  {
2757                          bForceServerStop = false;                          bForceServerStop = false;
# Line 2613  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 2689  lscp_status_t qsampler_client_callback ( Line 2838  lscp_status_t qsampler_client_callback (
2838          // as this is run under some other thread context.          // as this is run under some other thread context.
2839          // A custom event must be posted here...          // A custom event must be posted here...
2840          QApplication::postEvent(pMainForm,          QApplication::postEvent(pMainForm,
2841                  new CustomEvent(event, pchData, cchData));                  new LscpEvent(event, pchData, cchData));
2842    
2843          return LSCP_OK;          return LSCP_OK;
2844  }  }
# Line 2848  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.1840  
changed lines
  Added in v.2441

  ViewVC Help
Powered by ViewVC