/[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 1890 by capela, Tue Apr 28 09:06:43 2009 UTC revision 2459 by capela, Mon Jul 8 10:06:57 2013 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-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    }
69    #endif
70    
71  #ifdef HAVE_SIGNAL_H  #ifdef HAVE_SIGNAL_H
72  #include <signal.h>  #include <signal.h>
# Line 85  static WSADATA _wsaData; Line 96  static WSADATA _wsaData;
96  #endif  #endif
97    
98    
99    //-------------------------------------------------------------------------
100    // LADISH Level 1 support stuff.
101    
102    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
103    
104    #include <QSocketNotifier>
105    
106    #include <sys/types.h>
107    #include <sys/socket.h>
108    
109    #include <signal.h>
110    
111    // File descriptor for SIGUSR1 notifier.
112    static int g_fdUsr1[2];
113    
114    // Unix SIGUSR1 signal handler.
115    static void qsampler_sigusr1_handler ( int /* signo */ )
116    {
117            char c = 1;
118    
119            (::write(g_fdUsr1[0], &c, sizeof(c)) > 0);
120    }
121    
122    #endif  // HAVE_SIGNAL_H
123    
124    
125    //-------------------------------------------------------------------------
126    // qsampler -- namespace
127    
128    
129  namespace QSampler {  namespace QSampler {
130    
131  // Timer constant stuff.  // Timer constant stuff.
# Line 97  namespace QSampler { Line 138  namespace QSampler {
138  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
139    
140    
141    // Specialties for thread-callback comunication.
142    #define QSAMPLER_LSCP_EVENT   QEvent::Type(QEvent::User + 1)
143    
144    
145  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
146  // CustomEvent -- specialty for callback comunication.  // LscpEvent -- specialty for LSCP callback comunication.
147    
 #define QSAMPLER_CUSTOM_EVENT   QEvent::Type(QEvent::User + 0)  
148    
149  class CustomEvent : public QEvent  class LscpEvent : public QEvent
150  {  {
151  public:  public:
152    
153          // Constructor.          // Constructor.
154          CustomEvent(lscp_event_t event, const char *pchData, int cchData)          LscpEvent(lscp_event_t event, const char *pchData, int cchData)
155                  : QEvent(QSAMPLER_CUSTOM_EVENT)                  : QEvent(QSAMPLER_LSCP_EVENT)
156          {          {
157                  m_event = event;                  m_event = event;
158                  m_data  = QString::fromUtf8(pchData, cchData);                  m_data  = QString::fromUtf8(pchData, cchData);
# Line 161  MainForm::MainForm ( QWidget *pParent ) Line 205  MainForm::MainForm ( QWidget *pParent )
205    
206          m_iTimerSlot = 0;          m_iTimerSlot = 0;
207    
208  #ifdef HAVE_SIGNAL_H  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
209    
210          // Set to ignore any fatal "Broken pipe" signals.          // Set to ignore any fatal "Broken pipe" signals.
211          ::signal(SIGPIPE, SIG_IGN);          ::signal(SIGPIPE, SIG_IGN);
212  #endif  
213            // LADISH Level 1 suport.
214    
215            // Initialize file descriptors for SIGUSR1 socket notifier.
216            ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1);
217            m_pUsr1Notifier
218                    = new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this);
219    
220            QObject::connect(m_pUsr1Notifier,
221                    SIGNAL(activated(int)),
222                    SLOT(handle_sigusr1()));
223    
224            // Install SIGUSR1 signal handler.
225        struct sigaction usr1;
226        usr1.sa_handler = qsampler_sigusr1_handler;
227        sigemptyset(&usr1.sa_mask);
228        usr1.sa_flags = 0;
229        usr1.sa_flags |= SA_RESTART;
230        ::sigaction(SIGUSR1, &usr1, NULL);
231    
232    #else   // HAVE_SIGNAL_H
233    
234            m_pUsr1Notifier = NULL;
235            
236    #endif  // !HAVE_SIGNAL_H
237    
238  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
239          // Make some extras into the toolbar...          // Make some extras into the toolbar...
# Line 203  MainForm::MainForm ( QWidget *pParent ) Line 272  MainForm::MainForm ( QWidget *pParent )
272  #endif  #endif
273    
274          // Make it an MDI workspace.          // Make it an MDI workspace.
275          m_pWorkspace = new QWorkspace(this);          m_pWorkspace = new QMdiArea(this);
276          m_pWorkspace->setScrollBarsEnabled(true);          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
277            m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
278          // Set the activation connection.          // Set the activation connection.
279          QObject::connect(m_pWorkspace,          QObject::connect(m_pWorkspace,
280                  SIGNAL(windowActivated(QWidget *)),                  SIGNAL(subWindowActivated(QMdiSubWindow *)),
281                  SLOT(activateStrip(QWidget *)));                  SLOT(activateStrip(QMdiSubWindow *)));
282          // Make it shine :-)          // Make it shine :-)
283          setCentralWidget(m_pWorkspace);          setCentralWidget(m_pWorkspace);
284    
# Line 337  MainForm::~MainForm() Line 407  MainForm::~MainForm()
407          WSACleanup();          WSACleanup();
408  #endif  #endif
409    
410    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
411            if (m_pUsr1Notifier)
412                    delete m_pUsr1Notifier;
413    #endif
414    
415          // Finally drop any widgets around...          // Finally drop any widgets around...
416          if (m_pDeviceForm)          if (m_pDeviceForm)
417                  delete m_pDeviceForm;                  delete m_pDeviceForm;
# Line 375  void MainForm::setup ( Options *pOptions Line 450  void MainForm::setup ( Options *pOptions
450    
451          // What style do we create these forms?          // What style do we create these forms?
452          Qt::WindowFlags wflags = Qt::Window          Qt::WindowFlags wflags = Qt::Window
 #if QT_VERSION >= 0x040200  
453                  | Qt::CustomizeWindowHint                  | Qt::CustomizeWindowHint
 #endif  
454                  | Qt::WindowTitleHint                  | Qt::WindowTitleHint
455                  | Qt::WindowSystemMenuHint                  | Qt::WindowSystemMenuHint
456                  | Qt::WindowMinMaxButtonsHint;                  | Qt::WindowMinMaxButtonsHint
457                    | Qt::WindowCloseButtonHint;
458          if (m_pOptions->bKeepOnTop)          if (m_pOptions->bKeepOnTop)
459                  wflags |= Qt::Tool;                  wflags |= Qt::Tool;
460    
461          // Some child forms are to be created right now.          // Some child forms are to be created right now.
462          m_pMessages = new Messages(this);          m_pMessages = new Messages(this);
463          m_pDeviceForm = new DeviceForm(this, wflags);          m_pDeviceForm = new DeviceForm(this, wflags);
464  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
465          m_pInstrumentListForm = new InstrumentListForm(this, wflags);          m_pInstrumentListForm = new InstrumentListForm(this, wflags);
466  #else  #else
467          viewInstrumentsAction->setEnabled(false);          m_ui.viewInstrumentsAction->setEnabled(false);
468  #endif  #endif
469    
470          // Setup messages logging appropriately...          // Setup messages logging appropriately...
471          m_pMessages->setLogging(          m_pMessages->setLogging(
472                  m_pOptions->bMessagesLog,                  m_pOptions->bMessagesLog,
473                  m_pOptions->sMessagesLogPath);                  m_pOptions->sMessagesLogPath);
474    
475          // Set message defaults...          // Set message defaults...
476          updateMessagesFont();          updateMessagesFont();
477          updateMessagesLimit();          updateMessagesLimit();
# Line 425  void MainForm::setup ( Options *pOptions Line 502  void MainForm::setup ( Options *pOptions
502          }          }
503    
504          // Try to restore old window positioning and initial visibility.          // Try to restore old window positioning and initial visibility.
505          m_pOptions->loadWidgetGeometry(this);          m_pOptions->loadWidgetGeometry(this, true);
506          m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);          m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);
507          m_pOptions->loadWidgetGeometry(m_pDeviceForm);          m_pOptions->loadWidgetGeometry(m_pDeviceForm);
508    
# Line 469  bool MainForm::queryClose (void) Line 546  bool MainForm::queryClose (void)
546                          // And the children, and the main windows state,.                          // And the children, and the main windows state,.
547                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
548                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
549                          m_pOptions->saveWidgetGeometry(this);                          m_pOptions->saveWidgetGeometry(this, true);
550                          // Close popup widgets.                          // Close popup widgets.
551                          if (m_pInstrumentListForm)                          if (m_pInstrumentListForm)
552                                  m_pInstrumentListForm->close();                                  m_pInstrumentListForm->close();
# Line 518  void MainForm::dropEvent ( QDropEvent* p Line 595  void MainForm::dropEvent ( QDropEvent* p
595                  QListIterator<QUrl> iter(pMimeData->urls());                  QListIterator<QUrl> iter(pMimeData->urls());
596                  while (iter.hasNext()) {                  while (iter.hasNext()) {
597                          const QString& sPath = iter.next().toLocalFile();                          const QString& sPath = iter.next().toLocalFile();
598                          if (Channel::isInstrumentFile(sPath)) {                  //      if (Channel::isDlsInstrumentFile(sPath)) {
599                            if (QFileInfo(sPath).exists()) {
600                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
601                                  Channel *pChannel = new Channel();                                  Channel *pChannel = new Channel();
602                                  if (pChannel == NULL)                                  if (pChannel == NULL)
# Line 552  void MainForm::dropEvent ( QDropEvent* p Line 630  void MainForm::dropEvent ( QDropEvent* p
630    
631    
632  // Custome event handler.  // Custome event handler.
633  void MainForm::customEvent(QEvent* pCustomEvent)  void MainForm::customEvent ( QEvent* pEvent )
634  {  {
635          // For the time being, just pump it to messages.          // For the time being, just pump it to messages.
636          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pEvent->type() == QSAMPLER_LSCP_EVENT) {
637                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);                  LscpEvent *pLscpEvent = static_cast<LscpEvent *> (pEvent);
638                  switch (pEvent->event()) {                  switch (pLscpEvent->event()) {
639                          case LSCP_EVENT_CHANNEL_COUNT:                          case LSCP_EVENT_CHANNEL_COUNT:
640                                  updateAllChannelStrips(true);                                  updateAllChannelStrips(true);
641                                  break;                                  break;
642                          case LSCP_EVENT_CHANNEL_INFO: {                          case LSCP_EVENT_CHANNEL_INFO: {
643                                  int iChannelID = pEvent->data().toInt();                                  int iChannelID = pLscpEvent->data().toInt();
644                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
645                                  if (pChannelStrip)                                  if (pChannelStrip)
646                                          channelStripChanged(pChannelStrip);                                          channelStripChanged(pChannelStrip);
# Line 575  void MainForm::customEvent(QEvent* pCust Line 653  void MainForm::customEvent(QEvent* pCust
653                                  break;                                  break;
654                          case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: {                          case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: {
655                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
656                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt();
657                                  DeviceStatusForm::onDeviceChanged(iDeviceID);                                  DeviceStatusForm::onDeviceChanged(iDeviceID);
658                                  break;                                  break;
659                          }                          }
# Line 585  void MainForm::customEvent(QEvent* pCust Line 663  void MainForm::customEvent(QEvent* pCust
663                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:
664                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
665                                  break;                                  break;
666  #if CONFIG_EVENT_CHANNEL_MIDI                  #if CONFIG_EVENT_CHANNEL_MIDI
667                          case LSCP_EVENT_CHANNEL_MIDI: {                          case LSCP_EVENT_CHANNEL_MIDI: {
668                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iChannelID = pLscpEvent->data().section(' ', 0, 0).toInt();
669                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
670                                  if (pChannelStrip)                                  if (pChannelStrip)
671                                          pChannelStrip->midiArrived();                                          pChannelStrip->midiActivityLedOn();
672                                  break;                                  break;
673                          }                          }
674  #endif                  #endif
675  #if CONFIG_EVENT_DEVICE_MIDI                  #if CONFIG_EVENT_DEVICE_MIDI
676                          case LSCP_EVENT_DEVICE_MIDI: {                          case LSCP_EVENT_DEVICE_MIDI: {
677                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt();
678                                  const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();                                  const int iPortID   = pLscpEvent->data().section(' ', 1, 1).toInt();
679                                  DeviceStatusForm* pDeviceStatusForm =                                  DeviceStatusForm *pDeviceStatusForm
680                                          DeviceStatusForm::getInstance(iDeviceID);                                          = DeviceStatusForm::getInstance(iDeviceID);
681                                  if (pDeviceStatusForm)                                  if (pDeviceStatusForm)
682                                          pDeviceStatusForm->midiArrived(iPortID);                                          pDeviceStatusForm->midiArrived(iPortID);
683                                  break;                                  break;
684                          }                          }
685  #endif                  #endif
686                          default:                          default:
687                                  appendMessagesColor(tr("Notify event: %1 data: %2")                                  appendMessagesColor(tr("LSCP Event: %1 data: %2")
688                                          .arg(::lscp_event_to_text(pEvent->event()))                                          .arg(::lscp_event_to_text(pLscpEvent->event()))
689                                          .arg(pEvent->data()), "#996699");                                          .arg(pLscpEvent->data()), "#996699");
690                  }                  }
691          }          }
692  }  }
693    
694  void MainForm::updateViewMidiDeviceStatusMenu() {  
695    // LADISH Level 1 -- SIGUSR1 signal handler.
696    void MainForm::handle_sigusr1 (void)
697    {
698    #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
699    
700            char c;
701    
702            if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0)
703                    saveSession(false);
704    
705    #endif
706    }
707    
708    
709    void MainForm::updateViewMidiDeviceStatusMenu (void)
710    {
711          m_ui.viewMidiDeviceStatusMenu->clear();          m_ui.viewMidiDeviceStatusMenu->clear();
712          const std::map<int, DeviceStatusForm*> statusForms =          const std::map<int, DeviceStatusForm *> statusForms
713                  DeviceStatusForm::getInstances();                  = DeviceStatusForm::getInstances();
714          for (          std::map<int, DeviceStatusForm *>::const_iterator iter
715                  std::map<int, DeviceStatusForm*>::const_iterator iter = statusForms.begin();                  = statusForms.begin();
716                  iter != statusForms.end(); ++iter          for ( ; iter != statusForms.end(); ++iter) {
717          ) {                  DeviceStatusForm *pStatusForm = iter->second;
                 DeviceStatusForm* pForm = iter->second;  
718                  m_ui.viewMidiDeviceStatusMenu->addAction(                  m_ui.viewMidiDeviceStatusMenu->addAction(
719                          pForm->visibleAction()                          pStatusForm->visibleAction());
                 );  
720          }          }
721  }  }
722    
723    
724  // Context menu event handler.  // Context menu event handler.
725  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )
726  {  {
# Line 801  bool MainForm::closeSession ( bool bForc Line 894  bool MainForm::closeSession ( bool bForc
894          if (bClose) {          if (bClose) {
895                  // Remove all channel strips from sight...                  // Remove all channel strips from sight...
896                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
897                  QWidgetList wlist = m_pWorkspace->windowList();                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
898                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
899                          ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                          ChannelStrip *pChannelStrip = NULL;
900                            QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
901                            if (pMdiSubWindow)
902                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
903                          if (pChannelStrip) {                          if (pChannelStrip) {
904                                  Channel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
905                                  if (bForce && pChannel)                                  if (bForce && pChannel)
906                                          pChannel->removeChannel();                                          pChannel->removeChannel();
907                                  delete pChannelStrip;                                  delete pChannelStrip;
908                          }                          }
909                            if (pMdiSubWindow)
910                                    delete pMdiSubWindow;
911                  }                  }
912                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
913                  // We're now clean, for sure.                  // We're now clean, for sure.
# Line 1100  bool MainForm::saveSessionFile ( const Q Line 1198  bool MainForm::saveSessionFile ( const Q
1198  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1199    
1200          // Sampler channel mapping.          // Sampler channel mapping.
1201          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1202          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1203                  ChannelStrip* pChannelStrip                  ChannelStrip *pChannelStrip = NULL;
1204                          = static_cast<ChannelStrip *> (wlist.at(iChannel));                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1205                    if (pMdiSubWindow)
1206                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1207                  if (pChannelStrip) {                  if (pChannelStrip) {
1208                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1209                          if (pChannel) {                          if (pChannel) {
# Line 1151  bool MainForm::saveSessionFile ( const Q Line 1251  bool MainForm::saveSessionFile ( const Q
1251                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
1252                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1253                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
1254  #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1255                                  if (pChannel->midiMap() >= 0) {                                  if (pChannel->midiMap() >= 0) {
1256                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel
1257                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;
1258                                  }                                  }
1259  #endif                          #endif
1260  #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
1261                                  int iChannelID = pChannel->channelID();                                  int iChannelID = pChannel->channelID();
1262                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);                                  int *piFxSends = ::lscp_list_fxsends(m_pClient, iChannelID);
1263                                  for (int iFxSend = 0;                                  for (int iFxSend = 0;
# Line 1181  bool MainForm::saveSessionFile ( const Q Line 1281  bool MainForm::saveSessionFile ( const Q
1281                                                                  << " " << iAudioSrc                                                                  << " " << iAudioSrc
1282                                                                  << " " << piRouting[iAudioSrc] << endl;                                                                  << " " << piRouting[iAudioSrc] << endl;
1283                                                  }                                                  }
1284  #ifdef CONFIG_FXSEND_LEVEL                                          #ifdef CONFIG_FXSEND_LEVEL
1285                                                  ts << "SET FX_SEND LEVEL " << iChannel                                                  ts << "SET FX_SEND LEVEL " << iChannel
1286                                                          << " " << iFxSend                                                          << " " << iFxSend
1287                                                          << " " << pFxSendInfo->level << endl;                                                          << " " << pFxSendInfo->level << endl;
1288  #endif                                          #endif
1289                                          }       // Check for errors...                                          }       // Check for errors...
1290                                          else if (::lscp_client_get_errno(m_pClient)) {                                          else if (::lscp_client_get_errno(m_pClient)) {
1291                                                  appendMessagesClient("lscp_get_fxsend_info");                                                  appendMessagesClient("lscp_get_fxsend_info");
1292                                                  iErrors++;                                                  iErrors++;
1293                                          }                                          }
1294                                  }                                  }
1295  #endif                          #endif
1296                                  ts << endl;                                  ts << endl;
1297                          }                          }
1298                  }                  }
# Line 1417  void MainForm::editRemoveChannel (void) Line 1517  void MainForm::editRemoveChannel (void)
1517          if (m_pClient == NULL)          if (m_pClient == NULL)
1518                  return;                  return;
1519    
1520          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1521          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1522                  return;                  return;
1523    
# Line 1442  void MainForm::editRemoveChannel (void) Line 1542  void MainForm::editRemoveChannel (void)
1542          if (!pChannel->removeChannel())          if (!pChannel->removeChannel())
1543                  return;                  return;
1544    
         // Just delete the channel strip.  
         delete pChannelStrip;  
   
         // Do we auto-arrange?  
         if (m_pOptions && m_pOptions->bAutoArrange)  
                 channelsArrange();  
   
1545          // We'll be dirty, for sure...          // We'll be dirty, for sure...
1546          m_iDirtyCount++;          m_iDirtyCount++;
1547          stabilizeForm();  
1548            // Just delete the channel strip.
1549            destroyChannelStrip(pChannelStrip);
1550  }  }
1551    
1552    
# Line 1461  void MainForm::editSetupChannel (void) Line 1556  void MainForm::editSetupChannel (void)
1556          if (m_pClient == NULL)          if (m_pClient == NULL)
1557                  return;                  return;
1558    
1559          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1560          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1561                  return;                  return;
1562    
# Line 1476  void MainForm::editEditChannel (void) Line 1571  void MainForm::editEditChannel (void)
1571          if (m_pClient == NULL)          if (m_pClient == NULL)
1572                  return;                  return;
1573    
1574          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1575          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1576                  return;                  return;
1577    
# Line 1491  void MainForm::editResetChannel (void) Line 1586  void MainForm::editResetChannel (void)
1586          if (m_pClient == NULL)          if (m_pClient == NULL)
1587                  return;                  return;
1588    
1589          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1590          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1591                  return;                  return;
1592    
# Line 1509  void MainForm::editResetAllChannels (voi Line 1604  void MainForm::editResetAllChannels (voi
1604          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
1605          // for all channels out there...          // for all channels out there...
1606          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1607          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1608          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1609                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
1610                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1611                    if (pMdiSubWindow)
1612                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1613                  if (pChannelStrip)                  if (pChannelStrip)
1614                          pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1615          }          }
# Line 1614  void MainForm::viewOptions (void) Line 1712  void MainForm::viewOptions (void)
1712          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
1713          if (pOptionsForm) {          if (pOptionsForm) {
1714                  // Check out some initial nullities(tm)...                  // Check out some initial nullities(tm)...
1715                  ChannelStrip* pChannelStrip = activeChannelStrip();                  ChannelStrip *pChannelStrip = activeChannelStrip();
1716                  if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)                  if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
1717                          m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();                          m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
1718                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
# Line 1707  void MainForm::viewOptions (void) Line 1805  void MainForm::viewOptions (void)
1805  void MainForm::channelsArrange (void)  void MainForm::channelsArrange (void)
1806  {  {
1807          // Full width vertical tiling          // Full width vertical tiling
1808          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
1809          if (wlist.isEmpty())          if (wlist.isEmpty())
1810                  return;                  return;
1811    
1812          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1813          int y = 0;          int y = 0;
1814          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
1815                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
1816          /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
1817                          // Prevent flicker...                  if (pMdiSubWindow)
1818                          pChannelStrip->hide();                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1819                          pChannelStrip->showNormal();                  if (pChannelStrip) {
1820                  }   */                  /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1821                  pChannelStrip->adjustSize();                                  // Prevent flicker...
1822                  int iWidth  = m_pWorkspace->width();                                  pChannelStrip->hide();
1823                  if (iWidth < pChannelStrip->width())                                  pChannelStrip->showNormal();
1824                          iWidth = pChannelStrip->width();                          }   */
1825          //  int iHeight = pChannelStrip->height()                          pChannelStrip->adjustSize();
1826          //              + pChannelStrip->parentWidget()->baseSize().height();                          int iWidth  = m_pWorkspace->width();
1827                  int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();                          if (iWidth < pChannelStrip->width())
1828                  pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);                                  iWidth = pChannelStrip->width();
1829                  y += iHeight;                  //  int iHeight = pChannelStrip->height()
1830                    //              + pChannelStrip->parentWidget()->baseSize().height();
1831                            int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1832                            pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1833                            y += iHeight;
1834                    }
1835          }          }
1836          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1837    
# Line 1870  void MainForm::stabilizeForm (void) Line 1973  void MainForm::stabilizeForm (void)
1973          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1974    
1975          // Update the main menu state...          // Update the main menu state...
1976          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1977          bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);
1978          bool bHasChannel = (bHasClient && pChannelStrip != NULL);          bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1979            bool bHasChannels = (bHasClient && m_pWorkspace->subWindowList().count() > 0);
1980          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
1981          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
1982          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
# Line 1888  void MainForm::stabilizeForm (void) Line 1992  void MainForm::stabilizeForm (void)
1992          m_ui.editEditChannelAction->setEnabled(false);          m_ui.editEditChannelAction->setEnabled(false);
1993  #endif  #endif
1994          m_ui.editResetChannelAction->setEnabled(bHasChannel);          m_ui.editResetChannelAction->setEnabled(bHasChannel);
1995          m_ui.editResetAllChannelsAction->setEnabled(bHasChannel);          m_ui.editResetAllChannelsAction->setEnabled(bHasChannels);
1996          m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());          m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());
1997  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
1998          m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm          m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm
# Line 1900  void MainForm::stabilizeForm (void) Line 2004  void MainForm::stabilizeForm (void)
2004          m_ui.viewDevicesAction->setChecked(m_pDeviceForm          m_ui.viewDevicesAction->setChecked(m_pDeviceForm
2005                  && m_pDeviceForm->isVisible());                  && m_pDeviceForm->isVisible());
2006          m_ui.viewDevicesAction->setEnabled(bHasClient);          m_ui.viewDevicesAction->setEnabled(bHasClient);
2007          m_ui.channelsArrangeAction->setEnabled(bHasChannel);          m_ui.viewMidiDeviceStatusMenu->setEnabled(
2008                    DeviceStatusForm::getInstances().size() > 0);
2009            m_ui.channelsArrangeAction->setEnabled(bHasChannels);
2010    
2011  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
2012          // Toolbar widgets are also affected...          // Toolbar widgets are also affected...
# Line 1966  void MainForm::volumeChanged ( int iVolu Line 2072  void MainForm::volumeChanged ( int iVolu
2072    
2073    
2074  // Channel change receiver slot.  // Channel change receiver slot.
2075  void MainForm::channelStripChanged(ChannelStrip* pChannelStrip)  void MainForm::channelStripChanged ( ChannelStrip *pChannelStrip )
2076  {  {
2077          // Add this strip to the changed list...          // Add this strip to the changed list...
2078          if (!m_changedStrips.contains(pChannelStrip)) {          if (!m_changedStrips.contains(pChannelStrip)) {
# Line 2017  void MainForm::updateSession (void) Line 2123  void MainForm::updateSession (void)
2123                  m_pDeviceForm->refreshDevices();                  m_pDeviceForm->refreshDevices();
2124  }  }
2125    
2126  void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) {  
2127    void MainForm::updateAllChannelStrips ( bool bRemoveDeadStrips )
2128    {
2129          // Retrieve the current channel list.          // Retrieve the current channel list.
2130          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2131          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 2029  void MainForm::updateAllChannelStrips(bo Line 2137  void MainForm::updateAllChannelStrips(bo
2137          } else {          } else {
2138                  // Try to (re)create each channel.                  // Try to (re)create each channel.
2139                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
2140                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2141                          // Check if theres already a channel strip for this one...                          // Check if theres already a channel strip for this one...
2142                          if (!channelStrip(piChannelIDs[iChannel]))                          if (!channelStrip(piChannelIDs[iChannel]))
2143                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2144                  }                  }
   
2145                  // Do we auto-arrange?                  // Do we auto-arrange?
2146                  if (m_pOptions && m_pOptions->bAutoArrange)                  if (m_pOptions && m_pOptions->bAutoArrange)
2147                          channelsArrange();                          channelsArrange();
   
                 stabilizeForm();  
   
2148                  // remove dead channel strips                  // remove dead channel strips
2149                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2150                          for (int i = 0; channelStripAt(i); ++i) {                          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2151                                  ChannelStrip* pChannelStrip = channelStripAt(i);                          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2152                                  bool bExists = false;                                  ChannelStrip *pChannelStrip = NULL;
2153                                  for (int j = 0; piChannelIDs[j] >= 0; ++j) {                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2154                                          if (!pChannelStrip->channel()) break;                                  if (pMdiSubWindow)
2155                                          if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2156                                                  // strip exists, don't touch it                                  if (pChannelStrip) {
2157                                                  bExists = true;                                          bool bExists = false;
2158                                                  break;                                          for (int j = 0; piChannelIDs[j] >= 0; ++j) {
2159                                                    if (!pChannelStrip->channel())
2160                                                            break;
2161                                                    if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {
2162                                                            // strip exists, don't touch it
2163                                                            bExists = true;
2164                                                            break;
2165                                                    }
2166                                          }                                          }
2167                                            if (!bExists)
2168                                                    destroyChannelStrip(pChannelStrip);
2169                                  }                                  }
                                 if (!bExists) destroyChannelStrip(pChannelStrip);  
2170                          }                          }
2171                  }                  }
2172                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
2173          }          }
2174    
2175            stabilizeForm();
2176  }  }
2177    
2178    
2179  // Update the recent files list and menu.  // Update the recent files list and menu.
2180  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2181  {  {
# Line 2107  void MainForm::updateRecentFilesMenu (vo Line 2222  void MainForm::updateRecentFilesMenu (vo
2222  void MainForm::updateInstrumentNames (void)  void MainForm::updateInstrumentNames (void)
2223  {  {
2224          // Full channel list update...          // Full channel list update...
2225          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2226          if (wlist.isEmpty())          if (wlist.isEmpty())
2227                  return;                  return;
2228    
2229          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2230          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2231                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel);
2232                  if (pChannelStrip)                  if (pChannelStrip)
2233                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
# Line 2136  void MainForm::updateDisplayFont (void) Line 2251  void MainForm::updateDisplayFont (void)
2251                  return;                  return;
2252    
2253          // Full channel list update...          // Full channel list update...
2254          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2255          if (wlist.isEmpty())          if (wlist.isEmpty())
2256                  return;                  return;
2257    
2258          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2259          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2260                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2261                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2262                    if (pMdiSubWindow)
2263                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2264                  if (pChannelStrip)                  if (pChannelStrip)
2265                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2266          }          }
# Line 2154  void MainForm::updateDisplayFont (void) Line 2272  void MainForm::updateDisplayFont (void)
2272  void MainForm::updateDisplayEffect (void)  void MainForm::updateDisplayEffect (void)
2273  {  {
2274          // Full channel list update...          // Full channel list update...
2275          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2276          if (wlist.isEmpty())          if (wlist.isEmpty())
2277                  return;                  return;
2278    
2279          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2280          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2281                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2282                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2283                    if (pMdiSubWindow)
2284                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2285                  if (pChannelStrip)                  if (pChannelStrip)
2286                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2287          }          }
# Line 2182  void MainForm::updateMaxVolume (void) Line 2303  void MainForm::updateMaxVolume (void)
2303  #endif  #endif
2304    
2305          // Full channel list update...          // Full channel list update...
2306          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2307          if (wlist.isEmpty())          if (wlist.isEmpty())
2308                  return;                  return;
2309    
2310          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2311          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2312                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip *pChannelStrip = NULL;
2313                    QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2314                    if (pMdiSubWindow)
2315                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2316                  if (pChannelStrip)                  if (pChannelStrip)
2317                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
2318          }          }
# Line 2296  void MainForm::updateMessagesCapture (vo Line 2420  void MainForm::updateMessagesCapture (vo
2420  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
2421    
2422  // The channel strip creation executive.  // The channel strip creation executive.
2423  ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2424  {  {
2425          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == NULL || pChannel == NULL)
2426                  return NULL;                  return NULL;
# Line 2319  ChannelStrip* MainForm::createChannelStr Line 2443  ChannelStrip* MainForm::createChannelStr
2443          }          }
2444    
2445          // Add it to workspace...          // Add it to workspace...
2446          m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint);          m_pWorkspace->addSubWindow(pChannelStrip,
2447                    Qt::SubWindow | Qt::FramelessWindowHint);
2448    
2449          // Actual channel strip setup...          // Actual channel strip setup...
2450          pChannelStrip->setup(pChannel);          pChannelStrip->setup(pChannel);
2451    
2452          QObject::connect(pChannelStrip,          QObject::connect(pChannelStrip,
2453                  SIGNAL(channelChanged(ChannelStrip*)),                  SIGNAL(channelChanged(ChannelStrip *)),
2454                  SLOT(channelStripChanged(ChannelStrip*)));                  SLOT(channelStripChanged(ChannelStrip *)));
2455    
2456          // Now we show up us to the world.          // Now we show up us to the world.
2457          pChannelStrip->show();          pChannelStrip->show();
# Line 2338  ChannelStrip* MainForm::createChannelStr Line 2463  ChannelStrip* MainForm::createChannelStr
2463          return pChannelStrip;          return pChannelStrip;
2464  }  }
2465    
2466  void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) {  
2467    void MainForm::destroyChannelStrip ( ChannelStrip *pChannelStrip )
2468    {
2469            QMdiSubWindow *pMdiSubWindow
2470                    = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2471            if (pMdiSubWindow == NULL)
2472                    return;
2473    
2474          // Just delete the channel strip.          // Just delete the channel strip.
2475          delete pChannelStrip;          delete pChannelStrip;
2476            delete pMdiSubWindow;
2477    
2478          // Do we auto-arrange?          // Do we auto-arrange?
2479          if (m_pOptions && m_pOptions->bAutoArrange)          if (m_pOptions && m_pOptions->bAutoArrange)
# Line 2349  void MainForm::destroyChannelStrip(Chann Line 2482  void MainForm::destroyChannelStrip(Chann
2482          stabilizeForm();          stabilizeForm();
2483  }  }
2484    
2485    
2486  // Retrieve the active channel strip.  // Retrieve the active channel strip.
2487  ChannelStrip* MainForm::activeChannelStrip (void)  ChannelStrip *MainForm::activeChannelStrip (void)
2488  {  {
2489          return static_cast<ChannelStrip *> (m_pWorkspace->activeWindow());          QMdiSubWindow *pMdiSubWindow = m_pWorkspace->activeSubWindow();
2490            if (pMdiSubWindow)
2491                    return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2492            else
2493                    return NULL;
2494  }  }
2495    
2496    
2497  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2498  ChannelStrip* MainForm::channelStripAt ( int iChannel )  ChannelStrip *MainForm::channelStripAt ( int iChannel )
2499  {  {
2500          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return NULL;
2501    
2502          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2503          if (wlist.isEmpty())          if (wlist.isEmpty())
2504                  return NULL;                  return NULL;
2505    
2506          if (iChannel < 0 || iChannel >= wlist.size())          if (iChannel < 0 || iChannel >= wlist.size())
2507                  return NULL;                  return NULL;
2508    
2509          return dynamic_cast<ChannelStrip *> (wlist.at(iChannel));          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2510            if (pMdiSubWindow)
2511                    return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2512            else
2513                    return NULL;
2514  }  }
2515    
2516    
2517  // Retrieve a channel strip by sampler channel id.  // Retrieve a channel strip by sampler channel id.
2518  ChannelStrip* MainForm::channelStrip ( int iChannelID )  ChannelStrip *MainForm::channelStrip ( int iChannelID )
2519  {  {
2520          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2521          if (wlist.isEmpty())          if (wlist.isEmpty())
2522                  return NULL;                  return NULL;
2523    
2524          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2525                  ChannelStrip* pChannelStrip                  ChannelStrip *pChannelStrip = NULL;
2526                          = static_cast<ChannelStrip*> (wlist.at(iChannel));                  QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2527                    if (pMdiSubWindow)
2528                            pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2529                  if (pChannelStrip) {                  if (pChannelStrip) {
2530                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2531                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2401  void MainForm::channelsMenuAboutToShow ( Line 2545  void MainForm::channelsMenuAboutToShow (
2545          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction);
2546          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);          m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction);
2547    
2548          QWidgetList wlist = m_pWorkspace->windowList();          QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2549          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2550                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2551                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2552                          ChannelStrip* pChannelStrip                          ChannelStrip *pChannelStrip = NULL;
2553                                  = static_cast<ChannelStrip*> (wlist.at(iChannel));                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2554                            if (pMdiSubWindow)
2555                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2556                          if (pChannelStrip) {                          if (pChannelStrip) {
2557                                  QAction *pAction = m_ui.channelsMenu->addAction(                                  QAction *pAction = m_ui.channelsMenu->addAction(
2558                                          pChannelStrip->windowTitle(),                                          pChannelStrip->windowTitle(),
# Line 2428  void MainForm::channelsMenuActivated (vo Line 2574  void MainForm::channelsMenuActivated (vo
2574          if (pAction == NULL)          if (pAction == NULL)
2575                  return;                  return;
2576    
2577          ChannelStrip* pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
2578          if (pChannelStrip) {          if (pChannelStrip) {
2579                  pChannelStrip->showNormal();                  pChannelStrip->showNormal();
2580                  pChannelStrip->setFocus();                  pChannelStrip->setFocus();
# Line 2489  void MainForm::timerSlot (void) Line 2635  void MainForm::timerSlot (void)
2635                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {                          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {
2636                                  m_iTimerSlot = 0;                                  m_iTimerSlot = 0;
2637                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2638                                  QWidgetList wlist = m_pWorkspace->windowList();                                  QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList();
2639                                  for (int iChannel = 0;                                  for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) {
2640                                                  iChannel < (int) wlist.count(); iChannel++) {                                          ChannelStrip *pChannelStrip = NULL;
2641                                          ChannelStrip* pChannelStrip                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel);
2642                                                  = (ChannelStrip*) wlist.at(iChannel);                                          if (pMdiSubWindow)
2643                                                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2644                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
2645                                                  pChannelStrip->updateChannelUsage();                                                  pChannelStrip->updateChannelUsage();
2646                                  }                                  }
# Line 2545  void MainForm::startServer (void) Line 2692  void MainForm::startServer (void)
2692    
2693          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2694  //      if (m_pOptions->bStdoutCapture) {  //      if (m_pOptions->bStdoutCapture) {
 #if QT_VERSION >= 0x040200  
2695                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);                  m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
 #endif  
2696                  QObject::connect(m_pServer,                  QObject::connect(m_pServer,
2697                          SIGNAL(readyReadStandardOutput()),                          SIGNAL(readyReadStandardOutput()),
2698                          SLOT(readServerStdout()));                          SLOT(readServerStdout()));
# Line 2612  void MainForm::stopServer (bool bInterac Line 2757  void MainForm::stopServer (bool bInterac
2757          if (m_pServer && bForceServerStop) {          if (m_pServer && bForceServerStop) {
2758                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2759                  if (m_pServer->state() == QProcess::Running) {                  if (m_pServer->state() == QProcess::Running) {
2760  #if defined(WIN32)                  #if defined(WIN32)
2761                          // Try harder...                          // Try harder...
2762                          m_pServer->kill();                          m_pServer->kill();
2763  #else                  #else
2764                          // Try softly...                          // Try softly...
2765                          m_pServer->terminate();                          m_pServer->terminate();
2766  #endif                  #endif
2767                  }                  }
2768          }       // Do final processing anyway.          }       // Do final processing anyway.
2769          else processServerExit();          else processServerExit();
# Line 2688  lscp_status_t qsampler_client_callback ( Line 2833  lscp_status_t qsampler_client_callback (
2833          // as this is run under some other thread context.          // as this is run under some other thread context.
2834          // A custom event must be posted here...          // A custom event must be posted here...
2835          QApplication::postEvent(pMainForm,          QApplication::postEvent(pMainForm,
2836                  new CustomEvent(event, pchData, cchData));                  new LscpEvent(event, pchData, cchData));
2837    
2838          return LSCP_OK;          return LSCP_OK;
2839  }  }
# Line 2847  void MainForm::stopClient (void) Line 2992  void MainForm::stopClient (void)
2992    
2993    
2994  // Channel strip activation/selection.  // Channel strip activation/selection.
2995  void MainForm::activateStrip ( QWidget *pWidget )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
2996  {  {
2997          ChannelStrip *pChannelStrip          ChannelStrip *pChannelStrip = NULL;
2998                  = static_cast<ChannelStrip *> (pWidget);          if (pMdiSubWindow)
2999                    pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3000          if (pChannelStrip)          if (pChannelStrip)
3001                  pChannelStrip->setSelected(true);                  pChannelStrip->setSelected(true);
3002    

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

  ViewVC Help
Powered by ViewVC