/[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 3520 by capela, Mon Jul 1 10:53:41 2019 UTC revision 4068 by capela, Sat Nov 4 23:27:52 2023 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-2023, 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    #include <QElapsedTimer>
65    
66  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
67  #include <QMimeData>  #include <QMimeData>
68  #endif  #endif
# Line 69  const WindowFlags WindowCloseButtonHint Line 74  const WindowFlags WindowCloseButtonHint
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 113  static void qsampler_sigusr1_handler ( i Line 130  static void qsampler_sigusr1_handler ( i
130  {  {
131          char c = 1;          char c = 1;
132    
133          (::write(g_fdSigusr1[0], &c, sizeof(c)) > 0);          (void) (::write(g_fdSigusr1[0], &c, sizeof(c)) > 0);
134  }  }
135    
136  // File descriptor for SIGTERM notifier.  // File descriptor for SIGTERM notifier.
# Line 124  static void qsampler_sigterm_handler ( i Line 141  static void qsampler_sigterm_handler ( i
141  {  {
142          char c = 1;          char c = 1;
143    
144          (::write(g_fdSigterm[0], &c, sizeof(c)) > 0);          (void) (::write(g_fdSigterm[0], &c, sizeof(c)) > 0);
145  }  }
146    
147  #endif  // HAVE_SIGNAL_H  #endif  // HAVE_SIGNAL_H
# 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)
226  {  {
227          m_ui.setupUi(this);          m_ui.setupUi(this);
228    #if QT_VERSION < QT_VERSION_CHECK(6, 1, 0)
229            QMainWindow::setWindowIcon(QIcon(":/images/qsampler.png"));
230    #endif
231          // Pseudo-singleton reference setup.          // Pseudo-singleton reference setup.
232          g_pMainForm = this;          g_pMainForm = this;
233    
234          // Initialize some pointer references.          // Initialize some pointer references.
235          m_pOptions = NULL;          m_pOptions = nullptr;
236    
237          // All child forms are to be created later, not earlier than setup.          // All child forms are to be created later, not earlier than setup.
238          m_pMessages = NULL;          m_pMessages = nullptr;
239          m_pInstrumentListForm = NULL;          m_pInstrumentListForm = nullptr;
240          m_pDeviceForm = NULL;          m_pDeviceForm = nullptr;
241    
242          // We'll start clean.          // We'll start clean.
243          m_iUntitled   = 0;          m_iUntitled   = 0;
244          m_iDirtySetup = 0;          m_iDirtySetup = 0;
245          m_iDirtyCount = 0;          m_iDirtyCount = 0;
246    
247          m_pServer = NULL;          m_pServer = nullptr;
248          m_pClient = NULL;          m_pClient = nullptr;
249    
250          m_iStartDelay = 0;          m_iStartDelay = 0;
251          m_iTimerDelay = 0;          m_iTimerDelay = 0;
# Line 255  MainForm::MainForm ( QWidget *pParent ) Line 274  MainForm::MainForm ( QWidget *pParent )
274          sigemptyset(&sigusr1.sa_mask);          sigemptyset(&sigusr1.sa_mask);
275          sigusr1.sa_flags = 0;          sigusr1.sa_flags = 0;
276          sigusr1.sa_flags |= SA_RESTART;          sigusr1.sa_flags |= SA_RESTART;
277          ::sigaction(SIGUSR1, &sigusr1, NULL);          ::sigaction(SIGUSR1, &sigusr1, nullptr);
278    
279          // Initialize file descriptors for SIGTERM socket notifier.          // Initialize file descriptors for SIGTERM socket notifier.
280          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);
# Line 269  MainForm::MainForm ( QWidget *pParent ) Line 288  MainForm::MainForm ( QWidget *pParent )
288          // Install SIGTERM signal handler.          // Install SIGTERM signal handler.
289          struct sigaction sigterm;          struct sigaction sigterm;
290          sigterm.sa_handler = qsampler_sigterm_handler;          sigterm.sa_handler = qsampler_sigterm_handler;
291          ::sigemptyset(&sigterm.sa_mask);          sigemptyset(&sigterm.sa_mask);
292          sigterm.sa_flags = 0;          sigterm.sa_flags = 0;
293          sigterm.sa_flags |= SA_RESTART;          sigterm.sa_flags |= SA_RESTART;
294          ::sigaction(SIGTERM, &sigterm, NULL);          ::sigaction(SIGTERM, &sigterm, nullptr);
295          ::sigaction(SIGQUIT, &sigterm, NULL);          ::sigaction(SIGQUIT, &sigterm, nullptr);
296    
297          // Ignore SIGHUP/SIGINT signals.          // Ignore SIGHUP/SIGINT signals.
298          ::signal(SIGHUP, SIG_IGN);          ::signal(SIGHUP, SIG_IGN);
# Line 281  MainForm::MainForm ( QWidget *pParent ) Line 300  MainForm::MainForm ( QWidget *pParent )
300    
301  #else   // HAVE_SIGNAL_H  #else   // HAVE_SIGNAL_H
302    
303          m_pSigusr1Notifier = NULL;          m_pSigusr1Notifier = nullptr;
304          m_pSigtermNotifier = NULL;          m_pSigtermNotifier = nullptr;
305                    
306  #endif  // !HAVE_SIGNAL_H  #endif  // !HAVE_SIGNAL_H
307    
# Line 493  MainForm::~MainForm() Line 512  MainForm::~MainForm()
512  #endif  #endif
513    
514          // Pseudo-singleton reference shut-down.          // Pseudo-singleton reference shut-down.
515          g_pMainForm = NULL;          g_pMainForm = nullptr;
516  }  }
517    
518    
# Line 630  void MainForm::closeEvent ( QCloseEvent Line 649  void MainForm::closeEvent ( QCloseEvent
649  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
650  {  {
651          // Accept external drags only...          // Accept external drags only...
652          if (pDragEnterEvent->source() == NULL          if (pDragEnterEvent->source() == nullptr
653                  && pDragEnterEvent->mimeData()->hasUrls()) {                  && pDragEnterEvent->mimeData()->hasUrls()) {
654                  pDragEnterEvent->accept();                  pDragEnterEvent->accept();
655          } else {          } else {
# Line 654  void MainForm::dropEvent ( QDropEvent *p Line 673  void MainForm::dropEvent ( QDropEvent *p
673                          if (QFileInfo(sPath).exists()) {                          if (QFileInfo(sPath).exists()) {
674                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
675                                  Channel *pChannel = new Channel();                                  Channel *pChannel = new Channel();
676                                  if (pChannel == NULL)                                  if (pChannel == nullptr)
677                                          return;                                          return;
678                                  // Start setting the instrument filename...                                  // Start setting the instrument filename...
679                                  pChannel->setInstrument(sPath, 0);                                  pChannel->setInstrument(sPath, 0);
# Line 864  bool MainForm::newSession (void) Line 883  bool MainForm::newSession (void)
883  // Open an existing sampler session.  // Open an existing sampler session.
884  bool MainForm::openSession (void)  bool MainForm::openSession (void)
885  {  {
886          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
887                  return false;                  return false;
888    
889          // Ask for the filename to open...          // Ask for the filename to open...
890          QString sFilename = QFileDialog::getOpenFileName(this,          QString sFilename = QFileDialog::getOpenFileName(this,
891                  QSAMPLER_TITLE ": " + tr("Open Session"), // Caption.                  tr("Open Session"),                       // Caption.
892                  m_pOptions->sSessionDir,                  // Start here.                  m_pOptions->sSessionDir,                  // Start here.
893                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
894          );          );
# Line 890  bool MainForm::openSession (void) Line 909  bool MainForm::openSession (void)
909  // Save current sampler session with another name.  // Save current sampler session with another name.
910  bool MainForm::saveSession ( bool bPrompt )  bool MainForm::saveSession ( bool bPrompt )
911  {  {
912          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
913                  return false;                  return false;
914    
915          QString sFilename = m_sFilename;          QString sFilename = m_sFilename;
# Line 902  bool MainForm::saveSession ( bool bPromp Line 921  bool MainForm::saveSession ( bool bPromp
921                          sFilename = m_pOptions->sSessionDir;                          sFilename = m_pOptions->sSessionDir;
922                  // Prompt the guy...                  // Prompt the guy...
923                  sFilename = QFileDialog::getSaveFileName(this,                  sFilename = QFileDialog::getSaveFileName(this,
924                          QSAMPLER_TITLE ": " + tr("Save Session"), // Caption.                          tr("Save Session"),                       // Caption.
925                          sFilename,                                // Start here.                          sFilename,                                // Start here.
926                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
927                  );                  );
# Line 916  bool MainForm::saveSession ( bool bPromp Line 935  bool MainForm::saveSession ( bool bPromp
935                  // Check if already exists...                  // Check if already exists...
936                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
937                          if (QMessageBox::warning(this,                          if (QMessageBox::warning(this,
938                                  QSAMPLER_TITLE ": " + tr("Warning"),                                  tr("Warning"),
939                                  tr("The file already exists:\n\n"                                  tr("The file already exists:\n\n"
940                                  "\"%1\"\n\n"                                  "\"%1\"\n\n"
941                                  "Do you want to replace it?")                                  "Do you want to replace it?")
# Line 941  bool MainForm::closeSession ( bool bForc Line 960  bool MainForm::closeSession ( bool bForc
960          // Are we dirty enough to prompt it?          // Are we dirty enough to prompt it?
961          if (m_iDirtyCount > 0) {          if (m_iDirtyCount > 0) {
962                  switch (QMessageBox::warning(this,                  switch (QMessageBox::warning(this,
963                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
964                          tr("The current session has been changed:\n\n"                          tr("The current session has been changed:\n\n"
965                          "\"%1\"\n\n"                          "\"%1\"\n\n"
966                          "Do you want to save the changes?")                          "Do you want to save the changes?")
# Line 966  bool MainForm::closeSession ( bool bForc Line 985  bool MainForm::closeSession ( bool bForc
985                  m_pWorkspace->setUpdatesEnabled(false);                  m_pWorkspace->setUpdatesEnabled(false);
986                  const QList<QMdiSubWindow *>& wlist                  const QList<QMdiSubWindow *>& wlist
987                          = m_pWorkspace->subWindowList();                          = m_pWorkspace->subWindowList();
988                  const int iStripCount = wlist.count();                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
989                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                          ChannelStrip *pChannelStrip
990                          ChannelStrip *pChannelStrip = NULL;                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                         QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                         if (pMdiSubWindow)  
                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
991                          if (pChannelStrip) {                          if (pChannelStrip) {
992                                  Channel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
993                                  if (bForce && pChannel)                                  if (bForce && pChannel)
994                                          pChannel->removeChannel();                                          pChannel->removeChannel();
995                                  delete pChannelStrip;                                  delete pChannelStrip;
996                          }                          }
997                          if (pMdiSubWindow)                          delete pMdiSubWindow;
                                 delete pMdiSubWindow;  
998                  }                  }
999                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
1000                  // We're now clean, for sure.                  // We're now clean, for sure.
# Line 993  bool MainForm::closeSession ( bool bForc Line 1008  bool MainForm::closeSession ( bool bForc
1008  // Load a session from specific file path.  // Load a session from specific file path.
1009  bool MainForm::loadSessionFile ( const QString& sFilename )  bool MainForm::loadSessionFile ( const QString& sFilename )
1010  {  {
1011          if (m_pClient == NULL)          if (m_pClient == nullptr)
1012                  return false;                  return false;
1013    
1014          // Open and read from real file.          // Open and read from real file.
# Line 1069  bool MainForm::loadSessionFile ( const Q Line 1084  bool MainForm::loadSessionFile ( const Q
1084  // Save current session to specific file path.  // Save current session to specific file path.
1085  bool MainForm::saveSessionFile ( const QString& sFilename )  bool MainForm::saveSessionFile ( const QString& sFilename )
1086  {  {
1087          if (m_pClient == NULL)          if (m_pClient == nullptr)
1088                  return false;                  return false;
1089    
1090          // Check whether server is apparently OK...          // Check whether server is apparently OK...
# Line 1259  bool MainForm::saveSessionFile ( const Q Line 1274  bool MainForm::saveSessionFile ( const Q
1274                  }                  }
1275                  ts << endl;                  ts << endl;
1276                  // Check for errors...                  // Check for errors...
1277                  if (pInstrs == NULL && ::lscp_client_get_errno(m_pClient)) {                  if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) {
1278                          appendMessagesClient("lscp_list_midi_instruments");                          appendMessagesClient("lscp_list_midi_instruments");
1279                          iErrors++;                          iErrors++;
1280                  }                  }
# Line 1267  bool MainForm::saveSessionFile ( const Q Line 1282  bool MainForm::saveSessionFile ( const Q
1282                  midiInstrumentMap.insert(iMidiMap, iMap);                  midiInstrumentMap.insert(iMidiMap, iMap);
1283          }          }
1284          // Check for errors...          // Check for errors...
1285          if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {          if (piMaps == nullptr && ::lscp_client_get_errno(m_pClient)) {
1286                  appendMessagesClient("lscp_list_midi_instrument_maps");                  appendMessagesClient("lscp_list_midi_instrument_maps");
1287                  iErrors++;                  iErrors++;
1288          }          }
# Line 1277  bool MainForm::saveSessionFile ( const Q Line 1292  bool MainForm::saveSessionFile ( const Q
1292          int iChannelID = 0;          int iChannelID = 0;
1293          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1294                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1295          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1296          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
1297                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
1298                  if (pChannelStrip) {                  if (pChannelStrip) {
1299                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1300                          if (pChannel) {                          if (pChannel) {
# Line 1488  void MainForm::fileSaveAs (void) Line 1500  void MainForm::fileSaveAs (void)
1500  // Reset the sampler instance.  // Reset the sampler instance.
1501  void MainForm::fileReset (void)  void MainForm::fileReset (void)
1502  {  {
1503          if (m_pClient == NULL)          if (m_pClient == nullptr)
1504                  return;                  return;
1505    
1506          // Ask user whether he/she want's an internal sampler reset...          // Ask user whether he/she want's an internal sampler reset...
1507          if (m_pOptions && m_pOptions->bConfirmReset) {          if (m_pOptions && m_pOptions->bConfirmReset) {
1508                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1509                  const QString& sText = tr(                  const QString& sText = tr(
1510                          "Resetting the sampler instance will close\n"                          "Resetting the sampler instance will close\n"
1511                          "all device and channel configurations.\n\n"                          "all device and channel configurations.\n\n"
# Line 1544  void MainForm::fileReset (void) Line 1556  void MainForm::fileReset (void)
1556  // Restart the client/server instance.  // Restart the client/server instance.
1557  void MainForm::fileRestart (void)  void MainForm::fileRestart (void)
1558  {  {
1559          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1560                  return;                  return;
1561    
1562          bool bRestart = true;          bool bRestart = true;
# Line 1552  void MainForm::fileRestart (void) Line 1564  void MainForm::fileRestart (void)
1564          // Ask user whether he/she want's a complete restart...          // Ask user whether he/she want's a complete restart...
1565          // (if we're currently up and running)          // (if we're currently up and running)
1566          if (m_pOptions && m_pOptions->bConfirmRestart) {          if (m_pOptions && m_pOptions->bConfirmRestart) {
1567                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1568                  const QString& sText = tr(                  const QString& sText = tr(
1569                          "New settings will be effective after\n"                          "New settings will be effective after\n"
1570                          "restarting the client/server connection.\n\n"                          "restarting the client/server connection.\n\n"
# Line 1612  void MainForm::editAddChannel (void) Line 1624  void MainForm::editAddChannel (void)
1624    
1625  void MainForm::addChannelStrip (void)  void MainForm::addChannelStrip (void)
1626  {  {
1627          if (m_pClient == NULL)          if (m_pClient == nullptr)
1628                  return;                  return;
1629    
1630          // Just create the channel instance...          // Just create the channel instance...
1631          Channel *pChannel = new Channel();          Channel *pChannel = new Channel();
1632          if (pChannel == NULL)          if (pChannel == nullptr)
1633                  return;                  return;
1634    
1635          // 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 1665  void MainForm::editRemoveChannel (void)
1665    
1666  void MainForm::removeChannelStrip (void)  void MainForm::removeChannelStrip (void)
1667  {  {
1668          if (m_pClient == NULL)          if (m_pClient == nullptr)
1669                  return;                  return;
1670    
1671          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1672          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1673                  return;                  return;
1674    
1675          Channel *pChannel = pChannelStrip->channel();          Channel *pChannel = pChannelStrip->channel();
1676          if (pChannel == NULL)          if (pChannel == nullptr)
1677                  return;                  return;
1678    
1679          // Prompt user if he/she's sure about this...          // Prompt user if he/she's sure about this...
1680          if (m_pOptions && m_pOptions->bConfirmRemove) {          if (m_pOptions && m_pOptions->bConfirmRemove) {
1681                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning");                  const QString& sTitle = tr("Warning");
1682                  const QString& sText = tr(                  const QString& sText = tr(
1683                          "About to remove channel:\n\n"                          "About to remove channel:\n\n"
1684                          "%1\n\n"                          "%1\n\n"
# Line 1709  void MainForm::removeChannelStrip (void) Line 1721  void MainForm::removeChannelStrip (void)
1721  // Setup current sampler channel.  // Setup current sampler channel.
1722  void MainForm::editSetupChannel (void)  void MainForm::editSetupChannel (void)
1723  {  {
1724          if (m_pClient == NULL)          if (m_pClient == nullptr)
1725                  return;                  return;
1726    
1727          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1728          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1729                  return;                  return;
1730    
1731          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1724  void MainForm::editSetupChannel (void) Line 1736  void MainForm::editSetupChannel (void)
1736  // Edit current sampler channel.  // Edit current sampler channel.
1737  void MainForm::editEditChannel (void)  void MainForm::editEditChannel (void)
1738  {  {
1739          if (m_pClient == NULL)          if (m_pClient == nullptr)
1740                  return;                  return;
1741    
1742          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1743          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1744                  return;                  return;
1745    
1746          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1739  void MainForm::editEditChannel (void) Line 1751  void MainForm::editEditChannel (void)
1751  // Reset current sampler channel.  // Reset current sampler channel.
1752  void MainForm::editResetChannel (void)  void MainForm::editResetChannel (void)
1753  {  {
1754          if (m_pClient == NULL)          if (m_pClient == nullptr)
1755                  return;                  return;
1756    
1757          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1758          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
1759                  return;                  return;
1760    
1761          // Just invoque the channel strip procedure.          // Just invoque the channel strip procedure.
# Line 1754  void MainForm::editResetChannel (void) Line 1766  void MainForm::editResetChannel (void)
1766  // Reset all sampler channels.  // Reset all sampler channels.
1767  void MainForm::editResetAllChannels (void)  void MainForm::editResetAllChannels (void)
1768  {  {
1769          if (m_pClient == NULL)          if (m_pClient == nullptr)
1770                  return;                  return;
1771    
1772          // Invoque the channel strip procedure,          // Invoque the channel strip procedure,
# Line 1762  void MainForm::editResetAllChannels (voi Line 1774  void MainForm::editResetAllChannels (voi
1774          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
1775          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1776                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1777          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
1778          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
1779                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
1780                  if (pChannelStrip)                  if (pChannelStrip)
1781                          pChannelStrip->channelReset();                          pChannelStrip->channelReset();
1782          }          }
# Line 1826  void MainForm::viewMessages ( bool bOn ) Line 1835  void MainForm::viewMessages ( bool bOn )
1835  // Show/hide the MIDI instrument list-view form.  // Show/hide the MIDI instrument list-view form.
1836  void MainForm::viewInstruments (void)  void MainForm::viewInstruments (void)
1837  {  {
1838          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1839                  return;                  return;
1840    
1841          if (m_pInstrumentListForm) {          if (m_pInstrumentListForm) {
# Line 1845  void MainForm::viewInstruments (void) Line 1854  void MainForm::viewInstruments (void)
1854  // Show/hide the device configurator form.  // Show/hide the device configurator form.
1855  void MainForm::viewDevices (void)  void MainForm::viewDevices (void)
1856  {  {
1857          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1858                  return;                  return;
1859    
1860          if (m_pDeviceForm) {          if (m_pDeviceForm) {
# Line 1864  void MainForm::viewDevices (void) Line 1873  void MainForm::viewDevices (void)
1873  // Show options dialog.  // Show options dialog.
1874  void MainForm::viewOptions (void)  void MainForm::viewOptions (void)
1875  {  {
1876          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
1877                  return;                  return;
1878    
1879          OptionsForm* pOptionsForm = new OptionsForm(this);          OptionsForm* pOptionsForm = new OptionsForm(this);
# Line 1876  void MainForm::viewOptions (void) Line 1885  void MainForm::viewOptions (void)
1885                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)                  if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
1886                          m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();                          m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
1887                  // To track down deferred or immediate changes.                  // To track down deferred or immediate changes.
1888                  const QString sOldServerHost      = m_pOptions->sServerHost;                  const QString sOldServerHost       = m_pOptions->sServerHost;
1889                  const int     iOldServerPort      = m_pOptions->iServerPort;                  const int     iOldServerPort       = m_pOptions->iServerPort;
1890                  const int     iOldServerTimeout   = m_pOptions->iServerTimeout;                  const int     iOldServerTimeout    = m_pOptions->iServerTimeout;
1891                  const bool    bOldServerStart     = m_pOptions->bServerStart;                  const bool    bOldServerStart      = m_pOptions->bServerStart;
1892                  const QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;                  const QString sOldServerCmdLine    = m_pOptions->sServerCmdLine;
1893                  const bool    bOldMessagesLog     = m_pOptions->bMessagesLog;                  const bool    bOldMessagesLog      = m_pOptions->bMessagesLog;
1894                  const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath;                  const QString sOldMessagesLogPath  = m_pOptions->sMessagesLogPath;
1895                  const QString sOldDisplayFont     = m_pOptions->sDisplayFont;                  const QString sOldDisplayFont      = m_pOptions->sDisplayFont;
1896                  const bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;                  const bool    bOldDisplayEffect    = m_pOptions->bDisplayEffect;
1897                  const int     iOldMaxVolume       = m_pOptions->iMaxVolume;                  const int     iOldMaxVolume        = m_pOptions->iMaxVolume;
1898                  const QString sOldMessagesFont    = m_pOptions->sMessagesFont;                  const QString sOldMessagesFont     = m_pOptions->sMessagesFont;
1899                  const bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;                  const bool    bOldKeepOnTop        = m_pOptions->bKeepOnTop;
1900                  const bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;                  const bool    bOldStdoutCapture    = m_pOptions->bStdoutCapture;
1901                  const int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;                  const int     bOldMessagesLimit    = m_pOptions->bMessagesLimit;
1902                  const int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;                  const int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1903                  const bool    bOldCompletePath    = m_pOptions->bCompletePath;                  const bool    bOldCompletePath     = m_pOptions->bCompletePath;
1904                  const bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;                  const bool    bOldInstrumentNames  = m_pOptions->bInstrumentNames;
1905                  const int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;                  const int     iOldMaxRecentFiles   = m_pOptions->iMaxRecentFiles;
1906                  const int     iOldBaseFontSize    = m_pOptions->iBaseFontSize;                  const int     iOldBaseFontSize     = m_pOptions->iBaseFontSize;
1907                    const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme;
1908                    const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme;
1909                  // Load the current setup settings.                  // Load the current setup settings.
1910                  pOptionsForm->setup(m_pOptions);                  pOptionsForm->setup(m_pOptions);
1911                  // Show the setup dialog...                  // Show the setup dialog...
1912                  if (pOptionsForm->exec()) {                  if (pOptionsForm->exec()) {
1913                          // Warn if something will be only effective on next run.                          // Warn if something will be only effective on next run.
1914                            int iNeedRestart = 0;
1915                          if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||                          if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||
1916                                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||                                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture)) {
1917                                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||                                  updateMessagesCapture();
1918                                    ++iNeedRestart;
1919                            }
1920                            if (( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1921                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||
1922                                  (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {                                  (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {
1923                                  QMessageBox::information(this,                                  ++iNeedRestart;
1924                                          QSAMPLER_TITLE ": " + tr("Information"),                          }
1925                                          tr("Some settings may be only effective\n"                          // Check whether restart is needed or whether
1926                                          "next time you start this program."));                          // custom options maybe set up immediately...
1927                                  updateMessagesCapture();                          if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) {
1928                                    if (m_pOptions->sCustomStyleTheme.isEmpty()) {
1929                                            ++iNeedRestart;
1930                                    } else {
1931                                            QApplication::setStyle(
1932                                                    QStyleFactory::create(m_pOptions->sCustomStyleTheme));
1933                                    }
1934                            }
1935                            if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) {
1936                                    if (m_pOptions->sCustomColorTheme.isEmpty()) {
1937                                            ++iNeedRestart;
1938                                    } else {
1939                                            QPalette pal;
1940                                            if (PaletteForm::namedPalette(
1941                                                            &m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal))
1942                                                    QApplication::setPalette(pal);
1943                                    }
1944                          }                          }
1945                          // Check wheather something immediate has changed.                          // Check wheather something immediate has changed.
1946                          if (( bOldMessagesLog && !m_pOptions->bMessagesLog) ||                          if (( bOldMessagesLog && !m_pOptions->bMessagesLog) ||
# Line 1937  void MainForm::viewOptions (void) Line 1968  void MainForm::viewOptions (void)
1968                                  (!bOldMessagesLimit &&  m_pOptions->bMessagesLimit) ||                                  (!bOldMessagesLimit &&  m_pOptions->bMessagesLimit) ||
1969                                  (iOldMessagesLimitLines !=  m_pOptions->iMessagesLimitLines))                                  (iOldMessagesLimitLines !=  m_pOptions->iMessagesLimitLines))
1970                                  updateMessagesLimit();                                  updateMessagesLimit();
1971                            // Show restart needed message...
1972                            if (iNeedRestart > 0) {
1973                                    QMessageBox::information(this,
1974                                            tr("Information"),
1975                                            tr("Some settings may be only effective\n"
1976                                            "next time you start this program."));
1977                            }
1978                          // And now the main thing, whether we'll do client/server recycling?                          // And now the main thing, whether we'll do client/server recycling?
1979                          if ((sOldServerHost != m_pOptions->sServerHost) ||                          if ((sOldServerHost != m_pOptions->sServerHost) ||
1980                                  (iOldServerPort != m_pOptions->iServerPort) ||                                  (iOldServerPort != m_pOptions->iServerPort) ||
# Line 1970  void MainForm::channelsArrange (void) Line 2008  void MainForm::channelsArrange (void)
2008    
2009          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2010          int y = 0;          int y = 0;
2011          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2012          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  pMdiSubWindow->adjustSize();
2013                  QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                  const QRect& frameRect
2014                  if (pMdiSubWindow) {                          = pMdiSubWindow->frameGeometry();
2015                          pMdiSubWindow->adjustSize();                  int w = m_pWorkspace->width();
2016                          int iWidth = m_pWorkspace->width();                  if (w < frameRect.width())
2017                          if (iWidth < pMdiSubWindow->width())                          w = frameRect.width();
2018                                  iWidth = pMdiSubWindow->width();                  const int h = frameRect.height();
2019                          const int iHeight = pMdiSubWindow->frameGeometry().height();                  pMdiSubWindow->setGeometry(0, y, w, h);
2020                          pMdiSubWindow->setGeometry(0, y, iWidth, iHeight);                  y += h;
                         y += iHeight;  
                 }  
2021          }          }
2022          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
2023    
# Line 1992  void MainForm::channelsArrange (void) Line 2028  void MainForm::channelsArrange (void)
2028  // Auto-arrange channel strips.  // Auto-arrange channel strips.
2029  void MainForm::channelsAutoArrange ( bool bOn )  void MainForm::channelsAutoArrange ( bool bOn )
2030  {  {
2031          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2032                  return;                  return;
2033    
2034          // Toggle the auto-arrange flag.          // Toggle the auto-arrange flag.
# Line 2062  void MainForm::helpAbout (void) Line 2098  void MainForm::helpAbout (void)
2098  #endif  #endif
2099    
2100          // Stuff the about box text...          // Stuff the about box text...
2101          QString sText = "<p>\n";          QString sText = "<h1>" QSAMPLER_TITLE "</h1>\n";
2102          sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";          sText += "<p>" + tr(QSAMPLER_SUBTITLE) + "<br />\n";
2103          sText += "<br />\n";          sText += "<br />\n";
2104          sText += tr("Version") + ": <b>" CONFIG_BUILD_VERSION "</b><br />\n";          sText += tr("Version") + ": <b>" CONFIG_BUILD_VERSION "</b><br />\n";
2105  //      sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n";  //      sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n";
# Line 2073  void MainForm::helpAbout (void) Line 2109  void MainForm::helpAbout (void)
2109                  sText += "</font></small>";                  sText += "</font></small>";
2110          }          }
2111          sText += "<br />\n";          sText += "<br />\n";
2112          sText += tr("Using") + ": ";          sText += tr("Using: Qt %1").arg(qVersion());
2113    #if defined(QT_STATIC)
2114            sText += "-static";
2115    #endif
2116            sText += ", ";
2117          sText += ::lscp_client_package();          sText += ::lscp_client_package();
2118          sText += " ";          sText += " ";
2119          sText += ::lscp_client_version();          sText += ::lscp_client_version();
# Line 2096  void MainForm::helpAbout (void) Line 2136  void MainForm::helpAbout (void)
2136          sText += "</small>";          sText += "</small>";
2137          sText += "</p>\n";          sText += "</p>\n";
2138    
2139          QMessageBox::about(this, tr("About") + " " QSAMPLER_TITLE, sText);          QMessageBox::about(this, tr("About"), sText);
2140  }  }
2141    
2142    
# Line 2109  void MainForm::stabilizeForm (void) Line 2149  void MainForm::stabilizeForm (void)
2149          QString sSessionName = sessionName(m_sFilename);          QString sSessionName = sessionName(m_sFilename);
2150          if (m_iDirtyCount > 0)          if (m_iDirtyCount > 0)
2151                  sSessionName += " *";                  sSessionName += " *";
2152          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));          setWindowTitle(sSessionName);
2153    
2154          // Update the main menu state...          // Update the main menu state...
2155          ChannelStrip *pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
2156          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();          const QList<QMdiSubWindow *>& wlist = m_pWorkspace->subWindowList();
2157          const bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);          const bool bHasClient = (m_pOptions != nullptr && m_pClient != nullptr);
2158          const bool bHasChannel = (bHasClient && pChannelStrip != NULL);          const bool bHasChannel = (bHasClient && pChannelStrip != nullptr);
2159          const bool bHasChannels = (bHasClient && wlist.count() > 0);          const bool bHasChannels = (bHasClient && wlist.count() > 0);
2160          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
2161          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
2162          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
2163          m_ui.fileSaveAsAction->setEnabled(bHasClient);          m_ui.fileSaveAsAction->setEnabled(bHasClient);
2164          m_ui.fileResetAction->setEnabled(bHasClient);          m_ui.fileResetAction->setEnabled(bHasClient);
2165          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);          m_ui.fileRestartAction->setEnabled(bHasClient || m_pServer == nullptr);
2166          m_ui.editAddChannelAction->setEnabled(bHasClient);          m_ui.editAddChannelAction->setEnabled(bHasClient);
2167          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);          m_ui.editRemoveChannelAction->setEnabled(bHasChannel);
2168          m_ui.editSetupChannelAction->setEnabled(bHasChannel);          m_ui.editSetupChannelAction->setEnabled(bHasChannel);
# Line 2271  void MainForm::updateAllChannelStrips ( Line 2311  void MainForm::updateAllChannelStrips (
2311    
2312          // Retrieve the current channel list.          // Retrieve the current channel list.
2313          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2314          if (piChannelIDs == NULL) {          if (piChannelIDs == nullptr) {
2315                  if (::lscp_client_get_errno(m_pClient)) {                  if (::lscp_client_get_errno(m_pClient)) {
2316                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
2317                          appendMessagesError(                          appendMessagesError(
# Line 2291  void MainForm::updateAllChannelStrips ( Line 2331  void MainForm::updateAllChannelStrips (
2331                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2332                          const QList<QMdiSubWindow *>& wlist                          const QList<QMdiSubWindow *>& wlist
2333                                  = m_pWorkspace->subWindowList();                                  = m_pWorkspace->subWindowList();
2334                          const int iStripCount = wlist.count();                          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2335                          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                  ChannelStrip *pChannelStrip
2336                                  ChannelStrip *pChannelStrip = NULL;                                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                                 if (pMdiSubWindow)  
                                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2337                                  if (pChannelStrip) {                                  if (pChannelStrip) {
2338                                          bool bExists = false;                                          bool bExists = false;
2339                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {                                          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) {
2340                                                  Channel *pChannel = pChannelStrip->channel();                                                  Channel *pChannel = pChannelStrip->channel();
2341                                                  if (pChannel == NULL)                                                  if (pChannel == nullptr)
2342                                                          break;                                                          break;
2343                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {                                                  if (piChannelIDs[iChannel] == pChannel->channelID()) {
2344                                                          // strip exists, don't touch it                                                          // strip exists, don't touch it
# Line 2324  void MainForm::updateAllChannelStrips ( Line 2361  void MainForm::updateAllChannelStrips (
2361  // Update the recent files list and menu.  // Update the recent files list and menu.
2362  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
2363  {  {
2364          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2365                  return;                  return;
2366    
2367          // Remove from list if already there (avoid duplicates)          // Remove from list if already there (avoid duplicates)
# Line 2339  void MainForm::updateRecentFiles ( const Line 2376  void MainForm::updateRecentFiles ( const
2376  // Update the recent files list and menu.  // Update the recent files list and menu.
2377  void MainForm::updateRecentFilesMenu (void)  void MainForm::updateRecentFilesMenu (void)
2378  {  {
2379          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2380                  return;                  return;
2381    
2382          // Time to keep the list under limits.          // Time to keep the list under limits.
# Line 2373  void MainForm::updateInstrumentNames (vo Line 2410  void MainForm::updateInstrumentNames (vo
2410                  return;                  return;
2411    
2412          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2413          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2414          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2415                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2416                  if (pChannelStrip)                  if (pChannelStrip)
2417                          pChannelStrip->updateInstrumentName(true);                          pChannelStrip->updateInstrumentName(true);
2418          }          }
# Line 2389  void MainForm::updateInstrumentNames (vo Line 2423  void MainForm::updateInstrumentNames (vo
2423  // Force update of the channels display font.  // Force update of the channels display font.
2424  void MainForm::updateDisplayFont (void)  void MainForm::updateDisplayFont (void)
2425  {  {
2426          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2427                  return;                  return;
2428    
2429          // Check if display font is legal.          // Check if display font is legal.
# Line 2408  void MainForm::updateDisplayFont (void) Line 2442  void MainForm::updateDisplayFont (void)
2442                  return;                  return;
2443    
2444          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2445          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2446          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2447                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2448                  if (pChannelStrip)                  if (pChannelStrip)
2449                          pChannelStrip->setDisplayFont(font);                          pChannelStrip->setDisplayFont(font);
2450          }          }
# Line 2431  void MainForm::updateDisplayEffect (void Line 2462  void MainForm::updateDisplayEffect (void
2462                  return;                  return;
2463    
2464          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2465          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2466          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2467                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2468                  if (pChannelStrip)                  if (pChannelStrip)
2469                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2470          }          }
# Line 2447  void MainForm::updateDisplayEffect (void Line 2475  void MainForm::updateDisplayEffect (void
2475  // Force update of the channels maximum volume setting.  // Force update of the channels maximum volume setting.
2476  void MainForm::updateMaxVolume (void)  void MainForm::updateMaxVolume (void)
2477  {  {
2478          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2479                  return;                  return;
2480    
2481  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
# Line 2464  void MainForm::updateMaxVolume (void) Line 2492  void MainForm::updateMaxVolume (void)
2492                  return;                  return;
2493    
2494          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
2495          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2496          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2497                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2498                  if (pChannelStrip)                  if (pChannelStrip)
2499                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);                          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
2500          }          }
# Line 2481  void MainForm::updateMaxVolume (void) Line 2506  void MainForm::updateMaxVolume (void)
2506  // QSampler::MainForm -- Messages window form handlers.  // QSampler::MainForm -- Messages window form handlers.
2507    
2508  // Messages output methods.  // Messages output methods.
2509  void MainForm::appendMessages( const QString& s )  void MainForm::appendMessages ( const QString& s )
2510  {  {
2511          if (m_pMessages)          if (m_pMessages)
2512                  m_pMessages->appendMessages(s);                  m_pMessages->appendMessages(s);
# Line 2489  void MainForm::appendMessages( const QSt Line 2514  void MainForm::appendMessages( const QSt
2514          statusBar()->showMessage(s, 3000);          statusBar()->showMessage(s, 3000);
2515  }  }
2516    
2517  void MainForm::appendMessagesColor( const QString& s, const QString& c )  void MainForm::appendMessagesColor ( const QString& s, const QColor& rgb )
2518  {  {
2519          if (m_pMessages)          if (m_pMessages)
2520                  m_pMessages->appendMessagesColor(s, c);                  m_pMessages->appendMessagesColor(s, rgb);
2521    
2522          statusBar()->showMessage(s, 3000);          statusBar()->showMessage(s, 3000);
2523  }  }
2524    
2525  void MainForm::appendMessagesText( const QString& s )  void MainForm::appendMessagesText ( const QString& s )
2526  {  {
2527          if (m_pMessages)          if (m_pMessages)
2528                  m_pMessages->appendMessagesText(s);                  m_pMessages->appendMessagesText(s);
2529  }  }
2530    
2531  void MainForm::appendMessagesError( const QString& sText )  void MainForm::appendMessagesError ( const QString& s )
2532  {  {
2533          if (m_pMessages)          if (m_pMessages)
2534                  m_pMessages->show();                  m_pMessages->show();
2535    
2536          appendMessagesColor(sText.simplified(), "#ff0000");          appendMessagesColor(s.simplified(), Qt::red);
2537    
2538          // Make it look responsive...:)          // Make it look responsive...:)
2539          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2540    
2541          if (m_pOptions && m_pOptions->bConfirmError) {          if (m_pOptions && m_pOptions->bConfirmError) {
2542                  const QString& sTitle = QSAMPLER_TITLE ": " + tr("Error");                  const QString& sTitle = tr("Error");
2543          #if 0          #if 0
2544                  QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel);                  QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel);
2545          #else          #else
2546                  QMessageBox mbox(this);                  QMessageBox mbox(this);
2547                  mbox.setIcon(QMessageBox::Critical);                  mbox.setIcon(QMessageBox::Critical);
2548                  mbox.setWindowTitle(sTitle);                  mbox.setWindowTitle(sTitle);
2549                  mbox.setText(sText);                  mbox.setText(s);
2550                  mbox.setStandardButtons(QMessageBox::Cancel);                  mbox.setStandardButtons(QMessageBox::Cancel);
2551                  QCheckBox cbox(tr("Don't show this again"));                  QCheckBox cbox(tr("Don't show this again"));
2552                  cbox.setChecked(false);                  cbox.setChecked(false);
# Line 2537  void MainForm::appendMessagesError( cons Line 2562  void MainForm::appendMessagesError( cons
2562  // This is a special message format, just for client results.  // This is a special message format, just for client results.
2563  void MainForm::appendMessagesClient( const QString& s )  void MainForm::appendMessagesClient( const QString& s )
2564  {  {
2565          if (m_pClient == NULL)          if (m_pClient == nullptr)
2566                  return;                  return;
2567    
2568          appendMessagesColor(s + QString(": %1 (errno=%2)")          appendMessagesColor(s + QString(": %1 (errno=%2)")
# Line 2552  void MainForm::appendMessagesClient( con Line 2577  void MainForm::appendMessagesClient( con
2577  // Force update of the messages font.  // Force update of the messages font.
2578  void MainForm::updateMessagesFont (void)  void MainForm::updateMessagesFont (void)
2579  {  {
2580          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2581                  return;                  return;
2582    
2583          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {          if (m_pMessages && !m_pOptions->sMessagesFont.isEmpty()) {
# Line 2566  void MainForm::updateMessagesFont (void) Line 2591  void MainForm::updateMessagesFont (void)
2591  // Update messages window line limit.  // Update messages window line limit.
2592  void MainForm::updateMessagesLimit (void)  void MainForm::updateMessagesLimit (void)
2593  {  {
2594          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2595                  return;                  return;
2596    
2597          if (m_pMessages) {          if (m_pMessages) {
# Line 2581  void MainForm::updateMessagesLimit (void Line 2606  void MainForm::updateMessagesLimit (void
2606  // Enablement of the messages capture feature.  // Enablement of the messages capture feature.
2607  void MainForm::updateMessagesCapture (void)  void MainForm::updateMessagesCapture (void)
2608  {  {
2609          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2610                  return;                  return;
2611    
2612          if (m_pMessages)          if (m_pMessages)
# Line 2595  void MainForm::updateMessagesCapture (vo Line 2620  void MainForm::updateMessagesCapture (vo
2620  // The channel strip creation executive.  // The channel strip creation executive.
2621  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
2622  {  {
2623          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == nullptr || pChannel == nullptr)
2624                  return NULL;                  return nullptr;
2625    
2626          // Add a new channel itema...          // Add a new channel itema...
2627          ChannelStrip *pChannelStrip = new ChannelStrip();          ChannelStrip *pChannelStrip = new ChannelStrip();
2628          if (pChannelStrip == NULL)          if (pChannelStrip == nullptr)
2629                  return NULL;                  return nullptr;
2630    
2631          // Set some initial channel strip options...          // Set some initial channel strip options...
2632          if (m_pOptions) {          if (m_pOptions) {
# Line 2617  ChannelStrip *MainForm::createChannelStr Line 2642  ChannelStrip *MainForm::createChannelStr
2642          }          }
2643    
2644          // Add it to workspace...          // Add it to workspace...
2645          m_pWorkspace->addSubWindow(pChannelStrip,          QMdiSubWindow *pMdiSubWindow
2646                  Qt::SubWindow | Qt::FramelessWindowHint);                  = m_pWorkspace->addSubWindow(pChannelStrip,
2647                            Qt::SubWindow | Qt::FramelessWindowHint);
2648            pMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose);
2649    
2650          // Actual channel strip setup...          // Actual channel strip setup...
2651          pChannelStrip->setup(pChannel);          pChannelStrip->setup(pChannel);
# Line 2642  void MainForm::destroyChannelStrip ( Cha Line 2669  void MainForm::destroyChannelStrip ( Cha
2669  {  {
2670          QMdiSubWindow *pMdiSubWindow          QMdiSubWindow *pMdiSubWindow
2671                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());                  = static_cast<QMdiSubWindow *> (pChannelStrip->parentWidget());
2672          if (pMdiSubWindow == NULL)          if (pMdiSubWindow == nullptr)
2673                  return;                  return;
2674    
2675          // Just delete the channel strip.          // Just delete the channel strip.
# Line 2661  ChannelStrip *MainForm::activeChannelStr Line 2688  ChannelStrip *MainForm::activeChannelStr
2688          if (pMdiSubWindow)          if (pMdiSubWindow)
2689                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2690          else          else
2691                  return NULL;                  return nullptr;
2692  }  }
2693    
2694    
2695  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2696  ChannelStrip *MainForm::channelStripAt ( int iStrip )  ChannelStrip *MainForm::channelStripAt ( int iStrip )
2697  {  {
2698          if (!m_pWorkspace) return NULL;          if (!m_pWorkspace) return nullptr;
2699    
2700          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2701                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2702          if (wlist.isEmpty())          if (wlist.isEmpty())
2703                  return NULL;                  return nullptr;
2704    
2705          if (iStrip < 0 || iStrip >= wlist.count())          if (iStrip < 0 || iStrip >= wlist.count())
2706                  return NULL;                  return nullptr;
2707    
2708          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);
2709          if (pMdiSubWindow)          if (pMdiSubWindow)
2710                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  return static_cast<ChannelStrip *> (pMdiSubWindow->widget());
2711          else          else
2712                  return NULL;                  return nullptr;
2713  }  }
2714    
2715    
# Line 2692  ChannelStrip *MainForm::channelStrip ( i Line 2719  ChannelStrip *MainForm::channelStrip ( i
2719          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
2720                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2721          if (wlist.isEmpty())          if (wlist.isEmpty())
2722                  return NULL;                  return nullptr;
2723    
2724          const int iStripCount = wlist.count();          foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2725          for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  ChannelStrip *pChannelStrip
2726                  ChannelStrip *pChannelStrip = NULL;                          = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                 QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                 if (pMdiSubWindow)  
                         pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2727                  if (pChannelStrip) {                  if (pChannelStrip) {
2728                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2729                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2708  ChannelStrip *MainForm::channelStrip ( i Line 2732  ChannelStrip *MainForm::channelStrip ( i
2732          }          }
2733    
2734          // Not found.          // Not found.
2735          return NULL;          return nullptr;
2736  }  }
2737    
2738    
# Line 2723  void MainForm::channelsMenuAboutToShow ( Line 2747  void MainForm::channelsMenuAboutToShow (
2747                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
2748          if (!wlist.isEmpty()) {          if (!wlist.isEmpty()) {
2749                  m_ui.channelsMenu->addSeparator();                  m_ui.channelsMenu->addSeparator();
2750                  const int iStripCount = wlist.count();                  int iStrip = 0;
2751                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2752                          ChannelStrip *pChannelStrip = NULL;                          ChannelStrip *pChannelStrip
2753                          QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                         if (pMdiSubWindow)  
                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2754                          if (pChannelStrip) {                          if (pChannelStrip) {
2755                                  QAction *pAction = m_ui.channelsMenu->addAction(                                  QAction *pAction = m_ui.channelsMenu->addAction(
2756                                          pChannelStrip->windowTitle(),                                          pChannelStrip->windowTitle(),
# Line 2737  void MainForm::channelsMenuAboutToShow ( Line 2759  void MainForm::channelsMenuAboutToShow (
2759                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);                                  pAction->setChecked(activeChannelStrip() == pChannelStrip);
2760                                  pAction->setData(iStrip);                                  pAction->setData(iStrip);
2761                          }                          }
2762                            ++iStrip;
2763                  }                  }
2764          }          }
2765  }  }
# Line 2747  void MainForm::channelsMenuActivated (vo Line 2770  void MainForm::channelsMenuActivated (vo
2770  {  {
2771          // Retrive channel index from action data...          // Retrive channel index from action data...
2772          QAction *pAction = qobject_cast<QAction *> (sender());          QAction *pAction = qobject_cast<QAction *> (sender());
2773          if (pAction == NULL)          if (pAction == nullptr)
2774                  return;                  return;
2775    
2776          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());          ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt());
# Line 2778  void MainForm::stopSchedule (void) Line 2801  void MainForm::stopSchedule (void)
2801  // Timer slot funtion.  // Timer slot funtion.
2802  void MainForm::timerSlot (void)  void MainForm::timerSlot (void)
2803  {  {
2804          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2805                  return;                  return;
2806    
2807          // 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 2836  void MainForm::timerSlot (void)
2836                                  // Update the channel stream usage for each strip...                                  // Update the channel stream usage for each strip...
2837                                  const QList<QMdiSubWindow *>& wlist                                  const QList<QMdiSubWindow *>& wlist
2838                                          = m_pWorkspace->subWindowList();                                          = m_pWorkspace->subWindowList();
2839                                  const int iStripCount = wlist.count();                                  foreach (QMdiSubWindow *pMdiSubWindow, wlist) {
2840                                  for (int iStrip = 0; iStrip < iStripCount; ++iStrip) {                                          ChannelStrip *pChannelStrip
2841                                          ChannelStrip *pChannelStrip = NULL;                                                  = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
                                         QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip);  
                                         if (pMdiSubWindow)  
                                                 pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());  
2842                                          if (pChannelStrip && pChannelStrip->isVisible())                                          if (pChannelStrip && pChannelStrip->isVisible())
2843                                                  pChannelStrip->updateChannelUsage();                                                  pChannelStrip->updateChannelUsage();
2844                                  }                                  }
2845                          }                          }
2846                  }                  }
2847    
2848            #if CONFIG_LSCP_CLIENT_CONNECTION_LOST
2849                    // If we lost connection to server: Try to automatically reconnect if we
2850                    // did not start the server.
2851                    //
2852                    // TODO: If we started the server, then we might inform the user that
2853                    // the server probably crashed and asking user ONCE whether we should
2854                    // restart the server.
2855                    if (lscp_client_connection_lost(m_pClient) && !m_pServer)
2856                            startAutoReconnectClient();
2857            #endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST
2858          }          }
2859    
2860          // Register the next timer slot.          // Register the next timer slot.
# Line 2837  void MainForm::timerSlot (void) Line 2868  void MainForm::timerSlot (void)
2868  // Start linuxsampler server...  // Start linuxsampler server...
2869  void MainForm::startServer (void)  void MainForm::startServer (void)
2870  {  {
2871          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
2872                  return;                  return;
2873    
2874          // Aren't already a client, are we?          // Aren't already a client, are we?
# Line 2847  void MainForm::startServer (void) Line 2878  void MainForm::startServer (void)
2878          // Is the server process instance still here?          // Is the server process instance still here?
2879          if (m_pServer) {          if (m_pServer) {
2880                  if (QMessageBox::warning(this,                  if (QMessageBox::warning(this,
2881                          QSAMPLER_TITLE ": " + tr("Warning"),                          tr("Warning"),
2882                          tr("Could not start the LinuxSampler server.\n\n"                          tr("Could not start the LinuxSampler server.\n\n"
2883                          "Maybe it is already started."),                          "Maybe it is already started."),
2884                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
# Line 2900  void MainForm::startServer (void) Line 2931  void MainForm::startServer (void)
2931    
2932          // Show startup results...          // Show startup results...
2933          appendMessages(          appendMessages(
2934                  tr("Server was started with PID=%1.").arg((long) m_pServer->pid()));                  tr("Server was started with PID=%1.")
2935                    #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
2936                            .arg(quint64(m_pServer->pid())));
2937                    #else
2938                            .arg(quint64(m_pServer->processId())));
2939                    #endif
2940    
2941          // Reset (yet again) the timer counters,          // Reset (yet again) the timer counters,
2942          // 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 2953  void MainForm::stopServer ( bool bIntera
2953    
2954          if (m_pServer && bInteractive) {          if (m_pServer && bInteractive) {
2955                  if (QMessageBox::question(this,                  if (QMessageBox::question(this,
2956                          QSAMPLER_TITLE ": " + tr("The backend's fate ..."),                          tr("The backend's fate ..."),
2957                          tr("You have the option to keep the sampler backend (LinuxSampler)\n"                          tr("You have the option to keep the sampler backend (LinuxSampler)\n"
2958                          "running in the background. The sampler would continue to work\n"                          "running in the background. The sampler would continue to work\n"
2959                          "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 2986  void MainForm::stopServer ( bool bIntera
2986    
2987          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2988          if (bGraceWait) {          if (bGraceWait) {
2989                  QTime t;                  QElapsedTimer timer;
2990                  t.start();                  timer.start();
2991                  while (t.elapsed() < QSAMPLER_TIMER_MSECS)                  while (timer.elapsed() < QSAMPLER_TIMER_MSECS)
2992                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2993          }          }
2994  }  }
# Line 2982  void MainForm::processServerExit (void) Line 3018  void MainForm::processServerExit (void)
3018                          // Force final server shutdown...                          // Force final server shutdown...
3019                          m_pServer->kill();                          m_pServer->kill();
3020                          // Give it some time to terminate gracefully and stabilize...                          // Give it some time to terminate gracefully and stabilize...
3021                          QTime t;                          QElapsedTimer timer;
3022                          t.start();                          timer.start();
3023                          while (t.elapsed() < QSAMPLER_TIMER_MSECS)                          while (timer.elapsed() < QSAMPLER_TIMER_MSECS)
3024                                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
3025                  }                  }
3026                  // Force final server shutdown...                  // Force final server shutdown...
# Line 2992  void MainForm::processServerExit (void) Line 3028  void MainForm::processServerExit (void)
3028                          tr("Server was stopped with exit status %1.")                          tr("Server was stopped with exit status %1.")
3029                          .arg(m_pServer->exitStatus()));                          .arg(m_pServer->exitStatus()));
3030                  delete m_pServer;                  delete m_pServer;
3031                  m_pServer = NULL;                  m_pServer = nullptr;
3032          }          }
3033    
3034          // Again, make status visible stable.          // Again, make status visible stable.
# Line 3008  lscp_status_t qsampler_client_callback ( Line 3044  lscp_status_t qsampler_client_callback (
3044          lscp_event_t event, const char *pchData, int cchData, void *pvData )          lscp_event_t event, const char *pchData, int cchData, void *pvData )
3045  {  {
3046          MainForm* pMainForm = (MainForm *) pvData;          MainForm* pMainForm = (MainForm *) pvData;
3047          if (pMainForm == NULL)          if (pMainForm == nullptr)
3048                  return LSCP_FAILED;                  return LSCP_FAILED;
3049    
3050          // 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 3058  lscp_status_t qsampler_client_callback (
3058    
3059    
3060  // Start our almighty client...  // Start our almighty client...
3061  bool MainForm::startClient (void)  bool MainForm::startClient (bool bReconnectOnly)
3062  {  {
3063          // Have it a setup?          // Have it a setup?
3064          if (m_pOptions == NULL)          if (m_pOptions == nullptr)
3065                  return false;                  return false;
3066    
3067          // Aren't we already started, are we?          // Aren't we already started, are we?
# Line 3039  bool MainForm::startClient (void) Line 3075  bool MainForm::startClient (void)
3075          m_pClient = ::lscp_client_create(          m_pClient = ::lscp_client_create(
3076                  m_pOptions->sServerHost.toUtf8().constData(),                  m_pOptions->sServerHost.toUtf8().constData(),
3077                  m_pOptions->iServerPort, qsampler_client_callback, this);                  m_pOptions->iServerPort, qsampler_client_callback, this);
3078          if (m_pClient == NULL) {          if (m_pClient == nullptr) {
3079                  // Is this the first try?                  // Is this the first try?
3080                  // maybe we need to start a local server...                  // maybe we need to start a local server...
3081                  if ((m_pServer && m_pServer->state() == QProcess::Running)                  if ((m_pServer && m_pServer->state() == QProcess::Running)
3082                          || !m_pOptions->bServerStart) {                          || !m_pOptions->bServerStart || bReconnectOnly)
3083                          appendMessagesError(                  {
3084                                  tr("Could not connect to server as client.\n\nSorry."));                          // if this method is called from autoReconnectClient()
3085                            // then don't bother user with an error message...
3086                            if (!bReconnectOnly) {
3087                                    appendMessagesError(
3088                                            tr("Could not connect to server as client.\n\nSorry.")
3089                                    );
3090                            }
3091                  } else {                  } else {
3092                          startServer();                          startServer();
3093                  }                  }
# Line 3106  bool MainForm::startClient (void) Line 3148  bool MainForm::startClient (void)
3148                  m_pDeviceForm->refreshDevices();                  m_pDeviceForm->refreshDevices();
3149    
3150          // Is any session pending to be loaded?          // Is any session pending to be loaded?
3151          if (!m_pOptions->sSessionFile.isEmpty()) {          if (!m_pOptions->sessionFiles.isEmpty()) {
3152                  // Just load the prabably startup session...                  // Just load the prabably startup session...
3153                  if (loadSessionFile(m_pOptions->sSessionFile)) {                  if (loadSessionFile(m_pOptions->sessionFiles.first())) {
3154                          m_pOptions->sSessionFile = QString();                          m_pOptions->sessionFiles.clear();
3155                          return true;                          return true;
3156                  }                  }
3157          }          }
# Line 3125  bool MainForm::startClient (void) Line 3167  bool MainForm::startClient (void)
3167  // Stop client...  // Stop client...
3168  void MainForm::stopClient (void)  void MainForm::stopClient (void)
3169  {  {
3170          if (m_pClient == NULL)          if (m_pClient == nullptr)
3171                  return;                  return;
3172    
3173          // Log prepare here.          // Log prepare here.
# Line 3157  void MainForm::stopClient (void) Line 3199  void MainForm::stopClient (void)
3199          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
3200          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);
3201          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
3202          m_pClient = NULL;          m_pClient = nullptr;
3203    
3204          // Hard-notify instrumnet and device configuration forms,          // Hard-notify instrumnet and device configuration forms,
3205          // if visible, that we're running out...          // if visible, that we're running out...
# Line 3174  void MainForm::stopClient (void) Line 3216  void MainForm::stopClient (void)
3216  }  }
3217    
3218    
3219    void MainForm::startAutoReconnectClient (void)
3220    {
3221            stopClient();
3222            appendMessages(tr("Trying to reconnect..."));
3223            QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3224    }
3225    
3226    
3227    void MainForm::autoReconnectClient (void)
3228    {
3229            const bool bSuccess = startClient(true);
3230            if (!bSuccess)
3231                    QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient()));
3232    }
3233    
3234    
3235  // Channel strip activation/selection.  // Channel strip activation/selection.
3236  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )  void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow )
3237  {  {
3238          ChannelStrip *pChannelStrip = NULL;          ChannelStrip *pChannelStrip = nullptr;
3239          if (pMdiSubWindow)          if (pMdiSubWindow)
3240                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());                  pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget());
3241          if (pChannelStrip)          if (pChannelStrip)

Legend:
Removed from v.3520  
changed lines
  Added in v.4068

  ViewVC Help
Powered by ViewVC