/[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 3685 by capela, Thu Jan 2 19:03:34 2020 UTC revision 4038 by capela, Sun May 15 18:43:41 2022 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2022, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007-2019 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
# 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 71  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 115  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 126  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 210  MainForm::MainForm ( QWidget *pParent ) Line 225  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    
# Line 1868  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                                          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 1929  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 2063  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 2456  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 2464  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);
# Line 2496  void MainForm::appendMessagesError( cons Line 2546  void MainForm::appendMessagesError( cons
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 2881  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.

Legend:
Removed from v.3685  
changed lines
  Added in v.4038

  ViewVC Help
Powered by ViewVC