/[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 2978 by capela, Mon Aug 15 19:10:16 2016 UTC revision 3555 by capela, Tue Aug 13 10:19:32 2019 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007,2008,2015 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 58  Line 58 
58  #include <QTimer>  #include <QTimer>
59  #include <QDateTime>  #include <QDateTime>
60    
61  #if QT_VERSION >= 0x050000  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
62  #include <QMimeData>  #include <QMimeData>
63  #endif  #endif
64    
65  #if QT_VERSION < 0x040500  #if QT_VERSION < QT_VERSION_CHECK(4, 5, 0)
66  namespace Qt {  namespace Qt {
67  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
68  }  }
69  #endif  #endif
70    
 #ifdef HAVE_SIGNAL_H  
 #include <signal.h>  
 #endif  
   
71  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
72  #include <gig.h>  #include <gig.h>
73  #endif  #endif
# Line 91  static inline long lroundf ( float x ) Line 87  static inline long lroundf ( float x )
87    
88    
89  // All winsock apps needs this.  // All winsock apps needs this.
90  #if defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
91  static WSADATA _wsaData;  static WSADATA _wsaData;
92    #undef HAVE_SIGNAL_H
93  #endif  #endif
94    
95    
# Line 103  static WSADATA _wsaData; Line 100  static WSADATA _wsaData;
100    
101  #include <QSocketNotifier>  #include <QSocketNotifier>
102    
103    #include <unistd.h>
104  #include <sys/types.h>  #include <sys/types.h>
105  #include <sys/socket.h>  #include <sys/socket.h>
   
106  #include <signal.h>  #include <signal.h>
107    
108  // File descriptor for SIGUSR1 notifier.  // File descriptor for SIGUSR1 notifier.
109  static int g_fdUsr1[2];  static int g_fdSigusr1[2] = { -1, -1 };
110    
111  // Unix SIGUSR1 signal handler.  // Unix SIGUSR1 signal handler.
112  static void qsampler_sigusr1_handler ( int /* signo */ )  static void qsampler_sigusr1_handler ( int /* signo */ )
113  {  {
114          char c = 1;          char c = 1;
115    
116          (::write(g_fdUsr1[0], &c, sizeof(c)) > 0);          (::write(g_fdSigusr1[0], &c, sizeof(c)) > 0);
117    }
118    
119    // File descriptor for SIGTERM notifier.
120    static int g_fdSigterm[2] = { -1, -1 };
121    
122    // Unix SIGTERM signal handler.
123    static void qsampler_sigterm_handler ( int /* signo */ )
124    {
125            char c = 1;
126    
127            (::write(g_fdSigterm[0], &c, sizeof(c)) > 0);
128  }  }
129    
130  #endif  // HAVE_SIGNAL_H  #endif  // HAVE_SIGNAL_H
131    
132    
133  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
134  // qsampler -- namespace  // QSampler -- namespace
135    
136    
137  namespace QSampler {  namespace QSampler {
# Line 143  namespace QSampler { Line 151  namespace QSampler {
151    
152    
153  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
154  // LscpEvent -- specialty for LSCP callback comunication.  // QSampler::LscpEvent -- specialty for LSCP callback comunication.
   
155    
156  class LscpEvent : public QEvent  class LscpEvent : public QEvent
157  {  {
# Line 159  public: Line 166  public:
166          }          }
167    
168          // Accessors.          // Accessors.
169          lscp_event_t event() { return m_event; }          lscp_event_t  event() { return m_event; }
170          QString&     data()  { return m_data;  }          const QString& data() { return m_data;  }
171    
172  private:  private:
173    
# Line 172  private: Line 179  private:
179    
180    
181  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
182  // qsamplerMainForm -- Main window form implementation.  // QSampler::Workspace -- Main window workspace (MDI Area) decl.
183    
184    class Workspace : public QMdiArea
185    {
186    public:
187    
188            Workspace(MainForm *pMainForm) : QMdiArea(pMainForm) {}
189    
190    protected:
191    
192            void resizeEvent(QResizeEvent *)
193            {
194                    MainForm *pMainForm = static_cast<MainForm *> (parentWidget());
195                    if (pMainForm)
196                            pMainForm->channelsArrangeAuto();
197            }
198    };
199    
200    
201    //-------------------------------------------------------------------------
202    // QSampler::MainForm -- Main window form implementation.
203    
204  // Kind of singleton reference.  // Kind of singleton reference.
205  MainForm* MainForm::g_pMainForm = NULL;  MainForm *MainForm::g_pMainForm = nullptr;
206    
207  MainForm::MainForm ( QWidget *pParent )  MainForm::MainForm ( QWidget *pParent )
208          : QMainWindow(pParent)          : QMainWindow(pParent)
# Line 186  MainForm::MainForm ( QWidget *pParent ) Line 213  MainForm::MainForm ( QWidget *pParent )
213          g_pMainForm = this;          g_pMainForm = this;
214    
215          // Initialize some pointer references.          // Initialize some pointer references.
216          m_pOptions = NULL;          m_pOptions = nullptr;
217    
218          // All child forms are to be created later, not earlier than setup.          // All child forms are to be created later, not earlier than setup.
219          m_pMessages = NULL;          m_pMessages = nullptr;
220          m_pInstrumentListForm = NULL;          m_pInstrumentListForm = nullptr;
221          m_pDeviceForm = NULL;          m_pDeviceForm = nullptr;
222    
223          // We'll start clean.          // We'll start clean.
224          m_iUntitled   = 0;          m_iUntitled   = 0;
225          m_iDirtySetup = 0;          m_iDirtySetup = 0;
226          m_iDirtyCount = 0;          m_iDirtyCount = 0;
227    
228          m_pServer = NULL;          m_pServer = nullptr;
229          m_pClient = NULL;          m_pClient = nullptr;
230    
231          m_iStartDelay = 0;          m_iStartDelay = 0;
232          m_iTimerDelay = 0;          m_iTimerDelay = 0;
# Line 214  MainForm::MainForm ( QWidget *pParent ) Line 241  MainForm::MainForm ( QWidget *pParent )
241          // LADISH Level 1 suport.          // LADISH Level 1 suport.
242    
243          // Initialize file descriptors for SIGUSR1 socket notifier.          // Initialize file descriptors for SIGUSR1 socket notifier.
244          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1);          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigusr1);
245          m_pUsr1Notifier          m_pSigusr1Notifier
246                  = new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this);                  = new QSocketNotifier(g_fdSigusr1[1], QSocketNotifier::Read, this);
247    
248          QObject::connect(m_pUsr1Notifier,          QObject::connect(m_pSigusr1Notifier,
249                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
250                  SLOT(handle_sigusr1()));                  SLOT(handle_sigusr1()));
251    
252          // Install SIGUSR1 signal handler.          // Install SIGUSR1 signal handler.
253      struct sigaction usr1;          struct sigaction sigusr1;
254      usr1.sa_handler = qsampler_sigusr1_handler;          sigusr1.sa_handler = qsampler_sigusr1_handler;
255      sigemptyset(&usr1.sa_mask);          sigemptyset(&sigusr1.sa_mask);
256      usr1.sa_flags = 0;          sigusr1.sa_flags = 0;
257      usr1.sa_flags |= SA_RESTART;          sigusr1.sa_flags |= SA_RESTART;
258      ::sigaction(SIGUSR1, &usr1, NULL);          ::sigaction(SIGUSR1, &sigusr1, nullptr);
259    
260            // Initialize file descriptors for SIGTERM socket notifier.
261            ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);
262            m_pSigtermNotifier
263                    = new QSocketNotifier(g_fdSigterm[1], QSocketNotifier::Read, this);
264    
265            QObject::connect(m_pSigtermNotifier,
266                    SIGNAL(activated(int)),
267                    SLOT(handle_sigterm()));
268    
269            // Install SIGTERM signal handler.
270            struct sigaction sigterm;
271            sigterm.sa_handler = qsampler_sigterm_handler;
272            sigemptyset(&sigterm.sa_mask);
273            sigterm.sa_flags = 0;
274            sigterm.sa_flags |= SA_RESTART;
275            ::sigaction(SIGTERM, &sigterm, nullptr);
276            ::sigaction(SIGQUIT, &sigterm, nullptr);
277    
278            // Ignore SIGHUP/SIGINT signals.
279            ::signal(SIGHUP, SIG_IGN);
280            ::signal(SIGINT, SIG_IGN);
281    
282  #else   // HAVE_SIGNAL_H  #else   // HAVE_SIGNAL_H
283    
284          m_pUsr1Notifier = NULL;          m_pSigusr1Notifier = nullptr;
285            m_pSigtermNotifier = nullptr;
286                    
287  #endif  // !HAVE_SIGNAL_H  #endif  // !HAVE_SIGNAL_H
288    
# Line 270  MainForm::MainForm ( QWidget *pParent ) Line 320  MainForm::MainForm ( QWidget *pParent )
320  #endif  #endif
321    
322          // Make it an MDI workspace.          // Make it an MDI workspace.
323          m_pWorkspace = new QMdiArea(this);          m_pWorkspace = new Workspace(this);
324          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
325          m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);          m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
326          // Set the activation connection.          // Set the activation connection.
# Line 305  MainForm::MainForm ( QWidget *pParent ) Line 355  MainForm::MainForm ( QWidget *pParent )
355          m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;          m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
356          statusBar()->addWidget(pLabel);          statusBar()->addWidget(pLabel);
357    
358  #if defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
359          WSAStartup(MAKEWORD(1, 1), &_wsaData);          WSAStartup(MAKEWORD(1, 1), &_wsaData);
360  #endif  #endif
361    
# Line 406  MainForm::~MainForm() Line 456  MainForm::~MainForm()
456          // Do final processing anyway.          // Do final processing anyway.
457          processServerExit();          processServerExit();
458    
459  #if defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
460          WSACleanup();          WSACleanup();
461  #endif  #endif
462    
463  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
464          if (m_pUsr1Notifier)          if (m_pSigusr1Notifier)
465                  delete m_pUsr1Notifier;                  delete m_pSigusr1Notifier;
466            if (m_pSigtermNotifier)
467                    delete m_pSigtermNotifier;
468  #endif  #endif
469    
470          // Finally drop any widgets around...          // Finally drop any widgets around...
# Line 441  MainForm::~MainForm() Line 493  MainForm::~MainForm()
493  #endif  #endif
494    
495          // Pseudo-singleton reference shut-down.          // Pseudo-singleton reference shut-down.
496          g_pMainForm = NULL;          g_pMainForm = nullptr;
497  }  }
498    
499    
# Line 578  void MainForm::closeEvent ( QCloseEvent Line 630  void MainForm::closeEvent ( QCloseEvent
630  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
631  {  {
632          // Accept external drags only...          // Accept external drags only...
633          if (pDragEnterEvent->source() == NULL          if (pDragEnterEvent->source() == nullptr
634                  && pDragEnterEvent->mimeData()->hasUrls()) {                  && pDragEnterEvent->mimeData()->hasUrls()) {
635                  pDragEnterEvent->accept();                  pDragEnterEvent->accept();
636          } else {          } else {
# Line 602  void MainForm::dropEvent ( QDropEvent *p Line 654  void MainForm::dropEvent ( QDropEvent *p
654                          if (QFileInfo(sPath).exists()) {                          if (QFileInfo(sPath).exists()) {
655                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
656                                  Channel *pChannel = new Channel();                                  Channel *pChannel = new Channel();
657                                  if (pChannel == NULL)                                  if (pChannel == nullptr)
658                                          return;                                          return;
659                                  // Start setting the instrument filename...                                  // Start setting the instrument filename...
660                                  pChannel->setInstrument(sPath, 0);                                  pChannel->setInstrument(sPath, 0);
# Line 695  void MainForm::customEvent ( QEvent* pEv Line 747  void MainForm::customEvent ( QEvent* pEv
747  }  }
748    
749    
750  // Window resize event handler.  // LADISH Level 1 -- SIGUSR1 signal handler.
751  void MainForm::resizeEvent ( QResizeEvent * )  void MainForm::handle_sigusr1 (void)
752  {  {
753          if (m_pOptions->bAutoArrange)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
754                  channelsArrange();  
755            char c;
756    
757            if (::read(g_fdSigusr1[1], &c, sizeof(c)) > 0)
758                    saveSession(false);
759    
760    #endif
761  }  }
762    
763    
764  // LADISH Level 1 -- SIGUSR1 signal handler.  void MainForm::handle_sigterm (void)
 void MainForm::handle_sigusr1 (void)  
765  {  {
766  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
767    
768          char c;          char c;
769    
770          if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0)          if (::read(g_fdSigterm[1], &c, sizeof(c)) > 0)
771                  saveSession(false);                  close();
772    
773  #endif  #endif
774  }  }
# Line 742  void MainForm::contextMenuEvent( QContex Line 799  void MainForm::contextMenuEvent( QContex
799    
800    
801  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
802  // qsamplerMainForm -- Brainless public property accessors.  // QSampler::MainForm -- Brainless public property accessors.
803    
804  // The global options settings property.  // The global options settings property.
805  Options *MainForm::options (void) const  Options *MainForm::options (void) const
# Line 766  MainForm *MainForm::getInstance (void) Line 823  MainForm *MainForm::getInstance (void)
823    
824    
825  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
826  // qsamplerMainForm -- Session file stuff.  // QSampler::MainForm -- Session file stuff.
827    
828  // Format the displayable session filename.  // Format the displayable session filename.
829  QString MainForm::sessionName ( const QString& sFilename )  QString MainForm::sessionName ( const QString& sFilename )
# Line 795  bool MainForm::newSession (void) Line 852  bool MainForm::newSession (void)
852          m_iUntitled++;          m_iUntitled++;
853    
854          // Stabilize form.          // Stabilize form.
855          m_sFilename = QString::null;          m_sFilename = QString();
856          m_iDirtyCount = 0;          m_iDirtyCount = 0;
857          appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename)));          appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename)));
858          stabilizeForm();          stabilizeForm();
# Line 807  bool MainForm::newSession (void) Line 864  bool MainForm::newSession (void)
864  // Open an existing sampler session.  // Open an existing sampler session.
865  bool MainForm::openSession (void)  bool MainForm::openSession (void)
866  {  {
867          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
868                  return false;                  return false;
869    
870          // Ask for the filename to open...          // Ask for the filename to open...
# Line 833  bool MainForm::openSession (void) Line 890  bool MainForm::openSession (void)
890  // Save current sampler session with another name.  // Save current sampler session with another name.
891  bool MainForm::saveSession ( bool bPrompt )  bool MainForm::saveSession ( bool bPrompt )
892  {  {
893          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
894                  return false;                  return false;
895    
896          QString sFilename = m_sFilename;          QString sFilename = m_sFilename;
# Line 855  bool MainForm::saveSession ( bool bPromp Line 912  bool MainForm::saveSession ( bool bPromp
912                  // Enforce .lscp extension...                  // Enforce .lscp extension...
913                  if (QFileInfo(sFilename).suffix().isEmpty())                  if (QFileInfo(sFilename).suffix().isEmpty())
914                          sFilename += ".lscp";                          sFilename += ".lscp";
915            #if 0
916                  // Check if already exists...                  // Check if already exists...
917                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
918                          if (QMessageBox::warning(this,                          if (QMessageBox::warning(this,
# Line 867  bool MainForm::saveSession ( bool bPromp Line 925  bool MainForm::saveSession ( bool bPromp
925                                  == QMessageBox::No)                                  == QMessageBox::No)
926                                  return false;                                  return false;
927                  }                  }
928            #endif
929          }          }
930    
931          // Save it right away.          // Save it right away.
# Line 909  bool MainForm::closeSession ( bool bForc Line 968  bool MainForm::closeSession ( bool bForc
968                          = m_pWorkspace->subWindowList();                          = m_pWorkspace->subWindowList();
969                  const int iStripCount = wlist.count();                  const int iStripCount = wlist.count();
970                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
971                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip = nullptr;
972                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
973                          if (pMdiSubWindow)                          if (pMdiSubWindow)
974                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 934  bool MainForm::closeSession ( bool bForc Line 993  bool MainForm::closeSession ( bool bForc
993  // Load a session from specific file path.  // Load a session from specific file path.
994  bool MainForm::loadSessionFile ( const QString& sFilename )  bool MainForm::loadSessionFile ( const QString& sFilename )
995  {  {
996          if (m_pClient == NULL)          if (m_pClient == nullptr)
997                  return false;                  return false;
998    
999          // Open and read from real file.          // Open and read from real file.
# Line 1010  bool MainForm::loadSessionFile ( const Q Line 1069  bool MainForm::loadSessionFile ( const Q
1069  // Save current session to specific file path.  // Save current session to specific file path.
1070  bool MainForm::saveSessionFile ( const QString& sFilename )  bool MainForm::saveSessionFile ( const QString& sFilename )
1071  {  {
1072          if (m_pClient == NULL)          if (m_pClient == nullptr)
1073                  return false;                  return false;
1074    
1075          // Check whether server is apparently OK...          // Check whether server is apparently OK...
# Line 1035  bool MainForm::saveSessionFile ( const Q Line 1094  bool MainForm::saveSessionFile ( const Q
1094          int iErrors = 0;          int iErrors = 0;
1095          QTextStream ts(&file);          QTextStream ts(&file);
1096          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
1097          ts << "# " << tr("Version")          ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl;
1098          << ": " QSAMPLER_VERSION << endl;  //      ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl;
         ts << "# " << tr("Build")  
         << ": " __DATE__ " " __TIME__ << endl;  
1099          ts << "#"  << endl;          ts << "#"  << endl;
1100          ts << "# " << tr("File")          ts << "# " << tr("File")
1101          << ": " << QFileInfo(sFilename).fileName() << endl;          << ": " << QFileInfo(sFilename).fileName() << endl;
# Line 1051  bool MainForm::saveSessionFile ( const Q Line 1108  bool MainForm::saveSessionFile ( const Q
1108          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
1109          // will be loaded from a complete initialized server...          // will be loaded from a complete initialized server...
1110          int *piDeviceIDs;          int *piDeviceIDs;
1111          int  iDevice;          int  i, iDevice;
1112          ts << "RESET" << endl;          ts << "RESET" << endl;
1113    
1114          // Audio device mapping.          // Audio device mapping.
1115          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap; iDevice = 0;
1116          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);
1117          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
1118                  ts << endl;                  Device device(Device::Audio, piDeviceIDs[i]);
1119                  Device device(Device::Audio, piDeviceIDs[iDevice]);                  // Avoid plug-in driver devices...
1120                    if (device.driverName().toUpper() == "PLUGIN")
1121                            continue;
1122                  // Audio device specification...                  // Audio device specification...
1123                    ts << endl;
1124                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1125                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
1126                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
# Line 1091  bool MainForm::saveSessionFile ( const Q Line 1151  bool MainForm::saveSessionFile ( const Q
1151                          iPort++;                          iPort++;
1152                  }                  }
1153                  // Audio device index/id mapping.                  // Audio device index/id mapping.
1154                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap.insert(device.deviceID(), iDevice++);
1155                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1156                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1157          }          }
1158    
1159          // MIDI device mapping.          // MIDI device mapping.
1160          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap; iDevice = 0;
1161          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);
1162          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
1163                  ts << endl;                  Device device(Device::Midi, piDeviceIDs[i]);
1164                  Device device(Device::Midi, piDeviceIDs[iDevice]);                  // Avoid plug-in driver devices...
1165                    if (device.driverName().toUpper() == "PLUGIN")
1166                            continue;
1167                  // MIDI device specification...                  // MIDI device specification...
1168                    ts << endl;
1169                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1170                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
1171                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
# Line 1133  bool MainForm::saveSessionFile ( const Q Line 1196  bool MainForm::saveSessionFile ( const Q
1196                          iPort++;                          iPort++;
1197                  }                  }
1198                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
1199                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap.insert(device.deviceID(), iDevice++);
1200                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1201                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1202          }          }
# Line 1196  bool MainForm::saveSessionFile ( const Q Line 1259  bool MainForm::saveSessionFile ( const Q
1259                  }                  }
1260                  ts << endl;                  ts << endl;
1261                  // Check for errors...                  // Check for errors...
1262                  if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) {                  if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) {
1263                          appendMessagesClient("lscp_list_midi_instruments");                          appendMessagesClient("lscp_list_midi_instruments");
1264                          iErrors++;                          iErrors++;
1265                  }                  }
1266                  // MIDI strument index/id mapping.                  // MIDI strument index/id mapping.
1267                  midiInstrumentMap[iMidiMap] = iMap;                  midiInstrumentMap.insert(iMidiMap, iMap);
1268          }          }
1269          // Check for errors...          // Check for errors...
1270          if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {          if (piMaps == nullptr && ::lscp_client_get_errno(m_pClient)) {
1271                  appendMessagesClient("lscp_list_midi_instrument_maps");                  appendMessagesClient("lscp_list_midi_instrument_maps");
1272                  iErrors++;                  iErrors++;
1273          }          }
1274  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1275    
1276          // Sampler channel mapping.          // Sampler channel mapping...
1277            int iChannelID = 0;
1278          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1279                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1280          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
1281          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
1282                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
1283                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
1284                  if (pMdiSubWindow)                  if (pMdiSubWindow)
1285                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
1286                  if (pChannelStrip) {                  if (pChannelStrip) {
1287                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1288                          if (pChannel) {                          if (pChannel) {
1289                                  const int iChannelID = pChannel->channelID();                                  // Avoid "artifial" plug-in devices...
1290                                    const int iAudioDevice = pChannel->audioDevice();
1291                                    if (!audioDeviceMap.contains(iAudioDevice))
1292                                            continue;
1293                                    const int iMidiDevice = pChannel->midiDevice();
1294                                    if (!midiDeviceMap.contains(iMidiDevice))
1295                                            continue;
1296                                    // Go for regular, canonical devices...
1297                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;
1298                                  ts << "ADD CHANNEL" << endl;                                  ts << "ADD CHANNEL" << endl;
1299                                  if (audioDeviceMap.isEmpty()) {                                  if (audioDeviceMap.isEmpty()) {
# Line 1230  bool MainForm::saveSessionFile ( const Q Line 1301  bool MainForm::saveSessionFile ( const Q
1301                                                  << " " << pChannel->audioDriver() << endl;                                                  << " " << pChannel->audioDriver() << endl;
1302                                  } else {                                  } else {
1303                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID
1304                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;                                                  << " " << audioDeviceMap.value(iAudioDevice) << endl;
1305                                  }                                  }
1306                                  if (midiDeviceMap.isEmpty()) {                                  if (midiDeviceMap.isEmpty()) {
1307                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID
1308                                                  << " " << pChannel->midiDriver() << endl;                                                  << " " << pChannel->midiDriver() << endl;
1309                                  } else {                                  } else {
1310                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID
1311                                                  << " " << midiDeviceMap[pChannel->midiDevice()] << endl;                                                  << " " << midiDeviceMap.value(iMidiDevice) << endl;
1312                                  }                                  }
1313                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID
1314                                          << " " << pChannel->midiPort() << endl;                                          << " " << pChannel->midiPort() << endl;
# Line 1268  bool MainForm::saveSessionFile ( const Q Line 1339  bool MainForm::saveSessionFile ( const Q
1339                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1340                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;
1341                          #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1342                                  if (pChannel->midiMap() >= 0) {                                  const int iMidiMap = pChannel->midiMap();
1343                                    if (midiInstrumentMap.contains(iMidiMap)) {
1344                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID
1345                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap.value(iMidiMap) << endl;
1346                                  }                                  }
1347                          #endif                          #endif
1348                          #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
# Line 1309  bool MainForm::saveSessionFile ( const Q Line 1381  bool MainForm::saveSessionFile ( const Q
1381                                  }                                  }
1382                          #endif                          #endif
1383                                  ts << endl;                                  ts << endl;
1384                                    // Go for next channel...
1385                                    ++iChannelID;
1386                          }                          }
1387                  }                  }
1388                  // Try to keep it snappy :)                  // Try to keep it snappy :)
# Line 1360  void MainForm::sessionDirty (void) Line 1434  void MainForm::sessionDirty (void)
1434    
1435    
1436  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1437  // qsamplerMainForm -- File Action slots.  // QSampler::MainForm -- File Action slots.
1438    
1439  // Create a new sampler session.  // Create a new sampler session.
1440  void MainForm::fileNew (void)  void MainForm::fileNew (void)
# Line 1414  void MainForm::fileSaveAs (void) Line 1488  void MainForm::fileSaveAs (void)
1488  // Reset the sampler instance.  // Reset the sampler instance.
1489  void MainForm::fileReset (void)  void MainForm::fileReset (void)
1490  {  {
1491          if (m_pClient == NULL)          if (m_pClient == nullptr)
1492                  return;                  return;
1493    
1494          // Ask user whether he/she want's an internal sampler reset...          // Ask user whether he/she want's an internal sampler reset...
# Line 1470  void MainForm::fileReset (void) Line 1544  void MainForm::fileReset (void)
1544  // Restart the client/server instance.  // Restart the client/server instance.
1545  void MainForm::fileRestart (void)  void MainForm::fileRestart (void)
1546  {  {
1547          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1548                  return;                  return;
1549    
1550          bool bRestart = true;          bool bRestart = true;
# Line 1526  void MainForm::fileExit (void) Line 1600  void MainForm::fileExit (void)
1600    
1601    
1602  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1603  // qsamplerMainForm -- Edit Action slots.  // QSampler::MainForm -- Edit Action slots.
1604    
1605  // Add a new sampler channel.  // Add a new sampler channel.
1606  void MainForm::editAddChannel (void)  void MainForm::editAddChannel (void)
# Line 1538  void MainForm::editAddChannel (void) Line 1612  void MainForm::editAddChannel (void)
1612    
1613  void MainForm::addChannelStrip (void)  void MainForm::addChannelStrip (void)
1614  {  {
1615          if (m_pClient == NULL)          if (m_pClient == nullptr)
1616                  return;                  return;
1617    
1618          // Just create the channel instance...          // Just create the channel instance...
1619          Channel *pChannel = new Channel();          Channel *pChannel = new Channel();
1620          if (pChannel == NULL)          if (pChannel == nullptr)
1621                  return;                  return;
1622    
1623          // Before we show it up, may be we'll          // Before we show it up, may be we'll
# Line 1561  void MainForm::addChannelStrip (void) Line 1635  void MainForm::addChannelStrip (void)
1635          }          }
1636    
1637          // Do we auto-arrange?          // Do we auto-arrange?
1638          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
1639    
1640          // Make that an overall update.          // Make that an overall update.
1641          m_iDirtyCount++;          m_iDirtyCount++;
# Line 1580  void MainForm::editRemoveChannel (void) Line 1653  void MainForm::editRemoveChannel (void)
1653    
1654  void MainForm::removeChannelStrip (void)  void MainForm::removeChannelStrip (void)
1655  {  {
1656          if (m_pClient == NULL)          if (m_pClient == nullptr)
1657                  return;                  return;
1658    
1659          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1660          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1661                  return;                  return;
1662    
1663          Channel *pChannel = pChannelStrip->channel();          Channel *pChannel = pChannelStrip->channel();
1664          if (pChannel == NULL)          if (pChannel == nullptr)
1665                  return;                  return;
1666    
1667          // Prompt user if he/she's sure about this...          // Prompt user if he/she's sure about this...
# Line 1636  void MainForm::removeChannelStrip (void) Line 1709  void MainForm::removeChannelStrip (void)
1709  // Setup current sampler channel.  // Setup current sampler channel.
1710  void MainForm::editSetupChannel (void)  void MainForm::editSetupChannel (void)
1711  {  {
1712          if (m_pClient == NULL)          if (m_pClient == nullptr)
1713                  return;                  return;
1714    
1715          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1716          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1717                  return;                  return;
1718    
1719          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1651  void MainForm::editSetupChannel (void) Line 1724  void MainForm::editSetupChannel (void)
1724  // Edit current sampler channel.  // Edit current sampler channel.
1725  void MainForm::editEditChannel (void)  void MainForm::editEditChannel (void)
1726  {  {
1727          if (m_pClient == NULL)          if (m_pClient == nullptr)
1728                  return;                  return;
1729    
1730          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1731          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1732                  return;                  return;
1733    
1734          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1666  void MainForm::editEditChannel (void) Line 1739  void MainForm::editEditChannel (void)
1739  // Reset current sampler channel.  // Reset current sampler channel.
1740  void MainForm::editResetChannel (void)  void MainForm::editResetChannel (void)
1741  {  {
1742          if (m_pClient == NULL)          if (m_pClient == nullptr)
1743                  return;                  return;
1744    
1745          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1746          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1747                  return;                  return;
1748    
1749          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1681  void MainForm::editResetChannel (void) Line 1754  void MainForm::editResetChannel (void)
1754  // Reset all sampler channels.  // Reset all sampler channels.
1755  void MainForm::editResetAllChannels (void)  void MainForm::editResetAllChannels (void)
1756  {  {
1757          if (m_pClient == NULL)          if (m_pClient == nullptr)
1758                  return;                  return;
1759    
1760          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
# Line 1691  void MainForm::editResetAllChannels (voi Line 1764  void MainForm::editResetAllChannels (voi
1764                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1765          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
1766          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
1767                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
1768                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
1769                  if (pMdiSubWindow)                  if (pMdiSubWindow)
1770                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 1703  void MainForm::editResetAllChannels (voi Line 1776  void MainForm::editResetAllChannels (voi
1776    
1777    
1778  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1779  // qsamplerMainForm -- View Action slots.  // QSampler::MainForm -- View Action slots.
1780    
1781  // Show/hide the main program window menubar.  // Show/hide the main program window menubar.
1782  void MainForm::viewMenubar ( bool bOn )  void MainForm::viewMenubar ( bool bOn )
# Line 1753  void MainForm::viewMessages ( bool bOn ) Line 1826  void MainForm::viewMessages ( bool bOn )
1826  // Show/hide the MIDI instrument list-view form.  // Show/hide the MIDI instrument list-view form.
1827  void MainForm::viewInstruments (void)  void MainForm::viewInstruments (void)
1828  {  {
1829          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1830                  return;                  return;
1831    
1832          if (m_pInstrumentListForm) {          if (m_pInstrumentListForm) {
# Line 1772  void MainForm::viewInstruments (void) Line 1845  void MainForm::viewInstruments (void)
1845  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1846  void MainForm::viewDevices (void)  void MainForm::viewDevices (void)
1847  {  {
1848          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1849                  return;                  return;
1850    
1851          if (m_pDeviceForm) {          if (m_pDeviceForm) {
# Line 1791  void MainForm::viewDevices (void) Line 1864  void MainForm::viewDevices (void)
1864  // Show options dialog.  // Show options dialog.
1865  void MainForm::viewOptions (void)  void MainForm::viewOptions (void)
1866  {  {
1867          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1868                  return;                  return;
1869    
1870          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
# Line 1884  void MainForm::viewOptions (void) Line 1957  void MainForm::viewOptions (void)
1957    
1958    
1959  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1960  // qsamplerMainForm -- Channels action slots.  // QSampler::MainForm -- Channels action slots.
1961    
1962  // Arrange channel strips.  // Arrange channel strips.
1963  void MainForm::channelsArrange (void)  void MainForm::channelsArrange (void)
# Line 1919  void MainForm::channelsArrange (void) Line 1992  void MainForm::channelsArrange (void)
1992  // Auto-arrange channel strips.  // Auto-arrange channel strips.
1993  void MainForm::channelsAutoArrange ( bool bOn )  void MainForm::channelsAutoArrange ( bool bOn )
1994  {  {
1995          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1996                  return;                  return;
1997    
1998          // Toggle the auto-arrange flag.          // Toggle the auto-arrange flag.
1999          m_pOptions->bAutoArrange = bOn;          m_pOptions->bAutoArrange = bOn;
2000    
2001          // If on, update whole workspace...          // If on, update whole workspace...
2002          if (m_pOptions->bAutoArrange)          channelsArrangeAuto();
2003    }
2004    
2005    
2006    void MainForm::channelsArrangeAuto (void)
2007    {
2008            if (m_pOptions && m_pOptions->bAutoArrange)
2009                  channelsArrange();                  channelsArrange();
2010  }  }
2011    
2012    
2013  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2014  // qsamplerMainForm -- Help Action slots.  // QSampler::MainForm -- Help Action slots.
2015    
2016  // Show information about the Qt toolkit.  // Show information about the Qt toolkit.
2017  void MainForm::helpAboutQt (void)  void MainForm::helpAboutQt (void)
# Line 1944  void MainForm::helpAboutQt (void) Line 2023  void MainForm::helpAboutQt (void)
2023  // Show information about application program.  // Show information about application program.
2024  void MainForm::helpAbout (void)  void MainForm::helpAbout (void)
2025  {  {
2026          // Stuff the about box text...          QStringList list;
         QString sText = "<p>\n";  
         sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";  
         sText += "<br />\n";  
         sText += tr("Version") + ": <b>" QSAMPLER_VERSION "</b><br />\n";  
         sText += "<small>" + tr("Build") + ": " __DATE__ " " __TIME__ "</small><br />\n";  
2027  #ifdef CONFIG_DEBUG  #ifdef CONFIG_DEBUG
2028          sText += "<small><font color=\"red\">";          list << tr("Debugging option enabled.");
         sText += tr("Debugging option enabled.");  
         sText += "</font></small><br />";  
2029  #endif  #endif
2030  #ifndef CONFIG_LIBGIG  #ifndef CONFIG_LIBGIG
2031          sText += "<small><font color=\"red\">";          list << tr("GIG (libgig) file support disabled.");
         sText += tr("GIG (libgig) file support disabled.");  
         sText += "</font></small><br />";  
2032  #endif  #endif
2033  #ifndef CONFIG_INSTRUMENT_NAME  #ifndef CONFIG_INSTRUMENT_NAME
2034          sText += "<small><font color=\"red\">";          list << tr("LSCP (liblscp) instrument_name support disabled.");
         sText += tr("LSCP (liblscp) instrument_name support disabled.");  
         sText += "</font></small><br />";  
2035  #endif  #endif
2036  #ifndef CONFIG_MUTE_SOLO  #ifndef CONFIG_MUTE_SOLO
2037          sText += "<small><font color=\"red\">";          list << tr("Sampler channel Mute/Solo support disabled.");
         sText += tr("Sampler channel Mute/Solo support disabled.");  
         sText += "</font></small><br />";  
2038  #endif  #endif
2039  #ifndef CONFIG_AUDIO_ROUTING  #ifndef CONFIG_AUDIO_ROUTING
2040          sText += "<small><font color=\"red\">";          list << tr("LSCP (liblscp) audio_routing support disabled.");
         sText += tr("LSCP (liblscp) audio_routing support disabled.");  
         sText += "</font></small><br />";  
2041  #endif  #endif
2042  #ifndef CONFIG_FXSEND  #ifndef CONFIG_FXSEND
2043          sText += "<small><font color=\"red\">";          list << tr("Sampler channel Effect Sends support disabled.");
         sText += tr("Sampler channel Effect Sends support disabled.");  
         sText += "</font></small><br />";  
2044  #endif  #endif
2045  #ifndef CONFIG_VOLUME  #ifndef CONFIG_VOLUME
2046          sText += "<small><font color=\"red\">";          list << tr("Global volume support disabled.");
         sText += tr("Global volume support disabled.");  
         sText += "</font></small><br />";  
2047  #endif  #endif
2048  #ifndef CONFIG_MIDI_INSTRUMENT  #ifndef CONFIG_MIDI_INSTRUMENT
2049          sText += "<small><font color=\"red\">";          list << tr("MIDI instrument mapping support disabled.");
         sText += tr("MIDI instrument mapping support disabled.");  
         sText += "</font></small><br />";  
2050  #endif  #endif
2051  #ifndef CONFIG_EDIT_INSTRUMENT  #ifndef CONFIG_EDIT_INSTRUMENT
2052          sText += "<small><font color=\"red\">";          list << tr("Instrument editing support disabled.");
         sText += tr("Instrument editing support disabled.");  
         sText += "</font></small><br />";  
2053  #endif  #endif
2054  #ifndef CONFIG_EVENT_CHANNEL_MIDI  #ifndef CONFIG_EVENT_CHANNEL_MIDI
2055          sText += "<small><font color=\"red\">";          list << tr("Channel MIDI event support disabled.");
         sText += tr("Channel MIDI event support disabled.");  
         sText += "</font></small><br />";  
2056  #endif  #endif
2057  #ifndef CONFIG_EVENT_DEVICE_MIDI  #ifndef CONFIG_EVENT_DEVICE_MIDI
2058          sText += "<small><font color=\"red\">";          list << tr("Device MIDI event support disabled.");
         sText += tr("Device MIDI event support disabled.");  
         sText += "</font></small><br />";  
2059  #endif  #endif
2060  #ifndef CONFIG_MAX_VOICES  #ifndef CONFIG_MAX_VOICES
2061          sText += "<small><font color=\"red\">";          list << tr("Runtime max. voices / disk streams support disabled.");
         sText += tr("Runtime max. voices / disk streams support disabled.");  
         sText += "</font></small><br />";  
2062  #endif  #endif
2063    
2064            // Stuff the about box text...
2065            QString sText = "<p>\n";
2066            sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";
2067            sText += "<br />\n";
2068            sText += tr("Version") + ": <b>" CONFIG_BUILD_VERSION "</b><br />\n";
2069    //      sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n";
2070            if (!list.isEmpty()) {
2071                    sText += "<small><font color=\"red\">";
2072                    sText += list.join("<br />\n");
2073                    sText += "</font></small>";
2074            }
2075          sText += "<br />\n";          sText += "<br />\n";
2076          sText += tr("Using") + ": ";          sText += tr("Using") + ": ";
2077          sText += ::lscp_client_package();          sText += ::lscp_client_package();
# Line 2039  void MainForm::helpAbout (void) Line 2101  void MainForm::helpAbout (void)
2101    
2102    
2103  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2104  // qsamplerMainForm -- Main window stabilization.  // QSampler::MainForm -- Main window stabilization.
2105    
2106  void MainForm::stabilizeForm (void)  void MainForm::stabilizeForm (void)
2107  {  {
# Line 2052  void MainForm::stabilizeForm (void) Line 2114  void MainForm::stabilizeForm (void)
2114          // Update the main menu state...          // Update the main menu state...
2115          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
2116          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();
2117          const bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          const bool bHasClient = (m_pOptions != nullptr && m_pClient != nullptr);
2118          const bool bHasChannel = (bHasClient && pChannelStrip != NULL);          const bool bHasChannel = (bHasClient && pChannelStrip != nullptr);
2119          const bool bHasChannels = (bHasClient && wlist.count() > 0);          const bool bHasChannels = (bHasClient && wlist.count() > 0);
2120          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
2121          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
2122          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
2123          m_ui.fileSaveAsAction->setEnabled(bHasClient);          m_ui.fileSaveAsAction->setEnabled(bHasClient);
2124          m_ui.fileResetAction->setEnabled(bHasClient);          m_ui.fileResetAction->setEnabled(bHasClient);
2125          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == nullptr);
2126          m_ui.editAddChannelAction->setEnabled(bHasClient);          m_ui.editAddChannelAction->setEnabled(bHasClient);
2127          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);
2128          m_ui.editSetupChannelAction->setEnabled(bHasChannel);          m_ui.editSetupChannelAction->setEnabled(bHasChannel);
# Line 2191  void MainForm::updateSession (void) Line 2253  void MainForm::updateSession (void)
2253          updateAllChannelStrips(false);          updateAllChannelStrips(false);
2254    
2255          // Do we auto-arrange?          // Do we auto-arrange?
2256          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
2257    
2258          // Remember to refresh devices and instruments...          // Remember to refresh devices and instruments...
2259          if (m_pInstrumentListForm)          if (m_pInstrumentListForm)
# Line 2210  void MainForm::updateAllChannelStrips ( Line 2271  void MainForm::updateAllChannelStrips (
2271    
2272          // Retrieve the current channel list.          // Retrieve the current channel list.
2273          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2274          if (piChannelIDs == NULL) {          if (piChannelIDs == nullptr) {
2275                  if (::lscp_client_get_errno(m_pClient)) {                  if (::lscp_client_get_errno(m_pClient)) {
2276                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
2277                          appendMessagesError(                          appendMessagesError(
# Line 2225  void MainForm::updateAllChannelStrips ( Line 2286  void MainForm::updateAllChannelStrips (
2286                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2287                  }                  }
2288                  // Do we auto-arrange?                  // Do we auto-arrange?
2289                  if (m_pOptions && m_pOptions->bAutoArrange)                  channelsArrangeAuto();
                         channelsArrange();  
2290                  // remove dead channel strips                  // remove dead channel strips
2291                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2292                          const QList<QMdiSubWindow *>& wlist                          const QList<QMdiSubWindow *>& wlist
2293                                  = m_pWorkspace->subWindowList();                                  = m_pWorkspace->subWindowList();
2294                          const int iStripCount = wlist.count();                          const int iStripCount = wlist.count();
2295                          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2296                                  ChannelStrip *pChannelStrip = NULL;                                  ChannelStrip *pChannelStrip = nullptr;
2297                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2298                                  if (pMdiSubWindow)                                  if (pMdiSubWindow)
2299                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2241  void MainForm::updateAllChannelStrips ( Line 2301  void MainForm::updateAllChannelStrips (
2301                                          bool bExists = false;                                          bool bExists = false;
2302                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2303                                                  Channel *pChannel = pChannelStrip->channel();                                                  Channel *pChannel = pChannelStrip->channel();
2304                                                  if (pChannel == NULL)                                                  if (pChannel == nullptr)
2305                                                          break;                                                          break;
2306                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {
2307                                                          // strip exists, don't touch it                                                          // strip exists, don't touch it
# Line 2264  void MainForm::updateAllChannelStrips ( Line 2324  void MainForm::updateAllChannelStrips (
2324  // Update the recent files list and menu.  // Update the recent files list and menu.
2325  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2326  {  {
2327          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2328                  return;                  return;
2329    
2330          // Remove from list if already there (avoid duplicates)          // Remove from list if already there (avoid duplicates)
# Line 2279  void MainForm::updateRecentFiles ( const Line 2339  void MainForm::updateRecentFiles ( const
2339  // Update the recent files list and menu.  // Update the recent files list and menu.
2340  void MainForm::updateRecentFilesMenu (void)  void MainForm::updateRecentFilesMenu (void)
2341  {  {
2342          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2343                  return;                  return;
2344    
2345          // Time to keep the list under limits.          // Time to keep the list under limits.
# Line 2315  void MainForm::updateInstrumentNames (vo Line 2375  void MainForm::updateInstrumentNames (vo
2375          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2376          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
2377          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2378                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
2379                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2380                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2381                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2329  void MainForm::updateInstrumentNames (vo Line 2389  void MainForm::updateInstrumentNames (vo
2389  // Force update of the channels display font.  // Force update of the channels display font.
2390  void MainForm::updateDisplayFont (void)  void MainForm::updateDisplayFont (void)
2391  {  {
2392          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2393                  return;                  return;
2394    
2395          // Check if display font is legal.          // Check if display font is legal.
# Line 2350  void MainForm::updateDisplayFont (void) Line 2410  void MainForm::updateDisplayFont (void)
2410          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2411          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
2412          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2413                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
2414                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2415                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2416                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2373  void MainForm::updateDisplayEffect (void Line 2433  void MainForm::updateDisplayEffect (void
2433          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2434          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
2435          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2436                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
2437                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2438                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2439                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2387  void MainForm::updateDisplayEffect (void Line 2447  void MainForm::updateDisplayEffect (void
2447  // Force update of the channels maximum volume setting.  // Force update of the channels maximum volume setting.
2448  void MainForm::updateMaxVolume (void)  void MainForm::updateMaxVolume (void)
2449  {  {
2450          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2451                  return;                  return;
2452    
2453  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
# Line 2406  void MainForm::updateMaxVolume (void) Line 2466  void MainForm::updateMaxVolume (void)
2466          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2467          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
2468          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2469                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
2470                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2471                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2472                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2418  void MainForm::updateMaxVolume (void) Line 2478  void MainForm::updateMaxVolume (void)
2478    
2479    
2480  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2481  // qsamplerMainForm -- Messages window form handlers.  // QSampler::MainForm -- Messages window form handlers.
2482    
2483  // Messages output methods.  // Messages output methods.
2484  void MainForm::appendMessages( const QString& s )  void MainForm::appendMessages( const QString& s )
# Line 2477  void MainForm::appendMessagesError( cons Line 2537  void MainForm::appendMessagesError( cons
2537  // This is a special message format, just for client results.  // This is a special message format, just for client results.
2538  void MainForm::appendMessagesClient( const QString& s )  void MainForm::appendMessagesClient( const QString& s )
2539  {  {
2540          if (m_pClient == NULL)          if (m_pClient == nullptr)
2541                  return;                  return;
2542    
2543          appendMessagesColor(s + QString(": %1 (errno=%2)")          appendMessagesColor(s + QString(": %1 (errno=%2)")
# Line 2492  void MainForm::appendMessagesClient( con Line 2552  void MainForm::appendMessagesClient( con
2552  // Force update of the messages font.  // Force update of the messages font.
2553  void MainForm::updateMessagesFont (void)  void MainForm::updateMessagesFont (void)
2554  {  {
2555          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2556                  return;                  return;
2557    
2558          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {
# Line 2506  void MainForm::updateMessagesFont (void) Line 2566  void MainForm::updateMessagesFont (void)
2566  // Update messages window line limit.  // Update messages window line limit.
2567  void MainForm::updateMessagesLimit (void)  void MainForm::updateMessagesLimit (void)
2568  {  {
2569          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2570                  return;                  return;
2571    
2572          if (m_pMessages) {          if (m_pMessages) {
# Line 2521  void MainForm::updateMessagesLimit (void Line 2581  void MainForm::updateMessagesLimit (void
2581  // Enablement of the messages capture feature.  // Enablement of the messages capture feature.
2582  void MainForm::updateMessagesCapture (void)  void MainForm::updateMessagesCapture (void)
2583  {  {
2584          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2585                  return;                  return;
2586    
2587          if (m_pMessages)          if (m_pMessages)
# Line 2530  void MainForm::updateMessagesCapture (vo Line 2590  void MainForm::updateMessagesCapture (vo
2590    
2591    
2592  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2593  // qsamplerMainForm -- MDI channel strip management.  // QSampler::MainForm -- MDI channel strip management.
2594    
2595  // The channel strip creation executive.  // The channel strip creation executive.
2596  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2597  {  {
2598          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == nullptr || pChannel == nullptr)
2599                  return NULL;                  return nullptr;
2600    
2601          // Add a new channel itema...          // Add a new channel itema...
2602          ChannelStrip *pChannelStrip = new ChannelStrip();          ChannelStrip *pChannelStrip = new ChannelStrip();
2603          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
2604                  return NULL;                  return nullptr;
2605    
2606          // Set some initial channel strip options...          // Set some initial channel strip options...
2607          if (m_pOptions) {          if (m_pOptions) {
# Line 2582  void MainForm::destroyChannelStrip ( Cha Line 2642  void MainForm::destroyChannelStrip ( Cha
2642  {  {
2643          QMdiSubWindow *pMdiSubWindow          QMdiSubWindow *pMdiSubWindow
2644                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2645          if (pMdiSubWindow == NULL)          if (pMdiSubWindow == nullptr)
2646                  return;                  return;
2647    
2648          // Just delete the channel strip.          // Just delete the channel strip.
# Line 2590  void MainForm::destroyChannelStrip ( Cha Line 2650  void MainForm::destroyChannelStrip ( Cha
2650          delete pMdiSubWindow;          delete pMdiSubWindow;
2651    
2652          // Do we auto-arrange?          // Do we auto-arrange?
2653          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
2654  }  }
2655    
2656    
# Line 2602  ChannelStrip *MainForm::activeChannelStr Line 2661  ChannelStrip *MainForm::activeChannelStr
2661          if (pMdiSubWindow)          if (pMdiSubWindow)
2662                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2663          else          else
2664                  return NULL;                  return nullptr;
2665  }  }
2666    
2667    
2668  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2669  ChannelStrip *MainForm::channelStripAt ( int iStrip )  ChannelStrip *MainForm::channelStripAt ( int iStrip )
2670  {  {
2671          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return nullptr;
2672    
2673          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2674                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2675          if (wlist.isEmpty())          if (wlist.isEmpty())
2676                  return NULL;                  return nullptr;
2677    
2678          if (iStrip < 0 || iStrip >= wlist.count())          if (iStrip < 0 || iStrip >= wlist.count())
2679                  return NULL;                  return nullptr;
2680    
2681          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2682          if (pMdiSubWindow)          if (pMdiSubWindow)
2683                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2684          else          else
2685                  return NULL;                  return nullptr;
2686  }  }
2687    
2688    
# Line 2633  ChannelStrip *MainForm::channelStrip ( i Line 2692  ChannelStrip *MainForm::channelStrip ( i
2692          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2693                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2694          if (wlist.isEmpty())          if (wlist.isEmpty())
2695                  return NULL;                  return nullptr;
2696    
2697          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
2698          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2699                  ChannelStrip *pChannelStrip = NULL;                  ChannelStrip *pChannelStrip = nullptr;
2700                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2701                  if (pMdiSubWindow)                  if (pMdiSubWindow)
2702                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                          pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2649  ChannelStrip *MainForm::channelStrip ( i Line 2708  ChannelStrip *MainForm::channelStrip ( i
2708          }          }
2709    
2710          // Not found.          // Not found.
2711          return NULL;          return nullptr;
2712  }  }
2713    
2714    
# Line 2666  void MainForm::channelsMenuAboutToShow ( Line 2725  void MainForm::channelsMenuAboutToShow (
2725                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2726                  const int iStripCount = wlist.count();                  const int iStripCount = wlist.count();
2727                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2728                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip = nullptr;
2729                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2730                          if (pMdiSubWindow)                          if (pMdiSubWindow)
2731                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2688  void MainForm::channelsMenuActivated (vo Line 2747  void MainForm::channelsMenuActivated (vo
2747  {  {
2748          // Retrive channel index from action data...          // Retrive channel index from action data...
2749          QAction *pAction = qobject_cast<QAction *> (sender());          QAction *pAction = qobject_cast<QAction *> (sender());
2750          if (pAction == NULL)          if (pAction == nullptr)
2751                  return;                  return;
2752    
2753          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
# Line 2700  void MainForm::channelsMenuActivated (vo Line 2759  void MainForm::channelsMenuActivated (vo
2759    
2760    
2761  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2762  // qsamplerMainForm -- Timer stuff.  // QSampler::MainForm -- Timer stuff.
2763    
2764  // Set the pseudo-timer delay schedule.  // Set the pseudo-timer delay schedule.
2765  void MainForm::startSchedule ( int iStartDelay )  void MainForm::startSchedule ( int iStartDelay )
# Line 2719  void MainForm::stopSchedule (void) Line 2778  void MainForm::stopSchedule (void)
2778  // Timer slot funtion.  // Timer slot funtion.
2779  void MainForm::timerSlot (void)  void MainForm::timerSlot (void)
2780  {  {
2781          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2782                  return;                  return;
2783    
2784          // Is it the first shot on server start after a few delay?          // Is it the first shot on server start after a few delay?
# Line 2756  void MainForm::timerSlot (void) Line 2815  void MainForm::timerSlot (void)
2815                                          = m_pWorkspace->subWindowList();                                          = m_pWorkspace->subWindowList();
2816                                  const int iStripCount = wlist.count();                                  const int iStripCount = wlist.count();
2817                                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {
2818                                          ChannelStrip *pChannelStrip = NULL;                                          ChannelStrip *pChannelStrip = nullptr;
2819                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2820                                          if (pMdiSubWindow)                                          if (pMdiSubWindow)
2821                                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                                                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
# Line 2773  void MainForm::timerSlot (void) Line 2832  void MainForm::timerSlot (void)
2832    
2833    
2834  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2835  // qsamplerMainForm -- Server stuff.  // QSampler::MainForm -- Server stuff.
2836    
2837  // Start linuxsampler server...  // Start linuxsampler server...
2838  void MainForm::startServer (void)  void MainForm::startServer (void)
2839  {  {
2840          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2841                  return;                  return;
2842    
2843          // Aren't already a client, are we?          // Aren't already a client, are we?
# Line 2807  void MainForm::startServer (void) Line 2866  void MainForm::startServer (void)
2866    
2867          // OK. Let's build the startup process...          // OK. Let's build the startup process...
2868          m_pServer = new QProcess();          m_pServer = new QProcess();
2869          bForceServerStop = true;          m_bForceServerStop = true;
2870    
2871          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2872          m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);          m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
# Line 2851  void MainForm::startServer (void) Line 2910  void MainForm::startServer (void)
2910    
2911    
2912  // Stop linuxsampler server...  // Stop linuxsampler server...
2913  void MainForm::stopServer (bool bInteractive)  void MainForm::stopServer ( bool bInteractive )
2914  {  {
2915          // Stop client code.          // Stop client code.
2916          stopClient();          stopClient();
# Line 2865  void MainForm::stopServer (bool bInterac Line 2924  void MainForm::stopServer (bool bInterac
2924                          "sampler session at any time by relaunching QSampler.\n\n"                          "sampler session at any time by relaunching QSampler.\n\n"
2925                          "Do you want LinuxSampler to stop?"),                          "Do you want LinuxSampler to stop?"),
2926                          QMessageBox::Yes | QMessageBox::No,                          QMessageBox::Yes | QMessageBox::No,
2927                          QMessageBox::Yes) == QMessageBox::No)                          QMessageBox::Yes) == QMessageBox::No) {
2928                  {                          m_bForceServerStop = false;
                         bForceServerStop = false;  
2929                  }                  }
2930          }          }
2931    
2932            bool bGraceWait = true;
2933    
2934          // And try to stop server.          // And try to stop server.
2935          if (m_pServer && bForceServerStop) {          if (m_pServer && m_bForceServerStop) {
2936                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2937                  if (m_pServer->state() == QProcess::Running) {                  if (m_pServer->state() == QProcess::Running) {
2938                  #if defined(WIN32)                  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
2939                          // Try harder...                          // Try harder...
2940                          m_pServer->kill();                          m_pServer->kill();
2941                  #else                  #else
2942                          // Try softly...                          // Try softly...
2943                          m_pServer->terminate();                          m_pServer->terminate();
2944                            bool bFinished = m_pServer->waitForFinished(QSAMPLER_TIMER_MSECS * 1000);
2945                            if (bFinished) bGraceWait = false;
2946                  #endif                  #endif
2947                  }                  }
2948          }       // Do final processing anyway.          }       // Do final processing anyway.
2949          else processServerExit();          else processServerExit();
2950    
2951          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2952          QTime t;          if (bGraceWait) {
2953          t.start();                  QTime t;
2954          while (t.elapsed() < QSAMPLER_TIMER_MSECS)                  t.start();
2955                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  while (t.elapsed() < QSAMPLER_TIMER_MSECS)
2956                            QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2957            }
2958  }  }
2959    
2960    
# Line 2912  void MainForm::processServerExit (void) Line 2976  void MainForm::processServerExit (void)
2976          if (m_pMessages)          if (m_pMessages)
2977                  m_pMessages->flushStdoutBuffer();                  m_pMessages->flushStdoutBuffer();
2978    
2979          if (m_pServer && bForceServerStop) {          if (m_pServer && m_bForceServerStop) {
2980                  if (m_pServer->state() != QProcess::NotRunning) {                  if (m_pServer->state() != QProcess::NotRunning) {
2981                          appendMessages(tr("Server is being forced..."));                          appendMessages(tr("Server is being forced..."));
2982                          // Force final server shutdown...                          // Force final server shutdown...
# Line 2928  void MainForm::processServerExit (void) Line 2992  void MainForm::processServerExit (void)
2992                          tr("Server was stopped with exit status %1.")                          tr("Server was stopped with exit status %1.")
2993                          .arg(m_pServer->exitStatus()));                          .arg(m_pServer->exitStatus()));
2994                  delete m_pServer;                  delete m_pServer;
2995                  m_pServer = NULL;                  m_pServer = nullptr;
2996          }          }
2997    
2998          // Again, make status visible stable.          // Again, make status visible stable.
# Line 2937  void MainForm::processServerExit (void) Line 3001  void MainForm::processServerExit (void)
3001    
3002    
3003  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
3004  // qsamplerMainForm -- Client stuff.  // QSampler::MainForm -- Client stuff.
3005    
3006  // The LSCP client callback procedure.  // The LSCP client callback procedure.
3007  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/,  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/,
3008          lscp_event_t event, const char *pchData, int cchData, void *pvData )          lscp_event_t event, const char *pchData, int cchData, void *pvData )
3009  {  {
3010          MainForm* pMainForm = (MainForm *) pvData;          MainForm* pMainForm = (MainForm *) pvData;
3011          if (pMainForm == NULL)          if (pMainForm == nullptr)
3012                  return LSCP_FAILED;                  return LSCP_FAILED;
3013    
3014          // ATTN: DO NOT EVER call any GUI code here,          // ATTN: DO NOT EVER call any GUI code here,
# Line 2961  lscp_status_t qsampler_client_callback ( Line 3025  lscp_status_t qsampler_client_callback (
3025  bool MainForm::startClient (void)  bool MainForm::startClient (void)
3026  {  {
3027          // Have it a setup?          // Have it a setup?
3028          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
3029                  return false;                  return false;
3030    
3031          // Aren't we already started, are we?          // Aren't we already started, are we?
# Line 2975  bool MainForm::startClient (void) Line 3039  bool MainForm::startClient (void)
3039          m_pClient = ::lscp_client_create(          m_pClient = ::lscp_client_create(
3040                  m_pOptions->sServerHost.toUtf8().constData(),                  m_pOptions->sServerHost.toUtf8().constData(),
3041                  m_pOptions->iServerPort, qsampler_client_callback, this);                  m_pOptions->iServerPort, qsampler_client_callback, this);
3042          if (m_pClient == NULL) {          if (m_pClient == nullptr) {
3043                  // Is this the first try?                  // Is this the first try?
3044                  // maybe we need to start a local server...                  // maybe we need to start a local server...
3045                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
# Line 2989  bool MainForm::startClient (void) Line 3053  bool MainForm::startClient (void)
3053                  stabilizeForm();                  stabilizeForm();
3054                  return false;                  return false;
3055          }          }
3056    
3057          // Just set receive timeout value, blindly.          // Just set receive timeout value, blindly.
3058          ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);          ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);
3059          appendMessages(          appendMessages(
# Line 3044  bool MainForm::startClient (void) Line 3109  bool MainForm::startClient (void)
3109          if (!m_pOptions->sSessionFile.isEmpty()) {          if (!m_pOptions->sSessionFile.isEmpty()) {
3110                  // Just load the prabably startup session...                  // Just load the prabably startup session...
3111                  if (loadSessionFile(m_pOptions->sSessionFile)) {                  if (loadSessionFile(m_pOptions->sSessionFile)) {
3112                          m_pOptions->sSessionFile = QString::null;                          m_pOptions->sSessionFile = QString();
3113                          return true;                          return true;
3114                  }                  }
3115          }          }
# Line 3060  bool MainForm::startClient (void) Line 3125  bool MainForm::startClient (void)
3125  // Stop client...  // Stop client...
3126  void MainForm::stopClient (void)  void MainForm::stopClient (void)
3127  {  {
3128          if (m_pClient == NULL)          if (m_pClient == nullptr)
3129                  return;                  return;
3130    
3131          // Log prepare here.          // Log prepare here.
# Line 3092  void MainForm::stopClient (void) Line 3157  void MainForm::stopClient (void)
3157          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
3158          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);
3159          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
3160          m_pClient = NULL;          m_pClient = nullptr;
3161    
3162          // Hard-notify instrumnet and device configuration forms,          // Hard-notify instrumnet and device configuration forms,
3163          // if visible, that we're running out...          // if visible, that we're running out...
# Line 3112  void MainForm::stopClient (void) Line 3177  void MainForm::stopClient (void)
3177  // Channel strip activation/selection.  // Channel strip activation/selection.
3178  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3179  {  {
3180          ChannelStrip *pChannelStrip = NULL;          ChannelStrip *pChannelStrip = nullptr;
3181          if (pMdiSubWindow)          if (pMdiSubWindow)
3182                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3183          if (pChannelStrip)          if (pChannelStrip)

Legend:
Removed from v.2978  
changed lines
  Added in v.3555

  ViewVC Help
Powered by ViewVC