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

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

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

revision 1475 by schoenebeck, Tue Nov 6 22:12:32 2007 UTC revision 1507 by capela, Wed Nov 21 23:22:18 2007 UTC
# Line 22  Line 22 
22    
23  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
24    
 #include <qapplication.h>  
 #include <qeventloop.h>  
 #include <qworkspace.h>  
 #include <qprocess.h>  
 #include <qmessagebox.h>  
 //#include <qdragobject.h>  
 #include <qregexp.h>  
 #include <qfiledialog.h>  
 #include <qfileinfo.h>  
 #include <qfile.h>  
 #include <qtextstream.h>  
 #include <qstatusbar.h>  
 #include <qslider.h>  
 #include <qspinbox.h>  
 #include <qlabel.h>  
 #include <qtimer.h>  
 #include <qtooltip.h>  
   
25  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
26  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
27  #include "qsamplerChannel.h"  #include "qsamplerChannel.h"
# Line 52  Line 34 
34  #include "qsamplerDeviceForm.h"  #include "qsamplerDeviceForm.h"
35  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
36    
37    #include <QApplication>
38    #include <QWorkspace>
39    #include <QProcess>
40    #include <QMessageBox>
41    
42    #include <QRegExp>
43    #include <QTextStream>
44    #include <QFileDialog>
45    #include <QFileInfo>
46    #include <QFile>
47    #include <QUrl>
48    
49    #include <QDragEnterEvent>
50    
51    #include <QStatusBar>
52    #include <QSpinBox>
53    #include <QSlider>
54    #include <QLabel>
55    #include <QTimer>
56    #include <QDateTime>
57    
58    
59  #ifdef HAVE_SIGNAL_H  #ifdef HAVE_SIGNAL_H
60  #include <signal.h>  #include <signal.h>
61  #endif  #endif
# Line 103  public: Line 107  public:
107          : QEvent(QSAMPLER_CUSTOM_EVENT)          : QEvent(QSAMPLER_CUSTOM_EVENT)
108      {      {
109          m_event = event;          m_event = event;
110          m_data.setLatin1(pchData, cchData);          m_data  = QString::fromUtf8(pchData, cchData);
111      }      }
112    
113      // Accessors.      // Accessors.
# Line 165  MainForm::MainForm(QWidget* parent) : QM Line 169  MainForm::MainForm(QWidget* parent) : QM
169          // Volume slider...          // Volume slider...
170          ui.channelsToolbar->addSeparator();          ui.channelsToolbar->addSeparator();
171          m_pVolumeSlider = new QSlider(Qt::Horizontal, ui.channelsToolbar);          m_pVolumeSlider = new QSlider(Qt::Horizontal, ui.channelsToolbar);
172          m_pVolumeSlider->setTickmarks(QSlider::Below);          m_pVolumeSlider->setTickPosition(QSlider::TicksBelow);
173          m_pVolumeSlider->setTickInterval(10);          m_pVolumeSlider->setTickInterval(10);
174          m_pVolumeSlider->setPageStep(10);          m_pVolumeSlider->setPageStep(10);
175          m_pVolumeSlider->setRange(0, 100);          m_pVolumeSlider->setSingleStep(10);
176            m_pVolumeSlider->setMinimum(0);
177            m_pVolumeSlider->setMaximum(100);
178          m_pVolumeSlider->setMaximumHeight(26);          m_pVolumeSlider->setMaximumHeight(26);
179          m_pVolumeSlider->setMinimumWidth(160);          m_pVolumeSlider->setMinimumWidth(160);
180          QToolTip::add(m_pVolumeSlider, sVolumeText);          m_pVolumeSlider->setToolTip(sVolumeText);
181          QObject::connect(m_pVolumeSlider,          QObject::connect(m_pVolumeSlider,
182                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
183                  SLOT(volumeChanged(int)));                  SLOT(volumeChanged(int)));
# Line 182  MainForm::MainForm(QWidget* parent) : QM Line 188  MainForm::MainForm(QWidget* parent) : QM
188          ui.channelsToolbar->addSeparator();          ui.channelsToolbar->addSeparator();
189          m_pVolumeSpinBox = new QSpinBox(ui.channelsToolbar);          m_pVolumeSpinBox = new QSpinBox(ui.channelsToolbar);
190          m_pVolumeSpinBox->setSuffix(" %");          m_pVolumeSpinBox->setSuffix(" %");
191          m_pVolumeSpinBox->setRange(0, 100);          m_pVolumeSpinBox->setMinimum(0);
192          QToolTip::add(m_pVolumeSpinBox, sVolumeText);          m_pVolumeSpinBox->setMaximum(100);
193            m_pVolumeSpinBox->setToolTip(sVolumeText);
194          QObject::connect(m_pVolumeSpinBox,          QObject::connect(m_pVolumeSpinBox,
195                  SIGNAL(valueChanged(int)),                  SIGNAL(valueChanged(int)),
196                  SLOT(volumeChanged(int)));                  SLOT(volumeChanged(int)));
# Line 225  MainForm::MainForm(QWidget* parent) : QM Line 232  MainForm::MainForm(QWidget* parent) : QM
232      m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;      m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel;
233      statusBar()->addWidget(pLabel);      statusBar()->addWidget(pLabel);
234    
     // Create the recent files sub-menu.  
     m_pRecentFilesMenu = new Q3PopupMenu(this);  
     ui.fileMenu->insertSeparator(4);  
     ui.fileMenu->insertItem(tr("Recent &Files"), m_pRecentFilesMenu, 0, 5);  
   
235  #if defined(WIN32)  #if defined(WIN32)
236      WSAStartup(MAKEWORD(1, 1), &_wsaData);      WSAStartup(MAKEWORD(1, 1), &_wsaData);
237  #endif  #endif
238    
239          QObject::connect(ui.fileNewAction,          QObject::connect(ui.fileNewAction,
240                  SIGNAL(activated()),                  SIGNAL(triggered()),
241                  SLOT(fileNew()));                  SLOT(fileNew()));
242          QObject::connect(ui.fileOpenAction,          QObject::connect(ui.fileOpenAction,
243                  SIGNAL(activated()),                  SIGNAL(triggered()),
244                  SLOT(fileOpen()));                  SLOT(fileOpen()));
245          QObject::connect(ui.fileSaveAction,          QObject::connect(ui.fileSaveAction,
246                  SIGNAL(activated()),                  SIGNAL(triggered()),
247                  SLOT(fileSave()));                  SLOT(fileSave()));
248          QObject::connect(ui.fileSaveAsAction,          QObject::connect(ui.fileSaveAsAction,
249                  SIGNAL(activated()),                  SIGNAL(triggered()),
250                  SLOT(fileSaveAs()));                  SLOT(fileSaveAs()));
251          QObject::connect(ui.fileResetAction,          QObject::connect(ui.fileResetAction,
252                  SIGNAL(activated()),                  SIGNAL(triggered()),
253                  SLOT(fileReset()));                  SLOT(fileReset()));
254          QObject::connect(ui.fileRestartAction,          QObject::connect(ui.fileRestartAction,
255                  SIGNAL(activated()),                  SIGNAL(triggered()),
256                  SLOT(fileRestart()));                  SLOT(fileRestart()));
257          QObject::connect(ui.fileExitAction,          QObject::connect(ui.fileExitAction,
258                  SIGNAL(activated()),                  SIGNAL(triggered()),
259                  SLOT(fileExit()));                  SLOT(fileExit()));
260          QObject::connect(ui.editAddChannelAction,          QObject::connect(ui.editAddChannelAction,
261                  SIGNAL(activated()),                  SIGNAL(triggered()),
262                  SLOT(editAddChannel()));                  SLOT(editAddChannel()));
263          QObject::connect(ui.editRemoveChannelAction,          QObject::connect(ui.editRemoveChannelAction,
264                  SIGNAL(activated()),                  SIGNAL(triggered()),
265                  SLOT(editRemoveChannel()));                  SLOT(editRemoveChannel()));
266          QObject::connect(ui.editSetupChannelAction,          QObject::connect(ui.editSetupChannelAction,
267                  SIGNAL(activated()),                  SIGNAL(triggered()),
268                  SLOT(editSetupChannel()));                  SLOT(editSetupChannel()));
269          QObject::connect(ui.editEditChannelAction,          QObject::connect(ui.editEditChannelAction,
270                  SIGNAL(activated()),                  SIGNAL(triggered()),
271                  SLOT(editEditChannel()));                  SLOT(editEditChannel()));
272          QObject::connect(ui.editResetChannelAction,          QObject::connect(ui.editResetChannelAction,
273                  SIGNAL(activated()),                  SIGNAL(triggered()),
274                  SLOT(editResetChannel()));                  SLOT(editResetChannel()));
275          QObject::connect(ui.editResetAllChannelsAction,          QObject::connect(ui.editResetAllChannelsAction,
276                  SIGNAL(activated()),                  SIGNAL(triggered()),
277                  SLOT(editResetAllChannels()));                  SLOT(editResetAllChannels()));
278          QObject::connect(ui.viewMenubarAction,          QObject::connect(ui.viewMenubarAction,
279                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
# Line 286  MainForm::MainForm(QWidget* parent) : QM Line 288  MainForm::MainForm(QWidget* parent) : QM
288                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
289                  SLOT(viewMessages(bool)));                  SLOT(viewMessages(bool)));
290          QObject::connect(ui.viewInstrumentsAction,          QObject::connect(ui.viewInstrumentsAction,
291                  SIGNAL(activated()),                  SIGNAL(triggered()),
292                  SLOT(viewInstruments()));                  SLOT(viewInstruments()));
293          QObject::connect(ui.viewDevicesAction,          QObject::connect(ui.viewDevicesAction,
294                  SIGNAL(activated()),                  SIGNAL(triggered()),
295                  SLOT(viewDevices()));                  SLOT(viewDevices()));
296          QObject::connect(ui.viewOptionsAction,          QObject::connect(ui.viewOptionsAction,
297                  SIGNAL(activated()),                  SIGNAL(triggered()),
298                  SLOT(viewOptions()));                  SLOT(viewOptions()));
299          QObject::connect(ui.channelsArrangeAction,          QObject::connect(ui.channelsArrangeAction,
300                  SIGNAL(activated()),                  SIGNAL(triggered()),
301                  SLOT(channelsArrange()));                  SLOT(channelsArrange()));
302          QObject::connect(ui.channelsAutoArrangeAction,          QObject::connect(ui.channelsAutoArrangeAction,
303                  SIGNAL(toggled(bool)),                  SIGNAL(toggled(bool)),
304                  SLOT(channelsAutoArrange(bool)));                  SLOT(channelsAutoArrange(bool)));
305          QObject::connect(ui.helpAboutAction,          QObject::connect(ui.helpAboutAction,
306                  SIGNAL(activated()),                  SIGNAL(triggered()),
307                  SLOT(helpAbout()));                  SLOT(helpAbout()));
308          QObject::connect(ui.helpAboutQtAction,          QObject::connect(ui.helpAboutQtAction,
309                  SIGNAL(activated()),                  SIGNAL(triggered()),
310                  SLOT(helpAboutQt()));                  SLOT(helpAboutQt()));
311    
312            QObject::connect(ui.fileMenu,
313                    SIGNAL(aboutToShow()),
314                    SLOT(updateRecentFilesMenu()));
315            QObject::connect(ui.channelsMenu,
316                    SIGNAL(aboutToShow()),
317                    SLOT(channelsMenuAboutToShow()));
318  }  }
319    
320  // Destructor.  // Destructor.
# Line 343  MainForm::~MainForm() Line 352  MainForm::~MainForm()
352          delete m_pVolumeSlider;          delete m_pVolumeSlider;
353  #endif  #endif
354    
     // Delete recentfiles menu.  
     if (m_pRecentFilesMenu)  
         delete m_pRecentFilesMenu;  
   
355          // Pseudo-singleton reference shut-down.          // Pseudo-singleton reference shut-down.
356          g_pMainForm = NULL;          g_pMainForm = NULL;
357  }  }
# Line 359  void MainForm::setup ( qsamplerOptions * Line 364  void MainForm::setup ( qsamplerOptions *
364      m_pOptions = pOptions;      m_pOptions = pOptions;
365    
366      // What style do we create these forms?      // What style do we create these forms?
367          Qt::WFlags wflags = Qt::WStyle_Customize          Qt::WindowFlags wflags = Qt::Window
368                  | Qt::WStyle_NormalBorder  #if QT_VERSION >= 0x040200
369                  | Qt::WStyle_Title                  | Qt::CustomizeWindowHint
370                  | Qt::WStyle_SysMenu  #endif
371                  | Qt::WStyle_MinMax                  | Qt::WindowTitleHint
372                  | Qt::WType_TopLevel;                  | Qt::WindowSystemMenuHint
373      if (m_pOptions->bKeepOnTop)                  | Qt::WindowMinMaxButtonsHint;
374          wflags |= Qt::WStyle_Tool;          if (m_pOptions->bKeepOnTop)
375                    wflags |= Qt::Tool;
376      // Some child forms are to be created right now.      // Some child forms are to be created right now.
377      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
378      m_pDeviceForm = new DeviceForm(this, wflags);      m_pDeviceForm = new DeviceForm(this, wflags);
# Line 388  void MainForm::setup ( qsamplerOptions * Line 394  void MainForm::setup ( qsamplerOptions *
394                  SLOT(stabilizeForm()));                  SLOT(stabilizeForm()));
395    
396      // Initial decorations toggle state.      // Initial decorations toggle state.
397      ui.viewMenubarAction->setOn(m_pOptions->bMenubar);      ui.viewMenubarAction->setChecked(m_pOptions->bMenubar);
398      ui.viewToolbarAction->setOn(m_pOptions->bToolbar);      ui.viewToolbarAction->setChecked(m_pOptions->bToolbar);
399      ui.viewStatusbarAction->setOn(m_pOptions->bStatusbar);      ui.viewStatusbarAction->setChecked(m_pOptions->bStatusbar);
400      ui.channelsAutoArrangeAction->setOn(m_pOptions->bAutoArrange);      ui.channelsAutoArrangeAction->setChecked(m_pOptions->bAutoArrange);
401    
402      // Initial decorations visibility state.      // Initial decorations visibility state.
403      viewMenubar(m_pOptions->bMenubar);      viewMenubar(m_pOptions->bMenubar);
# Line 400  void MainForm::setup ( qsamplerOptions * Line 406  void MainForm::setup ( qsamplerOptions *
406    
407      addDockWidget(Qt::BottomDockWidgetArea, m_pMessages);      addDockWidget(Qt::BottomDockWidgetArea, m_pMessages);
408    
409      // Restore whole toolbar & dock windows states.          // Restore whole dock windows state.
410      QString sDockables = m_pOptions->settings().readEntry("/Layout/DockWindowsBase64" , QString::null);          QByteArray aDockables = m_pOptions->settings().value(
411      if (!sDockables.isEmpty()) {                  "/Layout/DockWindows").toByteArray();
412          restoreState(QByteArray::fromBase64(sDockables.toAscii()));          if (!aDockables.isEmpty()) {
413      }                  restoreState(aDockables);
414            }
415    
416      // Try to restore old window positioning and initial visibility.      // Try to restore old window positioning and initial visibility.
417      m_pOptions->loadWidgetGeometry(this);      m_pOptions->loadWidgetGeometry(this);
418      m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);      m_pOptions->loadWidgetGeometry(m_pInstrumentListForm);
# Line 416  void MainForm::setup ( qsamplerOptions * Line 424  void MainForm::setup ( qsamplerOptions *
424      stabilizeForm();      stabilizeForm();
425    
426      // Make it ready :-)      // Make it ready :-)
427      statusBar()->message(tr("Ready"), 3000);      statusBar()->showMessage(tr("Ready"), 3000);
428    
429      // We'll try to start immediately...      // We'll try to start immediately...
430      startSchedule(0);      startSchedule(0);
# Line 444  bool MainForm::queryClose (void) Line 452  bool MainForm::queryClose (void)
452              m_pOptions->bStatusbar = statusBar()->isVisible();              m_pOptions->bStatusbar = statusBar()->isVisible();
453              // Save the dock windows state.              // Save the dock windows state.
454              const QString sDockables = saveState().toBase64().data();              const QString sDockables = saveState().toBase64().data();
455              m_pOptions->settings().writeEntry("/Layout/DockWindowsBase64", sDockables);                          m_pOptions->settings().setValue("/Layout/DockWindows", saveState());
456              // And the children, and the main windows state,.              // And the children, and the main windows state,.
457                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);                          m_pOptions->saveWidgetGeometry(m_pDeviceForm);
458                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);                          m_pOptions->saveWidgetGeometry(m_pInstrumentListForm);
# Line 472  void MainForm::closeEvent ( QCloseEvent Line 480  void MainForm::closeEvent ( QCloseEvent
480  }  }
481    
482    
 // Drag'n'drop file handler.  
 bool MainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files )  
 {  
     bool bDecode = false;  
   
     if (Q3TextDrag::canDecode(pEvent)) {  
         QString sText;  
         bDecode = Q3TextDrag::decode(pEvent, sText);  
         if (bDecode) {  
             files = QStringList::split('\n', sText);  
             for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++)  
                 *iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path();  
         }  
     }  
   
     return bDecode;  
 }  
   
   
483  // Window drag-n-drop event handlers.  // Window drag-n-drop event handlers.
484  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
485  {  {
486          QStringList files;          // Accept external drags only...
487          pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files));          if (pDragEnterEvent->source() == NULL
488                    && pDragEnterEvent->mimeData()->hasUrls()) {
489                    pDragEnterEvent->accept();
490            } else {
491                    pDragEnterEvent->ignore();
492            }
493  }  }
494    
495    
496  void MainForm::dropEvent ( QDropEvent* pDropEvent )  void MainForm::dropEvent ( QDropEvent* pDropEvent )
497  {  {
498      QStringList files;          // Accept externally originated drops only...
499            if (pDropEvent->source())
500      if (!decodeDragFiles(pDropEvent, files))                  return;
         return;  
501    
502          for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) {          const QMimeData *pMimeData = pDropEvent->mimeData();
503                  const QString& sPath = *iter;          if (pMimeData->hasUrls()) {
504                  if (qsamplerChannel::isInstrumentFile(sPath)) {                  QListIterator<QUrl> iter(pMimeData->urls());
505                          // Try to create a new channel from instrument file...                  while (iter.hasNext()) {
506                          qsamplerChannel *pChannel = new qsamplerChannel();                          const QString& sPath = iter.next().toLocalFile();
507                          if (pChannel == NULL)                          if (qsamplerChannel::isInstrumentFile(sPath)) {
508                                  return;                                  // Try to create a new channel from instrument file...
509                          // Start setting the instrument filename...                                  qsamplerChannel *pChannel = new qsamplerChannel();
510                          pChannel->setInstrument(sPath, 0);                                  if (pChannel == NULL)
511                          // Before we show it up, may be we'll                                          return;
512                          // better ask for some initial values?                                  // Start setting the instrument filename...
513                          if (!pChannel->channelSetup(this)) {                                  pChannel->setInstrument(sPath, 0);
514                                  delete pChannel;                                  // Before we show it up, may be we'll
515                                  return;                                  // better ask for some initial values?
516                          }                                  if (!pChannel->channelSetup(this)) {
517                          // Finally, give it to a new channel strip...                                          delete pChannel;
518                          if (!createChannelStrip(pChannel)) {                                          return;
519                                  delete pChannel;                                  }
520                                  return;                                  // Finally, give it to a new channel strip...
521                                    if (!createChannelStrip(pChannel)) {
522                                            delete pChannel;
523                                            return;
524                                    }
525                                    // Make that an overall update.
526                                    m_iDirtyCount++;
527                                    stabilizeForm();
528                            }   // Otherwise, load an usual session file (LSCP script)...
529                            else if (closeSession(true)) {
530                                    loadSessionFile(sPath);
531                                    break;
532                          }                          }
                         // Make that an overall update.  
                         m_iDirtyCount++;  
                         stabilizeForm();  
                 }   // Otherwise, load an usual session file (LSCP script)...  
                 else if (closeSession(true)) {  
                         loadSessionFile(sPath);  
                         break;  
533                  }                  }
534                  // Make it look responsive...:)                  // Make it look responsive...:)
535                  QApplication::processEvents(QEventLoop::ExcludeUserInput);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
536          }          }
537  }  }
538    
539    
540  // Custome event handler.  // Custome event handler.
541  void MainForm::customEvent(QEvent* pCustomEvent)  void MainForm::customEvent(QEvent* pCustomEvent)
542  {  {
# Line 637  bool MainForm::openSession (void) Line 635  bool MainForm::openSession (void)
635          return false;          return false;
636    
637      // Ask for the filename to open...      // Ask for the filename to open...
638      QString sFilename = QFileDialog::getOpenFileName(          QString sFilename = QFileDialog::getOpenFileName(this,
639                  m_pOptions->sSessionDir,                // Start here.                  QSAMPLER_TITLE ": " + tr("Open Session"), // Caption.
640                  tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)                  m_pOptions->sSessionDir,                  // Start here.
641                  this, 0,                                // Parent and name (none)                  tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
642                  QSAMPLER_TITLE ": " + tr("Open Session")        // Caption.          );
     );  
643    
644      // Have we cancelled?      // Have we cancelled?
645      if (sFilename.isEmpty())      if (sFilename.isEmpty())
# Line 671  bool MainForm::saveSession ( bool bPromp Line 668  bool MainForm::saveSession ( bool bPromp
668          if (sFilename.isEmpty())          if (sFilename.isEmpty())
669              sFilename = m_pOptions->sSessionDir;              sFilename = m_pOptions->sSessionDir;
670          // Prompt the guy...          // Prompt the guy...
671          sFilename = QFileDialog::getSaveFileName(                  sFilename = QFileDialog::getSaveFileName(this,
672                          sFilename,                              // Start here.                          QSAMPLER_TITLE ": " + tr("Save Session"), // Caption.
673                          tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files)                          sFilename,                                // Start here.
674                          this, 0,                                // Parent and name (none)                          tr("LSCP Session files") + " (*.lscp)"    // Filter (LSCP files)
675                          QSAMPLER_TITLE ": " + tr("Save Session")        // Caption.                  );
         );  
676          // Have we cancelled it?          // Have we cancelled it?
677          if (sFilename.isEmpty())          if (sFilename.isEmpty())
678              return false;              return false;
679          // Enforce .lscp extension...          // Enforce .lscp extension...
680          if (QFileInfo(sFilename).extension().isEmpty())          if (QFileInfo(sFilename).suffix().isEmpty())
681              sFilename += ".lscp";              sFilename += ".lscp";
682          // Check if already exists...          // Check if already exists...
683          if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {          if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) {
# Line 757  bool MainForm::loadSessionFile ( const Q Line 753  bool MainForm::loadSessionFile ( const Q
753    
754      // Open and read from real file.      // Open and read from real file.
755      QFile file(sFilename);      QFile file(sFilename);
756      if (!file.open(IO_ReadOnly)) {      if (!file.open(QIODevice::ReadOnly)) {
757          appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename));
758          return false;          return false;
759      }      }
# Line 771  bool MainForm::loadSessionFile ( const Q Line 767  bool MainForm::loadSessionFile ( const Q
767      QTextStream ts(&file);      QTextStream ts(&file);
768      while (!ts.atEnd()) {      while (!ts.atEnd()) {
769          // Read the line.          // Read the line.
770          QString sCommand = ts.readLine().stripWhiteSpace();          QString sCommand = ts.readLine().trimmed();
771                  iLine++;                  iLine++;
772          // If not empty, nor a comment, call the server...          // If not empty, nor a comment, call the server...
773          if (!sCommand.isEmpty() && sCommand[0] != '#') {          if (!sCommand.isEmpty() && sCommand[0] != '#') {
774                          // Remember that, no matter what,                          // Remember that, no matter what,
775                          // all LSCP commands are CR/LF terminated.                          // all LSCP commands are CR/LF terminated.
776                          sCommand += "\r\n";                          sCommand += "\r\n";
777                          if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {                          if (::lscp_client_query(m_pClient, sCommand.toUtf8().constData())
778                                    != LSCP_OK) {
779                                  appendMessagesColor(QString("%1(%2): %3")                                  appendMessagesColor(QString("%1(%2): %3")
780                                          .arg(QFileInfo(sFilename).fileName()).arg(iLine)                                          .arg(QFileInfo(sFilename).fileName()).arg(iLine)
781                                          .arg(sCommand.simplifyWhiteSpace()), "#996633");                                          .arg(sCommand.simplified()), "#996633");
782                                  appendMessagesClient("lscp_client_query");                                  appendMessagesClient("lscp_client_query");
783                                  iErrors++;                                  iErrors++;
784                          }                          }
785          }          }
786          // Try to make it snappy :)          // Try to make it snappy :)
787          QApplication::processEvents(QEventLoop::ExcludeUserInput);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
788      }      }
789    
790      // Ok. we've read it.      // Ok. we've read it.
# Line 805  bool MainForm::loadSessionFile ( const Q Line 802  bool MainForm::loadSessionFile ( const Q
802    
803      // Save as default session directory.      // Save as default session directory.
804      if (m_pOptions)      if (m_pOptions)
805          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);          m_pOptions->sSessionDir = QFileInfo(sFilename).dir().absolutePath();
806          // We're not dirty anymore, if loaded without errors,          // We're not dirty anymore, if loaded without errors,
807          m_iDirtyCount = iErrors;          m_iDirtyCount = iErrors;
808      // Stabilize form...      // Stabilize form...
# Line 833  bool MainForm::saveSessionFile ( const Q Line 830  bool MainForm::saveSessionFile ( const Q
830    
831      // Open and write into real file.      // Open and write into real file.
832      QFile file(sFilename);      QFile file(sFilename);
833      if (!file.open(IO_WriteOnly | IO_Truncate)) {      if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
834          appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename));
835          return false;          return false;
836      }      }
# Line 878  bool MainForm::saveSessionFile ( const Q Line 875  bool MainForm::saveSessionFile ( const Q
875                  for (deviceParam = device.params().begin();                  for (deviceParam = device.params().begin();
876                                  deviceParam != device.params().end();                                  deviceParam != device.params().end();
877                                          ++deviceParam) {                                          ++deviceParam) {
878                          const qsamplerDeviceParam& param = deviceParam.data();                          const qsamplerDeviceParam& param = deviceParam.value();
879                          if (param.value.isEmpty()) ts << "# ";                          if (param.value.isEmpty()) ts << "# ";
880                          ts << " " << deviceParam.key() << "='" << param.value << "'";                          ts << " " << deviceParam.key() << "='" << param.value << "'";
881                  }                  }
882                  ts << endl;                  ts << endl;
883                  // Audio channel parameters...                  // Audio channel parameters...
884                  int iPort = 0;                  int iPort = 0;
885                  for (qsamplerDevicePort *pPort = device.ports().first();                  QListIterator<qsamplerDevicePort *> iter(device.ports());
886                                  pPort;                  while (iter.hasNext()) {
887                                          pPort = device.ports().next(), ++iPort) {                          qsamplerDevicePort *pPort = iter.next();
888                          qsamplerDeviceParamMap::ConstIterator portParam;                          qsamplerDeviceParamMap::ConstIterator portParam;
889                          for (portParam = pPort->params().begin();                          for (portParam = pPort->params().begin();
890                                          portParam != pPort->params().end();                                          portParam != pPort->params().end();
891                                                  ++portParam) {                                                  ++portParam) {
892                                  const qsamplerDeviceParam& param = portParam.data();                                  const qsamplerDeviceParam& param = portParam.value();
893                                  if (param.fix || param.value.isEmpty()) ts << "# ";                                  if (param.fix || param.value.isEmpty()) ts << "# ";
894                                  ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice                                  ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
895                                          << " " << iPort << " " << portParam.key()                                          << " " << iPort << " " << portParam.key()
896                                          << "='" << param.value << "'" << endl;                                          << "='" << param.value << "'" << endl;
897                          }                          }
898                            iPort++;
899                  }                  }
900                  // Audio device index/id mapping.                  // Audio device index/id mapping.
901                  audioDeviceMap[device.deviceID()] = iDevice;                  audioDeviceMap[device.deviceID()] = iDevice;
902                  // Try to keep it snappy :)                  // Try to keep it snappy :)
903                  QApplication::processEvents(QEventLoop::ExcludeUserInput);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
904          }          }
905    
906          // MIDI device mapping.          // MIDI device mapping.
# Line 919  bool MainForm::saveSessionFile ( const Q Line 917  bool MainForm::saveSessionFile ( const Q
917                  for (deviceParam = device.params().begin();                  for (deviceParam = device.params().begin();
918                                  deviceParam != device.params().end();                                  deviceParam != device.params().end();
919                                          ++deviceParam) {                                          ++deviceParam) {
920                          const qsamplerDeviceParam& param = deviceParam.data();                          const qsamplerDeviceParam& param = deviceParam.value();
921                          if (param.value.isEmpty()) ts << "# ";                          if (param.value.isEmpty()) ts << "# ";
922                          ts << " " << deviceParam.key() << "='" << param.value << "'";                          ts << " " << deviceParam.key() << "='" << param.value << "'";
923                  }                  }
924                  ts << endl;                  ts << endl;
925                  // MIDI port parameters...                  // MIDI port parameters...
926                  int iPort = 0;                  int iPort = 0;
927                  for (qsamplerDevicePort *pPort = device.ports().first();                  QListIterator<qsamplerDevicePort *> iter(device.ports());
928                                  pPort;                  while (iter.hasNext()) {
929                                          pPort = device.ports().next(), ++iPort) {                          qsamplerDevicePort *pPort = iter.next();
930                          qsamplerDeviceParamMap::ConstIterator portParam;                          qsamplerDeviceParamMap::ConstIterator portParam;
931                          for (portParam = pPort->params().begin();                          for (portParam = pPort->params().begin();
932                                          portParam != pPort->params().end();                                          portParam != pPort->params().end();
933                                                  ++portParam) {                                                  ++portParam) {
934                                  const qsamplerDeviceParam& param = portParam.data();                                  const qsamplerDeviceParam& param = portParam.value();
935                                  if (param.fix || param.value.isEmpty()) ts << "# ";                                  if (param.fix || param.value.isEmpty()) ts << "# ";
936                                  ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice                                  ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice
937                                     << " " << iPort << " " << portParam.key()                                     << " " << iPort << " " << portParam.key()
938                                     << "='" << param.value << "'" << endl;                                     << "='" << param.value << "'" << endl;
939                          }                          }
940                            iPort++;
941                  }                  }
942                  // MIDI device index/id mapping.                  // MIDI device index/id mapping.
943                  midiDeviceMap[device.deviceID()] = iDevice;                  midiDeviceMap[device.deviceID()] = iDevice;
944                  // Try to keep it snappy :)                  // Try to keep it snappy :)
945                  QApplication::processEvents(QEventLoop::ExcludeUserInput);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
946          }          }
947          ts << endl;          ts << endl;
948    
# Line 1000  bool MainForm::saveSessionFile ( const Q Line 999  bool MainForm::saveSessionFile ( const Q
999                                  iErrors++;                                  iErrors++;
1000                          }                          }
1001                          // Try to keep it snappy :)                          // Try to keep it snappy :)
1002                          QApplication::processEvents(QEventLoop::ExcludeUserInput);                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1003                  }                  }
1004                  ts << endl;                  ts << endl;
1005                  // Check for errors...                  // Check for errors...
# Line 1060  bool MainForm::saveSessionFile ( const Q Line 1059  bool MainForm::saveSessionFile ( const Q
1059                                                          ++audioRoute) {                                                          ++audioRoute) {
1060                                          ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel                                          ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel
1061                                                  << " " << audioRoute.key()                                                  << " " << audioRoute.key()
1062                                                  << " " << audioRoute.data() << endl;                                                  << " " << audioRoute.value() << endl;
1063                                  }                                  }
1064                                  ts << "SET CHANNEL VOLUME " << iChannel                                  ts << "SET CHANNEL VOLUME " << iChannel
1065                                          << " " << pChannel->volume() << endl;                                          << " " << pChannel->volume() << endl;
# Line 1114  bool MainForm::saveSessionFile ( const Q Line 1113  bool MainForm::saveSessionFile ( const Q
1113              }              }
1114          }          }
1115          // Try to keep it snappy :)          // Try to keep it snappy :)
1116          QApplication::processEvents(QEventLoop::ExcludeUserInput);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1117      }      }
1118    
1119  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
# Line 1135  bool MainForm::saveSessionFile ( const Q Line 1134  bool MainForm::saveSessionFile ( const Q
1134    
1135      // Save as default session directory.      // Save as default session directory.
1136      if (m_pOptions)      if (m_pOptions)
1137          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);          m_pOptions->sSessionDir = QFileInfo(sFilename).dir().absolutePath();
1138      // We're not dirty anymore.      // We're not dirty anymore.
1139      m_iDirtyCount = 0;      m_iDirtyCount = 0;
1140      // Stabilize form...      // Stabilize form...
# Line 1177  void MainForm::fileOpen (void) Line 1176  void MainForm::fileOpen (void)
1176    
1177    
1178  // Open a recent file session.  // Open a recent file session.
1179  void MainForm::fileOpenRecent ( int iIndex )  void MainForm::fileOpenRecent (void)
1180  {  {
1181      // Check if we can safely close the current session...          // Retrive filename index from action data...
1182      if (m_pOptions && closeSession(true)) {          QAction *pAction = qobject_cast<QAction *> (sender());
1183          QString sFilename = m_pOptions->recentFiles[iIndex];          if (pAction && m_pOptions) {
1184          loadSessionFile(sFilename);                  int iIndex = pAction->data().toInt();
1185      }                  if (iIndex >= 0 && iIndex < m_pOptions->recentFiles.count()) {
1186                            QString sFilename = m_pOptions->recentFiles[iIndex];
1187                            // Check if we can safely close the current session...
1188                            if (!sFilename.isEmpty() && closeSession(true))
1189                                    loadSessionFile(sFilename);
1190                    }
1191            }
1192  }  }
1193    
1194    
# Line 1333  void MainForm::editRemoveChannel (void) Line 1338  void MainForm::editRemoveChannel (void)
1338              tr("About to remove channel:\n\n"              tr("About to remove channel:\n\n"
1339                 "%1\n\n"                 "%1\n\n"
1340                 "Are you sure?")                 "Are you sure?")
1341                 .arg(pChannelStrip->caption()),                 .arg(pChannelStrip->windowTitle()),
1342              tr("OK"), tr("Cancel")) > 0)              tr("OK"), tr("Cancel")) > 0)
1343              return;              return;
1344      }      }
# Line 1480  void MainForm::viewInstruments (void) Line 1485  void MainForm::viewInstruments (void)
1485                  } else {                  } else {
1486                          m_pInstrumentListForm->show();                          m_pInstrumentListForm->show();
1487                          m_pInstrumentListForm->raise();                          m_pInstrumentListForm->raise();
1488                          m_pInstrumentListForm->setActiveWindow();                          m_pInstrumentListForm->activateWindow();
1489                  }                  }
1490          }          }
1491  }  }
# Line 1499  void MainForm::viewDevices (void) Line 1504  void MainForm::viewDevices (void)
1504                  } else {                  } else {
1505                          m_pDeviceForm->show();                          m_pDeviceForm->show();
1506                          m_pDeviceForm->raise();                          m_pDeviceForm->raise();
1507                          m_pDeviceForm->setActiveWindow();                          m_pDeviceForm->activateWindow();
1508                  }                  }
1509          }          }
1510  }  }
# Line 1741  void MainForm::stabilizeForm (void) Line 1746  void MainForm::stabilizeForm (void)
1746      QString sSessionName = sessionName(m_sFilename);      QString sSessionName = sessionName(m_sFilename);
1747      if (m_iDirtyCount > 0)      if (m_iDirtyCount > 0)
1748          sSessionName += " *";          sSessionName += " *";
1749      setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));      setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1750    
1751      // Update the main menu state...      // Update the main menu state...
1752      ChannelStrip* pChannelStrip = activeChannelStrip();      ChannelStrip* pChannelStrip = activeChannelStrip();
# Line 1763  void MainForm::stabilizeForm (void) Line 1768  void MainForm::stabilizeForm (void)
1768  #endif  #endif
1769      ui.editResetChannelAction->setEnabled(bHasChannel);      ui.editResetChannelAction->setEnabled(bHasChannel);
1770      ui.editResetAllChannelsAction->setEnabled(bHasChannel);      ui.editResetAllChannelsAction->setEnabled(bHasChannel);
1771      ui.viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible());      ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());
1772  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
1773          ui.viewInstrumentsAction->setOn(m_pInstrumentListForm          ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm
1774                  && m_pInstrumentListForm->isVisible());                  && m_pInstrumentListForm->isVisible());
1775          ui.viewInstrumentsAction->setEnabled(bHasClient);          ui.viewInstrumentsAction->setEnabled(bHasClient);
1776  #else  #else
1777          ui.viewInstrumentsAction->setEnabled(false);          ui.viewInstrumentsAction->setEnabled(false);
1778  #endif  #endif
1779          ui.viewDevicesAction->setOn(m_pDeviceForm          ui.viewDevicesAction->setChecked(m_pDeviceForm
1780                  && m_pDeviceForm->isVisible());                  && m_pDeviceForm->isVisible());
1781      ui.viewDevicesAction->setEnabled(bHasClient);      ui.viewDevicesAction->setEnabled(bHasClient);
1782      ui.channelsArrangeAction->setEnabled(bHasChannel);      ui.channelsArrangeAction->setEnabled(bHasChannel);
# Line 1792  void MainForm::stabilizeForm (void) Line 1797  void MainForm::stabilizeForm (void)
1797      }      }
1798      // Channel status...      // Channel status...
1799      if (bHasChannel)      if (bHasChannel)
1800          m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption());          m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->windowTitle());
1801      else      else
1802          m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear();          m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear();
1803      // Session status...      // Session status...
# Line 1802  void MainForm::stabilizeForm (void) Line 1807  void MainForm::stabilizeForm (void)
1807          m_statusItem[QSAMPLER_STATUS_SESSION]->clear();          m_statusItem[QSAMPLER_STATUS_SESSION]->clear();
1808    
1809      // Recent files menu.      // Recent files menu.
1810      m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0);          ui.fileOpenRecentMenu->setEnabled(m_pOptions->recentFiles.count() > 0);
1811  }  }
1812    
1813    
# Line 1842  void MainForm::volumeChanged ( int iVolu Line 1847  void MainForm::volumeChanged ( int iVolu
1847  void MainForm::channelStripChanged(ChannelStrip* pChannelStrip)  void MainForm::channelStripChanged(ChannelStrip* pChannelStrip)
1848  {  {
1849          // Add this strip to the changed list...          // Add this strip to the changed list...
1850          if (m_changedStrips.containsRef(pChannelStrip) == 0) {          if (!m_changedStrips.contains(pChannelStrip)) {
1851                  m_changedStrips.append(pChannelStrip);                  m_changedStrips.append(pChannelStrip);
1852                  pChannelStrip->resetErrorCount();                  pChannelStrip->resetErrorCount();
1853          }          }
# Line 1870  void MainForm::updateSession (void) Line 1875  void MainForm::updateSession (void)
1875          if (iMaps < 0)          if (iMaps < 0)
1876                  appendMessagesClient("lscp_get_midi_instrument_maps");                  appendMessagesClient("lscp_get_midi_instrument_maps");
1877          else if (iMaps < 1) {          else if (iMaps < 1) {
1878                  ::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1());                  ::lscp_add_midi_instrument_map(m_pClient,
1879                  ::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1());                          tr("Chromatic").toUtf8().constData());
1880                    ::lscp_add_midi_instrument_map(m_pClient,
1881                            tr("Drum Kits").toUtf8().constData());
1882          }          }
1883  #endif  #endif
1884    
# Line 1912  void MainForm::updateRecentFiles ( const Line 1919  void MainForm::updateRecentFiles ( const
1919          return;          return;
1920    
1921      // Remove from list if already there (avoid duplicates)      // Remove from list if already there (avoid duplicates)
1922      QStringList::Iterator iter = m_pOptions->recentFiles.find(sFilename);      int iIndex = m_pOptions->recentFiles.indexOf(sFilename);
1923      if (iter != m_pOptions->recentFiles.end())      if (iIndex >= 0)
1924          m_pOptions->recentFiles.remove(iter);          m_pOptions->recentFiles.removeAt(iIndex);
1925      // Put it to front...      // Put it to front...
1926      m_pOptions->recentFiles.push_front(sFilename);      m_pOptions->recentFiles.push_front(sFilename);
   
     // May update the menu.  
     updateRecentFilesMenu();  
1927  }  }
1928    
1929    
1930  // Update the recent files list and menu.  // Update the recent files list and menu.
1931  void MainForm::updateRecentFilesMenu (void)  void MainForm::updateRecentFilesMenu (void)
1932  {  {
1933      if (m_pOptions == NULL)          if (m_pOptions == NULL)
1934          return;                  return;
1935    
1936      // Time to keep the list under limits.          // Time to keep the list under limits.
1937      int iRecentFiles = m_pOptions->recentFiles.count();          int iRecentFiles = m_pOptions->recentFiles.count();
1938      while (iRecentFiles > m_pOptions->iMaxRecentFiles) {          while (iRecentFiles > m_pOptions->iMaxRecentFiles) {
1939          m_pOptions->recentFiles.pop_back();                  m_pOptions->recentFiles.pop_back();
1940          iRecentFiles--;                  iRecentFiles--;
1941      }          }
1942    
1943      // rebuild the recent files menu...          // Rebuild the recent files menu...
1944      m_pRecentFilesMenu->clear();          ui.fileOpenRecentMenu->clear();
1945      for (int i = 0; i < iRecentFiles; i++) {          for (int i = 0; i < iRecentFiles; i++) {
1946          const QString& sFilename = m_pOptions->recentFiles[i];                  const QString& sFilename = m_pOptions->recentFiles[i];
1947          if (QFileInfo(sFilename).exists()) {                  if (QFileInfo(sFilename).exists()) {
1948              m_pRecentFilesMenu->insertItem(QString("&%1 %2")                          QAction *pAction = ui.fileOpenRecentMenu->addAction(
1949                  .arg(i + 1).arg(sessionName(sFilename)),                                  QString("&%1 %2").arg(i + 1).arg(sessionName(sFilename)),
1950                  this, SLOT(fileOpenRecent(int)), 0, i);                                  this, SLOT(fileOpenRecent()));
1951          }                          pAction->setData(i);
1952      }                  }
1953            }
1954  }  }
1955    
1956    
# Line 1999  void MainForm::updateDisplayFont (void) Line 2004  void MainForm::updateDisplayFont (void)
2004  // Update channel strips background effect.  // Update channel strips background effect.
2005  void MainForm::updateDisplayEffect (void)  void MainForm::updateDisplayEffect (void)
2006  {  {
    QPixmap pm;  
     if (m_pOptions->bDisplayEffect)  
         pm = QPixmap(":/qsampler/pixmaps/displaybg1.png");  
   
2007      // Full channel list update...      // Full channel list update...
2008      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
2009      if (wlist.isEmpty())      if (wlist.isEmpty())
# Line 2011  void MainForm::updateDisplayEffect (void Line 2012  void MainForm::updateDisplayEffect (void
2012      m_pWorkspace->setUpdatesEnabled(false);      m_pWorkspace->setUpdatesEnabled(false);
2013      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
2014          ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);          ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);
2015          if (pChannelStrip)                  if (pChannelStrip)
2016              pChannelStrip->setDisplayBackground(pm);                          pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect);
2017      }      }
2018      m_pWorkspace->setUpdatesEnabled(true);      m_pWorkspace->setUpdatesEnabled(true);
2019  }  }
# Line 2026  void MainForm::updateMaxVolume (void) Line 2027  void MainForm::updateMaxVolume (void)
2027    
2028  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
2029          m_iVolumeChanging++;          m_iVolumeChanging++;
2030          m_pVolumeSlider->setMaxValue(m_pOptions->iMaxVolume);          m_pVolumeSlider->setMaximum(m_pOptions->iMaxVolume);
2031          m_pVolumeSpinBox->setMaxValue(m_pOptions->iMaxVolume);          m_pVolumeSpinBox->setMaximum(m_pOptions->iMaxVolume);
2032          m_iVolumeChanging--;          m_iVolumeChanging--;
2033  #endif  #endif
2034    
# Line 2055  void MainForm::appendMessages( const QSt Line 2056  void MainForm::appendMessages( const QSt
2056      if (m_pMessages)      if (m_pMessages)
2057          m_pMessages->appendMessages(s);          m_pMessages->appendMessages(s);
2058    
2059      statusBar()->message(s, 3000);      statusBar()->showMessage(s, 3000);
2060  }  }
2061    
2062  void MainForm::appendMessagesColor( const QString& s, const QString& c )  void MainForm::appendMessagesColor( const QString& s, const QString& c )
# Line 2063  void MainForm::appendMessagesColor( cons Line 2064  void MainForm::appendMessagesColor( cons
2064      if (m_pMessages)      if (m_pMessages)
2065          m_pMessages->appendMessagesColor(s, c);          m_pMessages->appendMessagesColor(s, c);
2066    
2067      statusBar()->message(s, 3000);      statusBar()->showMessage(s, 3000);
2068  }  }
2069    
2070  void MainForm::appendMessagesText( const QString& s )  void MainForm::appendMessagesText( const QString& s )
# Line 2080  void MainForm::appendMessagesError( cons Line 2081  void MainForm::appendMessagesError( cons
2081      appendMessagesColor(s.simplified(), "#ff0000");      appendMessagesColor(s.simplified(), "#ff0000");
2082    
2083          // Make it look responsive...:)          // Make it look responsive...:)
2084          QApplication::processEvents(QEventLoop::ExcludeUserInput);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2085    
2086      QMessageBox::critical(this,      QMessageBox::critical(this,
2087                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));
# Line 2098  void MainForm::appendMessagesClient( con Line 2099  void MainForm::appendMessagesClient( con
2099          .arg(::lscp_client_get_errno(m_pClient)), "#996666");          .arg(::lscp_client_get_errno(m_pClient)), "#996666");
2100    
2101          // Make it look responsive...:)          // Make it look responsive...:)
2102          QApplication::processEvents(QEventLoop::ExcludeUserInput);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2103  }  }
2104    
2105    
# Line 2157  ChannelStrip* MainForm::createChannelStr Line 2158  ChannelStrip* MainForm::createChannelStr
2158      if (m_pOptions && m_pOptions->bAutoArrange) {      if (m_pOptions && m_pOptions->bAutoArrange) {
2159          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
2160          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
2161              pChannelStrip = (ChannelStrip *) wlist.at(iChannel);                          pChannelStrip = static_cast<ChannelStrip *> (wlist.at(iChannel));
2162                          if (pChannelStrip) {                          if (pChannelStrip) {
2163                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();                          //  y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height();
2164                                  y += pChannelStrip->parentWidget()->frameGeometry().height();                                  y += pChannelStrip->parentWidget()->frameGeometry().height();
# Line 2170  ChannelStrip* MainForm::createChannelStr Line 2171  ChannelStrip* MainForm::createChannelStr
2171      if (pChannelStrip == NULL)      if (pChannelStrip == NULL)
2172          return NULL;          return NULL;
2173    
2174      m_pWorkspace->addWindow(pChannelStrip, Qt::Tool);          m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint);
2175    
2176      // Actual channel strip setup...      // Actual channel strip setup...
2177      pChannelStrip->setup(pChannel);      pChannelStrip->setup(pChannel);
# Line 2209  ChannelStrip* MainForm::createChannelStr Line 2210  ChannelStrip* MainForm::createChannelStr
2210  // Retrieve the active channel strip.  // Retrieve the active channel strip.
2211  ChannelStrip* MainForm::activeChannelStrip (void)  ChannelStrip* MainForm::activeChannelStrip (void)
2212  {  {
2213      return (ChannelStrip*) m_pWorkspace->activeWindow();      return static_cast<ChannelStrip *> (m_pWorkspace->activeWindow());
2214  }  }
2215    
2216    
# Line 2220  ChannelStrip* MainForm::channelStripAt ( Line 2221  ChannelStrip* MainForm::channelStripAt (
2221      if (wlist.isEmpty())      if (wlist.isEmpty())
2222          return NULL;          return NULL;
2223    
2224      return (ChannelStrip*) wlist.at(iChannel);      return static_cast<ChannelStrip *> (wlist.at(iChannel));
2225  }  }
2226    
2227    
# Line 2232  ChannelStrip* MainForm::channelStrip ( i Line 2233  ChannelStrip* MainForm::channelStrip ( i
2233                  return NULL;                  return NULL;
2234    
2235          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
2236                  ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                  ChannelStrip* pChannelStrip
2237                            = static_cast<ChannelStrip*> (wlist.at(iChannel));
2238                  if (pChannelStrip) {                  if (pChannelStrip) {
2239                          qsamplerChannel *pChannel = pChannelStrip->channel();                          qsamplerChannel *pChannel = pChannelStrip->channel();
2240                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
# Line 2249  ChannelStrip* MainForm::channelStrip ( i Line 2251  ChannelStrip* MainForm::channelStrip ( i
2251  void MainForm::channelsMenuAboutToShow (void)  void MainForm::channelsMenuAboutToShow (void)
2252  {  {
2253      ui.channelsMenu->clear();      ui.channelsMenu->clear();
2254      ui.channelsArrangeAction->addTo(ui.channelsMenu);          ui.channelsMenu->addAction(ui.channelsArrangeAction);
2255      ui.channelsAutoArrangeAction->addTo(ui.channelsMenu);          ui.channelsMenu->addAction(ui.channelsAutoArrangeAction);
2256    
2257      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
2258      if (!wlist.isEmpty()) {      if (!wlist.isEmpty()) {
2259          ui.channelsMenu->insertSeparator();                  ui.channelsMenu->addSeparator();
2260          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {          for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
2261              ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                          ChannelStrip* pChannelStrip
2262              if (pChannelStrip) {                                  = static_cast<ChannelStrip*> (wlist.at(iChannel));
2263                  int iItemID = ui.channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int)));                          if (pChannelStrip) {
2264                  ui.channelsMenu->setItemParameter(iItemID, iChannel);                                  QAction *pAction = ui.channelsMenu->addAction(
2265                  ui.channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip);                                          pChannelStrip->windowTitle(), this, SLOT(channelsMenuActivated()));
2266              }                                  pAction->setCheckable(true);
2267                                    pAction->setChecked(activeChannelStrip() == pChannelStrip);
2268                                    pAction->setData(iChannel);
2269                            }
2270          }          }
2271      }      }
2272  }  }
2273    
2274    
2275  // Windows menu activation slot  // Windows menu activation slot
2276  void MainForm::channelsMenuActivated ( int iChannel )  void MainForm::channelsMenuActivated (void)
2277  {  {
2278      ChannelStrip* pChannelStrip = channelStripAt(iChannel);          // Retrive channel index from action data...
2279      if (pChannelStrip)          QAction *pAction = qobject_cast<QAction *> (sender());
2280          pChannelStrip->showNormal();          if (pAction == NULL)
2281      pChannelStrip->setFocus();                  return;
2282    
2283            ChannelStrip* pChannelStrip = channelStripAt(pAction->data().toInt());
2284            if (pChannelStrip) {
2285                    pChannelStrip->showNormal();
2286                    pChannelStrip->setFocus();
2287            }
2288  }  }
2289    
2290    
# Line 2314  void MainForm::timerSlot (void) Line 2325  void MainForm::timerSlot (void)
2325    
2326          if (m_pClient) {          if (m_pClient) {
2327                  // Update the channel information for each pending strip...                  // Update the channel information for each pending strip...
2328                  if (m_changedStrips.count() > 0) {                  QListIterator<ChannelStrip *> iter(m_changedStrips);
2329                          for (ChannelStrip* pChannelStrip = m_changedStrips.first();                  while (iter.hasNext()) {
2330                                          pChannelStrip; pChannelStrip = m_changedStrips.next()) {                          ChannelStrip *pChannelStrip = iter.next();
2331                                  // If successfull, remove from pending list...                          // If successfull, remove from pending list...
2332                                  if (pChannelStrip->updateChannelInfo())                          if (pChannelStrip->updateChannelInfo()) {
2333                                          m_changedStrips.remove(pChannelStrip);                                  int iChannelStrip = m_changedStrips.indexOf(pChannelStrip);
2334                                    if (iChannelStrip >= 0)
2335                                            m_changedStrips.removeAt(iChannelStrip);
2336                          }                          }
2337                  }                  }
2338                  // Refresh each channel usage, on each period...                  // Refresh each channel usage, on each period...
# Line 2398  void MainForm::startServer (void) Line 2411  void MainForm::startServer (void)
2411                  SLOT(processServerExit()));                  SLOT(processServerExit()));
2412    
2413      // Build process arguments...      // Build process arguments...
2414      QStringList serverCmdLine = QStringList::split(' ', m_pOptions->sServerCmdLine);      QStringList serverCmdLine = m_pOptions->sServerCmdLine.split(' ');
2415    
2416      appendMessages(tr("Server is starting..."));      appendMessages(tr("Server is starting..."));
2417      appendMessagesColor(m_pOptions->sServerCmdLine, "#990099");      appendMessagesColor(m_pOptions->sServerCmdLine, "#990099");
# Line 2443  void MainForm::stopServer (void) Line 2456  void MainForm::stopServer (void)
2456      QTime t;      QTime t;
2457      t.start();      t.start();
2458      while (t.elapsed() < QSAMPLER_TIMER_MSECS)      while (t.elapsed() < QSAMPLER_TIMER_MSECS)
2459          QApplication::processEvents(QEventLoop::ExcludeUserInput);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2460    
2461       // Do final processing anyway.       // Do final processing anyway.
2462       processServerExit();       processServerExit();
# Line 2518  bool MainForm::startClient (void) Line 2531  bool MainForm::startClient (void)
2531      appendMessages(tr("Client connecting..."));      appendMessages(tr("Client connecting..."));
2532    
2533      // Create the client handle...      // Create the client handle...
2534      m_pClient = ::lscp_client_create(m_pOptions->sServerHost.latin1(), m_pOptions->iServerPort, qsampler_client_callback, this);          m_pClient = ::lscp_client_create(
2535                    m_pOptions->sServerHost.toUtf8().constData(),
2536                    m_pOptions->iServerPort, qsampler_client_callback, this);
2537      if (m_pClient == NULL) {      if (m_pClient == NULL) {
2538          // Is this the first try?          // Is this the first try?
2539          // maybe we need to start a local server...          // maybe we need to start a local server...

Legend:
Removed from v.1475  
changed lines
  Added in v.1507

  ViewVC Help
Powered by ViewVC