/[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 1815 by capela, Mon Dec 22 10:04:59 2008 UTC revision 2038 by capela, Thu Jan 7 18:42:26 2010 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 56  Line 56 
56  #include <QTimer>  #include <QTimer>
57  #include <QDateTime>  #include <QDateTime>
58    
59    #if QT_VERSION < 0x040500
60    namespace Qt {
61    const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000);
62    #if QT_VERSION < 0x040200
63    const WindowFlags CustomizeWindowHint   = WindowFlags(0x02000000);
64    #endif
65    }
66    #endif
67    
68  #ifdef HAVE_SIGNAL_H  #ifdef HAVE_SIGNAL_H
69  #include <signal.h>  #include <signal.h>
# Line 375  void MainForm::setup ( Options *pOptions Line 383  void MainForm::setup ( Options *pOptions
383    
384          // What style do we create these forms?          // What style do we create these forms?
385          Qt::WindowFlags wflags = Qt::Window          Qt::WindowFlags wflags = Qt::Window
 #if QT_VERSION >= 0x040200  
386                  | Qt::CustomizeWindowHint                  | Qt::CustomizeWindowHint
 #endif  
387                  | Qt::WindowTitleHint                  | Qt::WindowTitleHint
388                  | Qt::WindowSystemMenuHint                  | Qt::WindowSystemMenuHint
389                  | Qt::WindowMinMaxButtonsHint;                  | Qt::WindowMinMaxButtonsHint
390                    | Qt::WindowCloseButtonHint;
391          if (m_pOptions->bKeepOnTop)          if (m_pOptions->bKeepOnTop)
392                  wflags |= Qt::Tool;                  wflags |= Qt::Tool;
393    
394          // Some child forms are to be created right now.          // Some child forms are to be created right now.
395          m_pMessages = new Messages(this);          m_pMessages = new Messages(this);
396          m_pDeviceForm = new DeviceForm(this, wflags);          m_pDeviceForm = new DeviceForm(this, wflags);
397  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
398          m_pInstrumentListForm = new InstrumentListForm(this, wflags);          m_pInstrumentListForm = new InstrumentListForm(this, wflags);
399  #else  #else
400          viewInstrumentsAction->setEnabled(false);          m_ui.viewInstrumentsAction->setEnabled(false);
401  #endif  #endif
402    
403          // Setup messages logging appropriately...          // Setup messages logging appropriately...
404          m_pMessages->setLogging(          m_pMessages->setLogging(
405                  m_pOptions->bMessagesLog,                  m_pOptions->bMessagesLog,
406                  m_pOptions->sMessagesLogPath);                  m_pOptions->sMessagesLogPath);
407    
408          // Set message defaults...          // Set message defaults...
409          updateMessagesFont();          updateMessagesFont();
410          updateMessagesLimit();          updateMessagesLimit();
# Line 585  void MainForm::customEvent(QEvent* pCust Line 595  void MainForm::customEvent(QEvent* pCust
595                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:
596                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();                                  if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
597                                  break;                                  break;
598  #if CONFIG_EVENT_CHANNEL_MIDI                  #if CONFIG_EVENT_CHANNEL_MIDI
599                          case LSCP_EVENT_CHANNEL_MIDI: {                          case LSCP_EVENT_CHANNEL_MIDI: {
600                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();
601                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
602                                  if (pChannelStrip)                                  if (pChannelStrip)
603                                          pChannelStrip->midiArrived();                                          pChannelStrip->midiActivityLedOn();
604                                  break;                                  break;
605                          }                          }
606  #endif                  #endif
607  #if CONFIG_EVENT_DEVICE_MIDI                  #if CONFIG_EVENT_DEVICE_MIDI
608                          case LSCP_EVENT_DEVICE_MIDI: {                          case LSCP_EVENT_DEVICE_MIDI: {
609                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();
610                                  const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();                                  const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();
611                                  DeviceStatusForm* pDeviceStatusForm =                                  DeviceStatusForm *pDeviceStatusForm
612                                          DeviceStatusForm::getInstance(iDeviceID);                                          = DeviceStatusForm::getInstance(iDeviceID);
613                                  if (pDeviceStatusForm)                                  if (pDeviceStatusForm)
614                                          pDeviceStatusForm->midiArrived(iPortID);                                          pDeviceStatusForm->midiArrived(iPortID);
615                                  break;                                  break;
616                          }                          }
617  #endif                  #endif
618                          default:                          default:
619                                  appendMessagesColor(tr("Notify event: %1 data: %2")                                  appendMessagesColor(tr("Notify event: %1 data: %2")
620                                          .arg(::lscp_event_to_text(pEvent->event()))                                          .arg(::lscp_event_to_text(pEvent->event()))
# Line 613  void MainForm::customEvent(QEvent* pCust Line 623  void MainForm::customEvent(QEvent* pCust
623          }          }
624  }  }
625    
626  void MainForm::updateViewMidiDeviceStatusMenu() {  
627    void MainForm::updateViewMidiDeviceStatusMenu (void)
628    {
629          m_ui.viewMidiDeviceStatusMenu->clear();          m_ui.viewMidiDeviceStatusMenu->clear();
630          const std::map<int, DeviceStatusForm*> statusForms =          const std::map<int, DeviceStatusForm *> statusForms
631                  DeviceStatusForm::getInstances();                  = DeviceStatusForm::getInstances();
632          for (          std::map<int, DeviceStatusForm *>::const_iterator iter
633                  std::map<int, DeviceStatusForm*>::const_iterator iter = statusForms.begin();                  = statusForms.begin();
634                  iter != statusForms.end(); ++iter          for ( ; iter != statusForms.end(); ++iter) {
635          ) {                  DeviceStatusForm *pStatusForm = iter->second;
                 DeviceStatusForm* pForm = iter->second;  
636                  m_ui.viewMidiDeviceStatusMenu->addAction(                  m_ui.viewMidiDeviceStatusMenu->addAction(
637                          pForm->visibleAction()                          pStatusForm->visibleAction());
                 );  
638          }          }
639  }  }
640    
641    
642  // Context menu event handler.  // Context menu event handler.
643  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )
644  {  {
# Line 759  bool MainForm::saveSession ( bool bPromp Line 770  bool MainForm::saveSession ( bool bPromp
770                                  "\"%1\"\n\n"                                  "\"%1\"\n\n"
771                                  "Do you want to replace it?")                                  "Do you want to replace it?")
772                                  .arg(sFilename),                                  .arg(sFilename),
773                                  tr("Replace"), tr("Cancel")) > 0)                                  QMessageBox::Yes | QMessageBox::No)
774                                    == QMessageBox::No)
775                                  return false;                                  return false;
776                  }                  }
777          }          }
# Line 782  bool MainForm::closeSession ( bool bForc Line 794  bool MainForm::closeSession ( bool bForc
794                          "\"%1\"\n\n"                          "\"%1\"\n\n"
795                          "Do you want to save the changes?")                          "Do you want to save the changes?")
796                          .arg(sessionName(m_sFilename)),                          .arg(sessionName(m_sFilename)),
797                          tr("Save"), tr("Discard"), tr("Cancel"))) {                          QMessageBox::Save |
798                  case 0:     // Save...                          QMessageBox::Discard |
799                            QMessageBox::Cancel)) {
800                    case QMessageBox::Save:
801                          bClose = saveSession(false);                          bClose = saveSession(false);
802                          // Fall thru....                          // Fall thru....
803                  case 1:     // Discard                  case QMessageBox::Discard:
804                          break;                          break;
805                  default:    // Cancel.                  default:    // Cancel.
806                          bClose = false;                          bClose = false;
# Line 1307  void MainForm::fileReset (void) Line 1321  void MainForm::fileReset (void)
1321                  "Please note that this operation may cause\n"                  "Please note that this operation may cause\n"
1322                  "temporary MIDI and Audio disruption.\n\n"                  "temporary MIDI and Audio disruption.\n\n"
1323                  "Do you want to reset the sampler engine now?"),                  "Do you want to reset the sampler engine now?"),
1324                  tr("Reset"), tr("Cancel")) > 0)                  QMessageBox::Ok | QMessageBox::Cancel)
1325                    == QMessageBox::Cancel)
1326                  return;                  return;
1327    
1328          // Trye closing the current session, first...          // Trye closing the current session, first...
# Line 1348  void MainForm::fileRestart (void) Line 1363  void MainForm::fileRestart (void)
1363                          "Please note that this operation may cause\n"                          "Please note that this operation may cause\n"
1364                          "temporary MIDI and Audio disruption.\n\n"                          "temporary MIDI and Audio disruption.\n\n"
1365                          "Do you want to restart the connection now?"),                          "Do you want to restart the connection now?"),
1366                          tr("Restart"), tr("Cancel")) == 0);                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok);
1367          }          }
1368    
1369          // Are we still for it?          // Are we still for it?
# Line 1429  void MainForm::editRemoveChannel (void) Line 1444  void MainForm::editRemoveChannel (void)
1444                          "%1\n\n"                          "%1\n\n"
1445                          "Are you sure?")                          "Are you sure?")
1446                          .arg(pChannelStrip->windowTitle()),                          .arg(pChannelStrip->windowTitle()),
1447                          tr("OK"), tr("Cancel")) > 0)                          QMessageBox::Ok | QMessageBox::Cancel)
1448                            == QMessageBox::Cancel)
1449                          return;                          return;
1450          }          }
1451    
# Line 1647  void MainForm::viewOptions (void) Line 1663  void MainForm::viewOptions (void)
1663                                  QMessageBox::information(this,                                  QMessageBox::information(this,
1664                                          QSAMPLER_TITLE ": " + tr("Information"),                                          QSAMPLER_TITLE ": " + tr("Information"),
1665                                          tr("Some settings may be only effective\n"                                          tr("Some settings may be only effective\n"
1666                                          "next time you start this program."), tr("OK"));                                          "next time you start this program."));
1667                                  updateMessagesCapture();                                  updateMessagesCapture();
1668                          }                          }
1669                          // Check wheather something immediate has changed.                          // Check wheather something immediate has changed.
# Line 1865  void MainForm::stabilizeForm (void) Line 1881  void MainForm::stabilizeForm (void)
1881          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));          setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName));
1882    
1883          // Update the main menu state...          // Update the main menu state...
1884          ChannelStrip* pChannelStrip = activeChannelStrip();          ChannelStrip *pChannelStrip = activeChannelStrip();
1885          bool bHasClient  = (m_pOptions != NULL && m_pClient != NULL);          bool bHasClient = (m_pOptions != NULL && m_pClient != NULL);
1886          bool bHasChannel = (bHasClient && pChannelStrip != NULL);          bool bHasChannel = (bHasClient && pChannelStrip != NULL);
1887            bool bHasChannels = (bHasClient && m_pWorkspace->windowList().count() > 0);
1888          m_ui.fileNewAction->setEnabled(bHasClient);          m_ui.fileNewAction->setEnabled(bHasClient);
1889          m_ui.fileOpenAction->setEnabled(bHasClient);          m_ui.fileOpenAction->setEnabled(bHasClient);
1890          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);          m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
# Line 1883  void MainForm::stabilizeForm (void) Line 1900  void MainForm::stabilizeForm (void)
1900          m_ui.editEditChannelAction->setEnabled(false);          m_ui.editEditChannelAction->setEnabled(false);
1901  #endif  #endif
1902          m_ui.editResetChannelAction->setEnabled(bHasChannel);          m_ui.editResetChannelAction->setEnabled(bHasChannel);
1903          m_ui.editResetAllChannelsAction->setEnabled(bHasChannel);          m_ui.editResetAllChannelsAction->setEnabled(bHasChannels);
1904          m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());          m_ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible());
1905  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
1906          m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm          m_ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm
# Line 1895  void MainForm::stabilizeForm (void) Line 1912  void MainForm::stabilizeForm (void)
1912          m_ui.viewDevicesAction->setChecked(m_pDeviceForm          m_ui.viewDevicesAction->setChecked(m_pDeviceForm
1913                  && m_pDeviceForm->isVisible());                  && m_pDeviceForm->isVisible());
1914          m_ui.viewDevicesAction->setEnabled(bHasClient);          m_ui.viewDevicesAction->setEnabled(bHasClient);
1915          m_ui.channelsArrangeAction->setEnabled(bHasChannel);          m_ui.viewMidiDeviceStatusMenu->setEnabled(
1916                    DeviceStatusForm::getInstances().size() > 0);
1917            m_ui.channelsArrangeAction->setEnabled(bHasChannels);
1918    
1919  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
1920          // Toolbar widgets are also affected...          // Toolbar widgets are also affected...
# Line 2228  void MainForm::appendMessagesError( cons Line 2247  void MainForm::appendMessagesError( cons
2247          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
2248    
2249          QMessageBox::critical(this,          QMessageBox::critical(this,
2250                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));                  QSAMPLER_TITLE ": " + tr("Error"), s, QMessageBox::Cancel);
2251  }  }
2252    
2253    
# Line 2516  void MainForm::startServer (void) Line 2535  void MainForm::startServer (void)
2535    
2536          // Is the server process instance still here?          // Is the server process instance still here?
2537          if (m_pServer) {          if (m_pServer) {
2538                  switch (QMessageBox::warning(this,                  if (QMessageBox::warning(this,
2539                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
2540                          tr("Could not start the LinuxSampler server.\n\n"                          tr("Could not start the LinuxSampler server.\n\n"
2541                          "Maybe it is already started."),                          "Maybe it is already started."),
2542                          tr("Stop"), tr("Kill"), tr("Cancel"))) {                          QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
                 case 0:  
2543                          m_pServer->terminate();                          m_pServer->terminate();
                         break;  
                 case 1:  
2544                          m_pServer->kill();                          m_pServer->kill();
                         break;  
2545                  }                  }
2546                  return;                  return;
2547          }          }
# Line 2600  void MainForm::stopServer (bool bInterac Line 2615  void MainForm::stopServer (bool bInterac
2615                          "running in the background. The sampler would continue to work\n"                          "running in the background. The sampler would continue to work\n"
2616                          "according to your current sampler session and you could alter the\n"                          "according to your current sampler session and you could alter the\n"
2617                          "sampler session at any time by relaunching QSampler.\n\n"                          "sampler session at any time by relaunching QSampler.\n\n"
2618                          "Do you want LinuxSampler to stop or to keep running in\n"                          "Do you want LinuxSampler to stop?"),
2619                          "the background?"),                          QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
                         tr("Stop"), tr("Keep Running")) == 1)  
2620                  {                  {
2621                          bForceServerStop = false;                          bForceServerStop = false;
2622                  }                  }

Legend:
Removed from v.1815  
changed lines
  Added in v.2038

  ViewVC Help
Powered by ViewVC