/[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 1699 by schoenebeck, Sun Feb 17 10:46:17 2008 UTC revision 1749 by capela, Wed Jul 2 13:19:09 2008 UTC
# Line 1  Line 1 
1  // qsamplerMainForm.cpp  // qsamplerMainForm.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2008, 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 391  void MainForm::setup ( Options *pOptions Line 391  void MainForm::setup ( Options *pOptions
391  #else  #else
392          viewInstrumentsAction->setEnabled(false);          viewInstrumentsAction->setEnabled(false);
393  #endif  #endif
394            // Setup messages logging appropriately...
395            m_pMessages->setLogging(
396                    m_pOptions->bMessagesLog,
397                    m_pOptions->sMessagesLogPath);
398          // Set message defaults...          // Set message defaults...
399          updateMessagesFont();          updateMessagesFont();
400          updateMessagesLimit();          updateMessagesLimit();
# Line 554  void MainForm::customEvent(QEvent* pCust Line 558  void MainForm::customEvent(QEvent* pCust
558          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
559                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);
560                  switch (pEvent->event()) {                  switch (pEvent->event()) {
561                            case LSCP_EVENT_CHANNEL_COUNT:
562                                    updateAllChannelStrips(true);
563                                    break;
564                          case LSCP_EVENT_CHANNEL_INFO: {                          case LSCP_EVENT_CHANNEL_INFO: {
565                                  int iChannelID = pEvent->data().toInt();                                  int iChannelID = pEvent->data().toInt();
566                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
# Line 572  void MainForm::customEvent(QEvent* pCust Line 579  void MainForm::customEvent(QEvent* pCust
579                                  DeviceStatusForm::onDeviceChanged(iDeviceID);                                  DeviceStatusForm::onDeviceChanged(iDeviceID);
580                                  break;                                  break;
581                          }                          }
582  #if CONFIG_LSCP_CHANNEL_MIDI                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT:
583                                    if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
584                                    break;
585                            case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:
586                                    if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
587                                    break;
588    #if CONFIG_EVENT_CHANNEL_MIDI
589                          case LSCP_EVENT_CHANNEL_MIDI: {                          case LSCP_EVENT_CHANNEL_MIDI: {
590                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();
591                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
# Line 581  void MainForm::customEvent(QEvent* pCust Line 594  void MainForm::customEvent(QEvent* pCust
594                                  break;                                  break;
595                          }                          }
596  #endif  #endif
597  #if CONFIG_LSCP_DEVICE_MIDI  #if CONFIG_EVENT_DEVICE_MIDI
598                          case LSCP_EVENT_DEVICE_MIDI: {                          case LSCP_EVENT_DEVICE_MIDI: {
599                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();
600                                  const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();                                  const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();
# Line 1607  void MainForm::viewOptions (void) Line 1620  void MainForm::viewOptions (void)
1620                  int     iOldServerTimeout   = m_pOptions->iServerTimeout;                  int     iOldServerTimeout   = m_pOptions->iServerTimeout;
1621                  bool    bOldServerStart     = m_pOptions->bServerStart;                  bool    bOldServerStart     = m_pOptions->bServerStart;
1622                  QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;                  QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
1623                    bool    bOldMessagesLog     = m_pOptions->bMessagesLog;
1624                    QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath;
1625                  QString sOldDisplayFont     = m_pOptions->sDisplayFont;                  QString sOldDisplayFont     = m_pOptions->sDisplayFont;
1626                  bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;                  bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1627                  int     iOldMaxVolume       = m_pOptions->iMaxVolume;                  int     iOldMaxVolume       = m_pOptions->iMaxVolume;
# Line 1618  void MainForm::viewOptions (void) Line 1633  void MainForm::viewOptions (void)
1633                  bool    bOldCompletePath    = m_pOptions->bCompletePath;                  bool    bOldCompletePath    = m_pOptions->bCompletePath;
1634                  bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;                  bool    bOldInstrumentNames = m_pOptions->bInstrumentNames;
1635                  int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;                  int     iOldMaxRecentFiles  = m_pOptions->iMaxRecentFiles;
1636                    int     iOldBaseFontSize    = m_pOptions->iBaseFontSize;
1637                  // Load the current setup settings.                  // Load the current setup settings.
1638                  pOptionsForm->setup(m_pOptions);                  pOptionsForm->setup(m_pOptions);
1639                  // Show the setup dialog...                  // Show the setup dialog...
# Line 1626  void MainForm::viewOptions (void) Line 1642  void MainForm::viewOptions (void)
1642                          if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||                          if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||
1643                                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||                                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||
1644                                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||                                  ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1645                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)) {                                  (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)     ||
1646                                    (iOldBaseFontSize   !=  m_pOptions->iBaseFontSize)) {
1647                                  QMessageBox::information(this,                                  QMessageBox::information(this,
1648                                          QSAMPLER_TITLE ": " + tr("Information"),                                          QSAMPLER_TITLE ": " + tr("Information"),
1649                                          tr("Some settings may be only effective\n"                                          tr("Some settings may be only effective\n"
# Line 1634  void MainForm::viewOptions (void) Line 1651  void MainForm::viewOptions (void)
1651                                  updateMessagesCapture();                                  updateMessagesCapture();
1652                          }                          }
1653                          // Check wheather something immediate has changed.                          // Check wheather something immediate has changed.
1654                            if (( bOldMessagesLog && !m_pOptions->bMessagesLog) ||
1655                                    (!bOldMessagesLog &&  m_pOptions->bMessagesLog) ||
1656                                    (sOldMessagesLogPath != m_pOptions->sMessagesLogPath))
1657                                    m_pMessages->setLogging(
1658                                            m_pOptions->bMessagesLog, m_pOptions->sMessagesLogPath);
1659                          if (( bOldCompletePath && !m_pOptions->bCompletePath) ||                          if (( bOldCompletePath && !m_pOptions->bCompletePath) ||
1660                                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1661                                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
# Line 1962  void MainForm::updateSession (void) Line 1984  void MainForm::updateSession (void)
1984          }          }
1985  #endif  #endif
1986    
1987            updateAllChannelStrips(false);
1988    
1989            // Do we auto-arrange?
1990            if (m_pOptions && m_pOptions->bAutoArrange)
1991                    channelsArrange();
1992    
1993            // Remember to refresh devices and instruments...
1994            if (m_pInstrumentListForm)
1995                    m_pInstrumentListForm->refreshInstruments();
1996            if (m_pDeviceForm)
1997                    m_pDeviceForm->refreshDevices();
1998    }
1999    
2000    void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) {
2001          // Retrieve the current channel list.          // Retrieve the current channel list.
2002          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
2003          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 1978  void MainForm::updateSession (void) Line 2014  void MainForm::updateSession (void)
2014                          if (!channelStrip(piChannelIDs[iChannel]))                          if (!channelStrip(piChannelIDs[iChannel]))
2015                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2016                  }                  }
                 m_pWorkspace->setUpdatesEnabled(true);  
         }  
2017    
2018          // Do we auto-arrange?                  // Do we auto-arrange?
2019          if (m_pOptions && m_pOptions->bAutoArrange)                  if (m_pOptions && m_pOptions->bAutoArrange)
2020                  channelsArrange();                          channelsArrange();
2021    
2022          // Remember to refresh devices and instruments...                  stabilizeForm();
         if (m_pInstrumentListForm)  
                 m_pInstrumentListForm->refreshInstruments();  
         if (m_pDeviceForm)  
                 m_pDeviceForm->refreshDevices();  
 }  
2023    
2024                    // remove dead channel strips
2025                    if (bRemoveDeadStrips) {
2026                            for (int i = 0; channelStripAt(i); ++i) {
2027                                    ChannelStrip* pChannelStrip = channelStripAt(i);
2028                                    bool bExists = false;
2029                                    for (int j = 0; piChannelIDs[j] >= 0; ++j) {
2030                                            if (!pChannelStrip->channel()) break;
2031                                            if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {
2032                                                    // strip exists, don't touch it
2033                                                    bExists = true;
2034                                                    break;
2035                                            }
2036                                    }
2037                                    if (!bExists) destroyChannelStrip(pChannelStrip);
2038                            }
2039                    }
2040                    m_pWorkspace->setUpdatesEnabled(true);
2041            }
2042    }
2043    
2044  // Update the recent files list and menu.  // Update the recent files list and menu.
2045  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
# Line 2270  ChannelStrip* MainForm::createChannelStr Line 2318  ChannelStrip* MainForm::createChannelStr
2318          return pChannelStrip;          return pChannelStrip;
2319  }  }
2320    
2321    void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) {
2322            // Just delete the channel strip.
2323            delete pChannelStrip;
2324    
2325            // Do we auto-arrange?
2326            if (m_pOptions && m_pOptions->bAutoArrange)
2327                    channelsArrange();
2328    
2329            stabilizeForm();
2330    }
2331    
2332  // Retrieve the active channel strip.  // Retrieve the active channel strip.
2333  ChannelStrip* MainForm::activeChannelStrip (void)  ChannelStrip* MainForm::activeChannelStrip (void)
# Line 2281  ChannelStrip* MainForm::activeChannelStr Line 2339  ChannelStrip* MainForm::activeChannelStr
2339  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2340  ChannelStrip* MainForm::channelStripAt ( int iChannel )  ChannelStrip* MainForm::channelStripAt ( int iChannel )
2341  {  {
2342            if (!m_pWorkspace) return NULL;
2343    
2344          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
2345          if (wlist.isEmpty())          if (wlist.isEmpty())
2346                  return NULL;                  return NULL;
2347    
2348          return static_cast<ChannelStrip *> (wlist.at(iChannel));          if (iChannel < 0 || iChannel >= wlist.size())
2349                    return NULL;
2350    
2351            return dynamic_cast<ChannelStrip *> (wlist.at(iChannel));
2352  }  }
2353    
2354    
# Line 2655  bool MainForm::startClient (void) Line 2718  bool MainForm::startClient (void)
2718                  .arg(::lscp_client_get_timeout(m_pClient)));                  .arg(::lscp_client_get_timeout(m_pClient)));
2719    
2720          // Subscribe to channel info change notifications...          // Subscribe to channel info change notifications...
2721            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT) != LSCP_OK)
2722                    appendMessagesClient("lscp_client_subscribe(CHANNEL_COUNT)");
2723          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)
2724                  appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)");                  appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)");
2725    
# Line 2664  bool MainForm::startClient (void) Line 2729  bool MainForm::startClient (void)
2729                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)");                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)");
2730          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO) != LSCP_OK)
2731                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)");                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)");
2732            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT) != LSCP_OK)
2733                    appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_COUNT)");
2734            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO) != LSCP_OK)
2735                    appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_INFO)");
2736    
2737  #if CONFIG_LSCP_CHANNEL_MIDI  #if CONFIG_EVENT_CHANNEL_MIDI
2738          // Subscribe to channel MIDI data notifications...          // Subscribe to channel MIDI data notifications...
2739          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK)
2740                  appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)");                  appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)");
2741  #endif  #endif
2742    
2743  #if CONFIG_LSCP_DEVICE_MIDI  #if CONFIG_EVENT_DEVICE_MIDI
2744          // Subscribe to channel MIDI data notifications...          // Subscribe to channel MIDI data notifications...
2745          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK)
2746                  appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)");                  appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)");
# Line 2729  void MainForm::stopClient (void) Line 2798  void MainForm::stopClient (void)
2798          closeSession(false);          closeSession(false);
2799    
2800          // Close us as a client...          // Close us as a client...
2801  #if CONFIG_LSCP_DEVICE_MIDI  #if CONFIG_EVENT_DEVICE_MIDI
2802          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI);
2803  #endif  #endif
2804  #if CONFIG_LSCP_CHANNEL_MIDI  #if CONFIG_EVENT_CHANNEL_MIDI
2805          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI);
2806  #endif  #endif
2807            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO);
2808            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT);
2809          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
2810          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
2811          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
2812            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);
2813          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
2814          m_pClient = NULL;          m_pClient = NULL;
2815    

Legend:
Removed from v.1699  
changed lines
  Added in v.1749

  ViewVC Help
Powered by ViewVC