/[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 1840 by capela, Thu Feb 19 11:44:57 2009 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-2009, 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 1870  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 1888  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 1900  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 2601  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?"),
                         "the background?"),  
2619                          QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)                          QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
2620                  {                  {
2621                          bForceServerStop = false;                          bForceServerStop = false;

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

  ViewVC Help
Powered by ViewVC