/[svn]/qsampler/trunk/src/qsamplerMainForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.ui.h

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

revision 267 by capela, Wed Oct 6 15:42:59 2004 UTC revision 968 by capela, Tue Dec 5 12:37:06 2006 UTC
# Line 2  Line 2 
2  //  //
3  // ui.h extension file, included from the uic-generated form implementation.  // ui.h extension file, included from the uic-generated form implementation.
4  /****************************************************************************  /****************************************************************************
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved.
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 14  Line 14 
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
18     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21  *****************************************************************************/  *****************************************************************************/
22    
# Line 26  Line 26 
26  #include <qprocess.h>  #include <qprocess.h>
27  #include <qmessagebox.h>  #include <qmessagebox.h>
28  #include <qdragobject.h>  #include <qdragobject.h>
29    #include <qregexp.h>
30  #include <qfiledialog.h>  #include <qfiledialog.h>
31  #include <qfileinfo.h>  #include <qfileinfo.h>
32  #include <qfile.h>  #include <qfile.h>
# Line 40  Line 41 
41  #include "qsamplerMessages.h"  #include "qsamplerMessages.h"
42    
43  #include "qsamplerChannelStrip.h"  #include "qsamplerChannelStrip.h"
44    #include "qsamplerInstrumentList.h"
45    
46    #include "qsamplerInstrumentListForm.h"
47    #include "qsamplerDeviceForm.h"
48  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
49    
50  #include "config.h"  #ifdef HAVE_SIGNAL_H
51    #include <signal.h>
52    #endif
53    
54    #ifdef CONFIG_LIBGIG
55    #include <gig.h>
56    #endif
57    
58  // Timer constant stuff.  // Timer constant stuff.
59  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
# Line 94  private: Line 104  private:
104  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
105  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
106    
107    // Kind of singleton reference.
108    qsamplerMainForm *qsamplerMainForm::g_pMainForm = NULL;
109    
110    
111  // Kind of constructor.  // Kind of constructor.
112  void qsamplerMainForm::init (void)  void qsamplerMainForm::init (void)
113  {  {
114            // Pseudo-singleton reference setup.
115            g_pMainForm = this;
116    
117      // Initialize some pointer references.      // Initialize some pointer references.
118      m_pOptions = NULL;      m_pOptions = NULL;
119    
120      // All child forms are to be created later, not earlier than setup.      // All child forms are to be created later, not earlier than setup.
121      m_pMessages = NULL;      m_pMessages = NULL;
122        m_pInstrumentListForm = NULL;
123        m_pDeviceForm = NULL;
124    
125      // We'll start clean.      // We'll start clean.
126      m_iUntitled = 0;      m_iUntitled   = 0;
127      m_iDirtyCount = 0;      m_iDirtyCount = 0;
128    
129      m_pServer = NULL;      m_pServer = NULL;
# Line 115  void qsamplerMainForm::init (void) Line 134  void qsamplerMainForm::init (void)
134    
135      m_iTimerSlot = 0;      m_iTimerSlot = 0;
136    
137    #ifdef HAVE_SIGNAL_H
138            // Set to ignore any fatal "Broken pipe" signals.
139            ::signal(SIGPIPE, SIG_IGN);
140    #endif
141    
142      // Make it an MDI workspace.      // Make it an MDI workspace.
143      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
144      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
# Line 129  void qsamplerMainForm::init (void) Line 153  void qsamplerMainForm::init (void)
153      pLabel = new QLabel(tr("Connected"), this);      pLabel = new QLabel(tr("Connected"), this);
154      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
155      pLabel->setMinimumSize(pLabel->sizeHint());      pLabel->setMinimumSize(pLabel->sizeHint());
156      m_status[QSAMPLER_STATUS_CLIENT] = pLabel;      m_statusItem[QSAMPLER_STATUS_CLIENT] = pLabel;
157      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
158      // Server address.      // Server address.
159      pLabel = new QLabel(this);      pLabel = new QLabel(this);
160      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
161      m_status[QSAMPLER_STATUS_SERVER] = pLabel;      m_statusItem[QSAMPLER_STATUS_SERVER] = pLabel;
162      statusBar()->addWidget(pLabel, 1);      statusBar()->addWidget(pLabel, 1);
163      // Channel title.      // Channel title.
164      pLabel = new QLabel(this);      pLabel = new QLabel(this);
165      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
166      m_status[QSAMPLER_STATUS_CHANNEL] = pLabel;      m_statusItem[QSAMPLER_STATUS_CHANNEL] = pLabel;
167      statusBar()->addWidget(pLabel, 2);      statusBar()->addWidget(pLabel, 2);
168      // Session modification status.      // Session modification status.
169      pLabel = new QLabel(tr("MOD"), this);      pLabel = new QLabel(tr("MOD"), this);
170      pLabel->setAlignment(Qt::AlignHCenter);      pLabel->setAlignment(Qt::AlignHCenter);
171      pLabel->setMinimumSize(pLabel->sizeHint());      pLabel->setMinimumSize(pLabel->sizeHint());
172      m_status[QSAMPLER_STATUS_SESSION] = pLabel;      m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
173      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
174    
175      // Create the recent files sub-menu.      // Create the recent files sub-menu.
# Line 164  void qsamplerMainForm::destroy (void) Line 188  void qsamplerMainForm::destroy (void)
188  {  {
189      // Do final processing anyway.      // Do final processing anyway.
190      processServerExit();      processServerExit();
191        
192      // Delete recentfiles menu.  #if defined(WIN32)
193      if (m_pRecentFilesMenu)      WSACleanup();
194          delete m_pRecentFilesMenu;  #endif
     // Delete status item labels one by one.  
     if (m_status[QSAMPLER_STATUS_CLIENT])  
         delete m_status[QSAMPLER_STATUS_CLIENT];  
     if (m_status[QSAMPLER_STATUS_SERVER])  
         delete m_status[QSAMPLER_STATUS_SERVER];  
     if (m_status[QSAMPLER_STATUS_CHANNEL])  
         delete m_status[QSAMPLER_STATUS_CHANNEL];  
     if (m_status[QSAMPLER_STATUS_SESSION])  
         delete m_status[QSAMPLER_STATUS_SESSION];  
195    
196      // Finally drop any widgets around...      // Finally drop any widgets around...
197        if (m_pDeviceForm)
198            delete m_pDeviceForm;
199        if (m_pInstrumentListForm)
200            delete m_pInstrumentListForm;
201      if (m_pMessages)      if (m_pMessages)
202          delete m_pMessages;          delete m_pMessages;
203      if (m_pWorkspace)      if (m_pWorkspace)
204          delete m_pWorkspace;          delete m_pWorkspace;
205    
206  #if defined(WIN32)      // Delete status item labels one by one.
207      WSACleanup();      if (m_statusItem[QSAMPLER_STATUS_CLIENT])
208  #endif          delete m_statusItem[QSAMPLER_STATUS_CLIENT];
209        if (m_statusItem[QSAMPLER_STATUS_SERVER])
210            delete m_statusItem[QSAMPLER_STATUS_SERVER];
211        if (m_statusItem[QSAMPLER_STATUS_CHANNEL])
212            delete m_statusItem[QSAMPLER_STATUS_CHANNEL];
213        if (m_statusItem[QSAMPLER_STATUS_SESSION])
214            delete m_statusItem[QSAMPLER_STATUS_SESSION];
215    
216        // Delete recentfiles menu.
217        if (m_pRecentFilesMenu)
218            delete m_pRecentFilesMenu;
219    
220            // Pseudo-singleton reference shut-down.
221            g_pMainForm = NULL;
222  }  }
223    
224    
# Line 196  void qsamplerMainForm::setup ( qsamplerO Line 228  void qsamplerMainForm::setup ( qsamplerO
228      // We got options?      // We got options?
229      m_pOptions = pOptions;      m_pOptions = pOptions;
230    
231        // What style do we create these forms?
232            Qt::WFlags wflags = Qt::WStyle_Customize
233                    | Qt::WStyle_NormalBorder
234                    | Qt::WStyle_Title
235                    | Qt::WStyle_SysMenu
236                    | Qt::WStyle_MinMax
237                    | Qt::WType_TopLevel;
238        if (m_pOptions->bKeepOnTop)
239            wflags |= Qt::WStyle_Tool;
240      // Some child forms are to be created right now.      // Some child forms are to be created right now.
241      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
242        m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);
243    #ifdef CONFIG_MIDI_INSTRUMENT
244        m_pInstrumentListForm = new qsamplerInstrumentListForm(this, 0, wflags);
245            QObject::connect(m_pInstrumentListForm->InstrumentList,
246                    SIGNAL(instrumentsChanged()),
247                    SLOT(sessionDirty()));
248    #else
249            viewInstrumentsAction->setEnabled(false);
250    #endif
251      // Set message defaults...      // Set message defaults...
252      updateMessagesFont();      updateMessagesFont();
253      updateMessagesLimit();      updateMessagesLimit();
254      updateMessagesCapture();      updateMessagesCapture();
255      // Set the visibility signal.      // Set the visibility signal.
256      QObject::connect(m_pMessages, SIGNAL(visibilityChanged(bool)), this, SLOT(stabilizeForm()));      QObject::connect(m_pMessages,
257                    SIGNAL(visibilityChanged(bool)),
258                    SLOT(stabilizeForm()));
259    
260      // Initial decorations toggle state.      // Initial decorations toggle state.
261      viewMenubarAction->setOn(m_pOptions->bMenubar);      viewMenubarAction->setOn(m_pOptions->bMenubar);
# Line 226  void qsamplerMainForm::setup ( qsamplerO Line 278  void qsamplerMainForm::setup ( qsamplerO
278          QTextIStream istr(&sDockables);          QTextIStream istr(&sDockables);
279          istr >> *this;          istr >> *this;
280      }      }
281      // Try to restore old window positioning.      // Try to restore old window positioning and initial visibility.
282      m_pOptions->loadWidgetGeometry(this);      m_pOptions->loadWidgetGeometry(this);
283        m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);
284        m_pOptions->loadWidgetGeometry(m_pDeviceForm);
285    
286      // Final startup stabilization...      // Final startup stabilization...
287      updateRecentFilesMenu();      updateRecentFilesMenu();
# Line 265  bool qsamplerMainForm::queryClose (void) Line 319  bool qsamplerMainForm::queryClose (void)
319              QTextOStream ostr(&sDockables);              QTextOStream ostr(&sDockables);
320              ostr << *this;              ostr << *this;
321              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);
322              // And the main windows state.              // And the children, and the main windows state,.
323              m_pOptions->saveWidgetGeometry(this);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
324                            m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
325                            m_pOptions->saveWidgetGeometry(this);
326                            // Close popup widgets.
327                            if (m_pInstrumentListForm)
328                                    m_pInstrumentListForm->close();
329                            if (m_pDeviceForm)
330                                    m_pDeviceForm->close();
331              // Stop client and/or server, gracefully.              // Stop client and/or server, gracefully.
332              stopServer();              stopServer();
333          }          }
# Line 285  void qsamplerMainForm::closeEvent ( QClo Line 346  void qsamplerMainForm::closeEvent ( QClo
346  }  }
347    
348    
349  // Window drag-n-drop event handlers.  // Drag'n'drop file handler.
350  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files )
351  {  {
352      bool bAccept = false;      bool bDecode = false;
353    
354      if (QTextDrag::canDecode(pDragEnterEvent)) {      if (QTextDrag::canDecode(pEvent)) {
355          QString sUrl;          QString sText;
356          if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient)          bDecode = QTextDrag::decode(pEvent, sText);
357              bAccept = QFileInfo(QUrl(sUrl).path()).exists();          if (bDecode) {
358                files = QStringList::split('\n', sText);
359                for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++)
360                    *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();
361            }
362      }      }
363    
364      pDragEnterEvent->accept(bAccept);      return bDecode;
365    }
366    
367    
368    // Window drag-n-drop event handlers.
369    void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
370    {
371            QStringList files;
372            pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));
373  }  }
374    
375    
376  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )
377  {  {
378      if (QTextDrag::canDecode(pDropEvent)) {      QStringList files;
379          QString sUrl;  
380          if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true))      if (!decodeDragFiles(pDropEvent, files))
381              loadSessionFile(QUrl(sUrl).path());          return;
382      }  
383            for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
384                    const QString& sPath = *iter;
385                    if (qsamplerChannel::isInstrumentFile(sPath)) {
386                            // Try to create a new channel from instrument file...
387                            qsamplerChannel *pChannel = new qsamplerChannel();
388                            if (pChannel == NULL)
389                                    return;
390                            // Start setting the instrument filename...
391                            pChannel->setInstrument(sPath, 0);
392                            // Before we show it up, may be we'll
393                            // better ask for some initial values?
394                            if (!pChannel->channelSetup(this)) {
395                                    delete pChannel;
396                                    return;
397                            }
398                            // Finally, give it to a new channel strip...
399                            if (!createChannelStrip(pChannel)) {
400                                    delete pChannel;
401                                    return;
402                            }
403                            // Make that an overall update.
404                            m_iDirtyCount++;
405                            stabilizeForm();
406                    }   // Otherwise, load an usual session file (LSCP script)...
407                    else if (closeSession(true))
408                            loadSessionFile(sPath);
409                    // Make it look responsive...:)
410                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
411            }
412  }  }
413    
414    
# Line 316  void qsamplerMainForm::customEvent ( QCu Line 418  void qsamplerMainForm::customEvent ( QCu
418      // For the time being, just pump it to messages.      // For the time being, just pump it to messages.
419      if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {      if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
420          qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;          qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
421          appendMessagesColor(tr("Notify event: %1 data: %2")                  if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) {
422              .arg(::lscp_event_to_text(pEvent->event()))                          int iChannelID = pEvent->data().toInt();
423              .arg(pEvent->data()), "#996699");                          qsamplerChannelStrip *pChannelStrip = channelStrip(iChannelID);
424                            if (pChannelStrip)
425                                    channelStripChanged(pChannelStrip);
426                    } else {
427                            appendMessagesColor(tr("Notify event: %1 data: %2")
428                                    .arg(::lscp_event_to_text(pEvent->event()))
429                                    .arg(pEvent->data()), "#996699");
430                    }
431      }      }
432  }  }
433    
# Line 327  void qsamplerMainForm::customEvent ( QCu Line 436  void qsamplerMainForm::customEvent ( QCu
436  void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
437  {  {
438      stabilizeForm();      stabilizeForm();
439        
440      editMenu->exec(pEvent->globalPos());      editMenu->exec(pEvent->globalPos());
441  }  }
442    
# Line 341  qsamplerOptions *qsamplerMainForm::optio Line 450  qsamplerOptions *qsamplerMainForm::optio
450      return m_pOptions;      return m_pOptions;
451  }  }
452    
453    
454  // The LSCP client descriptor property.  // The LSCP client descriptor property.
455  lscp_client_t *qsamplerMainForm::client (void)  lscp_client_t *qsamplerMainForm::client (void)
456  {  {
# Line 348  lscp_client_t *qsamplerMainForm::client Line 458  lscp_client_t *qsamplerMainForm::client
458  }  }
459    
460    
461    // The pseudo-singleton instance accessor.
462    qsamplerMainForm *qsamplerMainForm::getInstance (void)
463    {
464            return g_pMainForm;
465    }
466    
467    
468  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
469  // qsamplerMainForm -- Session file stuff.  // qsamplerMainForm -- Session file stuff.
470    
# Line 371  bool qsamplerMainForm::newSession (void) Line 488  bool qsamplerMainForm::newSession (void)
488      if (!closeSession(true))      if (!closeSession(true))
489          return false;          return false;
490    
491            // Give us what the server has, right now...
492            updateSession();
493    
494      // Ok increment untitled count.      // Ok increment untitled count.
495      m_iUntitled++;      m_iUntitled++;
496    
# Line 392  bool qsamplerMainForm::openSession (void Line 512  bool qsamplerMainForm::openSession (void
512    
513      // Ask for the filename to open...      // Ask for the filename to open...
514      QString sFilename = QFileDialog::getOpenFileName(      QString sFilename = QFileDialog::getOpenFileName(
515              m_pOptions->sSessionDir,                // Start here.                  m_pOptions->sSessionDir,                // Start here.
516              tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)                  tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)
517              this, 0,                                // Parent and name (none)                  this, 0,                                // Parent and name (none)
518              tr("Open Session")                      // Caption.                  QSAMPLER_TITLE ": " + tr("Open Session")        // Caption.
519      );      );
520    
521      // Have we cancelled?      // Have we cancelled?
# Line 426  bool qsamplerMainForm::saveSession ( boo Line 546  bool qsamplerMainForm::saveSession ( boo
546              sFilename = m_pOptions->sSessionDir;              sFilename = m_pOptions->sSessionDir;
547          // Prompt the guy...          // Prompt the guy...
548          sFilename = QFileDialog::getSaveFileName(          sFilename = QFileDialog::getSaveFileName(
549                  sFilename,                              // Start here.                          sFilename,                              // Start here.
550                  tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)                          tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)
551                  this, 0,                                // Parent and name (none)                          this, 0,                                // Parent and name (none)
552                  tr("Save Session")                      // Caption.                          QSAMPLER_TITLE ": " + tr("Save Session")        // Caption.
553          );          );
554          // Have we cancelled it?          // Have we cancelled it?
555          if (sFilename.isEmpty())          if (sFilename.isEmpty())
# Line 439  bool qsamplerMainForm::saveSession ( boo Line 559  bool qsamplerMainForm::saveSession ( boo
559              sFilename += ".lscp";              sFilename += ".lscp";
560          // Check if already exists...          // Check if already exists...
561          if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {          if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
562              if (QMessageBox::warning(this, tr("Warning"),              if (QMessageBox::warning(this,
563                                    QSAMPLER_TITLE ": " + tr("Warning"),
564                  tr("The file already exists:\n\n"                  tr("The file already exists:\n\n"
565                     "\"%1\"\n\n"                     "\"%1\"\n\n"
566                     "Do you want to replace it?")                     "Do you want to replace it?")
# Line 461  bool qsamplerMainForm::closeSession ( bo Line 582  bool qsamplerMainForm::closeSession ( bo
582    
583      // Are we dirty enough to prompt it?      // Are we dirty enough to prompt it?
584      if (m_iDirtyCount > 0) {      if (m_iDirtyCount > 0) {
585          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this,
586                            QSAMPLER_TITLE ": " + tr("Warning"),
587              tr("The current session has been changed:\n\n"              tr("The current session has been changed:\n\n"
588              "\"%1\"\n\n"              "\"%1\"\n\n"
589              "Do you want to save the changes?")              "Do you want to save the changes?")
# Line 487  bool qsamplerMainForm::closeSession ( bo Line 609  bool qsamplerMainForm::closeSession ( bo
609              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
610              if (pChannelStrip) {              if (pChannelStrip) {
611                  qsamplerChannel *pChannel = pChannelStrip->channel();                  qsamplerChannel *pChannel = pChannelStrip->channel();
612                  if (bForce && pChannel && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)                  if (bForce && pChannel)
613                      appendMessagesClient("lscp_remove_channel");                      pChannel->removeChannel();
614                  delete pChannelStrip;                  delete pChannelStrip;
615              }              }
616          }          }
# Line 519  bool qsamplerMainForm::loadSessionFile ( Line 641  bool qsamplerMainForm::loadSessionFile (
641      QTextStream ts(&file);      QTextStream ts(&file);
642      while (!ts.atEnd()) {      while (!ts.atEnd()) {
643          // Read the line.          // Read the line.
644          QString sCommand = ts.readLine().simplifyWhiteSpace();          QString sCommand = ts.readLine().stripWhiteSpace();
645          // If not empty, nor a comment, call the server...          // If not empty, nor a comment, call the server...
646          if (!sCommand.isEmpty() && sCommand[0] != '#') {          if (!sCommand.isEmpty() && sCommand[0] != '#') {
647              appendMessagesColor(sCommand, "#996633");              appendMessagesColor(sCommand, "#996633");
# Line 538  bool qsamplerMainForm::loadSessionFile ( Line 660  bool qsamplerMainForm::loadSessionFile (
660      // Ok. we've read it.      // Ok. we've read it.
661      file.close();      file.close();
662    
663      // Have we any errors?          // Now we'll try to create (update) the whole GUI session.
664      if (iErrors > 0)          updateSession();
         appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));  
665    
666      // Now we'll try to create the whole GUI session.          // Have we any errors?
667      int iChannels = ::lscp_get_channels(m_pClient);          if (iErrors > 0)
668      if (iChannels < 0) {                  appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));
         appendMessagesClient("lscp_get_channels");  
         appendMessagesError(tr("Could not get current number of channels.\n\nSorry."));  
     }  
       
     // Try to (re)create each channel.  
     m_pWorkspace->setUpdatesEnabled(false);  
     for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) {  
         createChannel(iChannelID, false);  
         QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
     }  
     m_pWorkspace->setUpdatesEnabled(true);  
669    
670      // Save as default session directory.      // Save as default session directory.
671      if (m_pOptions)      if (m_pOptions)
672          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);
673      // We're not dirty anymore.          // We're not dirty anymore, if loaded without errors,
674      m_iDirtyCount = 0;          m_iDirtyCount = iErrors;
675      // Stabilize form...      // Stabilize form...
676      m_sFilename = sFilename;      m_sFilename = sFilename;
677      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
678      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
679    
680        // Make that an overall update.
681      stabilizeForm();      stabilizeForm();
682      return true;      return true;
683  }  }
# Line 582  bool qsamplerMainForm::saveSessionFile ( Line 694  bool qsamplerMainForm::saveSessionFile (
694      }      }
695    
696      // Write the file.      // Write the file.
697      int iErrors = 0;      int  iErrors = 0;
698      QTextStream ts(&file);      QTextStream ts(&file);
699      ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;      ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
700      ts << "# " << tr("Version")      ts << "# " << tr("Version")
# Line 593  bool qsamplerMainForm::saveSessionFile ( Line 705  bool qsamplerMainForm::saveSessionFile (
705      ts << "# " << tr("File")      ts << "# " << tr("File")
706         << ": " << QFileInfo(sFilename).fileName() << endl;         << ": " << QFileInfo(sFilename).fileName() << endl;
707      ts << "# " << tr("Date")      ts << "# " << tr("Date")
708         << ": " << QDate::currentDate().toString("MMMM dd yyyy")         << ": " << QDate::currentDate().toString("MMM dd yyyy")
709         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
710      ts << "#"  << endl;      ts << "#"  << endl;
711      ts << endl;      ts << endl;
712            // It is assumed that this new kind of device+session file
713            // will be loaded from a complete
714            int *piDeviceIDs;
715            int  iDevice;
716            ts << "RESET" << endl;
717            // Audio device mapping.
718            QMap<int, int> audioDeviceMap;
719            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
720            for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
721                    ts << endl;
722                    qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]);
723                    // Audio device specification...
724                    ts << "# " << device.deviceTypeName() << " " << device.driverName()
725                            << " " << tr("Device") << " " << iDevice << endl;
726                    ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
727                    qsamplerDeviceParamMap::ConstIterator deviceParam;
728                    for (deviceParam = device.params().begin();
729                                    deviceParam != device.params().end();
730                                            ++deviceParam) {
731                            const qsamplerDeviceParam& param = deviceParam.data();
732                            if (param.value.isEmpty()) ts << "# ";
733                            ts << " " << deviceParam.key() << "='" << param.value << "'";
734                    }
735                    ts << endl;
736                    // Audio channel parameters...
737                    int iPort = 0;
738                    for (qsamplerDevicePort *pPort = device.ports().first();
739                                    pPort;
740                                            pPort = device.ports().next(), ++iPort) {
741                            qsamplerDeviceParamMap::ConstIterator portParam;
742                            for (portParam = pPort->params().begin();
743                                            portParam != pPort->params().end();
744                                                    ++portParam) {
745                                    const qsamplerDeviceParam& param = portParam.data();
746                                    if (param.fix || param.value.isEmpty()) ts << "# ";
747                                    ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
748                                            << " " << iPort << " " << portParam.key()
749                                            << "='" << param.value << "'" << endl;
750                            }
751                    }
752                    // Audio device index/id mapping.
753                    audioDeviceMap[device.deviceID()] = iDevice;
754            // Try to keep it snappy :)
755            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
756            }
757            // MIDI device mapping.
758            QMap<int, int> midiDeviceMap;
759            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
760            for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
761                    ts << endl;
762                    qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]);
763                    // MIDI device specification...
764                    ts << "# " << device.deviceTypeName() << " " << device.driverName()
765                            << " " << tr("Device") << " " << iDevice << endl;
766                    ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
767                    qsamplerDeviceParamMap::ConstIterator deviceParam;
768                    for (deviceParam = device.params().begin();
769                                    deviceParam != device.params().end();
770                                            ++deviceParam) {
771                            const qsamplerDeviceParam& param = deviceParam.data();
772                            if (param.value.isEmpty()) ts << "# ";
773                            ts << " " << deviceParam.key() << "='" << param.value << "'";
774                    }
775                    ts << endl;
776                    // MIDI port parameters...
777                    int iPort = 0;
778                    for (qsamplerDevicePort *pPort = device.ports().first();
779                                    pPort;
780                                            pPort = device.ports().next(), ++iPort) {
781                            qsamplerDeviceParamMap::ConstIterator portParam;
782                            for (portParam = pPort->params().begin();
783                                            portParam != pPort->params().end();
784                                                    ++portParam) {
785                                    const qsamplerDeviceParam& param = portParam.data();
786                                    if (param.fix || param.value.isEmpty()) ts << "# ";
787                                    ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice
788                                       << " " << iPort << " " << portParam.key()
789                                       << "='" << param.value << "'" << endl;
790                            }
791                    }
792                    // MIDI device index/id mapping.
793                    midiDeviceMap[device.deviceID()] = iDevice;
794            // Try to keep it snappy :)
795            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
796            }
797            ts << endl;
798            // Sampler channel mapping.
799      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
800      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
801          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
802          if (pChannelStrip) {          if (pChannelStrip) {
803              qsamplerChannel *pChannel = pChannelStrip->channel();              qsamplerChannel *pChannel = pChannelStrip->channel();
804              if (pChannel) {              if (pChannel) {
805                  int iChannelID = pChannel->channelID();                  ts << "# " << tr("Channel") << " " << iChannel << endl;
                 ts << "# " << pChannelStrip->caption() << endl;  
806                  ts << "ADD CHANNEL" << endl;                  ts << "ADD CHANNEL" << endl;
807                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                                  if (audioDeviceMap.isEmpty()) {
808                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel
809                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                                                  << " " << pChannel->audioDriver() << endl;
810                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";                                  } else {
811                  if (pChannel->midiChannel() > 0)                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel
812                      ts << pChannel->midiChannel();                                                  << " " << audioDeviceMap[pChannel->audioDevice()] << endl;
813                   else                                  }
814                                    if (midiDeviceMap.isEmpty()) {
815                                            ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel
816                                                    << " " << pChannel->midiDriver() << endl;
817                                    } else {
818                                            ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel
819                                                    << " " << midiDeviceMap[pChannel->midiDevice()] << endl;
820                                    }
821                                    ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel
822                                            << " " << pChannel->midiPort() << endl;
823                    ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";
824                    if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
825                      ts << "ALL";                      ts << "ALL";
826                    else
827                        ts << pChannel->midiChannel();
828                  ts << endl;                  ts << endl;
829                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;                  ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
830                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;
831                  ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                                  qsamplerChannelRoutingMap::ConstIterator audioRoute;
832                                    for (audioRoute = pChannel->audioRouting().begin();
833                                                    audioRoute != pChannel->audioRouting().end();
834                                                            ++audioRoute) {
835                                            ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel
836                                                    << " " << audioRoute.key()
837                                                    << " " << audioRoute.data() << endl;
838                                    }
839                    ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;
840                                    if (pChannel->channelMute())
841                                            ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl;
842                                    if (pChannel->channelSolo())
843                                            ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl;
844                  ts << endl;                  ts << endl;
845              }              }
846          }          }
# Line 625  bool qsamplerMainForm::saveSessionFile ( Line 848  bool qsamplerMainForm::saveSessionFile (
848          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
849      }      }
850    
851    #ifdef CONFIG_MIDI_INSTRUMENT
852            // MIDI instrument mapping...
853            lscp_midi_instrument_t *pInstrs = ::lscp_list_midi_instruments(m_pClient);
854            if (pInstrs)
855            ts << "# " << tr("MIDI instrument mapping") << endl;
856            for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; iInstr++) {
857                    lscp_midi_instrument_info_t *pInstrInfo
858                            = ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]);
859                    if (pInstrInfo) {
860                            ts << "MAP MIDI_INSTRUMENT "
861                                    << pInstrs[iInstr].bank_msb    << " "
862                                    << pInstrs[iInstr].bank_lsb    << " "
863                                    << pInstrs[iInstr].program     << " "
864                                    << pInstrInfo->engine_name     << " '"
865                                    << pInstrInfo->instrument_file << "' "
866                                    << pInstrInfo->instrument_nr   << " "
867                                    << pInstrInfo->volume          << " ";
868                            switch (pInstrInfo->load_mode) {
869                                    case LSCP_LOAD_PERSISTENT:
870                                            ts << "PERSISTENT";
871                                            break;
872                                    case LSCP_LOAD_ON_DEMAND_HOLD:
873                                            ts << "ON_DEMAND_HOLD";
874                                            break;
875                                    case LSCP_LOAD_ON_DEMAND:
876                                    case LSCP_LOAD_DEFAULT:
877                                    default:
878                                            ts << "ON_DEMAND";
879                                            break;
880                            }
881                            if (pInstrInfo->name)
882                                    ts << " '" << pInstrInfo->name << "'";
883                            ts << endl;
884                    }
885                    ts << endl;
886            // Try to keep it snappy :)
887            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
888            }
889    #endif //  CONFIG_MIDI_INSTRUMENT
890    
891      // Ok. we've wrote it.      // Ok. we've wrote it.
892      file.close();      file.close();
893    
# Line 646  bool qsamplerMainForm::saveSessionFile ( Line 909  bool qsamplerMainForm::saveSessionFile (
909  }  }
910    
911    
912    // Session change receiver slot.
913    void qsamplerMainForm::sessionDirty (void)
914    {
915        // Just mark the dirty form.
916        m_iDirtyCount++;
917        // and update the form status...
918        stabilizeForm();
919    }
920    
921    
922  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
923  // qsamplerMainForm -- File Action slots.  // qsamplerMainForm -- File Action slots.
924    
# Line 699  void qsamplerMainForm::fileReset (void) Line 972  void qsamplerMainForm::fileReset (void)
972          return;          return;
973    
974      // Ask user whether he/she want's an internal sampler reset...      // Ask user whether he/she want's an internal sampler reset...
975      if (QMessageBox::warning(this, tr("Warning"),      if (QMessageBox::warning(this,
976                    QSAMPLER_TITLE ": " + tr("Warning"),
977          tr("Resetting the sampler instance will close\n"          tr("Resetting the sampler instance will close\n"
978             "all device and channel configurations.\n\n"             "all device and channel configurations.\n\n"
979             "Please note that this operation may cause\n"             "Please note that this operation may cause\n"
980             "temporary MIDI and Audio disruption\n\n"             "temporary MIDI and Audio disruption.\n\n"
981             "Do you want to reset the sampler engine now?"),             "Do you want to reset the sampler engine now?"),
982          tr("Reset"), tr("Cancel")) > 0)          tr("Reset"), tr("Cancel")) > 0)
983          return;          return;
# Line 717  void qsamplerMainForm::fileReset (void) Line 991  void qsamplerMainForm::fileReset (void)
991    
992      // Log this.      // Log this.
993      appendMessages(tr("Sampler reset."));      appendMessages(tr("Sampler reset."));
994    
995            // Make it a new session...
996            newSession();
997  }  }
998    
999    
# Line 725  void qsamplerMainForm::fileRestart (void Line 1002  void qsamplerMainForm::fileRestart (void
1002  {  {
1003      if (m_pOptions == NULL)      if (m_pOptions == NULL)
1004          return;          return;
1005            
1006      bool bRestart = true;      bool bRestart = true;
1007        
1008      // Ask user whether he/she want's a complete restart...      // Ask user whether he/she want's a complete restart...
1009      // (if we're currently up and running)      // (if we're currently up and running)
1010      if (bRestart && m_pClient) {      if (bRestart && m_pClient) {
1011          bRestart = (QMessageBox::warning(this, tr("Warning"),          bRestart = (QMessageBox::warning(this,
1012                            QSAMPLER_TITLE ": " + tr("Warning"),
1013              tr("New settings will be effective after\n"              tr("New settings will be effective after\n"
1014                 "restarting the client/server connection.\n\n"                 "restarting the client/server connection.\n\n"
1015                 "Please note that this operation may cause\n"                 "Please note that this operation may cause\n"
1016                 "temporary MIDI and Audio disruption\n\n"                 "temporary MIDI and Audio disruption.\n\n"
1017                 "Do you want to restart the connection now?"),                 "Do you want to restart the connection now?"),
1018              tr("Restart"), tr("Cancel")) == 0);              tr("Restart"), tr("Cancel")) == 0);
1019      }      }
# Line 767  void qsamplerMainForm::editAddChannel (v Line 1045  void qsamplerMainForm::editAddChannel (v
1045      if (m_pClient == NULL)      if (m_pClient == NULL)
1046          return;          return;
1047    
1048      // Create the new sampler channel.      // Just create the channel instance...
1049      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel();
1050      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
1051          return;          return;
     }  
1052    
1053      // Log this happening.      // Before we show it up, may be we'll
1054      appendMessages(tr("Channel %1 created.").arg(iChannelID));      // better ask for some initial values?
1055        if (!pChannel->channelSetup(this)) {
1056            delete pChannel;
1057            return;
1058        }
1059    
1060      // Just create the channel strip with given id.      // And give it to the strip (will own the channel instance, if successful).
1061      createChannel(iChannelID, true);      if (!createChannelStrip(pChannel)) {
1062            delete pChannel;
1063            return;
1064        }
1065    
1066      // We'll be dirty, for sure...      // Make that an overall update.
1067      m_iDirtyCount++;      m_iDirtyCount++;
     // Stabilize form anyway.  
1068      stabilizeForm();      stabilizeForm();
1069  }  }
1070    
# Line 797  void qsamplerMainForm::editRemoveChannel Line 1078  void qsamplerMainForm::editRemoveChannel
1078      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1079      if (pChannelStrip == NULL)      if (pChannelStrip == NULL)
1080          return;          return;
1081            
1082      qsamplerChannel *pChannel = pChannelStrip->channel();      qsamplerChannel *pChannel = pChannelStrip->channel();
1083      if (pChannel == NULL)      if (pChannel == NULL)
1084          return;          return;
1085    
1086      // Prompt user if he/she's sure about this...      // Prompt user if he/she's sure about this...
1087      if (m_pOptions && m_pOptions->bConfirmRemove) {      if (m_pOptions && m_pOptions->bConfirmRemove) {
1088          if (QMessageBox::warning(this, tr("Warning"),          if (QMessageBox::warning(this,
1089                            QSAMPLER_TITLE ": " + tr("Warning"),
1090              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
1091                 "%1\n\n"                 "%1\n\n"
1092                 "Are you sure?")                 "Are you sure?")
# Line 814  void qsamplerMainForm::editRemoveChannel Line 1096  void qsamplerMainForm::editRemoveChannel
1096      }      }
1097    
1098      // Remove the existing sampler channel.      // Remove the existing sampler channel.
1099      if (::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      if (!pChannel->removeChannel())
         appendMessagesClient("lscp_remove_channel");  
         appendMessagesError(tr("Could not remove channel.\n\nSorry."));  
1100          return;          return;
     }  
1101    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
1102      // Just delete the channel strip.      // Just delete the channel strip.
1103      delete pChannelStrip;      delete pChannelStrip;
1104        
1105      // Do we auto-arrange?      // Do we auto-arrange?
1106      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
1107          channelsArrange();          channelsArrange();
# Line 847  void qsamplerMainForm::editSetupChannel Line 1123  void qsamplerMainForm::editSetupChannel
1123          return;          return;
1124    
1125      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
1126      pChannelStrip->showChannelSetup(false);      pChannelStrip->channelSetup();
1127  }  }
1128    
1129    
# Line 861  void qsamplerMainForm::editResetChannel Line 1137  void qsamplerMainForm::editResetChannel
1137      if (pChannelStrip == NULL)      if (pChannelStrip == NULL)
1138          return;          return;
1139    
1140      qsamplerChannel *pChannel = pChannelStrip->channel();      // Just invoque the channel strip procedure.
1141      if (pChannel == NULL)      pChannelStrip->channelReset();
1142          return;  }
   
     // Remove the existing sampler channel.  
     if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {  
         appendMessagesClient("lscp_reset_channel");  
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
         return;  
     }  
1143    
     // Log this.  
     appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));  
1144    
1145      // Refresh channel strip info.  // Reset all sampler channels.
1146      pChannelStrip->updateChannelInfo();  void qsamplerMainForm::editResetAllChannels (void)
1147    {
1148            if (m_pClient == NULL)
1149                    return;
1150    
1151            // Invoque the channel strip procedure,
1152            // for all channels out there...
1153            m_pWorkspace->setUpdatesEnabled(false);
1154            QWidgetList wlist = m_pWorkspace->windowList();
1155            for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1156                    qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1157                    if (pChannelStrip)
1158                            pChannelStrip->channelReset();
1159            }
1160            m_pWorkspace->setUpdatesEnabled(true);
1161  }  }
1162    
1163    
# Line 928  void qsamplerMainForm::viewMessages ( bo Line 1209  void qsamplerMainForm::viewMessages ( bo
1209  }  }
1210    
1211    
1212    // Show/hide the MIDI instrument list-view form.
1213    void qsamplerMainForm::viewInstruments (void)
1214    {
1215            if (m_pOptions == NULL)
1216                    return;
1217    
1218            if (m_pInstrumentListForm) {
1219                    m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
1220                    if (m_pInstrumentListForm->isVisible()) {
1221                            m_pInstrumentListForm->hide();
1222                    } else {
1223                            m_pInstrumentListForm->show();
1224                            m_pInstrumentListForm->raise();
1225                            m_pInstrumentListForm->setActiveWindow();
1226                    }
1227            }
1228    }
1229    
1230    
1231    // Show/hide the device configurator form.
1232    void qsamplerMainForm::viewDevices (void)
1233    {
1234            if (m_pOptions == NULL)
1235                    return;
1236    
1237            if (m_pDeviceForm) {
1238                    m_pOptions->saveWidgetGeometry(m_pDeviceForm);
1239                    if (m_pDeviceForm->isVisible()) {
1240                            m_pDeviceForm->hide();
1241                    } else {
1242                            m_pDeviceForm->show();
1243                            m_pDeviceForm->raise();
1244                            m_pDeviceForm->setActiveWindow();
1245                    }
1246            }
1247    }
1248    
1249    
1250  // Show options dialog.  // Show options dialog.
1251  void qsamplerMainForm::viewOptions (void)  void qsamplerMainForm::viewOptions (void)
1252  {  {
# Line 952  void qsamplerMainForm::viewOptions (void Line 1271  void qsamplerMainForm::viewOptions (void
1271          bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;          bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1272          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
1273          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
1274            bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;
1275          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
1276          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
1277          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1278          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
1279            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
1280          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1281          // Load the current setup settings.          // Load the current setup settings.
1282          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 963  void qsamplerMainForm::viewOptions (void Line 1284  void qsamplerMainForm::viewOptions (void
1284          if (pOptionsForm->exec()) {          if (pOptionsForm->exec()) {
1285              // Warn if something will be only effective on next run.              // Warn if something will be only effective on next run.
1286              if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||              if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||
1287                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture)) {                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||
1288                  QMessageBox::information(this, tr("Information"),                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1289                    (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)) {
1290                    QMessageBox::information(this,
1291                                            QSAMPLER_TITLE ": " + tr("Information"),
1292                      tr("Some settings may be only effective\n"                      tr("Some settings may be only effective\n"
1293                         "next time you start this program."), tr("OK"));                         "next time you start this program."), tr("OK"));
1294                  updateMessagesCapture();                  updateMessagesCapture();
# Line 974  void qsamplerMainForm::viewOptions (void Line 1298  void qsamplerMainForm::viewOptions (void
1298                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1299                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
1300                  updateRecentFilesMenu();                  updateRecentFilesMenu();
1301                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
1302                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
1303                    updateInstrumentNames();
1304              if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||              if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
1305                  (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))                  (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
1306                  updateDisplayEffect();                  updateDisplayEffect();
# Line 1035  void qsamplerMainForm::channelsArrange ( Line 1362  void qsamplerMainForm::channelsArrange (
1362          y += iHeight;          y += iHeight;
1363      }      }
1364      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1365        
1366      stabilizeForm();      stabilizeForm();
1367  }  }
1368    
# Line 1084  void qsamplerMainForm::helpAbout (void) Line 1411  void qsamplerMainForm::helpAbout (void)
1411      sText += tr("GIG (libgig) file support disabled.");      sText += tr("GIG (libgig) file support disabled.");
1412      sText += "</font></small><br />";      sText += "</font></small><br />";
1413  #endif  #endif
1414    #ifndef CONFIG_INSTRUMENT_NAME
1415        sText += "<small><font color=\"red\">";
1416        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1417        sText += "</font></small><br />";
1418    #endif
1419    #ifndef CONFIG_MUTE_SOLO
1420        sText += "<small><font color=\"red\">";
1421        sText += tr("Sampler channel Mute/Solo support disabled.");
1422        sText += "</font></small><br />";
1423    #endif
1424    #ifndef CONFIG_MIDI_INSTRUMENT
1425        sText += "<small><font color=\"red\">";
1426        sText += tr("MIDI instrument mapping support disabled.");
1427        sText += "</font></small><br />";
1428    #endif
1429      sText += "<br />\n";      sText += "<br />\n";
1430      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1431      sText += ::lscp_client_package();      sText += ::lscp_client_package();
1432      sText += " ";      sText += " ";
1433      sText += ::lscp_client_version();      sText += ::lscp_client_version();
1434    #ifdef CONFIG_LIBGIG
1435        sText += ", ";
1436        sText += gig::libraryName().c_str();
1437        sText += " ";
1438        sText += gig::libraryVersion().c_str();
1439    #endif
1440      sText += "<br />\n";      sText += "<br />\n";
1441      sText += "<br />\n";      sText += "<br />\n";
1442      sText += tr("Website") + ": <a href=\"" QSAMPLER_WEBSITE "\">" QSAMPLER_WEBSITE "</a><br />\n";      sText += tr("Website") + ": <a href=\"" QSAMPLER_WEBSITE "\">" QSAMPLER_WEBSITE "</a><br />\n";
# Line 1111  void qsamplerMainForm::helpAbout (void) Line 1459  void qsamplerMainForm::helpAbout (void)
1459  void qsamplerMainForm::stabilizeForm (void)  void qsamplerMainForm::stabilizeForm (void)
1460  {  {
1461      // Update the main application caption...      // Update the main application caption...
1462      QString sSessioName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1463      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1464          sSessioName += '*';          sSessionName += " *";
1465      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1466    
1467      // Update the main menu state...      // Update the main menu state...
1468      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
# Line 1130  void qsamplerMainForm::stabilizeForm (vo Line 1478  void qsamplerMainForm::stabilizeForm (vo
1478      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
1479      editSetupChannelAction->setEnabled(bHasChannel);      editSetupChannelAction->setEnabled(bHasChannel);
1480      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1481      channelsArrangeAction->setEnabled(bHasChannel);      editResetAllChannelsAction->setEnabled(bHasChannel);
1482      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1483    #ifdef CONFIG_MIDI_INSTRUMENT
1484            viewInstrumentsAction->setOn(m_pInstrumentListForm
1485                    && m_pInstrumentListForm->isVisible());
1486            viewInstrumentsAction->setEnabled(bHasClient);
1487    #endif
1488            viewDevicesAction->setOn(m_pDeviceForm
1489                    && m_pDeviceForm->isVisible());
1490        viewDevicesAction->setEnabled(bHasClient);
1491        channelsArrangeAction->setEnabled(bHasChannel);
1492    
1493      // Client/Server status...      // Client/Server status...
1494      if (bHasClient) {      if (bHasClient) {
1495          m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected"));          m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected"));
1496          m_status[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort));          m_statusItem[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort));
1497      } else {      } else {
1498          m_status[QSAMPLER_STATUS_CLIENT]->clear();          m_statusItem[QSAMPLER_STATUS_CLIENT]->clear();
1499          m_status[QSAMPLER_STATUS_SERVER]->clear();          m_statusItem[QSAMPLER_STATUS_SERVER]->clear();
1500      }      }
1501      // Channel status...      // Channel status...
1502      if (bHasChannel)      if (bHasChannel)
1503          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());          m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1504      else      else
1505          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear();
1506      // Session status...      // Session status...
1507      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1508          m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD"));          m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD"));
1509      else      else
1510          m_status[QSAMPLER_STATUS_SESSION]->clear();          m_statusItem[QSAMPLER_STATUS_SESSION]->clear();
1511    
1512      // Recent files menu.      // Recent files menu.
1513      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);
# Line 1162  void qsamplerMainForm::stabilizeForm (vo Line 1519  void qsamplerMainForm::stabilizeForm (vo
1519    
1520    
1521  // Channel change receiver slot.  // Channel change receiver slot.
1522  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )
1523  {  {
1524            // Add this strip to the changed list...
1525            if (m_changedStrips.containsRef(pChannelStrip) == 0) {
1526                    m_changedStrips.append(pChannelStrip);
1527                    pChannelStrip->resetErrorCount();
1528            }
1529    
1530      // Just mark the dirty form.      // Just mark the dirty form.
1531      m_iDirtyCount++;      m_iDirtyCount++;
1532      // and update the form status...      // and update the form status...
# Line 1171  void qsamplerMainForm::channelStripChang Line 1534  void qsamplerMainForm::channelStripChang
1534  }  }
1535    
1536    
1537    // Grab and restore current sampler channels session.
1538    void qsamplerMainForm::updateSession (void)
1539    {
1540            // Retrieve the current channel list.
1541            int *piChannelIDs = ::lscp_list_channels(m_pClient);
1542            if (piChannelIDs == NULL) {
1543                    if (::lscp_client_get_errno(m_pClient)) {
1544                            appendMessagesClient("lscp_list_channels");
1545                            appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1546                    }
1547                    return;
1548            }
1549    
1550            // Try to (re)create each channel.
1551            m_pWorkspace->setUpdatesEnabled(false);
1552            for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1553                    // Check if theres already a channel strip for this one...
1554                    if (!channelStrip(piChannelIDs[iChannel]))
1555                            createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));
1556                    // Make it visibly responsive...
1557                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1558            }
1559            m_pWorkspace->setUpdatesEnabled(true);
1560            
1561            // Remember to refresh devices and instruments...
1562            if (m_pInstrumentListForm)
1563                m_pInstrumentListForm->refreshInstruments();
1564            if (m_pDeviceForm)
1565                m_pDeviceForm->refreshDevices();
1566    }
1567    
1568    
1569  // Update the recent files list and menu.  // Update the recent files list and menu.
1570  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )
1571  {  {
# Line 1215  void qsamplerMainForm::updateRecentFiles Line 1610  void qsamplerMainForm::updateRecentFiles
1610  }  }
1611    
1612    
1613    // Force update of the channels instrument names mode.
1614    void qsamplerMainForm::updateInstrumentNames (void)
1615    {
1616        // Full channel list update...
1617        QWidgetList wlist = m_pWorkspace->windowList();
1618        if (wlist.isEmpty())
1619            return;
1620    
1621        m_pWorkspace->setUpdatesEnabled(false);
1622        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1623            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1624            if (pChannelStrip)
1625                pChannelStrip->updateInstrumentName(true);
1626        }
1627        m_pWorkspace->setUpdatesEnabled(true);
1628    }
1629    
1630    
1631  // Force update of the channels display font.  // Force update of the channels display font.
1632  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1633  {  {
# Line 1320  void qsamplerMainForm::appendMessagesErr Line 1733  void qsamplerMainForm::appendMessagesErr
1733    
1734      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");
1735    
1736      QMessageBox::critical(this, tr("Error"), s, tr("Cancel"));      QMessageBox::critical(this,
1737                    QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));
1738  }  }
1739    
1740    
# Line 1360  void qsamplerMainForm::updateMessagesLim Line 1774  void qsamplerMainForm::updateMessagesLim
1774          if (m_pOptions->bMessagesLimit)          if (m_pOptions->bMessagesLimit)
1775              m_pMessages->setMessagesLimit(m_pOptions->iMessagesLimitLines);              m_pMessages->setMessagesLimit(m_pOptions->iMessagesLimitLines);
1776          else          else
1777              m_pMessages->setMessagesLimit(0);              m_pMessages->setMessagesLimit(-1);
1778      }      }
1779  }  }
1780    
# Line 1380  void qsamplerMainForm::updateMessagesCap Line 1794  void qsamplerMainForm::updateMessagesCap
1794  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1795    
1796  // The channel strip creation executive.  // The channel strip creation executive.
1797  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1798  {  {
1799      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1800          return;          return NULL;
1801    
1802      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1803      qsamplerChannelStrip *pChannelStrip = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
# Line 1392  void qsamplerMainForm::createChannel ( i Line 1806  void qsamplerMainForm::createChannel ( i
1806          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1807          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1808              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1809          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();                          if (pChannelStrip) {
1810              y += pChannelStrip->parentWidget()->frameGeometry().height();                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1811                                    y += pChannelStrip->parentWidget()->frameGeometry().height();
1812                            }
1813          }          }
1814      }      }
1815    
1816      // Add a new channel itema...      // Add a new channel itema...
1817      WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;      WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;
1818      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1819        if (pChannelStrip == NULL)
1820            return NULL;
1821    
1822        // Actual channel strip setup...
1823        pChannelStrip->setup(pChannel);
1824        QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1825      // Set some initial aesthetic options...      // Set some initial aesthetic options...
1826      if (m_pOptions) {      if (m_pOptions) {
1827          // Background display effect...          // Background display effect...
# Line 1411  void qsamplerMainForm::createChannel ( i Line 1833  void qsamplerMainForm::createChannel ( i
1833          // Maximum allowed volume setting.          // Maximum allowed volume setting.
1834          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);          pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1835      }      }
1836      // Actual channel setup.  
     pChannelStrip->setup(this, iChannelID);  
     QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));  
     // Before we show it up, may be we'll  
     // better ask for some initial values?  
     if (bPrompt)  
         pChannelStrip->showChannelSetup(true);  
1837      // Now we show up us to the world.      // Now we show up us to the world.
1838      pChannelStrip->show();      pChannelStrip->show();
1839      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
# Line 1427  void qsamplerMainForm::createChannel ( i Line 1843  void qsamplerMainForm::createChannel ( i
1843          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1844          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1845      }      }
1846    
1847            // This is pretty new, so we'll watch for it closely.
1848            channelStripChanged(pChannelStrip);
1849    
1850        // Return our successful reference...
1851        return pChannelStrip;
1852  }  }
1853    
1854    
# Line 1442  qsamplerChannelStrip *qsamplerMainForm:: Line 1864  qsamplerChannelStrip *qsamplerMainForm::
1864  {  {
1865      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1866      if (wlist.isEmpty())      if (wlist.isEmpty())
1867          return 0;          return NULL;
1868    
1869      return (qsamplerChannelStrip *) wlist.at(iChannel);      return (qsamplerChannelStrip *) wlist.at(iChannel);
1870  }  }
1871    
1872    
1873    // Retrieve a channel strip by sampler channel id.
1874    qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID )
1875    {
1876            QWidgetList wlist = m_pWorkspace->windowList();
1877            if (wlist.isEmpty())
1878                    return NULL;
1879    
1880            for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1881                    qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1882                    if (pChannelStrip) {
1883                            qsamplerChannel *pChannel = pChannelStrip->channel();
1884                            if (pChannel && pChannel->channelID() == iChannelID)
1885                                    return pChannelStrip;
1886                    }
1887            }
1888    
1889            // Not found.
1890            return NULL;
1891    }
1892    
1893    
1894  // Construct the windows menu.  // Construct the windows menu.
1895  void qsamplerMainForm::channelsMenuAboutToShow (void)  void qsamplerMainForm::channelsMenuAboutToShow (void)
1896  {  {
# Line 1514  void qsamplerMainForm::timerSlot (void) Line 1957  void qsamplerMainForm::timerSlot (void)
1957              }              }
1958          }          }
1959      }      }
1960        
1961          // Refresh each channel usage, on each period...          if (m_pClient) {
1962      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {                  // Update the channel information for each pending strip...
1963          m_iTimerSlot += QSAMPLER_TIMER_MSECS;                  if (m_changedStrips.count() > 0) {
1964          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {                          for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();
1965              m_iTimerSlot = 0;                                          pChannelStrip; pChannelStrip = m_changedStrips.next()) {
1966              QWidgetList wlist = m_pWorkspace->windowList();                                  // If successfull, remove from pending list...
1967              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                                  if (pChannelStrip->updateChannelInfo())
1968                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);                                          m_changedStrips.remove(pChannelStrip);
1969                  if (pChannelStrip && pChannelStrip->isVisible())                          }
1970                      pChannelStrip->updateChannelUsage();                  }
1971              }                  // Refresh each channel usage, on each period...
1972          }                  if (m_pOptions->bAutoRefresh) {
1973      }                          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1974                            if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {
1975                                    m_iTimerSlot = 0;
1976                                    // Update the channel stream usage for each strip...
1977                                    QWidgetList wlist = m_pWorkspace->windowList();
1978                                    for (int iChannel = 0;
1979                                                    iChannel < (int) wlist.count(); iChannel++) {
1980                                            qsamplerChannelStrip *pChannelStrip
1981                                                    = (qsamplerChannelStrip *) wlist.at(iChannel);
1982                                            if (pChannelStrip && pChannelStrip->isVisible())
1983                                                    pChannelStrip->updateChannelUsage();
1984                                    }
1985                            }
1986                    }
1987            }
1988    
1989      // Register the next timer slot.      // Register the next timer slot.
1990      QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(timerSlot()));      QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(timerSlot()));
# Line 1549  void qsamplerMainForm::startServer (void Line 2006  void qsamplerMainForm::startServer (void
2006    
2007      // Is the server process instance still here?      // Is the server process instance still here?
2008      if (m_pServer) {      if (m_pServer) {
2009          switch (QMessageBox::warning(this, tr("Warning"),          switch (QMessageBox::warning(this,
2010                            QSAMPLER_TITLE ": " + tr("Warning"),
2011              tr("Could not start the LinuxSampler server.\n\n"              tr("Could not start the LinuxSampler server.\n\n"
2012                 "Maybe it ss already started."),                 "Maybe it ss already started."),
2013              tr("Stop"), tr("Kill"), tr("Cancel"))) {              tr("Stop"), tr("Kill"), tr("Cancel"))) {
# Line 1708  bool qsamplerMainForm::startClient (void Line 2166  bool qsamplerMainForm::startClient (void
2166      ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);      ::lscp_client_set_timeout(m_pClient, m_pOptions->iServerTimeout);
2167      appendMessages(tr("Client receive timeout is set to %1 msec.").arg(::lscp_client_get_timeout(m_pClient)));      appendMessages(tr("Client receive timeout is set to %1 msec.").arg(::lscp_client_get_timeout(m_pClient)));
2168    
2169            // Subscribe to channel info change notifications...
2170            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)
2171                    appendMessagesClient("lscp_client_subscribe");
2172    
2173      // We may stop scheduling around.      // We may stop scheduling around.
2174      stopSchedule();      stopSchedule();
2175    
# Line 1717  bool qsamplerMainForm::startClient (void Line 2179  bool qsamplerMainForm::startClient (void
2179      // Log success here.      // Log success here.
2180      appendMessages(tr("Client connected."));      appendMessages(tr("Client connected."));
2181    
2182            // Hard-notify instrumnet and device configuration forms,
2183            // if visible, that we're ready...
2184            if (m_pInstrumentListForm)
2185                m_pInstrumentListForm->refreshInstruments();
2186            if (m_pDeviceForm)
2187                m_pDeviceForm->refreshDevices();
2188    
2189      // Is any session pending to be loaded?      // Is any session pending to be loaded?
2190      if (!m_pOptions->sSessionFile.isEmpty()) {      if (!m_pOptions->sSessionFile.isEmpty()) {
2191          // Just load the prabably startup session...          // Just load the prabably startup session...
# Line 1751  void qsamplerMainForm::stopClient (void) Line 2220  void qsamplerMainForm::stopClient (void)
2220      // channels from the back-end server.      // channels from the back-end server.
2221      m_iDirtyCount = 0;      m_iDirtyCount = 0;
2222      closeSession(false);      closeSession(false);
2223        
2224      // Close us as a client...      // Close us as a client...
2225      lscp_client_destroy(m_pClient);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
2226        ::lscp_client_destroy(m_pClient);
2227      m_pClient = NULL;      m_pClient = NULL;
2228    
2229            // Hard-notify instrumnet and device configuration forms,
2230            // if visible, that we're running out...
2231            if (m_pInstrumentListForm)
2232                m_pInstrumentListForm->refreshInstruments();
2233            if (m_pDeviceForm)
2234                m_pDeviceForm->refreshDevices();
2235    
2236      // Log final here.      // Log final here.
2237      appendMessages(tr("Client disconnected."));      appendMessages(tr("Client disconnected."));
2238    

Legend:
Removed from v.267  
changed lines
  Added in v.968

  ViewVC Help
Powered by ViewVC