/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2978 by capela, Mon Aug 15 19:10:16 2016 UTC revision 3508 by capela, Mon Apr 1 22:36:26 2019 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2016, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007,2008,2015 Christian Schoenebeck     Copyright (C) 2007,2008,2015 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 91  static inline long lroundf ( float x ) Line 91  static inline long lroundf ( float x )
91    
92    
93  // All winsock apps needs this.  // All winsock apps needs this.
94  #if defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
95  static WSADATA _wsaData;  static WSADATA _wsaData;
96  #endif  #endif
97    
# Line 109  static WSADATA _wsaData; Line 109  static WSADATA _wsaData;
109  #include <signal.h>  #include <signal.h>
110    
111  // File descriptor for SIGUSR1 notifier.  // File descriptor for SIGUSR1 notifier.
112  static int g_fdUsr1[2];  static int g_fdSigusr1[2];
113    
114  // Unix SIGUSR1 signal handler.  // Unix SIGUSR1 signal handler.
115  static void qsampler_sigusr1_handler ( int /* signo */ )  static void qsampler_sigusr1_handler ( int /* signo */ )
116  {  {
117          char c = 1;          char c = 1;
118    
119          (::write(g_fdUsr1[0], &c, sizeof(c)) > 0);          (::write(g_fdSigusr1[0], &c, sizeof(c)) > 0);
120    }
121    
122    // File descriptor for SIGTERM notifier.
123    static int g_fdSigterm[2];
124    
125    // Unix SIGTERM signal handler.
126    static void qsampler_sigterm_handler ( int /* signo */ )
127    {
128            char c = 1;
129    
130            (::write(g_fdSigterm[0], &c, sizeof(c)) > 0);
131  }  }
132    
133  #endif  // HAVE_SIGNAL_H  #endif  // HAVE_SIGNAL_H
134    
135    
136  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
137  // qsampler -- namespace  // QSampler -- namespace
138    
139    
140  namespace QSampler {  namespace QSampler {
# Line 143  namespace QSampler { Line 154  namespace QSampler {
154    
155    
156  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
157  // LscpEvent -- specialty for LSCP callback comunication.  // QSampler::LscpEvent -- specialty for LSCP callback comunication.
   
158    
159  class LscpEvent : public QEvent  class LscpEvent : public QEvent
160  {  {
# Line 159  public: Line 169  public:
169          }          }
170    
171          // Accessors.          // Accessors.
172          lscp_event_t event() { return m_event; }          lscp_event_t  event() { return m_event; }
173          QString&     data()  { return m_data;  }          const QString& data() { return m_data;  }
174    
175  private:  private:
176    
# Line 172  private: Line 182  private:
182    
183    
184  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
185  // qsamplerMainForm -- Main window form implementation.  // QSampler::Workspace -- Main window workspace (MDI Area) decl.
186    
187    class Workspace : public QMdiArea
188    {
189    public:
190    
191            Workspace(MainForm *pMainForm) : QMdiArea(pMainForm) {}
192    
193    protected:
194    
195            void resizeEvent(QResizeEvent *)
196            {
197                    MainForm *pMainForm = static_cast<MainForm *> (parentWidget());
198                    if (pMainForm)
199                            pMainForm->channelsArrangeAuto();
200            }
201    };
202    
203    
204    //-------------------------------------------------------------------------
205    // QSampler::MainForm -- Main window form implementation.
206    
207  // Kind of singleton reference.  // Kind of singleton reference.
208  MainForm* MainForm::g_pMainForm = NULL;  MainForm *MainForm::g_pMainForm = NULL;
209    
210  MainForm::MainForm ( QWidget *pParent )  MainForm::MainForm ( QWidget *pParent )
211          : QMainWindow(pParent)          : QMainWindow(pParent)
# Line 214  MainForm::MainForm ( QWidget *pParent ) Line 244  MainForm::MainForm ( QWidget *pParent )
244          // LADISH Level 1 suport.          // LADISH Level 1 suport.
245    
246          // Initialize file descriptors for SIGUSR1 socket notifier.          // Initialize file descriptors for SIGUSR1 socket notifier.
247          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1);          ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigusr1);
248          m_pUsr1Notifier          m_pSigusr1Notifier
249                  = new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this);                  = new QSocketNotifier(g_fdSigusr1[1], QSocketNotifier::Read, this);
250    
251          QObject::connect(m_pUsr1Notifier,          QObject::connect(m_pSigusr1Notifier,
252                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
253                  SLOT(handle_sigusr1()));                  SLOT(handle_sigusr1()));
254    
255          // Install SIGUSR1 signal handler.          // Install SIGUSR1 signal handler.
256      struct sigaction usr1;      struct sigaction sigusr1;
257      usr1.sa_handler = qsampler_sigusr1_handler;      sigusr1.sa_handler = qsampler_sigusr1_handler;
258      sigemptyset(&usr1.sa_mask);      sigemptyset(&sigusr1.sa_mask);
259      usr1.sa_flags = 0;      sigusr1.sa_flags = 0;
260      usr1.sa_flags |= SA_RESTART;      sigusr1.sa_flags |= SA_RESTART;
261      ::sigaction(SIGUSR1, &usr1, NULL);      ::sigaction(SIGUSR1, &sigusr1, NULL);
262    
263            // Initialize file descriptors for SIGTERM socket notifier.
264            ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdSigterm);
265            m_pSigtermNotifier
266                    = new QSocketNotifier(g_fdSigterm[1], QSocketNotifier::Read, this);
267    
268            QObject::connect(m_pSigtermNotifier,
269                    SIGNAL(activated(int)),
270                    SLOT(handle_sigterm()));
271    
272            // Install SIGTERM signal handler.
273            struct sigaction sigterm;
274            sigterm.sa_handler = qsampler_sigterm_handler;
275            ::sigemptyset(&sigterm.sa_mask);
276            sigterm.sa_flags = 0;
277            sigterm.sa_flags |= SA_RESTART;
278            ::sigaction(SIGTERM, &sigterm, NULL);
279            ::sigaction(SIGQUIT, &sigterm, NULL);
280    
281            // Ignore SIGHUP/SIGINT signals.
282            ::signal(SIGHUP, SIG_IGN);
283            ::signal(SIGINT, SIG_IGN);
284    
285  #else   // HAVE_SIGNAL_H  #else   // HAVE_SIGNAL_H
286    
287          m_pUsr1Notifier = NULL;          m_pSigusr1Notifier = NULL;
288            m_pSigtermNotifier = NULL;
289                    
290  #endif  // !HAVE_SIGNAL_H  #endif  // !HAVE_SIGNAL_H
291    
# Line 270  MainForm::MainForm ( QWidget *pParent ) Line 323  MainForm::MainForm ( QWidget *pParent )
323  #endif  #endif
324    
325          // Make it an MDI workspace.          // Make it an MDI workspace.
326          m_pWorkspace = new QMdiArea(this);          m_pWorkspace = new Workspace(this);
327          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);          m_pWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
328          m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);          m_pWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
329          // Set the activation connection.          // Set the activation connection.
# Line 305  MainForm::MainForm ( QWidget *pParent ) Line 358  MainForm::MainForm ( QWidget *pParent )
358          m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;          m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
359          statusBar()->addWidget(pLabel);          statusBar()->addWidget(pLabel);
360    
361  #if defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
362          WSAStartup(MAKEWORD(1, 1), &_wsaData);          WSAStartup(MAKEWORD(1, 1), &_wsaData);
363  #endif  #endif
364    
# Line 406  MainForm::~MainForm() Line 459  MainForm::~MainForm()
459          // Do final processing anyway.          // Do final processing anyway.
460          processServerExit();          processServerExit();
461    
462  #if defined(WIN32)  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
463          WSACleanup();          WSACleanup();
464  #endif  #endif
465    
466  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
467          if (m_pUsr1Notifier)          if (m_pSigusr1Notifier)
468                  delete m_pUsr1Notifier;                  delete m_pSigusr1Notifier;
469            if (m_pSigtermNotifier)
470                    delete m_pSigtermNotifier;
471  #endif  #endif
472    
473          // Finally drop any widgets around...          // Finally drop any widgets around...
# Line 695  void MainForm::customEvent ( QEvent* pEv Line 750  void MainForm::customEvent ( QEvent* pEv
750  }  }
751    
752    
753  // Window resize event handler.  // LADISH Level 1 -- SIGUSR1 signal handler.
754  void MainForm::resizeEvent ( QResizeEvent * )  void MainForm::handle_sigusr1 (void)
755  {  {
756          if (m_pOptions->bAutoArrange)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
757                  channelsArrange();  
758            char c;
759    
760            if (::read(g_fdSigusr1[1], &c, sizeof(c)) > 0)
761                    saveSession(false);
762    
763    #endif
764  }  }
765    
766    
767  // LADISH Level 1 -- SIGUSR1 signal handler.  void MainForm::handle_sigterm (void)
 void MainForm::handle_sigusr1 (void)  
768  {  {
769  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)  #if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H)
770    
771          char c;          char c;
772    
773          if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0)          if (::read(g_fdSigterm[1], &c, sizeof(c)) > 0)
774                  saveSession(false);                  close();
775    
776  #endif  #endif
777  }  }
# Line 742  void MainForm::contextMenuEvent( QContex Line 802  void MainForm::contextMenuEvent( QContex
802    
803    
804  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
805  // qsamplerMainForm -- Brainless public property accessors.  // QSampler::MainForm -- Brainless public property accessors.
806    
807  // The global options settings property.  // The global options settings property.
808  Options *MainForm::options (void) const  Options *MainForm::options (void) const
# Line 766  MainForm *MainForm::getInstance (void) Line 826  MainForm *MainForm::getInstance (void)
826    
827    
828  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
829  // qsamplerMainForm -- Session file stuff.  // QSampler::MainForm -- Session file stuff.
830    
831  // Format the displayable session filename.  // Format the displayable session filename.
832  QString MainForm::sessionName ( const QString& sFilename )  QString MainForm::sessionName ( const QString& sFilename )
# Line 855  bool MainForm::saveSession ( bool bPromp Line 915  bool MainForm::saveSession ( bool bPromp
915                  // Enforce .lscp extension...                  // Enforce .lscp extension...
916                  if (QFileInfo(sFilename).suffix().isEmpty())                  if (QFileInfo(sFilename).suffix().isEmpty())
917                          sFilename += ".lscp";                          sFilename += ".lscp";
918            #if 0
919                  // Check if already exists...                  // Check if already exists...
920                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {                  if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
921                          if (QMessageBox::warning(this,                          if (QMessageBox::warning(this,
# Line 867  bool MainForm::saveSession ( bool bPromp Line 928  bool MainForm::saveSession ( bool bPromp
928                                  == QMessageBox::No)                                  == QMessageBox::No)
929                                  return false;                                  return false;
930                  }                  }
931            #endif
932          }          }
933    
934          // Save it right away.          // Save it right away.
# Line 1035  bool MainForm::saveSessionFile ( const Q Line 1097  bool MainForm::saveSessionFile ( const Q
1097          int iErrors = 0;          int iErrors = 0;
1098          QTextStream ts(&file);          QTextStream ts(&file);
1099          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
1100          ts << "# " << tr("Version")          ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl;
1101          << ": " QSAMPLER_VERSION << endl;  //      ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl;
         ts << "# " << tr("Build")  
         << ": " __DATE__ " " __TIME__ << endl;  
1102          ts << "#"  << endl;          ts << "#"  << endl;
1103          ts << "# " << tr("File")          ts << "# " << tr("File")
1104          << ": " << QFileInfo(sFilename).fileName() << endl;          << ": " << QFileInfo(sFilename).fileName() << endl;
# Line 1051  bool MainForm::saveSessionFile ( const Q Line 1111  bool MainForm::saveSessionFile ( const Q
1111          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
1112          // will be loaded from a complete initialized server...          // will be loaded from a complete initialized server...
1113          int *piDeviceIDs;          int *piDeviceIDs;
1114          int  iDevice;          int  i, iDevice;
1115          ts << "RESET" << endl;          ts << "RESET" << endl;
1116    
1117          // Audio device mapping.          // Audio device mapping.
1118          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap; iDevice = 0;
1119          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);
1120          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
1121                  ts << endl;                  Device device(Device::Audio, piDeviceIDs[i]);
1122                  Device device(Device::Audio, piDeviceIDs[iDevice]);                  // Avoid plug-in driver devices...
1123                    if (device.driverName().toUpper() == "PLUGIN")
1124                            continue;
1125                  // Audio device specification...                  // Audio device specification...
1126                    ts << endl;
1127                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1128                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
1129                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
# Line 1091  bool MainForm::saveSessionFile ( const Q Line 1154  bool MainForm::saveSessionFile ( const Q
1154                          iPort++;                          iPort++;
1155                  }                  }
1156                  // Audio device index/id mapping.                  // Audio device index/id mapping.
1157                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap.insert(device.deviceID(), iDevice++);
1158                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1159                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1160          }          }
1161    
1162          // MIDI device mapping.          // MIDI device mapping.
1163          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap; iDevice = 0;
1164          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);
1165          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; ++i) {
1166                  ts << endl;                  Device device(Device::Midi, piDeviceIDs[i]);
1167                  Device device(Device::Midi, piDeviceIDs[iDevice]);                  // Avoid plug-in driver devices...
1168                    if (device.driverName().toUpper() == "PLUGIN")
1169                            continue;
1170                  // MIDI device specification...                  // MIDI device specification...
1171                    ts << endl;
1172                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1173                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
1174                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
# Line 1133  bool MainForm::saveSessionFile ( const Q Line 1199  bool MainForm::saveSessionFile ( const Q
1199                          iPort++;                          iPort++;
1200                  }                  }
1201                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
1202                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap.insert(device.deviceID(), iDevice++);
1203                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1204                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1205          }          }
# Line 1201  bool MainForm::saveSessionFile ( const Q Line 1267  bool MainForm::saveSessionFile ( const Q
1267                          iErrors++;                          iErrors++;
1268                  }                  }
1269                  // MIDI strument index/id mapping.                  // MIDI strument index/id mapping.
1270                  midiInstrumentMap[iMidiMap] = iMap;                  midiInstrumentMap.insert(iMidiMap, iMap);
1271          }          }
1272          // Check for errors...          // Check for errors...
1273          if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {          if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {
# Line 1210  bool MainForm::saveSessionFile ( const Q Line 1276  bool MainForm::saveSessionFile ( const Q
1276          }          }
1277  #endif  // CONFIG_MIDI_INSTRUMENT  #endif  // CONFIG_MIDI_INSTRUMENT
1278    
1279          // Sampler channel mapping.          // Sampler channel mapping...
1280            int iChannelID = 0;
1281          const QList<QMdiSubWindow *>& wlist          const QList<QMdiSubWindow *>& wlist
1282                  = m_pWorkspace->subWindowList();                  = m_pWorkspace->subWindowList();
1283          const int iStripCount = wlist.count();          const int iStripCount = wlist.count();
# Line 1222  bool MainForm::saveSessionFile ( const Q Line 1289  bool MainForm::saveSessionFile ( const Q
1289                  if (pChannelStrip) {                  if (pChannelStrip) {
1290                          Channel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1291                          if (pChannel) {                          if (pChannel) {
1292                                  const int iChannelID = pChannel->channelID();                                  // Avoid "artifial" plug-in devices...
1293                                    const int iAudioDevice = pChannel->audioDevice();
1294                                    if (!audioDeviceMap.contains(iAudioDevice))
1295                                            continue;
1296                                    const int iMidiDevice = pChannel->midiDevice();
1297                                    if (!midiDeviceMap.contains(iMidiDevice))
1298                                            continue;
1299                                    // Go for regular, canonical devices...
1300                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;
1301                                  ts << "ADD CHANNEL" << endl;                                  ts << "ADD CHANNEL" << endl;
1302                                  if (audioDeviceMap.isEmpty()) {                                  if (audioDeviceMap.isEmpty()) {
# Line 1230  bool MainForm::saveSessionFile ( const Q Line 1304  bool MainForm::saveSessionFile ( const Q
1304                                                  << " " << pChannel->audioDriver() << endl;                                                  << " " << pChannel->audioDriver() << endl;
1305                                  } else {                                  } else {
1306                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID
1307                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;                                                  << " " << audioDeviceMap.value(iAudioDevice) << endl;
1308                                  }                                  }
1309                                  if (midiDeviceMap.isEmpty()) {                                  if (midiDeviceMap.isEmpty()) {
1310                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID
1311                                                  << " " << pChannel->midiDriver() << endl;                                                  << " " << pChannel->midiDriver() << endl;
1312                                  } else {                                  } else {
1313                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID
1314                                                  << " " << midiDeviceMap[pChannel->midiDevice()] << endl;                                                  << " " << midiDeviceMap.value(iMidiDevice) << endl;
1315                                  }                                  }
1316                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID
1317                                          << " " << pChannel->midiPort() << endl;                                          << " " << pChannel->midiPort() << endl;
# Line 1268  bool MainForm::saveSessionFile ( const Q Line 1342  bool MainForm::saveSessionFile ( const Q
1342                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1343                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;
1344                          #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1345                                  if (pChannel->midiMap() >= 0) {                                  const int iMidiMap = pChannel->midiMap();
1346                                    if (midiInstrumentMap.contains(iMidiMap)) {
1347                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID
1348                                                  << " " << midiInstrumentMap[pChannel->midiMap()] << endl;                                                  << " " << midiInstrumentMap.value(iMidiMap) << endl;
1349                                  }                                  }
1350                          #endif                          #endif
1351                          #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
# Line 1309  bool MainForm::saveSessionFile ( const Q Line 1384  bool MainForm::saveSessionFile ( const Q
1384                                  }                                  }
1385                          #endif                          #endif
1386                                  ts << endl;                                  ts << endl;
1387                                    // Go for next channel...
1388                                    ++iChannelID;
1389                          }                          }
1390                  }                  }
1391                  // Try to keep it snappy :)                  // Try to keep it snappy :)
# Line 1360  void MainForm::sessionDirty (void) Line 1437  void MainForm::sessionDirty (void)
1437    
1438    
1439  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1440  // qsamplerMainForm -- File Action slots.  // QSampler::MainForm -- File Action slots.
1441    
1442  // Create a new sampler session.  // Create a new sampler session.
1443  void MainForm::fileNew (void)  void MainForm::fileNew (void)
# Line 1526  void MainForm::fileExit (void) Line 1603  void MainForm::fileExit (void)
1603    
1604    
1605  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1606  // qsamplerMainForm -- Edit Action slots.  // QSampler::MainForm -- Edit Action slots.
1607    
1608  // Add a new sampler channel.  // Add a new sampler channel.
1609  void MainForm::editAddChannel (void)  void MainForm::editAddChannel (void)
# Line 1561  void MainForm::addChannelStrip (void) Line 1638  void MainForm::addChannelStrip (void)
1638          }          }
1639    
1640          // Do we auto-arrange?          // Do we auto-arrange?
1641          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
1642    
1643          // Make that an overall update.          // Make that an overall update.
1644          m_iDirtyCount++;          m_iDirtyCount++;
# Line 1703  void MainForm::editResetAllChannels (voi Line 1779  void MainForm::editResetAllChannels (voi
1779    
1780    
1781  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1782  // qsamplerMainForm -- View Action slots.  // QSampler::MainForm -- View Action slots.
1783    
1784  // Show/hide the main program window menubar.  // Show/hide the main program window menubar.
1785  void MainForm::viewMenubar ( bool bOn )  void MainForm::viewMenubar ( bool bOn )
# Line 1884  void MainForm::viewOptions (void) Line 1960  void MainForm::viewOptions (void)
1960    
1961    
1962  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1963  // qsamplerMainForm -- Channels action slots.  // QSampler::MainForm -- Channels action slots.
1964    
1965  // Arrange channel strips.  // Arrange channel strips.
1966  void MainForm::channelsArrange (void)  void MainForm::channelsArrange (void)
# Line 1926  void MainForm::channelsAutoArrange ( boo Line 2002  void MainForm::channelsAutoArrange ( boo
2002          m_pOptions->bAutoArrange = bOn;          m_pOptions->bAutoArrange = bOn;
2003    
2004          // If on, update whole workspace...          // If on, update whole workspace...
2005          if (m_pOptions->bAutoArrange)          channelsArrangeAuto();
2006    }
2007    
2008    
2009    void MainForm::channelsArrangeAuto (void)
2010    {
2011            if (m_pOptions && m_pOptions->bAutoArrange)
2012                  channelsArrange();                  channelsArrange();
2013  }  }
2014    
2015    
2016  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2017  // qsamplerMainForm -- Help Action slots.  // QSampler::MainForm -- Help Action slots.
2018    
2019  // Show information about the Qt toolkit.  // Show information about the Qt toolkit.
2020  void MainForm::helpAboutQt (void)  void MainForm::helpAboutQt (void)
# Line 1944  void MainForm::helpAboutQt (void) Line 2026  void MainForm::helpAboutQt (void)
2026  // Show information about application program.  // Show information about application program.
2027  void MainForm::helpAbout (void)  void MainForm::helpAbout (void)
2028  {  {
2029          // Stuff the about box text...          QStringList list;
         QString sText = "<p>\n";  
         sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";  
         sText += "<br />\n";  
         sText += tr("Version") + ": <b>" QSAMPLER_VERSION "</b><br />\n";  
         sText += "<small>" + tr("Build") + ": " __DATE__ " " __TIME__ "</small><br />\n";  
2030  #ifdef CONFIG_DEBUG  #ifdef CONFIG_DEBUG
2031          sText += "<small><font color=\"red\">";          list << tr("Debugging option enabled.");
         sText += tr("Debugging option enabled.");  
         sText += "</font></small><br />";  
2032  #endif  #endif
2033  #ifndef CONFIG_LIBGIG  #ifndef CONFIG_LIBGIG
2034          sText += "<small><font color=\"red\">";          list << tr("GIG (libgig) file support disabled.");
         sText += tr("GIG (libgig) file support disabled.");  
         sText += "</font></small><br />";  
2035  #endif  #endif
2036  #ifndef CONFIG_INSTRUMENT_NAME  #ifndef CONFIG_INSTRUMENT_NAME
2037          sText += "<small><font color=\"red\">";          list << tr("LSCP (liblscp) instrument_name support disabled.");
         sText += tr("LSCP (liblscp) instrument_name support disabled.");  
         sText += "</font></small><br />";  
2038  #endif  #endif
2039  #ifndef CONFIG_MUTE_SOLO  #ifndef CONFIG_MUTE_SOLO
2040          sText += "<small><font color=\"red\">";          list << tr("Sampler channel Mute/Solo support disabled.");
         sText += tr("Sampler channel Mute/Solo support disabled.");  
         sText += "</font></small><br />";  
2041  #endif  #endif
2042  #ifndef CONFIG_AUDIO_ROUTING  #ifndef CONFIG_AUDIO_ROUTING
2043          sText += "<small><font color=\"red\">";          list << tr("LSCP (liblscp) audio_routing support disabled.");
         sText += tr("LSCP (liblscp) audio_routing support disabled.");  
         sText += "</font></small><br />";  
2044  #endif  #endif
2045  #ifndef CONFIG_FXSEND  #ifndef CONFIG_FXSEND
2046          sText += "<small><font color=\"red\">";          list << tr("Sampler channel Effect Sends support disabled.");
         sText += tr("Sampler channel Effect Sends support disabled.");  
         sText += "</font></small><br />";  
2047  #endif  #endif
2048  #ifndef CONFIG_VOLUME  #ifndef CONFIG_VOLUME
2049          sText += "<small><font color=\"red\">";          list << tr("Global volume support disabled.");
         sText += tr("Global volume support disabled.");  
         sText += "</font></small><br />";  
2050  #endif  #endif
2051  #ifndef CONFIG_MIDI_INSTRUMENT  #ifndef CONFIG_MIDI_INSTRUMENT
2052          sText += "<small><font color=\"red\">";          list << tr("MIDI instrument mapping support disabled.");
         sText += tr("MIDI instrument mapping support disabled.");  
         sText += "</font></small><br />";  
2053  #endif  #endif
2054  #ifndef CONFIG_EDIT_INSTRUMENT  #ifndef CONFIG_EDIT_INSTRUMENT
2055          sText += "<small><font color=\"red\">";          list << tr("Instrument editing support disabled.");
         sText += tr("Instrument editing support disabled.");  
         sText += "</font></small><br />";  
2056  #endif  #endif
2057  #ifndef CONFIG_EVENT_CHANNEL_MIDI  #ifndef CONFIG_EVENT_CHANNEL_MIDI
2058          sText += "<small><font color=\"red\">";          list << tr("Channel MIDI event support disabled.");
         sText += tr("Channel MIDI event support disabled.");  
         sText += "</font></small><br />";  
2059  #endif  #endif
2060  #ifndef CONFIG_EVENT_DEVICE_MIDI  #ifndef CONFIG_EVENT_DEVICE_MIDI
2061          sText += "<small><font color=\"red\">";          list << tr("Device MIDI event support disabled.");
         sText += tr("Device MIDI event support disabled.");  
         sText += "</font></small><br />";  
2062  #endif  #endif
2063  #ifndef CONFIG_MAX_VOICES  #ifndef CONFIG_MAX_VOICES
2064          sText += "<small><font color=\"red\">";          list << tr("Runtime max. voices / disk streams support disabled.");
         sText += tr("Runtime max. voices / disk streams support disabled.");  
         sText += "</font></small><br />";  
2065  #endif  #endif
2066    
2067            // Stuff the about box text...
2068            QString sText = "<p>\n";
2069            sText += "<b>" QSAMPLER_TITLE " - " + tr(QSAMPLER_SUBTITLE) + "</b><br />\n";
2070            sText += "<br />\n";
2071            sText += tr("Version") + ": <b>" CONFIG_BUILD_VERSION "</b><br />\n";
2072    //      sText += "<small>" + tr("Build") + ": " CONFIG_BUILD_DATE "</small><br />\n";
2073            if (!list.isEmpty()) {
2074                    sText += "<small><font color=\"red\">";
2075                    sText += list.join("<br />\n");
2076                    sText += "</font></small>";
2077            }
2078          sText += "<br />\n";          sText += "<br />\n";
2079          sText += tr("Using") + ": ";          sText += tr("Using") + ": ";
2080          sText += ::lscp_client_package();          sText += ::lscp_client_package();
# Line 2039  void MainForm::helpAbout (void) Line 2104  void MainForm::helpAbout (void)
2104    
2105    
2106  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2107  // qsamplerMainForm -- Main window stabilization.  // QSampler::MainForm -- Main window stabilization.
2108    
2109  void MainForm::stabilizeForm (void)  void MainForm::stabilizeForm (void)
2110  {  {
# Line 2191  void MainForm::updateSession (void) Line 2256  void MainForm::updateSession (void)
2256          updateAllChannelStrips(false);          updateAllChannelStrips(false);
2257    
2258          // Do we auto-arrange?          // Do we auto-arrange?
2259          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
2260    
2261          // Remember to refresh devices and instruments...          // Remember to refresh devices and instruments...
2262          if (m_pInstrumentListForm)          if (m_pInstrumentListForm)
# Line 2225  void MainForm::updateAllChannelStrips ( Line 2289  void MainForm::updateAllChannelStrips (
2289                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2290                  }                  }
2291                  // Do we auto-arrange?                  // Do we auto-arrange?
2292                  if (m_pOptions && m_pOptions->bAutoArrange)                  channelsArrangeAuto();
                         channelsArrange();  
2293                  // remove dead channel strips                  // remove dead channel strips
2294                  if (bRemoveDeadStrips) {                  if (bRemoveDeadStrips) {
2295                          const QList<QMdiSubWindow *>& wlist                          const QList<QMdiSubWindow *>& wlist
# Line 2418  void MainForm::updateMaxVolume (void) Line 2481  void MainForm::updateMaxVolume (void)
2481    
2482    
2483  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2484  // qsamplerMainForm -- Messages window form handlers.  // QSampler::MainForm -- Messages window form handlers.
2485    
2486  // Messages output methods.  // Messages output methods.
2487  void MainForm::appendMessages( const QString& s )  void MainForm::appendMessages( const QString& s )
# Line 2530  void MainForm::updateMessagesCapture (vo Line 2593  void MainForm::updateMessagesCapture (vo
2593    
2594    
2595  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2596  // qsamplerMainForm -- MDI channel strip management.  // QSampler::MainForm -- MDI channel strip management.
2597    
2598  // The channel strip creation executive.  // The channel strip creation executive.
2599  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )  ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel )
# Line 2590  void MainForm::destroyChannelStrip ( Cha Line 2653  void MainForm::destroyChannelStrip ( Cha
2653          delete pMdiSubWindow;          delete pMdiSubWindow;
2654    
2655          // Do we auto-arrange?          // Do we auto-arrange?
2656          if (m_pOptions && m_pOptions->bAutoArrange)          channelsArrangeAuto();
                 channelsArrange();  
2657  }  }
2658    
2659    
# Line 2700  void MainForm::channelsMenuActivated (vo Line 2762  void MainForm::channelsMenuActivated (vo
2762    
2763    
2764  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2765  // qsamplerMainForm -- Timer stuff.  // QSampler::MainForm -- Timer stuff.
2766    
2767  // Set the pseudo-timer delay schedule.  // Set the pseudo-timer delay schedule.
2768  void MainForm::startSchedule ( int iStartDelay )  void MainForm::startSchedule ( int iStartDelay )
# Line 2773  void MainForm::timerSlot (void) Line 2835  void MainForm::timerSlot (void)
2835    
2836    
2837  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
2838  // qsamplerMainForm -- Server stuff.  // QSampler::MainForm -- Server stuff.
2839    
2840  // Start linuxsampler server...  // Start linuxsampler server...
2841  void MainForm::startServer (void)  void MainForm::startServer (void)
# Line 2807  void MainForm::startServer (void) Line 2869  void MainForm::startServer (void)
2869    
2870          // OK. Let's build the startup process...          // OK. Let's build the startup process...
2871          m_pServer = new QProcess();          m_pServer = new QProcess();
2872          bForceServerStop = true;          m_bForceServerStop = true;
2873    
2874          // Setup stdout/stderr capture...          // Setup stdout/stderr capture...
2875          m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);          m_pServer->setProcessChannelMode(QProcess::ForwardedChannels);
# Line 2851  void MainForm::startServer (void) Line 2913  void MainForm::startServer (void)
2913    
2914    
2915  // Stop linuxsampler server...  // Stop linuxsampler server...
2916  void MainForm::stopServer (bool bInteractive)  void MainForm::stopServer ( bool bInteractive )
2917  {  {
2918          // Stop client code.          // Stop client code.
2919          stopClient();          stopClient();
# Line 2865  void MainForm::stopServer (bool bInterac Line 2927  void MainForm::stopServer (bool bInterac
2927                          "sampler session at any time by relaunching QSampler.\n\n"                          "sampler session at any time by relaunching QSampler.\n\n"
2928                          "Do you want LinuxSampler to stop?"),                          "Do you want LinuxSampler to stop?"),
2929                          QMessageBox::Yes | QMessageBox::No,                          QMessageBox::Yes | QMessageBox::No,
2930                          QMessageBox::Yes) == QMessageBox::No)                          QMessageBox::Yes) == QMessageBox::No) {
2931                  {                          m_bForceServerStop = false;
                         bForceServerStop = false;  
2932                  }                  }
2933          }          }
2934    
2935            bool bGraceWait = true;
2936    
2937          // And try to stop server.          // And try to stop server.
2938          if (m_pServer && bForceServerStop) {          if (m_pServer && m_bForceServerStop) {
2939                  appendMessages(tr("Server is stopping..."));                  appendMessages(tr("Server is stopping..."));
2940                  if (m_pServer->state() == QProcess::Running) {                  if (m_pServer->state() == QProcess::Running) {
2941                  #if defined(WIN32)                  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
2942                          // Try harder...                          // Try harder...
2943                          m_pServer->kill();                          m_pServer->kill();
2944                  #else                  #else
2945                          // Try softly...                          // Try softly...
2946                          m_pServer->terminate();                          m_pServer->terminate();
2947                            bool bFinished = m_pServer->waitForFinished(QSAMPLER_TIMER_MSECS * 1000);
2948                            if (bFinished) bGraceWait = false;
2949                  #endif                  #endif
2950                  }                  }
2951          }       // Do final processing anyway.          }       // Do final processing anyway.
2952          else processServerExit();          else processServerExit();
2953    
2954          // Give it some time to terminate gracefully and stabilize...          // Give it some time to terminate gracefully and stabilize...
2955          QTime t;          if (bGraceWait) {
2956          t.start();                  QTime t;
2957          while (t.elapsed() < QSAMPLER_TIMER_MSECS)                  t.start();
2958                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  while (t.elapsed() < QSAMPLER_TIMER_MSECS)
2959                            QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2960            }
2961  }  }
2962    
2963    
# Line 2912  void MainForm::processServerExit (void) Line 2979  void MainForm::processServerExit (void)
2979          if (m_pMessages)          if (m_pMessages)
2980                  m_pMessages->flushStdoutBuffer();                  m_pMessages->flushStdoutBuffer();
2981    
2982          if (m_pServer && bForceServerStop) {          if (m_pServer && m_bForceServerStop) {
2983                  if (m_pServer->state() != QProcess::NotRunning) {                  if (m_pServer->state() != QProcess::NotRunning) {
2984                          appendMessages(tr("Server is being forced..."));                          appendMessages(tr("Server is being forced..."));
2985                          // Force final server shutdown...                          // Force final server shutdown...
# Line 2937  void MainForm::processServerExit (void) Line 3004  void MainForm::processServerExit (void)
3004    
3005    
3006  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
3007  // qsamplerMainForm -- Client stuff.  // QSampler::MainForm -- Client stuff.
3008    
3009  // The LSCP client callback procedure.  // The LSCP client callback procedure.
3010  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/,  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/,
# Line 2989  bool MainForm::startClient (void) Line 3056  bool MainForm::startClient (void)
3056                  stabilizeForm();                  stabilizeForm();
3057                  return false;                  return false;
3058          }          }
3059    
3060          // Just set receive timeout value, blindly.          // Just set receive timeout value, blindly.
3061          ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);          ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);
3062          appendMessages(          appendMessages(

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

  ViewVC Help
Powered by ViewVC