/[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 176 by capela, Tue Jul 6 10:54:45 2004 UTC revision 433 by capela, Wed Mar 9 16:44:04 2005 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-2005, 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 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 36  Line 37 
37    
38  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
39  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
40    #include "qsamplerChannel.h"
41  #include "qsamplerMessages.h"  #include "qsamplerMessages.h"
42    
43  #include "qsamplerChannelStrip.h"  #include "qsamplerChannelStrip.h"
44    
45    #include "qsamplerDeviceForm.h"
46  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
47    
48  #include "config.h"  #include "config.h"
49    
50    #ifdef HAVE_SIGNAL_H
51    #include <signal.h>
52    #endif
53    
54  // Timer constant stuff.  // Timer constant stuff.
55  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
# Line 100  void qsamplerMainForm::init (void) Line 107  void qsamplerMainForm::init (void)
107      m_pOptions = NULL;      m_pOptions = NULL;
108    
109      // All child forms are to be created later, not earlier than setup.      // All child forms are to be created later, not earlier than setup.
110      m_pMessages = NULL;      m_pMessages   = NULL;
111        m_pDeviceForm = NULL;
112    
113      // We'll start clean.      // We'll start clean.
114      m_iUntitled = 0;      m_iUntitled   = 0;
115      m_iDirtyCount = 0;      m_iDirtyCount = 0;
116    
117      m_pServer = NULL;      m_pServer = NULL;
# Line 114  void qsamplerMainForm::init (void) Line 122  void qsamplerMainForm::init (void)
122    
123      m_iTimerSlot = 0;      m_iTimerSlot = 0;
124    
125    #ifdef HAVE_SIGNAL_H
126            // Set to ignore any fatal "Broken pipe" signals.
127            ::signal(SIGPIPE, SIG_IGN);
128    #endif
129    
130      // Make it an MDI workspace.      // Make it an MDI workspace.
131      m_pWorkspace = new QWorkspace(this);      m_pWorkspace = new QWorkspace(this);
132      m_pWorkspace->setScrollBarsEnabled(true);      m_pWorkspace->setScrollBarsEnabled(true);
# Line 128  void qsamplerMainForm::init (void) Line 141  void qsamplerMainForm::init (void)
141      pLabel = new QLabel(tr("Connected"), this);      pLabel = new QLabel(tr("Connected"), this);
142      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
143      pLabel->setMinimumSize(pLabel->sizeHint());      pLabel->setMinimumSize(pLabel->sizeHint());
144      m_status[QSAMPLER_STATUS_CLIENT] = pLabel;      m_statusItem[QSAMPLER_STATUS_CLIENT] = pLabel;
145      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
146      // Server address.      // Server address.
147      pLabel = new QLabel(this);      pLabel = new QLabel(this);
148      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
149      m_status[QSAMPLER_STATUS_SERVER] = pLabel;      m_statusItem[QSAMPLER_STATUS_SERVER] = pLabel;
150      statusBar()->addWidget(pLabel, 1);      statusBar()->addWidget(pLabel, 1);
151      // Channel title.      // Channel title.
152      pLabel = new QLabel(this);      pLabel = new QLabel(this);
153      pLabel->setAlignment(Qt::AlignLeft);      pLabel->setAlignment(Qt::AlignLeft);
154      m_status[QSAMPLER_STATUS_CHANNEL] = pLabel;      m_statusItem[QSAMPLER_STATUS_CHANNEL] = pLabel;
155      statusBar()->addWidget(pLabel, 2);      statusBar()->addWidget(pLabel, 2);
156      // Session modification status.      // Session modification status.
157      pLabel = new QLabel(tr("MOD"), this);      pLabel = new QLabel(tr("MOD"), this);
158      pLabel->setAlignment(Qt::AlignHCenter);      pLabel->setAlignment(Qt::AlignHCenter);
159      pLabel->setMinimumSize(pLabel->sizeHint());      pLabel->setMinimumSize(pLabel->sizeHint());
160      m_status[QSAMPLER_STATUS_SESSION] = pLabel;      m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
161      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
162    
163      // Create the recent files sub-menu.      // Create the recent files sub-menu.
# Line 163  void qsamplerMainForm::destroy (void) Line 176  void qsamplerMainForm::destroy (void)
176  {  {
177      // Do final processing anyway.      // Do final processing anyway.
178      processServerExit();      processServerExit();
179        
180      // Delete recentfiles menu.  #if defined(WIN32)
181      if (m_pRecentFilesMenu)      WSACleanup();
182          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];  
183    
184      // Finally drop any widgets around...      // Finally drop any widgets around...
185        if (m_pDeviceForm)
186            delete m_pDeviceForm;
187      if (m_pMessages)      if (m_pMessages)
188          delete m_pMessages;          delete m_pMessages;
189      if (m_pWorkspace)      if (m_pWorkspace)
190          delete m_pWorkspace;          delete m_pWorkspace;
191    
192  #if defined(WIN32)      // Delete status item labels one by one.
193      WSACleanup();      if (m_statusItem[QSAMPLER_STATUS_CLIENT])
194  #endif          delete m_statusItem[QSAMPLER_STATUS_CLIENT];
195        if (m_statusItem[QSAMPLER_STATUS_SERVER])
196            delete m_statusItem[QSAMPLER_STATUS_SERVER];
197        if (m_statusItem[QSAMPLER_STATUS_CHANNEL])
198            delete m_statusItem[QSAMPLER_STATUS_CHANNEL];
199        if (m_statusItem[QSAMPLER_STATUS_SESSION])
200            delete m_statusItem[QSAMPLER_STATUS_SESSION];
201    
202        // Delete recentfiles menu.
203        if (m_pRecentFilesMenu)
204            delete m_pRecentFilesMenu;
205  }  }
206    
207    
# Line 197  void qsamplerMainForm::setup ( qsamplerO Line 213  void qsamplerMainForm::setup ( qsamplerO
213    
214      // Some child forms are to be created right now.      // Some child forms are to be created right now.
215      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
216        m_pDeviceForm = new qsamplerDeviceForm(this);
217      // Set message defaults...      // Set message defaults...
218      updateMessagesFont();      updateMessagesFont();
219      updateMessagesLimit();      updateMessagesLimit();
# Line 225  void qsamplerMainForm::setup ( qsamplerO Line 242  void qsamplerMainForm::setup ( qsamplerO
242          QTextIStream istr(&sDockables);          QTextIStream istr(&sDockables);
243          istr >> *this;          istr >> *this;
244      }      }
245      // Try to restore old window positioning.      // Try to restore old window positioning and initial visibility.
246      m_pOptions->loadWidgetGeometry(this);      m_pOptions->loadWidgetGeometry(this);
247        m_pOptions->loadWidgetGeometry(m_pDeviceForm);
248    
249      // Final startup stabilization...      // Final startup stabilization...
250      updateRecentFilesMenu();      updateRecentFilesMenu();
# Line 264  bool qsamplerMainForm::queryClose (void) Line 282  bool qsamplerMainForm::queryClose (void)
282              QTextOStream ostr(&sDockables);              QTextOStream ostr(&sDockables);
283              ostr << *this;              ostr << *this;
284              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);              m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables);
285              // And the main windows state.              // And the children, and the main windows state,.
286                    m_pOptions->saveWidgetGeometry(m_pDeviceForm);
287              m_pOptions->saveWidgetGeometry(this);              m_pOptions->saveWidgetGeometry(this);
288                    // Close popup widgets.
289                    if (m_pDeviceForm)
290                        m_pDeviceForm->close();
291              // Stop client and/or server, gracefully.              // Stop client and/or server, gracefully.
292              stopServer();              stopServer();
293          }          }
# Line 284  void qsamplerMainForm::closeEvent ( QClo Line 306  void qsamplerMainForm::closeEvent ( QClo
306  }  }
307    
308    
309  // Window drag-n-drop event handlers.  // Drag'n'drop file handler.
310  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files )
311  {  {
312      bool bAccept = false;      bool bDecode = false;
313    
314      if (QTextDrag::canDecode(pDragEnterEvent)) {      if (QTextDrag::canDecode(pEvent)) {
315          QString sUrl;          QString sText;
316          if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient)          bDecode = QTextDrag::decode(pEvent, sText);
317              bAccept = QFileInfo(QUrl(sUrl).path()).exists();          if (bDecode) {
318                files = QStringList::split('\n', sText);
319                for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++)
320                    *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();
321            }
322      }      }
323    
324      pDragEnterEvent->accept(bAccept);      return bDecode;
325    }
326    
327    
328    // Window drag-n-drop event handlers.
329    void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
330    {
331            QStringList files;
332            pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));
333  }  }
334    
335    
336  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )  void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent )
337  {  {
338      if (QTextDrag::canDecode(pDropEvent)) {      QStringList files;
339          QString sUrl;  
340          if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true))      if (!decodeDragFiles(pDropEvent, files))
341              loadSessionFile(QUrl(sUrl).path());          return;
342      }  
343        for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {
344                    const QString& sPath = *iter;
345                    if (qsamplerChannel::isInstrumentFile(sPath)) {
346                            // Try to create a new channel from instrument file...
347                        qsamplerChannel *pChannel = new qsamplerChannel(this);
348                        if (pChannel == NULL)
349                            return;
350                            // Start setting the instrument filename...
351                            pChannel->setInstrument(sPath, 0);
352                        // Before we show it up, may be we'll
353                        // better ask for some initial values?
354                        if (!pChannel->channelSetup(this)) {
355                            delete pChannel;
356                            return;
357                        }
358                        // Finally, give it to a new channel strip...
359                            if (!createChannelStrip(pChannel)) {
360                            delete pChannel;
361                            return;
362                            }
363                        // Make that an overall update.
364                        m_iDirtyCount++;
365                        stabilizeForm();
366                    }   // Otherwise, load an usual session file (LSCP script)...
367                    else if (closeSession(true))
368                            loadSessionFile(sPath);
369                    // Make it look responsive...:)
370                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
371            }
372  }  }
373    
374    
# Line 370  bool qsamplerMainForm::newSession (void) Line 433  bool qsamplerMainForm::newSession (void)
433      if (!closeSession(true))      if (!closeSession(true))
434          return false;          return false;
435    
436            // Give us what the server has, right now...
437            updateSession();
438    
439      // Ok increment untitled count.      // Ok increment untitled count.
440      m_iUntitled++;      m_iUntitled++;
441    
# Line 483  bool qsamplerMainForm::closeSession ( bo Line 549  bool qsamplerMainForm::closeSession ( bo
549          m_pWorkspace->setUpdatesEnabled(false);          m_pWorkspace->setUpdatesEnabled(false);
550          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
551          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
552              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
553              if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK)              if (pChannelStrip) {
554                  appendMessagesClient("lscp_remove_channel");                  qsamplerChannel *pChannel = pChannelStrip->channel();
555              delete pChannel;                  if (bForce && pChannel)
556                        pChannel->removeChannel();
557                    delete pChannelStrip;
558                }
559          }          }
560          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
561          // We're now clean, for sure.          // We're now clean, for sure.
# Line 525  bool qsamplerMainForm::loadSessionFile ( Line 594  bool qsamplerMainForm::loadSessionFile (
594              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
595                  appendMessagesClient("lscp_client_query");                  appendMessagesClient("lscp_client_query");
596                  iErrors++;                  iErrors++;
597                    break;
598              }              }
599          }          }
600          // Try to make it snappy :)          // Try to make it snappy :)
# Line 536  bool qsamplerMainForm::loadSessionFile ( Line 606  bool qsamplerMainForm::loadSessionFile (
606    
607      // Have we any errors?      // Have we any errors?
608      if (iErrors > 0)      if (iErrors > 0)
609          appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename));
610    
611      // Now we'll try to create the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
612      int iChannels = ::lscp_get_channels(m_pClient);          updateSession();
     if (iChannels < 0) {  
         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);  
613    
614      // Save as default session directory.      // Save as default session directory.
615      if (m_pOptions)      if (m_pOptions)
# Line 562  bool qsamplerMainForm::loadSessionFile ( Line 620  bool qsamplerMainForm::loadSessionFile (
620      m_sFilename = sFilename;      m_sFilename = sFilename;
621      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
622      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));      appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename)));
623        
624        // Make that an overall update.
625      stabilizeForm();      stabilizeForm();
626      return true;      return true;
627  }  }
# Line 595  bool qsamplerMainForm::saveSessionFile ( Line 655  bool qsamplerMainForm::saveSessionFile (
655      ts << endl;      ts << endl;
656      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
657      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
658          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
659          int iChannelID = pChannel->channelID();          if (pChannelStrip) {
660          ts << "# " << pChannel->caption() << endl;              qsamplerChannel *pChannel = pChannelStrip->channel();
661          ts << "ADD CHANNEL" << endl;              if (pChannel) {
662          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;                  ts << "# Channel " << iChannel << endl;
663          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;                  ts << "ADD CHANNEL" << endl;
664          ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl;
665          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl;
666          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;              //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl;
667          ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";
668          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
669          ts << endl;                      ts << "ALL";
670                    else
671                        ts << pChannel->midiChannel();
672                    ts << endl;
673                    ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl;
674                    ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl;
675                    ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl;
676                    ts << endl;
677                }
678            }
679          // Try to keep it snappy :)          // Try to keep it snappy :)
680          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
681      }      }
# Line 632  bool qsamplerMainForm::saveSessionFile ( Line 701  bool qsamplerMainForm::saveSessionFile (
701  }  }
702    
703    
704    // Session change receiver slot.
705    void qsamplerMainForm::sessionDirty (void)
706    {
707        // Just mark the dirty form.
708        m_iDirtyCount++;
709        // and update the form status...
710        stabilizeForm();
711    }
712    
713    
714  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
715  // qsamplerMainForm -- File Action slots.  // qsamplerMainForm -- File Action slots.
716    
# Line 678  void qsamplerMainForm::fileSaveAs (void) Line 757  void qsamplerMainForm::fileSaveAs (void)
757  }  }
758    
759    
760    // Reset the sampler instance.
761    void qsamplerMainForm::fileReset (void)
762    {
763        if (m_pClient == NULL)
764            return;
765    
766        // Ask user whether he/she want's an internal sampler reset...
767        if (QMessageBox::warning(this, tr("Warning"),
768            tr("Resetting the sampler instance will close\n"
769               "all device and channel configurations.\n\n"
770               "Please note that this operation may cause\n"
771               "temporary MIDI and Audio disruption\n\n"
772               "Do you want to reset the sampler engine now?"),
773            tr("Reset"), tr("Cancel")) > 0)
774            return;
775    
776        // Just do the reset, after closing down current session...
777        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {
778            appendMessagesClient("lscp_reset_sampler");
779            appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
780            return;
781        }
782    
783        // Log this.
784        appendMessages(tr("Sampler reset."));
785    
786            // Make it a new session...
787            newSession();
788    }
789    
790    
791  // Restart the client/server instance.  // Restart the client/server instance.
792  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
793  {  {
# Line 725  void qsamplerMainForm::editAddChannel (v Line 835  void qsamplerMainForm::editAddChannel (v
835      if (m_pClient == NULL)      if (m_pClient == NULL)
836          return;          return;
837    
838      // Create the new sampler channel.      // Just create the channel instance...
839      int iChannelID = ::lscp_add_channel(m_pClient);      qsamplerChannel *pChannel = new qsamplerChannel(this);
840      if (iChannelID < 0) {      if (pChannel == NULL)
         appendMessagesClient("lscp_add_channel");  
         appendMessagesError(tr("Could not create the new channel.\n\nSorry."));  
841          return;          return;
     }  
   
     // Log this happening.  
     appendMessages(tr("Channel %1 created.").arg(iChannelID));  
842    
843      // Just create the channel strip with given id.      // Before we show it up, may be we'll
844      createChannel(iChannelID, true);      // better ask for some initial values?
845        if (!pChannel->channelSetup(this)) {
846            delete pChannel;
847            return;
848        }
849        
850        // And give it to the strip (will own the channel instance, if successful).
851        if (!createChannelStrip(pChannel)) {
852            delete pChannel;
853            return;
854        }
855    
856      // We'll be dirty, for sure...      // Make that an overall update.
857      m_iDirtyCount++;      m_iDirtyCount++;
     // Stabilize form anyway.  
858      stabilizeForm();      stabilizeForm();
859  }  }
860    
# Line 752  void qsamplerMainForm::editRemoveChannel Line 865  void qsamplerMainForm::editRemoveChannel
865      if (m_pClient == NULL)      if (m_pClient == NULL)
866          return;          return;
867    
868      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
869        if (pChannelStrip == NULL)
870            return;
871            
872        qsamplerChannel *pChannel = pChannelStrip->channel();
873      if (pChannel == NULL)      if (pChannel == NULL)
874          return;          return;
875    
# Line 762  void qsamplerMainForm::editRemoveChannel Line 879  void qsamplerMainForm::editRemoveChannel
879              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
880                 "%1\n\n"                 "%1\n\n"
881                 "Are you sure?")                 "Are you sure?")
882                 .arg(pChannel->caption()),                 .arg(pChannelStrip->caption()),
883              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
884              return;              return;
885      }      }
886    
887      // Remove the existing sampler channel.      // Remove the existing sampler channel.
888      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."));  
889          return;          return;
     }  
890    
     // Log this happening.  
     appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID()));  
       
891      // Just delete the channel strip.      // Just delete the channel strip.
892      delete pChannel;      delete pChannelStrip;
893        
894      // Do we auto-arrange?      // Do we auto-arrange?
895      if (m_pOptions && m_pOptions->bAutoArrange)      if (m_pOptions && m_pOptions->bAutoArrange)
896          channelsArrange();          channelsArrange();
# Line 795  void qsamplerMainForm::editSetupChannel Line 907  void qsamplerMainForm::editSetupChannel
907      if (m_pClient == NULL)      if (m_pClient == NULL)
908          return;          return;
909    
910      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
911      if (pChannel == NULL)      if (pChannelStrip == NULL)
912          return;          return;
913    
914      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
915      pChannel->channelSetup(false);      pChannelStrip->channelSetup();
916  }  }
917    
918    
# Line 810  void qsamplerMainForm::editResetChannel Line 922  void qsamplerMainForm::editResetChannel
922      if (m_pClient == NULL)      if (m_pClient == NULL)
923          return;          return;
924    
925      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
926      if (pChannel == NULL)      if (pChannelStrip == NULL)
927          return;          return;
928    
929      // Remove the existing sampler channel.      // Just invoque the channel strip procedure.
930      if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) {      pChannelStrip->channelReset();
931          appendMessagesClient("lscp_reset_channel");  }
         appendMessagesError(tr("Could not reset channel.\n\nSorry."));  
         return;  
     }  
932    
     // Log this.  
     appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID()));  
933    
934      // Refresh channel strip info.  // Reset all sampler channels.
935      pChannel->updateChannelInfo();  void qsamplerMainForm::editResetAllChannels (void)
936    {
937        if (m_pClient == NULL)
938            return;
939    
940        // Invoque the channel strip procedure,
941            // for all channels out there...
942        m_pWorkspace->setUpdatesEnabled(false);
943        QWidgetList wlist = m_pWorkspace->windowList();
944        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
945            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
946            if (pChannelStrip)
947                    pChannelStrip->channelReset();
948        }
949        m_pWorkspace->setUpdatesEnabled(true);
950  }  }
951    
952    
# Line 877  void qsamplerMainForm::viewMessages ( bo Line 998  void qsamplerMainForm::viewMessages ( bo
998  }  }
999    
1000    
1001    // Show/hide the device configurator form.
1002    void qsamplerMainForm::viewDevices (void)
1003    {
1004        if (m_pOptions == NULL)
1005            return;
1006    
1007        if (m_pDeviceForm) {
1008            m_pOptions->saveWidgetGeometry(m_pDeviceForm);
1009                    m_pDeviceForm->setClient(m_pClient);
1010            if (m_pDeviceForm->isVisible()) {
1011                m_pDeviceForm->hide();
1012            } else {
1013                m_pDeviceForm->show();
1014                m_pDeviceForm->raise();
1015                m_pDeviceForm->setActiveWindow();
1016            }
1017        }
1018    }
1019    
1020    
1021  // Show options dialog.  // Show options dialog.
1022  void qsamplerMainForm::viewOptions (void)  void qsamplerMainForm::viewOptions (void)
1023  {  {
# Line 886  void qsamplerMainForm::viewOptions (void Line 1027  void qsamplerMainForm::viewOptions (void
1027      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);      qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this);
1028      if (pOptionsForm) {      if (pOptionsForm) {
1029          // Check out some initial nullities(tm)...          // Check out some initial nullities(tm)...
1030          qsamplerChannelStrip *pChannel = activeChannel();          qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1031          if (m_pOptions->sDisplayFont.isEmpty() && pChannel)          if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip)
1032              m_pOptions->sDisplayFont = pChannel->displayFont().toString();              m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString();
1033          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)          if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages)
1034              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
1035          // To track down deferred or immediate changes.          // To track down deferred or immediate changes.
# Line 898  void qsamplerMainForm::viewOptions (void Line 1039  void qsamplerMainForm::viewOptions (void
1039          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
1040          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
1041          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
1042            bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1043          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
1044          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
1045          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
1046          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
1047          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
1048          bool    bOldCompletePath    = m_pOptions->bCompletePath;          bool    bOldCompletePath    = m_pOptions->bCompletePath;
1049            bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
1050          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;          int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1051          // Load the current setup settings.          // Load the current setup settings.
1052          pOptionsForm->setup(m_pOptions);          pOptionsForm->setup(m_pOptions);
# Line 922  void qsamplerMainForm::viewOptions (void Line 1065  void qsamplerMainForm::viewOptions (void
1065                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1066                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
1067                  updateRecentFilesMenu();                  updateRecentFilesMenu();
1068                if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) ||
1069                    (!bOldInstrumentNames &&  m_pOptions->bInstrumentNames))
1070                    updateInstrumentNames();
1071                if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) ||
1072                    (!bOldDisplayEffect &&  m_pOptions->bDisplayEffect))
1073                    updateDisplayEffect();
1074              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
1075                  updateDisplayFont();                  updateDisplayFont();
1076              if (iOldMaxVolume != m_pOptions->iMaxVolume)              if (iOldMaxVolume != m_pOptions->iMaxVolume)
# Line 964  void qsamplerMainForm::channelsArrange ( Line 1113  void qsamplerMainForm::channelsArrange (
1113      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1114      int y = 0;      int y = 0;
1115      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1116          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1117      /*  if (pChannel->testWState(WState_Maximized | WState_Minimized)) {      /*  if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) {
1118              // Prevent flicker...              // Prevent flicker...
1119              pChannel->hide();              pChannelStrip->hide();
1120              pChannel->showNormal();              pChannelStrip->showNormal();
1121          }   */          }   */
1122          pChannel->adjustSize();          pChannelStrip->adjustSize();
1123          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1124          if (iWidth < pChannel->width())          if (iWidth < pChannelStrip->width())
1125              iWidth = pChannel->width();              iWidth = pChannelStrip->width();
1126      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1127          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1128          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1129          y += iHeight;          y += iHeight;
1130      }      }
1131      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
# Line 1029  void qsamplerMainForm::helpAbout (void) Line 1178  void qsamplerMainForm::helpAbout (void)
1178      sText += tr("GIG (libgig) file support disabled.");      sText += tr("GIG (libgig) file support disabled.");
1179      sText += "</font></small><br />";      sText += "</font></small><br />";
1180  #endif  #endif
1181    #ifndef CONFIG_INSTRUMENT_NAME
1182        sText += "<small><font color=\"red\">";
1183        sText += tr("LSCP (liblscp) instrument_name support disabled.");
1184        sText += "</font></small><br />";
1185    #endif
1186      sText += "<br />\n";      sText += "<br />\n";
1187      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1188      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1056  void qsamplerMainForm::helpAbout (void) Line 1210  void qsamplerMainForm::helpAbout (void)
1210  void qsamplerMainForm::stabilizeForm (void)  void qsamplerMainForm::stabilizeForm (void)
1211  {  {
1212      // Update the main application caption...      // Update the main application caption...
1213      QString sSessioName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1214      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1215          sSessioName += '*';          sSessionName += '*';
1216      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName));      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1217    
1218      // Update the main menu state...      // Update the main menu state...
1219      qsamplerChannelStrip *pChannel = activeChannel();      qsamplerChannelStrip *pChannelStrip = activeChannelStrip();
1220      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);      bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);
1221      bool bHasChannel = (bHasClient && pChannel != NULL);      bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1222      fileNewAction->setEnabled(bHasClient);      fileNewAction->setEnabled(bHasClient);
1223      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1224      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1225      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1226        fileResetAction->setEnabled(bHasClient);
1227      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1228      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1229      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
1230      editSetupChannelAction->setEnabled(bHasChannel);      editSetupChannelAction->setEnabled(bHasChannel);
1231      editResetChannelAction->setEnabled(bHasChannel);      editResetChannelAction->setEnabled(bHasChannel);
1232      channelsArrangeAction->setEnabled(bHasChannel);      editResetAllChannelsAction->setEnabled(bHasChannel);
1233      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());
1234        viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible());
1235        viewDevicesAction->setEnabled(bHasClient);
1236        channelsArrangeAction->setEnabled(bHasChannel);
1237    
1238      // Client/Server status...      // Client/Server status...
1239      if (bHasClient) {      if (bHasClient) {
1240          m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected"));          m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected"));
1241          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));
1242      } else {      } else {
1243          m_status[QSAMPLER_STATUS_CLIENT]->clear();          m_statusItem[QSAMPLER_STATUS_CLIENT]->clear();
1244          m_status[QSAMPLER_STATUS_SERVER]->clear();          m_statusItem[QSAMPLER_STATUS_SERVER]->clear();
1245      }      }
1246      // Channel status...      // Channel status...
1247      if (bHasChannel)      if (bHasChannel)
1248          m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption());          m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());
1249      else      else
1250          m_status[QSAMPLER_STATUS_CHANNEL]->clear();          m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear();
1251      // Session status...      // Session status...
1252      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1253          m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD"));          m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD"));
1254      else      else
1255          m_status[QSAMPLER_STATUS_SESSION]->clear();          m_statusItem[QSAMPLER_STATUS_SESSION]->clear();
1256    
1257      // Recent files menu.      // Recent files menu.
1258      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);
# Line 1106  void qsamplerMainForm::stabilizeForm (vo Line 1264  void qsamplerMainForm::stabilizeForm (vo
1264    
1265    
1266  // Channel change receiver slot.  // Channel change receiver slot.
1267  void qsamplerMainForm::channelChanged( qsamplerChannelStrip * )  void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip )
1268  {  {
1269            // Add this strip to the changed list...
1270            if (m_changedStrips.containsRef(pChannelStrip) == 0)
1271                    m_changedStrips.append(pChannelStrip);
1272    
1273      // Just mark the dirty form.      // Just mark the dirty form.
1274      m_iDirtyCount++;      m_iDirtyCount++;
1275      // and update the form status...      // and update the form status...
# Line 1115  void qsamplerMainForm::channelChanged( q Line 1277  void qsamplerMainForm::channelChanged( q
1277  }  }
1278    
1279    
1280    // Grab and restore current sampler channels session.
1281    void qsamplerMainForm::updateSession (void)
1282    {
1283            // Retrieve the current channel list.
1284            int *piChannelIDs = ::lscp_list_channels(m_pClient);
1285            if (piChannelIDs == NULL) {
1286                    if (::lscp_client_get_errno(m_pClient)) {
1287                            appendMessagesClient("lscp_list_channels");
1288                            appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1289                    }
1290                    return;
1291            }
1292    
1293            // Try to (re)create each channel.
1294            m_pWorkspace->setUpdatesEnabled(false);
1295            for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1296                    // Check if theres already a channel strip for this one...
1297                    if (!channelStrip(piChannelIDs[iChannel]))
1298                            createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel]));
1299                    // Make it visibly responsive...
1300                    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1301            }
1302            m_pWorkspace->setUpdatesEnabled(true);
1303    }
1304    
1305    
1306  // Update the recent files list and menu.  // Update the recent files list and menu.
1307  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )  void qsamplerMainForm::updateRecentFiles ( const QString& sFilename )
1308  {  {
# Line 1159  void qsamplerMainForm::updateRecentFiles Line 1347  void qsamplerMainForm::updateRecentFiles
1347  }  }
1348    
1349    
1350    // Force update of the channels instrument names mode.
1351    void qsamplerMainForm::updateInstrumentNames (void)
1352    {
1353        // Full channel list update...
1354        QWidgetList wlist = m_pWorkspace->windowList();
1355        if (wlist.isEmpty())
1356            return;
1357    
1358        m_pWorkspace->setUpdatesEnabled(false);
1359        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1360            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1361            if (pChannelStrip)
1362                pChannelStrip->updateInstrumentName(true);
1363        }
1364        m_pWorkspace->setUpdatesEnabled(true);
1365    }
1366    
1367    
1368  // Force update of the channels display font.  // Force update of the channels display font.
1369  void qsamplerMainForm::updateDisplayFont (void)  void qsamplerMainForm::updateDisplayFont (void)
1370  {  {
# Line 1180  void qsamplerMainForm::updateDisplayFont Line 1386  void qsamplerMainForm::updateDisplayFont
1386    
1387      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1388      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1389          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1390          pChannel->setDisplayFont(font);          if (pChannelStrip)
1391                pChannelStrip->setDisplayFont(font);
1392        }
1393        m_pWorkspace->setUpdatesEnabled(true);
1394    }
1395    
1396    
1397    // Update channel strips background effect.
1398    void qsamplerMainForm::updateDisplayEffect (void)
1399    {
1400       QPixmap pm;
1401        if (m_pOptions->bDisplayEffect)
1402            pm = QPixmap::fromMimeSource("displaybg1.png");
1403    
1404        // Full channel list update...
1405        QWidgetList wlist = m_pWorkspace->windowList();
1406        if (wlist.isEmpty())
1407            return;
1408    
1409        m_pWorkspace->setUpdatesEnabled(false);
1410        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1411            qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1412            if (pChannelStrip)
1413                pChannelStrip->setDisplayBackground(pm);
1414      }      }
1415      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1416  }  }
# Line 1200  void qsamplerMainForm::updateMaxVolume ( Line 1429  void qsamplerMainForm::updateMaxVolume (
1429    
1430      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
1431      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1432          qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1433          pChannel->setMaxVolume(m_pOptions->iMaxVolume);          if (pChannelStrip)
1434                pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1435      }      }
1436      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
1437  }  }
# Line 1300  void qsamplerMainForm::updateMessagesCap Line 1530  void qsamplerMainForm::updateMessagesCap
1530  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
1531    
1532  // The channel strip creation executive.  // The channel strip creation executive.
1533  void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt )  qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel )
1534  {  {
1535      if (m_pClient == NULL)      if (m_pClient == NULL || pChannel == NULL)
1536          return;          return NULL;
1537    
1538      // Prepare for auto-arrange?      // Prepare for auto-arrange?
1539      qsamplerChannelStrip *pChannel = NULL;      qsamplerChannelStrip *pChannelStrip = NULL;
1540      int y = 0;      int y = 0;
1541      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1542          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
1543          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1544              pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1545          //  y += pChannel->height() + pChannel->parentWidget()->baseSize().height();                          if (pChannelStrip) {
1546              y += pChannel->parentWidget()->frameGeometry().height();                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
1547                                    y += pChannelStrip->parentWidget()->frameGeometry().height();
1548                            }
1549          }          }
1550      }      }
1551    
1552      // Add a new channel itema...      // Add a new channel itema...
1553      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;
1554      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1555      pChannel->setMaxVolume(m_pOptions->iMaxVolume);      if (pChannelStrip == NULL)
1556      pChannel->setup(this, iChannelID);          return NULL;
1557      // We'll need a display font.          
1558      QFont font;      // Actual channel strip setup...
1559      if (m_pOptions && font.fromString(m_pOptions->sDisplayFont))      pChannelStrip->setup(pChannel);
1560          pChannel->setDisplayFont(font);      QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *)));
1561      // Track channel setup changes.      // Set some initial aesthetic options...
1562      QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *)));      if (m_pOptions) {
1563      // Before we show it up, may be we'll          // Background display effect...
1564      // better ask for some initial values?          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
1565      if (bPrompt)          // We'll need a display font.
1566          pChannel->channelSetup(true);          QFont font;
1567            if (font.fromString(m_pOptions->sDisplayFont))
1568                pChannelStrip->setDisplayFont(font);
1569            // Maximum allowed volume setting.
1570            pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume);
1571        }
1572    
1573      // Now we show up us to the world.      // Now we show up us to the world.
1574      pChannel->show();      pChannelStrip->show();
1575      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
1576      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
1577          int iWidth  = m_pWorkspace->width();          int iWidth  = m_pWorkspace->width();
1578      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();      //  int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height();
1579          int iHeight = pChannel->parentWidget()->frameGeometry().height();          int iHeight = pChannelStrip->parentWidget()->frameGeometry().height();
1580          pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight);          pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight);
1581      }      }
1582    
1583            // This is pretty new, so we'll watch for it closely.
1584            channelStripChanged(pChannelStrip);
1585    
1586        // Return our successful reference...
1587        return pChannelStrip;
1588  }  }
1589    
1590    
1591  // Retrieve the active channel strip.  // Retrieve the active channel strip.
1592  qsamplerChannelStrip *qsamplerMainForm::activeChannel (void)  qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void)
1593  {  {
1594      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();      return (qsamplerChannelStrip *) m_pWorkspace->activeWindow();
1595  }  }
1596    
1597    
1598  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
1599  qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel )  qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel )
1600  {  {
1601      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
1602      if (wlist.isEmpty())      if (wlist.isEmpty())
1603          return 0;          return NULL;
1604    
1605      return (qsamplerChannelStrip *) wlist.at(iChannel);      return (qsamplerChannelStrip *) wlist.at(iChannel);
1606  }  }
1607    
1608    
1609    // Retrieve a channel strip by sampler channel id.
1610    qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID )
1611    {
1612            QWidgetList wlist = m_pWorkspace->windowList();
1613            if (wlist.isEmpty())
1614                    return NULL;
1615            
1616            for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1617                    qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1618                    if (pChannelStrip) {
1619                            qsamplerChannel *pChannel = pChannelStrip->channel();
1620                            if (pChannel && pChannel->channelID() == iChannelID)
1621                                    return pChannelStrip;
1622                    }
1623            }
1624    
1625            // Not found.
1626            return NULL;
1627    }
1628    
1629    
1630  // Construct the windows menu.  // Construct the windows menu.
1631  void qsamplerMainForm::channelsMenuAboutToShow (void)  void qsamplerMainForm::channelsMenuAboutToShow (void)
1632  {  {
# Line 1373  void qsamplerMainForm::channelsMenuAbout Line 1638  void qsamplerMainForm::channelsMenuAbout
1638      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
1639          channelsMenu->insertSeparator();          channelsMenu->insertSeparator();
1640          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1641              qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);              qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1642              int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int)));              if (pChannelStrip) {
1643              channelsMenu->setItemParameter(iItemID, iChannel);                  int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));
1644              channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel);                  channelsMenu->setItemParameter(iItemID, iChannel);
1645                    channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);
1646                }
1647          }          }
1648      }      }
1649  }  }
# Line 1385  void qsamplerMainForm::channelsMenuAbout Line 1652  void qsamplerMainForm::channelsMenuAbout
1652  // Windows menu activation slot  // Windows menu activation slot
1653  void qsamplerMainForm::channelsMenuActivated ( int iChannel )  void qsamplerMainForm::channelsMenuActivated ( int iChannel )
1654  {  {
1655      qsamplerChannelStrip *pChannel = channelAt(iChannel);      qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel);
1656      if (pChannel)      if (pChannelStrip)
1657          pChannel->showNormal();          pChannelStrip->showNormal();
1658      pChannel->setFocus();      pChannelStrip->setFocus();
1659  }  }
1660    
1661    
# Line 1428  void qsamplerMainForm::timerSlot (void) Line 1695  void qsamplerMainForm::timerSlot (void)
1695      }      }
1696            
1697          // Refresh each channel usage, on each period...          // Refresh each channel usage, on each period...
1698      if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) {      if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) {
1699          m_iTimerSlot += QSAMPLER_TIMER_MSECS;          m_iTimerSlot += QSAMPLER_TIMER_MSECS;
1700          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime)  {          if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled())  {
1701              m_iTimerSlot = 0;              m_iTimerSlot = 0;
1702                // Update the channel information for each pending strip...
1703                for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first();
1704                        pChannelStrip;
1705                                                    pChannelStrip = m_changedStrips.next()) {
1706                                    // If successfull, remove from pending list...
1707                                    if (pChannelStrip->updateChannelInfo())
1708                        m_changedStrips.remove(pChannelStrip);
1709                            }
1710                // Update the channel stream usage for each strip...
1711              QWidgetList wlist = m_pWorkspace->windowList();              QWidgetList wlist = m_pWorkspace->windowList();
1712              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {              for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1713                  qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);                  qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
1714                  if (pChannel->isVisible())                  if (pChannelStrip && pChannelStrip->isVisible())
1715                      pChannel->updateChannelUsage();                      pChannelStrip->updateChannelUsage();
1716              }              }
1717          }          }
1718      }      }
# Line 1629  bool qsamplerMainForm::startClient (void Line 1905  bool qsamplerMainForm::startClient (void
1905      // Log success here.      // Log success here.
1906      appendMessages(tr("Client connected."));      appendMessages(tr("Client connected."));
1907    
1908            // Hard-notify device configuration form,
1909            // if visible, that we're ready...
1910            if (m_pDeviceForm && m_pDeviceForm->isVisible())
1911                m_pDeviceForm->setClient(m_pClient);
1912                
1913      // Is any session pending to be loaded?      // Is any session pending to be loaded?
1914      if (!m_pOptions->sSessionFile.isEmpty()) {      if (!m_pOptions->sSessionFile.isEmpty()) {
1915          // Just load the prabably startup session...          // Just load the prabably startup session...
# Line 1649  void qsamplerMainForm::stopClient (void) Line 1930  void qsamplerMainForm::stopClient (void)
1930      if (m_pClient == NULL)      if (m_pClient == NULL)
1931          return;          return;
1932    
1933            // Hard-notify device configuration form,
1934            // if visible, that we're running out...
1935            if (m_pDeviceForm && m_pDeviceForm->isVisible())
1936                m_pDeviceForm->setClient(NULL);
1937    
1938      // Log prepare here.      // Log prepare here.
1939      appendMessages(tr("Client disconnecting..."));      appendMessages(tr("Client disconnecting..."));
1940    

Legend:
Removed from v.176  
changed lines
  Added in v.433

  ViewVC Help
Powered by ViewVC