/[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 3510 by capela, Wed Apr 10 23:03:23 2019 UTC revision 3855 by capela, Thu Feb 4 10:09:42 2021 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007-2019 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 35  Line 35 
35  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
36  #include "qsamplerDeviceStatusForm.h"  #include "qsamplerDeviceStatusForm.h"
37    
38    #include "qsamplerPaletteForm.h"
39    
40    #include <QStyleFactory>
41    
42  #include <QMdiArea>  #include <QMdiArea>
43  #include <QMdiSubWindow>  #include <QMdiSubWindow>
44    
# Line 42  Line 46 
46  #include <QProcess>  #include <QProcess>
47  #include <QMessageBox>  #include <QMessageBox>
48    
 #include <QRegExp>  
49  #include <QTextStream>  #include <QTextStream>
50  #include <QFileDialog>  #include <QFileDialog>
51  #include <QFileInfo>  #include <QFileInfo>
# Line 58  Line 61 
61  #include <QTimer>  #include <QTimer>
62  #include <QDateTime>  #include <QDateTime>
63    
64  #if QT_VERSION >= 0x050000  #include <QElapsedTimer>
65    
66    #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
67  #include <QMimeData>  #include <QMimeData>
68  #endif  #endif
69    
70  #if QT_VERSION < 0x040500  #if QT_VERSION < QT_VERSION_CHECK(4, 5, 0)
71  namespace Qt {  namespace Qt {
72  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);  const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
73  }  }
74  #endif  #endif
75    
76  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
77    #if defined(Q_CC_GNU) || defined(Q_CC_MINGW)
78    #pragma GCC diagnostic push
79    #pragma GCC diagnostic ignored "-Wunused-parameter"
80    #endif
81  #include <gig.h>  #include <gig.h>
82    #if defined(Q_CC_GNU) || defined(Q_CC_MINGW)
83    #pragma GCC diagnostic pop
84    #endif
85  #endif  #endif
86    
87  // Needed for lroundf()  // Deprecated QTextStreamFunctions/Qt namespaces workaround.
88  #include <math.h>  #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
89    #define endl    Qt::endl
90    #endif
91    
92  #ifndef CONFIG_ROUND  // Needed for lroundf()
93    #ifdef CONFIG_ROUND
94    #include <cmath>
95    #else
96  static inline long lroundf ( float x )  static inline long lroundf ( float x )
97  {  {
98          if (x >= 0.0f)          if (x >= 0.0f)
# Line 202  protected: Line 219  protected:
219  // QSampler::MainForm -- Main window form implementation.  // QSampler::MainForm -- Main window form implementation.
220    
221  // Kind of singleton reference.  // Kind of singleton reference.
222  MainForm *MainForm::g_pMainForm = NULL;  MainForm *MainForm::g_pMainForm = nullptr;
223    
224  MainForm::MainForm ( QWidget *pParent )  MainForm::MainForm ( QWidget *pParent )
225          : QMainWindow(pParent)          : QMainWindow(pParent)
# Line 213  MainForm::MainForm ( QWidget *pParent ) Line 230  MainForm::MainForm ( QWidget *pParent )
230          g_pMainForm = this;          g_pMainForm = this;
231    
232          // Initialize some pointer references.          // Initialize some pointer references.
233          m_pOptions = NULL;          m_pOptions = nullptr;
234    
235          // All child forms are to be created later, not earlier than setup.          // All child forms are to be created later, not earlier than setup.
236          m_pMessages = NULL;          m_pMessages = nullptr;
237          m_pInstrumentListForm = NULL;          m_pInstrumentListForm = nullptr;
238          m_pDeviceForm = NULL;          m_pDeviceForm = nullptr;
239    
240          // We'll start clean.          // We'll start clean.
241          m_iUntitled   = 0;          m_iUntitled   = 0;
242          m_iDirtySetup = 0;          m_iDirtySetup = 0;
243          m_iDirtyCount = 0;          m_iDirtyCount = 0;
244    
245          m_pServer = NULL;          m_pServer = nullptr;
246          m_pClient = NULL;          m_pClient = nullptr;
247    
248          m_iStartDelay = 0;          m_iStartDelay = 0;
249          m_iTimerDelay = 0;          m_iTimerDelay = 0;
# Line 255  MainForm::MainForm ( QWidget *pParent ) Line 272  MainForm::MainForm ( QWidget *pParent )
272          sigemptyset(&sigusr1.sa_mask);          sigemptyset(&sigusr1.sa_mask);
273          sigusr1.sa_flags = 0;          sigusr1.sa_flags = 0;
274          sigusr1.sa_flags |= SA_RESTART;          sigusr1.sa_flags |= SA_RESTART;
275          ::sigaction(SIGUSR1, &sigusr1, NULL);          ::sigaction(SIGUSR1, &sigusr1, nullptr);
276    
277          // Initialize file descriptors for SIGTERM socket notifier.          // Initialize file descriptors for SIGTERM socket notifier.
278          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);
# Line 269  MainForm::MainForm ( QWidget *pParent ) Line 286  MainForm::MainForm ( QWidget *pParent )
286          // Install SIGTERM signal handler.          // Install SIGTERM signal handler.
287          struct sigaction sigterm;          struct sigaction sigterm;
288          sigterm.sa_handler = qsampler_sigterm_handler;          sigterm.sa_handler = qsampler_sigterm_handler;
289          ::sigemptyset(&sigterm.sa_mask);          sigemptyset(&sigterm.sa_mask);
290          sigterm.sa_flags = 0;          sigterm.sa_flags = 0;
291          sigterm.sa_flags |= SA_RESTART;          sigterm.sa_flags |= SA_RESTART;
292          ::sigaction(SIGTERM, &sigterm, NULL);          ::sigaction(SIGTERM, &sigterm, nullptr);
293          ::sigaction(SIGQUIT, &sigterm, NULL);          ::sigaction(SIGQUIT, &sigterm, nullptr);
294    
295          // Ignore SIGHUP/SIGINT signals.          // Ignore SIGHUP/SIGINT signals.
296          ::signal(SIGHUP, SIG_IGN);          ::signal(SIGHUP, SIG_IGN);
# Line 281  MainForm::MainForm ( QWidget *pParent ) Line 298  MainForm::MainForm ( QWidget *pParent )
298    
299  #else   // HAVE_SIGNAL_H  #else   // HAVE_SIGNAL_H
300    
301          m_pSigusr1Notifier = NULL;          m_pSigusr1Notifier = nullptr;
302          m_pSigtermNotifier = NULL;          m_pSigtermNotifier = nullptr;
303                    
304  #endif  // !HAVE_SIGNAL_H  #endif  // !HAVE_SIGNAL_H
305    
# Line 493  MainForm::~MainForm() Line 510  MainForm::~MainForm()
510  #endif  #endif
511    
512          // Pseudo-singleton reference shut-down.          // Pseudo-singleton reference shut-down.
513          g_pMainForm = NULL;          g_pMainForm = nullptr;
514  }  }
515    
516    
# Line 630  void MainForm::closeEvent ( QCloseEvent Line 647  void MainForm::closeEvent ( QCloseEvent
647  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
648  {  {
649          // Accept external drags only...          // Accept external drags only...
650          if (pDragEnterEvent->source() == NULL          if (pDragEnterEvent->source() == nullptr
651                  && pDragEnterEvent->mimeData()->hasUrls()) {                  && pDragEnterEvent->mimeData()->hasUrls()) {
652                  pDragEnterEvent->accept();                  pDragEnterEvent->accept();
653          } else {          } else {
# Line 654  void MainForm::dropEvent ( QDropEvent *p Line 671  void MainForm::dropEvent ( QDropEvent *p
671                          if (QFileInfo(sPath).exists()) {                          if (QFileInfo(sPath).exists()) {
672                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
673                                  Channel *pChannel = new Channel();                                  Channel *pChannel = new Channel();
674                                  if (pChannel == NULL)                                  if (pChannel == nullptr)
675                                          return;                                          return;
676                                  // Start setting the instrument filename...                                  // Start setting the instrument filename...
677                                  pChannel->setInstrument(sPath, 0);                                  pChannel->setInstrument(sPath, 0);
# Line 852  bool MainForm::newSession (void) Line 869  bool MainForm::newSession (void)
869          m_iUntitled++;          m_iUntitled++;
870    
871          // Stabilize form.          // Stabilize form.
872          m_sFilename = QString::null;          m_sFilename = QString();
873          m_iDirtyCount = 0;          m_iDirtyCount = 0;
874          appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename)));          appendMessages(tr("New session: \"%1\".").arg(sessionName(m_sFilename)));
875          stabilizeForm();          stabilizeForm();
# Line 864  bool MainForm::newSession (void) Line 881  bool MainForm::newSession (void)
881  // Open an existing sampler session.  // Open an existing sampler session.
882  bool MainForm::openSession (void)  bool MainForm::openSession (void)
883  {  {
884          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
885                  return false;                  return false;
886    
887          // Ask for the filename to open...          // Ask for the filename to open...
888          QString sFilename = QFileDialog::getOpenFileName(this,          QString sFilename = QFileDialog::getOpenFileName(this,
889                  QSAMPLER_TITLE ": " + tr("Open Session"), // Caption.                  tr("Open Session"),                       // Caption.
890                  m_pOptions->sSessionDir,                  // Start here.                  m_pOptions->sSessionDir,                  // Start here.
891                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
892          );          );
# Line 890  bool MainForm::openSession (void) Line 907  bool MainForm::openSession (void)
907  // Save current sampler session with another name.  // Save current sampler session with another name.
908  bool MainForm::saveSession ( bool bPrompt )  bool MainForm::saveSession ( bool bPrompt )
909  {  {
910          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
911                  return false;                  return false;
912    
913          QString sFilename = m_sFilename;          QString sFilename = m_sFilename;
# Line 902  bool MainForm::saveSession ( bool bPromp Line 919  bool MainForm::saveSession ( bool bPromp
919                          sFilename = m_pOptions->sSessionDir;                          sFilename = m_pOptions->sSessionDir;
920                  // Prompt the guy...                  // Prompt the guy...
921                  sFilename = QFileDialog::getSaveFileName(this,                  sFilename = QFileDialog::getSaveFileName(this,
922                          QSAMPLER_TITLE ": " + tr("Save Session"), // Caption.                          tr("Save Session"),                       // Caption.
923                          sFilename,                                // Start here.                          sFilename,                                // Start here.
924                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
925                  );                  );
# Line 916  bool MainForm::saveSession ( bool bPromp Line 933  bool MainForm::saveSession ( bool bPromp
933                  // Check if already exists...                  // Check if already exists...
934                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
935                          if (QMessageBox::warning(this,                          if (QMessageBox::warning(this,
936                                  QSAMPLER_TITLE ": " + tr("Warning"),                                  tr("Warning"),
937                                  tr("The file already exists:\n\n"                                  tr("The file already exists:\n\n"
938                                  "\"%1\"\n\n"                                  "\"%1\"\n\n"
939                                  "Do you want to replace it?")                                  "Do you want to replace it?")
# Line 941  bool MainForm::closeSession ( bool bForc Line 958  bool MainForm::closeSession ( bool bForc
958          // Are we dirty enough to prompt it?          // Are we dirty enough to prompt it?
959          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
960                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
961                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
962                          tr("The current session has been changed:\n\n"                          tr("The current session has been changed:\n\n"
963                          "\"%1\"\n\n"                          "\"%1\"\n\n"
964                          "Do you want to save the changes?")                          "Do you want to save the changes?")
# Line 966  bool MainForm::closeSession ( bool bForc Line 983  bool MainForm::closeSession ( bool bForc
983                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
984                  const QList<QMdiSubWindow *>& wlist                  const QList<QMdiSubWindow *>& wlist
985                          = m_pWorkspace->subWindowList();                          = m_pWorkspace->subWindowList();
986                  const int iStripCount = wlist.count();                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
987                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                          ChannelStrip *pChannelStrip
988                          ChannelStrip *pChannelStrip = NULL;                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                         QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                         if (pMdiSubWindow)  
                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
989                          if (pChannelStrip) {                          if (pChannelStrip) {
990                                  Channel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
991                                  if (bForce && pChannel)                                  if (bForce && pChannel)
992                                          pChannel->removeChannel();                                          pChannel->removeChannel();
993                                  delete pChannelStrip;                                  delete pChannelStrip;
994                          }                          }
995                          if (pMdiSubWindow)                          delete pMdiSubWindow;
                                 delete pMdiSubWindow;  
996                  }                  }
997                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
998                  // We're now clean, for sure.                  // We're now clean, for sure.
# Line 993  bool MainForm::closeSession ( bool bForc Line 1006  bool MainForm::closeSession ( bool bForc
1006  // Load a session from specific file path.  // Load a session from specific file path.
1007  bool MainForm::loadSessionFile ( const QString& sFilename )  bool MainForm::loadSessionFile ( const QString& sFilename )
1008  {  {
1009          if (m_pClient == NULL)          if (m_pClient == nullptr)
1010                  return false;                  return false;
1011    
1012          // Open and read from real file.          // Open and read from real file.
# Line 1069  bool MainForm::loadSessionFile ( const Q Line 1082  bool MainForm::loadSessionFile ( const Q
1082  // Save current session to specific file path.  // Save current session to specific file path.
1083  bool MainForm::saveSessionFile ( const QString& sFilename )  bool MainForm::saveSessionFile ( const QString& sFilename )
1084  {  {
1085          if (m_pClient == NULL)          if (m_pClient == nullptr)
1086                  return false;                  return false;
1087    
1088          // Check whether server is apparently OK...          // Check whether server is apparently OK...
# Line 1259  bool MainForm::saveSessionFile ( const Q Line 1272  bool MainForm::saveSessionFile ( const Q
1272                  }                  }
1273                  ts << endl;                  ts << endl;
1274                  // Check for errors...                  // Check for errors...
1275                  if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) {                  if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) {
1276                          appendMessagesClient("lscp_list_midi_instruments");                          appendMessagesClient("lscp_list_midi_instruments");
1277                          iErrors++;                          iErrors++;
1278                  }                  }
# Line 1267  bool MainForm::saveSessionFile ( const Q Line 1280  bool MainForm::saveSessionFile ( const Q
1280                  midiInstrumentMap.insert(iMidiMap, iMap);                  midiInstrumentMap.insert(iMidiMap, iMap);
1281          }          }
1282          // Check for errors...          // Check for errors...
1283          if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {          if (piMaps == nullptr && ::lscp_client_get_errno(m_pClient)) {
1284                  appendMessagesClient("lscp_list_midi_instrument_maps");                  appendMessagesClient("lscp_list_midi_instrument_maps");
1285                  iErrors++;                  iErrors++;
1286          }          }
# Line 1277  bool MainForm::saveSessionFile ( const Q Line 1290  bool MainForm::saveSessionFile ( const Q
1290          int iChannelID = 0;          int iChannelID = 0;
1291          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1292                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1293          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1294          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
1295                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
1296                  if (pChannelStrip) {                  if (pChannelStrip) {
1297                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1298                          if (pChannel) {                          if (pChannel) {
# Line 1488  void MainForm::fileSaveAs (void) Line 1498  void MainForm::fileSaveAs (void)
1498  // Reset the sampler instance.  // Reset the sampler instance.
1499  void MainForm::fileReset (void)  void MainForm::fileReset (void)
1500  {  {
1501          if (m_pClient == NULL)          if (m_pClient == nullptr)
1502                  return;                  return;
1503    
1504          // Ask user whether he/she want's an internal sampler reset...          // Ask user whether he/she want's an internal sampler reset...
1505          if (m_pOptions && m_pOptions->bConfirmReset) {          if (m_pOptions && m_pOptions->bConfirmReset) {
1506                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1507                  const QString& sText = tr(                  const QString& sText = tr(
1508                          "Resetting the sampler instance will close\n"                          "Resetting the sampler instance will close\n"
1509                          "all device and channel configurations.\n\n"                          "all device and channel configurations.\n\n"
# Line 1544  void MainForm::fileReset (void) Line 1554  void MainForm::fileReset (void)
1554  // Restart the client/server instance.  // Restart the client/server instance.
1555  void MainForm::fileRestart (void)  void MainForm::fileRestart (void)
1556  {  {
1557          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1558                  return;                  return;
1559    
1560          bool bRestart = true;          bool bRestart = true;
# Line 1552  void MainForm::fileRestart (void) Line 1562  void MainForm::fileRestart (void)
1562          // Ask user whether he/she want's a complete restart...          // Ask user whether he/she want's a complete restart...
1563          // (if we're currently up and running)          // (if we're currently up and running)
1564          if (m_pOptions && m_pOptions->bConfirmRestart) {          if (m_pOptions && m_pOptions->bConfirmRestart) {
1565                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1566                  const QString& sText = tr(                  const QString& sText = tr(
1567                          "New settings will be effective after\n"                          "New settings will be effective after\n"
1568                          "restarting the client/server connection.\n\n"                          "restarting the client/server connection.\n\n"
# Line 1612  void MainForm::editAddChannel (void) Line 1622  void MainForm::editAddChannel (void)
1622    
1623  void MainForm::addChannelStrip (void)  void MainForm::addChannelStrip (void)
1624  {  {
1625          if (m_pClient == NULL)          if (m_pClient == nullptr)
1626                  return;                  return;
1627    
1628          // Just create the channel instance...          // Just create the channel instance...
1629          Channel *pChannel = new Channel();          Channel *pChannel = new Channel();
1630          if (pChannel == NULL)          if (pChannel == nullptr)
1631                  return;                  return;
1632    
1633          // Before we show it up, may be we'll          // Before we show it up, may be we'll
# Line 1653  void MainForm::editRemoveChannel (void) Line 1663  void MainForm::editRemoveChannel (void)
1663    
1664  void MainForm::removeChannelStrip (void)  void MainForm::removeChannelStrip (void)
1665  {  {
1666          if (m_pClient == NULL)          if (m_pClient == nullptr)
1667                  return;                  return;
1668    
1669          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1670          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1671                  return;                  return;
1672    
1673          Channel *pChannel = pChannelStrip->channel();          Channel *pChannel = pChannelStrip->channel();
1674          if (pChannel == NULL)          if (pChannel == nullptr)
1675                  return;                  return;
1676    
1677          // Prompt user if he/she's sure about this...          // Prompt user if he/she's sure about this...
1678          if (m_pOptions && m_pOptions->bConfirmRemove) {          if (m_pOptions && m_pOptions->bConfirmRemove) {
1679                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1680                  const QString& sText = tr(                  const QString& sText = tr(
1681                          "About to remove channel:\n\n"                          "About to remove channel:\n\n"
1682                          "%1\n\n"                          "%1\n\n"
# Line 1709  void MainForm::removeChannelStrip (void) Line 1719  void MainForm::removeChannelStrip (void)
1719  // Setup current sampler channel.  // Setup current sampler channel.
1720  void MainForm::editSetupChannel (void)  void MainForm::editSetupChannel (void)
1721  {  {
1722          if (m_pClient == NULL)          if (m_pClient == nullptr)
1723                  return;                  return;
1724    
1725          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1726          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1727                  return;                  return;
1728    
1729          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1724  void MainForm::editSetupChannel (void) Line 1734  void MainForm::editSetupChannel (void)
1734  // Edit current sampler channel.  // Edit current sampler channel.
1735  void MainForm::editEditChannel (void)  void MainForm::editEditChannel (void)
1736  {  {
1737          if (m_pClient == NULL)          if (m_pClient == nullptr)
1738                  return;                  return;
1739    
1740          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1741          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1742                  return;                  return;
1743    
1744          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1739  void MainForm::editEditChannel (void) Line 1749  void MainForm::editEditChannel (void)
1749  // Reset current sampler channel.  // Reset current sampler channel.
1750  void MainForm::editResetChannel (void)  void MainForm::editResetChannel (void)
1751  {  {
1752          if (m_pClient == NULL)          if (m_pClient == nullptr)
1753                  return;                  return;
1754    
1755          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1756          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1757                  return;                  return;
1758    
1759          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1754  void MainForm::editResetChannel (void) Line 1764  void MainForm::editResetChannel (void)
1764  // Reset all sampler channels.  // Reset all sampler channels.
1765  void MainForm::editResetAllChannels (void)  void MainForm::editResetAllChannels (void)
1766  {  {
1767          if (m_pClient == NULL)          if (m_pClient == nullptr)
1768                  return;                  return;
1769    
1770          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
# Line 1762  void MainForm::editResetAllChannels (voi Line 1772  void MainForm::editResetAllChannels (voi
1772          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1773          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1774                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1775          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1776          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
1777                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
1778                  if (pChannelStrip)                  if (pChannelStrip)
1779                          pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1780          }          }
# Line 1826  void MainForm::viewMessages ( bool bOn ) Line 1833  void MainForm::viewMessages ( bool bOn )
1833  // Show/hide the MIDI instrument list-view form.  // Show/hide the MIDI instrument list-view form.
1834  void MainForm::viewInstruments (void)  void MainForm::viewInstruments (void)
1835  {  {
1836          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1837                  return;                  return;
1838    
1839          if (m_pInstrumentListForm) {          if (m_pInstrumentListForm) {
# Line 1845  void MainForm::viewInstruments (void) Line 1852  void MainForm::viewInstruments (void)
1852  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1853  void MainForm::viewDevices (void)  void MainForm::viewDevices (void)
1854  {  {
1855          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1856                  return;                  return;
1857    
1858          if (m_pDeviceForm) {          if (m_pDeviceForm) {
# Line 1864  void MainForm::viewDevices (void) Line 1871  void MainForm::viewDevices (void)
1871  // Show options dialog.  // Show options dialog.
1872  void MainForm::viewOptions (void)  void MainForm::viewOptions (void)
1873  {  {
1874          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1875                  return;                  return;
1876    
1877          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
# Line 1876  void MainForm::viewOptions (void) Line 1883  void MainForm::viewOptions (void)
1883                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
1884                          m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();                          m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
1885                  // To track down deferred or immediate changes.                  // To track down deferred or immediate changes.
1886                  const QString sOldServerHost      = m_pOptions->sServerHost;                  const QString sOldServerHost       = m_pOptions->sServerHost;
1887                  const int     iOldServerPort      = m_pOptions->iServerPort;                  const int     iOldServerPort       = m_pOptions->iServerPort;
1888                  const int     iOldServerTimeout   = m_pOptions->iServerTimeout;                  const int     iOldServerTimeout    = m_pOptions->iServerTimeout;
1889                  const bool    bOldServerStart     = m_pOptions->bServerStart;                  const bool    bOldServerStart      = m_pOptions->bServerStart;
1890                  const QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;                  const QString sOldServerCmdLine    = m_pOptions->sServerCmdLine;
1891                  const bool    bOldMessagesLog     = m_pOptions->bMessagesLog;                  const bool    bOldMessagesLog      = m_pOptions->bMessagesLog;
1892                  const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath;                  const QString sOldMessagesLogPath  = m_pOptions->sMessagesLogPath;
1893                  const QString sOldDisplayFont     = m_pOptions->sDisplayFont;                  const QString sOldDisplayFont      = m_pOptions->sDisplayFont;
1894                  const bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;                  const bool    bOldDisplayEffect    = m_pOptions->bDisplayEffect;
1895                  const int     iOldMaxVolume       = m_pOptions->iMaxVolume;                  const int     iOldMaxVolume        = m_pOptions->iMaxVolume;
1896                  const QString sOldMessagesFont    = m_pOptions->sMessagesFont;                  const QString sOldMessagesFont     = m_pOptions->sMessagesFont;
1897                  const bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;                  const bool    bOldKeepOnTop        = m_pOptions->bKeepOnTop;
1898                  const bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;                  const bool    bOldStdoutCapture    = m_pOptions->bStdoutCapture;
1899                  const int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;                  const int     bOldMessagesLimit    = m_pOptions->bMessagesLimit;
1900                  const int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;                  const int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1901                  const bool    bOldCompletePath    = m_pOptions->bCompletePath;                  const bool    bOldCompletePath     = m_pOptions->bCompletePath;
1902                  const bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;                  const bool    bOldInstrumentNames  = m_pOptions->bInstrumentNames;
1903                  const int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;                  const int     iOldMaxRecentFiles   = m_pOptions->iMaxRecentFiles;
1904                  const int     iOldBaseFontSize    = m_pOptions->iBaseFontSize;                  const int     iOldBaseFontSize     = m_pOptions->iBaseFontSize;
1905                    const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme;
1906                    const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme;
1907                  // Load the current setup settings.                  // Load the current setup settings.
1908                  pOptionsForm->setup(m_pOptions);                  pOptionsForm->setup(m_pOptions);
1909                  // Show the setup dialog...                  // Show the setup dialog...
1910                  if (pOptionsForm->exec()) {                  if (pOptionsForm->exec()) {
1911                          // Warn if something will be only effective on next run.                          // Warn if something will be only effective on next run.
1912                            int iNeedRestart = 0;
1913                          if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||                          if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||
1914                                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||                                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture)) {
1915                                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||                                  updateMessagesCapture();
1916                                    ++iNeedRestart;
1917                            }
1918                            if (( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1919                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||
1920                                  (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {                                  (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {
1921                                  QMessageBox::information(this,                                  ++iNeedRestart;
1922                                          QSAMPLER_TITLE ": " + tr("Information"),                          }
1923                                          tr("Some settings may be only effective\n"                          // Check whether restart is needed or whether
1924                                          "next time you start this program."));                          // custom options maybe set up immediately...
1925                                  updateMessagesCapture();                          if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) {
1926                                    if (m_pOptions->sCustomStyleTheme.isEmpty()) {
1927                                            ++iNeedRestart;
1928                                    } else {
1929                                            QApplication::setStyle(
1930                                                    QStyleFactory::create(m_pOptions->sCustomStyleTheme));
1931                                    }
1932                            }
1933                            if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) {
1934                                    if (m_pOptions->sCustomColorTheme.isEmpty()) {
1935                                            ++iNeedRestart;
1936                                    } else {
1937                                            QPalette pal;
1938                                            if (PaletteForm::namedPalette(
1939                                                            &m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal))
1940                                                    QApplication::setPalette(pal);
1941                                    }
1942                          }                          }
1943                          // Check wheather something immediate has changed.                          // Check wheather something immediate has changed.
1944                          if (( bOldMessagesLog && !m_pOptions->bMessagesLog) ||                          if (( bOldMessagesLog && !m_pOptions->bMessagesLog) ||
# Line 1937  void MainForm::viewOptions (void) Line 1966  void MainForm::viewOptions (void)
1966                                  (!bOldMessagesLimit &&  m_pOptions->bMessagesLimit) ||                                  (!bOldMessagesLimit &&  m_pOptions->bMessagesLimit) ||
1967                                  (iOldMessagesLimitLines !=  m_pOptions->iMessagesLimitLines))                                  (iOldMessagesLimitLines !=  m_pOptions->iMessagesLimitLines))
1968                                  updateMessagesLimit();                                  updateMessagesLimit();
1969                            // Show restart needed message...
1970                            if (iNeedRestart > 0) {
1971                                    QMessageBox::information(this,
1972                                            tr("Information"),
1973                                            tr("Some settings may be only effective\n"
1974                                            "next time you start this program."));
1975                            }
1976                          // And now the main thing, whether we'll do client/server recycling?                          // And now the main thing, whether we'll do client/server recycling?
1977                          if ((sOldServerHost != m_pOptions->sServerHost) ||                          if ((sOldServerHost != m_pOptions->sServerHost) ||
1978                                  (iOldServerPort != m_pOptions->iServerPort) ||                                  (iOldServerPort != m_pOptions->iServerPort) ||
# Line 1970  void MainForm::channelsArrange (void) Line 2006  void MainForm::channelsArrange (void)
2006    
2007          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2008          int y = 0;          int y = 0;
2009          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2010          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  pMdiSubWindow->adjustSize();
2011                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  const QRect& frameRect
2012                  if (pMdiSubWindow) {                          = pMdiSubWindow->frameGeometry();
2013                          pMdiSubWindow->adjustSize();                  int w = m_pWorkspace->width();
2014                          int iWidth = m_pWorkspace->width();                  if (w < frameRect.width())
2015                          if (iWidth < pMdiSubWindow->width())                          w = frameRect.width();
2016                                  iWidth = pMdiSubWindow->width();                  const int h = frameRect.height();
2017                          const int iHeight = pMdiSubWindow->frameGeometry().height();                  pMdiSubWindow->setGeometry(0, y, w, h);
2018                          pMdiSubWindow->setGeometry(0, y, iWidth, iHeight);                  y += h;
                         y += iHeight;  
                 }  
2019          }          }
2020          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
2021    
# Line 1992  void MainForm::channelsArrange (void) Line 2026  void MainForm::channelsArrange (void)
2026  // Auto-arrange channel strips.  // Auto-arrange channel strips.
2027  void MainForm::channelsAutoArrange ( bool bOn )  void MainForm::channelsAutoArrange ( bool bOn )
2028  {  {
2029          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2030                  return;                  return;
2031    
2032          // Toggle the auto-arrange flag.          // Toggle the auto-arrange flag.
# Line 2073  void MainForm::helpAbout (void) Line 2107  void MainForm::helpAbout (void)
2107                  sText += "</font></small>";                  sText += "</font></small>";
2108          }          }
2109          sText += "<br />\n";          sText += "<br />\n";
2110          sText += tr("Using") + ": ";          sText += tr("Using: Qt %1").arg(qVersion());
2111    #if defined(QT_STATIC)
2112            sText += "-static";
2113    #endif
2114            sText += ", ";
2115          sText += ::lscp_client_package();          sText += ::lscp_client_package();
2116          sText += " ";          sText += " ";
2117          sText += ::lscp_client_version();          sText += ::lscp_client_version();
# Line 2096  void MainForm::helpAbout (void) Line 2134  void MainForm::helpAbout (void)
2134          sText += "</small>";          sText += "</small>";
2135          sText += "</p>\n";          sText += "</p>\n";
2136    
2137          QMessageBox::about(this, tr("About") + " " QSAMPLER_TITLE, sText);          QMessageBox::about(this, tr("About"), sText);
2138  }  }
2139    
2140    
# Line 2109  void MainForm::stabilizeForm (void) Line 2147  void MainForm::stabilizeForm (void)
2147          QString sSessionName = sessionName(m_sFilename);          QString sSessionName = sessionName(m_sFilename);
2148          if (m_iDirtyCount > 0)          if (m_iDirtyCount > 0)
2149                  sSessionName += " *";                  sSessionName += " *";
2150          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));          setWindowTitle(sSessionName);
2151    
2152          // Update the main menu state...          // Update the main menu state...
2153          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
2154          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();
2155          const bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          const bool bHasClient = (m_pOptions != nullptr && m_pClient != nullptr);
2156          const bool bHasChannel = (bHasClient && pChannelStrip != NULL);          const bool bHasChannel = (bHasClient && pChannelStrip != nullptr);
2157          const bool bHasChannels = (bHasClient && wlist.count() > 0);          const bool bHasChannels = (bHasClient && wlist.count() > 0);
2158          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
2159          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
2160          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
2161          m_ui.fileSaveAsAction->setEnabled(bHasClient);          m_ui.fileSaveAsAction->setEnabled(bHasClient);
2162          m_ui.fileResetAction->setEnabled(bHasClient);          m_ui.fileResetAction->setEnabled(bHasClient);
2163          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == nullptr);
2164          m_ui.editAddChannelAction->setEnabled(bHasClient);          m_ui.editAddChannelAction->setEnabled(bHasClient);
2165          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);
2166          m_ui.editSetupChannelAction->setEnabled(bHasChannel);          m_ui.editSetupChannelAction->setEnabled(bHasChannel);
# Line 2271  void MainForm::updateAllChannelStrips ( Line 2309  void MainForm::updateAllChannelStrips (
2309    
2310          // Retrieve the current channel list.          // Retrieve the current channel list.
2311          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2312          if (piChannelIDs == NULL) {          if (piChannelIDs == nullptr) {
2313                  if (::lscp_client_get_errno(m_pClient)) {                  if (::lscp_client_get_errno(m_pClient)) {
2314                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
2315                          appendMessagesError(                          appendMessagesError(
# Line 2291  void MainForm::updateAllChannelStrips ( Line 2329  void MainForm::updateAllChannelStrips (
2329                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2330                          const QList<QMdiSubWindow *>& wlist                          const QList<QMdiSubWindow *>& wlist
2331                                  = m_pWorkspace->subWindowList();                                  = m_pWorkspace->subWindowList();
2332                          const int iStripCount = wlist.count();                          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2333                          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                  ChannelStrip *pChannelStrip
2334                                  ChannelStrip *pChannelStrip = NULL;                                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                                 if (pMdiSubWindow)  
                                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2335                                  if (pChannelStrip) {                                  if (pChannelStrip) {
2336                                          bool bExists = false;                                          bool bExists = false;
2337                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2338                                                  Channel *pChannel = pChannelStrip->channel();                                                  Channel *pChannel = pChannelStrip->channel();
2339                                                  if (pChannel == NULL)                                                  if (pChannel == nullptr)
2340                                                          break;                                                          break;
2341                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {
2342                                                          // strip exists, don't touch it                                                          // strip exists, don't touch it
# Line 2324  void MainForm::updateAllChannelStrips ( Line 2359  void MainForm::updateAllChannelStrips (
2359  // Update the recent files list and menu.  // Update the recent files list and menu.
2360  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2361  {  {
2362          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2363                  return;                  return;
2364    
2365          // Remove from list if already there (avoid duplicates)          // Remove from list if already there (avoid duplicates)
# Line 2339  void MainForm::updateRecentFiles ( const Line 2374  void MainForm::updateRecentFiles ( const
2374  // Update the recent files list and menu.  // Update the recent files list and menu.
2375  void MainForm::updateRecentFilesMenu (void)  void MainForm::updateRecentFilesMenu (void)
2376  {  {
2377          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2378                  return;                  return;
2379    
2380          // Time to keep the list under limits.          // Time to keep the list under limits.
# Line 2373  void MainForm::updateInstrumentNames (vo Line 2408  void MainForm::updateInstrumentNames (vo
2408                  return;                  return;
2409    
2410          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2411          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2412          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2413                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2414                  if (pChannelStrip)                  if (pChannelStrip)
2415                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
2416          }          }
# Line 2389  void MainForm::updateInstrumentNames (vo Line 2421  void MainForm::updateInstrumentNames (vo
2421  // Force update of the channels display font.  // Force update of the channels display font.
2422  void MainForm::updateDisplayFont (void)  void MainForm::updateDisplayFont (void)
2423  {  {
2424          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2425                  return;                  return;
2426    
2427          // Check if display font is legal.          // Check if display font is legal.
# Line 2408  void MainForm::updateDisplayFont (void) Line 2440  void MainForm::updateDisplayFont (void)
2440                  return;                  return;
2441    
2442          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2443          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2444          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2445                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2446                  if (pChannelStrip)                  if (pChannelStrip)
2447                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2448          }          }
# Line 2431  void MainForm::updateDisplayEffect (void Line 2460  void MainForm::updateDisplayEffect (void
2460                  return;                  return;
2461    
2462          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2463          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2464          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2465                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2466                  if (pChannelStrip)                  if (pChannelStrip)
2467                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2468          }          }
# Line 2447  void MainForm::updateDisplayEffect (void Line 2473  void MainForm::updateDisplayEffect (void
2473  // Force update of the channels maximum volume setting.  // Force update of the channels maximum volume setting.
2474  void MainForm::updateMaxVolume (void)  void MainForm::updateMaxVolume (void)
2475  {  {
2476          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2477                  return;                  return;
2478    
2479  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
# Line 2464  void MainForm::updateMaxVolume (void) Line 2490  void MainForm::updateMaxVolume (void)
2490                  return;                  return;
2491    
2492          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2493          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2494          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2495                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2496                  if (pChannelStrip)                  if (pChannelStrip)
2497                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
2498          }          }
# Line 2481  void MainForm::updateMaxVolume (void) Line 2504  void MainForm::updateMaxVolume (void)
2504  // QSampler::MainForm -- Messages window form handlers.  // QSampler::MainForm -- Messages window form handlers.
2505    
2506  // Messages output methods.  // Messages output methods.
2507  void MainForm::appendMessages( const QString& s )  void MainForm::appendMessages ( const QString& s )
2508  {  {
2509          if (m_pMessages)          if (m_pMessages)
2510                  m_pMessages->appendMessages(s);                  m_pMessages->appendMessages(s);
# Line 2489  void MainForm::appendMessages( const QSt Line 2512  void MainForm::appendMessages( const QSt
2512          statusBar()->showMessage(s, 3000);          statusBar()->showMessage(s, 3000);
2513  }  }
2514    
2515  void MainForm::appendMessagesColor( const QString& s, const QString& c )  void MainForm::appendMessagesColor ( const QString& s, const QColor& rgb )
2516  {  {
2517          if (m_pMessages)          if (m_pMessages)
2518                  m_pMessages->appendMessagesColor(s, c);                  m_pMessages->appendMessagesColor(s, rgb);
2519    
2520          statusBar()->showMessage(s, 3000);          statusBar()->showMessage(s, 3000);
2521  }  }
2522    
2523  void MainForm::appendMessagesText( const QString& s )  void MainForm::appendMessagesText ( const QString& s )
2524  {  {
2525          if (m_pMessages)          if (m_pMessages)
2526                  m_pMessages->appendMessagesText(s);                  m_pMessages->appendMessagesText(s);
2527  }  }
2528    
2529  void MainForm::appendMessagesError( const QString& sText )  void MainForm::appendMessagesError ( const QString& s )
2530  {  {
2531          if (m_pMessages)          if (m_pMessages)
2532                  m_pMessages->show();                  m_pMessages->show();
2533    
2534          appendMessagesColor(sText.simplified(), "#ff0000");          appendMessagesColor(s.simplified(), Qt::red);
2535    
2536          // Make it look responsive...:)          // Make it look responsive...:)
2537          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2538    
2539          if (m_pOptions && m_pOptions->bConfirmError) {          if (m_pOptions && m_pOptions->bConfirmError) {
2540                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Error");                  const QString& sTitle = tr("Error");
2541          #if 0          #if 0
2542                  QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel);                  QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel);
2543          #else          #else
2544                  QMessageBox mbox(this);                  QMessageBox mbox(this);
2545                  mbox.setIcon(QMessageBox::Critical);                  mbox.setIcon(QMessageBox::Critical);
2546                  mbox.setWindowTitle(sTitle);                  mbox.setWindowTitle(sTitle);
2547                  mbox.setText(sText);                  mbox.setText(s);
2548                  mbox.setStandardButtons(QMessageBox::Cancel);                  mbox.setStandardButtons(QMessageBox::Cancel);
2549                  QCheckBox cbox(tr("Don't show this again"));                  QCheckBox cbox(tr("Don't show this again"));
2550                  cbox.setChecked(false);                  cbox.setChecked(false);
# Line 2537  void MainForm::appendMessagesError( cons Line 2560  void MainForm::appendMessagesError( cons
2560  // This is a special message format, just for client results.  // This is a special message format, just for client results.
2561  void MainForm::appendMessagesClient( const QString& s )  void MainForm::appendMessagesClient( const QString& s )
2562  {  {
2563          if (m_pClient == NULL)          if (m_pClient == nullptr)
2564                  return;                  return;
2565    
2566          appendMessagesColor(s + QString(": %1 (errno=%2)")          appendMessagesColor(s + QString(": %1 (errno=%2)")
# Line 2552  void MainForm::appendMessagesClient( con Line 2575  void MainForm::appendMessagesClient( con
2575  // Force update of the messages font.  // Force update of the messages font.
2576  void MainForm::updateMessagesFont (void)  void MainForm::updateMessagesFont (void)
2577  {  {
2578          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2579                  return;                  return;
2580    
2581          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {
# Line 2566  void MainForm::updateMessagesFont (void) Line 2589  void MainForm::updateMessagesFont (void)
2589  // Update messages window line limit.  // Update messages window line limit.
2590  void MainForm::updateMessagesLimit (void)  void MainForm::updateMessagesLimit (void)
2591  {  {
2592          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2593                  return;                  return;
2594    
2595          if (m_pMessages) {          if (m_pMessages) {
# Line 2581  void MainForm::updateMessagesLimit (void Line 2604  void MainForm::updateMessagesLimit (void
2604  // Enablement of the messages capture feature.  // Enablement of the messages capture feature.
2605  void MainForm::updateMessagesCapture (void)  void MainForm::updateMessagesCapture (void)
2606  {  {
2607          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2608                  return;                  return;
2609    
2610          if (m_pMessages)          if (m_pMessages)
# Line 2595  void MainForm::updateMessagesCapture (vo Line 2618  void MainForm::updateMessagesCapture (vo
2618  // The channel strip creation executive.  // The channel strip creation executive.
2619  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2620  {  {
2621          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == nullptr || pChannel == nullptr)
2622                  return NULL;                  return nullptr;
2623    
2624          // Add a new channel itema...          // Add a new channel itema...
2625          ChannelStrip *pChannelStrip = new ChannelStrip();          ChannelStrip *pChannelStrip = new ChannelStrip();
2626          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
2627                  return NULL;                  return nullptr;
2628    
2629          // Set some initial channel strip options...          // Set some initial channel strip options...
2630          if (m_pOptions) {          if (m_pOptions) {
# Line 2617  ChannelStrip *MainForm::createChannelStr Line 2640  ChannelStrip *MainForm::createChannelStr
2640          }          }
2641    
2642          // Add it to workspace...          // Add it to workspace...
2643          m_pWorkspace->addSubWindow(pChannelStrip,          QMdiSubWindow *pMdiSubWindow
2644                  Qt::SubWindow | Qt::FramelessWindowHint);                  = m_pWorkspace->addSubWindow(pChannelStrip,
2645                            Qt::SubWindow | Qt::FramelessWindowHint);
2646            pMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose);
2647    
2648          // Actual channel strip setup...          // Actual channel strip setup...
2649          pChannelStrip->setup(pChannel);          pChannelStrip->setup(pChannel);
# Line 2642  void MainForm::destroyChannelStrip ( Cha Line 2667  void MainForm::destroyChannelStrip ( Cha
2667  {  {
2668          QMdiSubWindow *pMdiSubWindow          QMdiSubWindow *pMdiSubWindow
2669                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2670          if (pMdiSubWindow == NULL)          if (pMdiSubWindow == nullptr)
2671                  return;                  return;
2672    
2673          // Just delete the channel strip.          // Just delete the channel strip.
# Line 2661  ChannelStrip *MainForm::activeChannelStr Line 2686  ChannelStrip *MainForm::activeChannelStr
2686          if (pMdiSubWindow)          if (pMdiSubWindow)
2687                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2688          else          else
2689                  return NULL;                  return nullptr;
2690  }  }
2691    
2692    
2693  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2694  ChannelStrip *MainForm::channelStripAt ( int iStrip )  ChannelStrip *MainForm::channelStripAt ( int iStrip )
2695  {  {
2696          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return nullptr;
2697    
2698          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2699                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2700          if (wlist.isEmpty())          if (wlist.isEmpty())
2701                  return NULL;                  return nullptr;
2702    
2703          if (iStrip < 0 || iStrip >= wlist.count())          if (iStrip < 0 || iStrip >= wlist.count())
2704                  return NULL;                  return nullptr;
2705    
2706          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2707          if (pMdiSubWindow)          if (pMdiSubWindow)
2708                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2709          else          else
2710                  return NULL;                  return nullptr;
2711  }  }
2712    
2713    
# Line 2692  ChannelStrip *MainForm::channelStrip ( i Line 2717  ChannelStrip *MainForm::channelStrip ( i
2717          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2718                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2719          if (wlist.isEmpty())          if (wlist.isEmpty())
2720                  return NULL;                  return nullptr;
2721    
2722          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2723          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2724                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2725                  if (pChannelStrip) {                  if (pChannelStrip) {
2726                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2727                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2708  ChannelStrip *MainForm::channelStrip ( i Line 2730  ChannelStrip *MainForm::channelStrip ( i
2730          }          }
2731    
2732          // Not found.          // Not found.
2733          return NULL;          return nullptr;
2734  }  }
2735    
2736    
# Line 2723  void MainForm::channelsMenuAboutToShow ( Line 2745  void MainForm::channelsMenuAboutToShow (
2745                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2746          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2747                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2748                  const int iStripCount = wlist.count();                  int iStrip = 0;
2749                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2750                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip
2751                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                         if (pMdiSubWindow)  
                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2752                          if (pChannelStrip) {                          if (pChannelStrip) {
2753                                  QAction *pAction = m_ui.channelsMenu->addAction(                                  QAction *pAction = m_ui.channelsMenu->addAction(
2754                                          pChannelStrip->windowTitle(),                                          pChannelStrip->windowTitle(),
# Line 2737  void MainForm::channelsMenuAboutToShow ( Line 2757  void MainForm::channelsMenuAboutToShow (
2757                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);
2758                                  pAction->setData(iStrip);                                  pAction->setData(iStrip);
2759                          }                          }
2760                            ++iStrip;
2761                  }                  }
2762          }          }
2763  }  }
# Line 2747  void MainForm::channelsMenuActivated (vo Line 2768  void MainForm::channelsMenuActivated (vo
2768  {  {
2769          // Retrive channel index from action data...          // Retrive channel index from action data...
2770          QAction *pAction = qobject_cast<QAction *> (sender());          QAction *pAction = qobject_cast<QAction *> (sender());
2771          if (pAction == NULL)          if (pAction == nullptr)
2772                  return;                  return;
2773    
2774          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
# Line 2778  void MainForm::stopSchedule (void) Line 2799  void MainForm::stopSchedule (void)
2799  // Timer slot funtion.  // Timer slot funtion.
2800  void MainForm::timerSlot (void)  void MainForm::timerSlot (void)
2801  {  {
2802          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2803                  return;                  return;
2804    
2805          // 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 2813  void MainForm::timerSlot (void) Line 2834  void MainForm::timerSlot (void)
2834                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2835                                  const QList<QMdiSubWindow *>& wlist                                  const QList<QMdiSubWindow *>& wlist
2836                                          = m_pWorkspace->subWindowList();                                          = m_pWorkspace->subWindowList();
2837                                  const int iStripCount = wlist.count();                                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2838                                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                          ChannelStrip *pChannelStrip
2839                                          ChannelStrip *pChannelStrip = NULL;                                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                                         QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                                         if (pMdiSubWindow)  
                                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2840                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
2841                                                  pChannelStrip->updateChannelUsage();                                                  pChannelStrip->updateChannelUsage();
2842                                  }                                  }
2843                          }                          }
2844                  }                  }
2845    
2846            #if CONFIG_LSCP_CLIENT_CONNECTION_LOST
2847                    // If we lost connection to server: Try to automatically reconnect if we
2848                    // did not start the server.
2849                    //
2850                    // TODO: If we started the server, then we might inform the user that
2851                    // the server probably crashed and asking user ONCE whether we should
2852                    // restart the server.
2853                    if (lscp_client_connection_lost(m_pClient) && !m_pServer)
2854                            startAutoReconnectClient();
2855            #endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST
2856          }          }
2857    
2858          // Register the next timer slot.          // Register the next timer slot.
# Line 2837  void MainForm::timerSlot (void) Line 2866  void MainForm::timerSlot (void)
2866  // Start linuxsampler server...  // Start linuxsampler server...
2867  void MainForm::startServer (void)  void MainForm::startServer (void)
2868  {  {
2869          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2870                  return;                  return;
2871    
2872          // Aren't already a client, are we?          // Aren't already a client, are we?
# Line 2847  void MainForm::startServer (void) Line 2876  void MainForm::startServer (void)
2876          // Is the server process instance still here?          // Is the server process instance still here?
2877          if (m_pServer) {          if (m_pServer) {
2878                  if (QMessageBox::warning(this,                  if (QMessageBox::warning(this,
2879                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
2880                          tr("Could not start the LinuxSampler server.\n\n"                          tr("Could not start the LinuxSampler server.\n\n"
2881                          "Maybe it is already started."),                          "Maybe it is already started."),
2882                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
# Line 2900  void MainForm::startServer (void) Line 2929  void MainForm::startServer (void)
2929    
2930          // Show startup results...          // Show startup results...
2931          appendMessages(          appendMessages(
2932                  tr("Server was started with PID=%1.").arg((long) m_pServer->pid()));                  tr("Server was started with PID=%1.")
2933                    #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
2934                            .arg(quint64(m_pServer->pid())));
2935                    #else
2936                            .arg(quint64(m_pServer->processId())));
2937                    #endif
2938    
2939          // Reset (yet again) the timer counters,          // Reset (yet again) the timer counters,
2940          // but this time is deferred as the user opted.          // but this time is deferred as the user opted.
# Line 2917  void MainForm::stopServer ( bool bIntera Line 2951  void MainForm::stopServer ( bool bIntera
2951    
2952          if (m_pServer && bInteractive) {          if (m_pServer && bInteractive) {
2953                  if (QMessageBox::question(this,                  if (QMessageBox::question(this,
2954                          QSAMPLER_TITLE ": " + tr("The backend's fate ..."),                          tr("The backend's fate ..."),
2955                          tr("You have the option to keep the sampler backend (LinuxSampler)\n"                          tr("You have the option to keep the sampler backend (LinuxSampler)\n"
2956                          "running in the background. The sampler would continue to work\n"                          "running in the background. The sampler would continue to work\n"
2957                          "according to your current sampler session and you could alter the\n"                          "according to your current sampler session and you could alter the\n"
# Line 2950  void MainForm::stopServer ( bool bIntera Line 2984  void MainForm::stopServer ( bool bIntera
2984    
2985          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2986          if (bGraceWait) {          if (bGraceWait) {
2987                  QTime t;                  QElapsedTimer timer;
2988                  t.start();                  timer.start();
2989                  while (t.elapsed() < QSAMPLER_TIMER_MSECS)                  while (timer.elapsed() < QSAMPLER_TIMER_MSECS)
2990                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2991          }          }
2992  }  }
# Line 2982  void MainForm::processServerExit (void) Line 3016  void MainForm::processServerExit (void)
3016                          // Force final server shutdown...                          // Force final server shutdown...
3017                          m_pServer->kill();                          m_pServer->kill();
3018                          // Give it some time to terminate gracefully and stabilize...                          // Give it some time to terminate gracefully and stabilize...
3019                          QTime t;                          QElapsedTimer timer;
3020                          t.start();                          timer.start();
3021                          while (t.elapsed() < QSAMPLER_TIMER_MSECS)                          while (timer.elapsed() < QSAMPLER_TIMER_MSECS)
3022                                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
3023                  }                  }
3024                  // Force final server shutdown...                  // Force final server shutdown...
# Line 2992  void MainForm::processServerExit (void) Line 3026  void MainForm::processServerExit (void)
3026                          tr("Server was stopped with exit status %1.")                          tr("Server was stopped with exit status %1.")
3027                          .arg(m_pServer->exitStatus()));                          .arg(m_pServer->exitStatus()));
3028                  delete m_pServer;                  delete m_pServer;
3029                  m_pServer = NULL;                  m_pServer = nullptr;
3030          }          }
3031    
3032          // Again, make status visible stable.          // Again, make status visible stable.
# Line 3008  lscp_status_t qsampler_client_callback ( Line 3042  lscp_status_t qsampler_client_callback (
3042          lscp_event_t event, const char *pchData, int cchData, void *pvData )          lscp_event_t event, const char *pchData, int cchData, void *pvData )
3043  {  {
3044          MainForm* pMainForm = (MainForm *) pvData;          MainForm* pMainForm = (MainForm *) pvData;
3045          if (pMainForm == NULL)          if (pMainForm == nullptr)
3046                  return LSCP_FAILED;                  return LSCP_FAILED;
3047    
3048          // ATTN: DO NOT EVER call any GUI code here,          // ATTN: DO NOT EVER call any GUI code here,
# Line 3022  lscp_status_t qsampler_client_callback ( Line 3056  lscp_status_t qsampler_client_callback (
3056    
3057    
3058  // Start our almighty client...  // Start our almighty client...
3059  bool MainForm::startClient (void)  bool MainForm::startClient (bool bReconnectOnly)
3060  {  {
3061          // Have it a setup?          // Have it a setup?
3062          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
3063                  return false;                  return false;
3064    
3065          // Aren't we already started, are we?          // Aren't we already started, are we?
# Line 3039  bool MainForm::startClient (void) Line 3073  bool MainForm::startClient (void)
3073          m_pClient = ::lscp_client_create(          m_pClient = ::lscp_client_create(
3074                  m_pOptions->sServerHost.toUtf8().constData(),                  m_pOptions->sServerHost.toUtf8().constData(),
3075                  m_pOptions->iServerPort, qsampler_client_callback, this);                  m_pOptions->iServerPort, qsampler_client_callback, this);
3076          if (m_pClient == NULL) {          if (m_pClient == nullptr) {
3077                  // Is this the first try?                  // Is this the first try?
3078                  // maybe we need to start a local server...                  // maybe we need to start a local server...
3079                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
3080                          || !m_pOptions->bServerStart) {                          || !m_pOptions->bServerStart || bReconnectOnly)
3081                          appendMessagesError(                  {
3082                                  tr("Could not connect to server as client.\n\nSorry."));                          // if this method is called from autoReconnectClient()
3083                            // then don't bother user with an error message...
3084                            if (!bReconnectOnly) {
3085                                    appendMessagesError(
3086                                            tr("Could not connect to server as client.\n\nSorry.")
3087                                    );
3088                            }
3089                  } else {                  } else {
3090                          startServer();                          startServer();
3091                  }                  }
# Line 3109  bool MainForm::startClient (void) Line 3149  bool MainForm::startClient (void)
3149          if (!m_pOptions->sSessionFile.isEmpty()) {          if (!m_pOptions->sSessionFile.isEmpty()) {
3150                  // Just load the prabably startup session...                  // Just load the prabably startup session...
3151                  if (loadSessionFile(m_pOptions->sSessionFile)) {                  if (loadSessionFile(m_pOptions->sSessionFile)) {
3152                          m_pOptions->sSessionFile = QString::null;                          m_pOptions->sSessionFile = QString();
3153                          return true;                          return true;
3154                  }                  }
3155          }          }
# Line 3125  bool MainForm::startClient (void) Line 3165  bool MainForm::startClient (void)
3165  // Stop client...  // Stop client...
3166  void MainForm::stopClient (void)  void MainForm::stopClient (void)
3167  {  {
3168          if (m_pClient == NULL)          if (m_pClient == nullptr)
3169                  return;                  return;
3170    
3171          // Log prepare here.          // Log prepare here.
# Line 3157  void MainForm::stopClient (void) Line 3197  void MainForm::stopClient (void)
3197          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
3198          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);
3199          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
3200          m_pClient = NULL;          m_pClient = nullptr;
3201    
3202          // Hard-notify instrumnet and device configuration forms,          // Hard-notify instrumnet and device configuration forms,
3203          // if visible, that we're running out...          // if visible, that we're running out...
# Line 3174  void MainForm::stopClient (void) Line 3214  void MainForm::stopClient (void)
3214  }  }
3215    
3216    
3217    void MainForm::startAutoReconnectClient (void)
3218    {
3219            stopClient();
3220            appendMessages(tr("Trying to reconnect..."));
3221            QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3222    }
3223    
3224    
3225    void MainForm::autoReconnectClient (void)
3226    {
3227            const bool bSuccess = startClient(true);
3228            if (!bSuccess)
3229                    QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3230    }
3231    
3232    
3233  // Channel strip activation/selection.  // Channel strip activation/selection.
3234  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3235  {  {
3236          ChannelStrip *pChannelStrip = NULL;          ChannelStrip *pChannelStrip = nullptr;
3237          if (pMdiSubWindow)          if (pMdiSubWindow)
3238                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3239          if (pChannelStrip)          if (pChannelStrip)

Legend:
Removed from v.3510  
changed lines
  Added in v.3855

  ViewVC Help
Powered by ViewVC