/[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 1738 by capela, Wed May 14 15:24:22 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 appropriately...
395            m_pMessages->setLogging(m_pOptions->bMessagesLog, m_pOptions->sMessagesLogPath);
396          // Set message defaults...          // Set message defaults...
397          updateMessagesFont();          updateMessagesFont();
398          updateMessagesLimit();          updateMessagesLimit();
# Line 554  void MainForm::customEvent(QEvent* pCust Line 556  void MainForm::customEvent(QEvent* pCust
556          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
557                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);
558                  switch (pEvent->event()) {                  switch (pEvent->event()) {
559                            case LSCP_EVENT_CHANNEL_COUNT:
560                                    updateAllChannelStrips(true);
561                                    break;
562                          case LSCP_EVENT_CHANNEL_INFO: {                          case LSCP_EVENT_CHANNEL_INFO: {
563                                  int iChannelID = pEvent->data().toInt();                                  int iChannelID = pEvent->data().toInt();
564                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
# Line 572  void MainForm::customEvent(QEvent* pCust Line 577  void MainForm::customEvent(QEvent* pCust
577                                  DeviceStatusForm::onDeviceChanged(iDeviceID);                                  DeviceStatusForm::onDeviceChanged(iDeviceID);
578                                  break;                                  break;
579                          }                          }
580  #if CONFIG_LSCP_CHANNEL_MIDI                          case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT:
581                                    if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
582                                    break;
583                            case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO:
584                                    if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
585                                    break;
586    #if CONFIG_EVENT_CHANNEL_MIDI
587                          case LSCP_EVENT_CHANNEL_MIDI: {                          case LSCP_EVENT_CHANNEL_MIDI: {
588                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();
589                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
# Line 581  void MainForm::customEvent(QEvent* pCust Line 592  void MainForm::customEvent(QEvent* pCust
592                                  break;                                  break;
593                          }                          }
594  #endif  #endif
595  #if CONFIG_LSCP_DEVICE_MIDI  #if CONFIG_EVENT_DEVICE_MIDI
596                          case LSCP_EVENT_DEVICE_MIDI: {                          case LSCP_EVENT_DEVICE_MIDI: {
597                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();                                  const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();
598                                  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 1618  void MainForm::viewOptions (void)
1618                  int     iOldServerTimeout   = m_pOptions->iServerTimeout;                  int     iOldServerTimeout   = m_pOptions->iServerTimeout;
1619                  bool    bOldServerStart     = m_pOptions->bServerStart;                  bool    bOldServerStart     = m_pOptions->bServerStart;
1620                  QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;                  QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
1621                    bool    bOldMessagesLog     = m_pOptions->bMessagesLog;
1622                    QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath;
1623                  QString sOldDisplayFont     = m_pOptions->sDisplayFont;                  QString sOldDisplayFont     = m_pOptions->sDisplayFont;
1624                  bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;                  bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1625                  int     iOldMaxVolume       = m_pOptions->iMaxVolume;                  int     iOldMaxVolume       = m_pOptions->iMaxVolume;
# Line 1634  void MainForm::viewOptions (void) Line 1647  void MainForm::viewOptions (void)
1647                                  updateMessagesCapture();                                  updateMessagesCapture();
1648                          }                          }
1649                          // Check wheather something immediate has changed.                          // Check wheather something immediate has changed.
1650                            if (( bOldMessagesLog && !m_pOptions->bMessagesLog) ||
1651                                    (!bOldMessagesLog &&  m_pOptions->bMessagesLog) ||
1652                                    (sOldMessagesLogPath != m_pOptions->sMessagesLogPath))
1653                                    m_pMessages->setLogging(
1654                                            m_pOptions->bMessagesLog, m_pOptions->sMessagesLogPath);
1655                          if (( bOldCompletePath && !m_pOptions->bCompletePath) ||                          if (( bOldCompletePath && !m_pOptions->bCompletePath) ||
1656                                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||                                  (!bOldCompletePath &&  m_pOptions->bCompletePath) ||
1657                                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))                                  (iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles))
# Line 1962  void MainForm::updateSession (void) Line 1980  void MainForm::updateSession (void)
1980          }          }
1981  #endif  #endif
1982    
1983            updateAllChannelStrips(false);
1984    
1985            // Do we auto-arrange?
1986            if (m_pOptions && m_pOptions->bAutoArrange)
1987                    channelsArrange();
1988    
1989            // Remember to refresh devices and instruments...
1990            if (m_pInstrumentListForm)
1991                    m_pInstrumentListForm->refreshInstruments();
1992            if (m_pDeviceForm)
1993                    m_pDeviceForm->refreshDevices();
1994    }
1995    
1996    void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) {
1997          // Retrieve the current channel list.          // Retrieve the current channel list.
1998          int *piChannelIDs = ::lscp_list_channels(m_pClient);          int *piChannelIDs = ::lscp_list_channels(m_pClient);
1999          if (piChannelIDs == NULL) {          if (piChannelIDs == NULL) {
# Line 1978  void MainForm::updateSession (void) Line 2010  void MainForm::updateSession (void)
2010                          if (!channelStrip(piChannelIDs[iChannel]))                          if (!channelStrip(piChannelIDs[iChannel]))
2011                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
2012                  }                  }
                 m_pWorkspace->setUpdatesEnabled(true);  
         }  
2013    
2014          // Do we auto-arrange?                  // Do we auto-arrange?
2015          if (m_pOptions && m_pOptions->bAutoArrange)                  if (m_pOptions && m_pOptions->bAutoArrange)
2016                  channelsArrange();                          channelsArrange();
2017    
2018          // Remember to refresh devices and instruments...                  stabilizeForm();
         if (m_pInstrumentListForm)  
                 m_pInstrumentListForm->refreshInstruments();  
         if (m_pDeviceForm)  
                 m_pDeviceForm->refreshDevices();  
 }  
2019    
2020                    // remove dead channel strips
2021                    if (bRemoveDeadStrips) {
2022                            for (int i = 0; channelStripAt(i); ++i) {
2023                                    ChannelStrip* pChannelStrip = channelStripAt(i);
2024                                    bool bExists = false;
2025                                    for (int j = 0; piChannelIDs[j] >= 0; ++j) {
2026                                            if (!pChannelStrip->channel()) break;
2027                                            if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) {
2028                                                    // strip exists, don't touch it
2029                                                    bExists = true;
2030                                                    break;
2031                                            }
2032                                    }
2033                                    if (!bExists) destroyChannelStrip(pChannelStrip);
2034                            }
2035                    }
2036                    m_pWorkspace->setUpdatesEnabled(true);
2037            }
2038    }
2039    
2040  // Update the recent files list and menu.  // Update the recent files list and menu.
2041  void MainForm::updateRecentFiles ( const QString& sFilename )  void MainForm::updateRecentFiles ( const QString& sFilename )
# Line 2270  ChannelStrip* MainForm::createChannelStr Line 2314  ChannelStrip* MainForm::createChannelStr
2314          return pChannelStrip;          return pChannelStrip;
2315  }  }
2316    
2317    void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) {
2318            // Just delete the channel strip.
2319            delete pChannelStrip;
2320    
2321            // Do we auto-arrange?
2322            if (m_pOptions && m_pOptions->bAutoArrange)
2323                    channelsArrange();
2324    
2325            stabilizeForm();
2326    }
2327    
2328  // Retrieve the active channel strip.  // Retrieve the active channel strip.
2329  ChannelStrip* MainForm::activeChannelStrip (void)  ChannelStrip* MainForm::activeChannelStrip (void)
# Line 2281  ChannelStrip* MainForm::activeChannelStr Line 2335  ChannelStrip* MainForm::activeChannelStr
2335  // Retrieve a channel strip by index.  // Retrieve a channel strip by index.
2336  ChannelStrip* MainForm::channelStripAt ( int iChannel )  ChannelStrip* MainForm::channelStripAt ( int iChannel )
2337  {  {
2338            if (!m_pWorkspace) return NULL;
2339    
2340          QWidgetList wlist = m_pWorkspace->windowList();          QWidgetList wlist = m_pWorkspace->windowList();
2341          if (wlist.isEmpty())          if (wlist.isEmpty())
2342                  return NULL;                  return NULL;
2343    
2344          return static_cast<ChannelStrip *> (wlist.at(iChannel));          if (iChannel < 0 || iChannel >= wlist.size())
2345                    return NULL;
2346    
2347            return dynamic_cast<ChannelStrip *> (wlist.at(iChannel));
2348  }  }
2349    
2350    
# Line 2655  bool MainForm::startClient (void) Line 2714  bool MainForm::startClient (void)
2714                  .arg(::lscp_client_get_timeout(m_pClient)));                  .arg(::lscp_client_get_timeout(m_pClient)));
2715    
2716          // Subscribe to channel info change notifications...          // Subscribe to channel info change notifications...
2717            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT) != LSCP_OK)
2718                    appendMessagesClient("lscp_client_subscribe(CHANNEL_COUNT)");
2719          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)
2720                  appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)");                  appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)");
2721    
# Line 2664  bool MainForm::startClient (void) Line 2725  bool MainForm::startClient (void)
2725                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)");                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)");
2726          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)
2727                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)");                  appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)");
2728            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT) != LSCP_OK)
2729                    appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_COUNT)");
2730            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO) != LSCP_OK)
2731                    appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_INFO)");
2732    
2733  #if CONFIG_LSCP_CHANNEL_MIDI  #if CONFIG_EVENT_CHANNEL_MIDI
2734          // Subscribe to channel MIDI data notifications...          // Subscribe to channel MIDI data notifications...
2735          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK)
2736                  appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)");                  appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)");
2737  #endif  #endif
2738    
2739  #if CONFIG_LSCP_DEVICE_MIDI  #if CONFIG_EVENT_DEVICE_MIDI
2740          // Subscribe to channel MIDI data notifications...          // Subscribe to channel MIDI data notifications...
2741          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK)
2742                  appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)");                  appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)");
# Line 2729  void MainForm::stopClient (void) Line 2794  void MainForm::stopClient (void)
2794          closeSession(false);          closeSession(false);
2795    
2796          // Close us as a client...          // Close us as a client...
2797  #if CONFIG_LSCP_DEVICE_MIDI  #if CONFIG_EVENT_DEVICE_MIDI
2798          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI);
2799  #endif  #endif
2800  #if CONFIG_LSCP_CHANNEL_MIDI  #if CONFIG_EVENT_CHANNEL_MIDI
2801          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI);
2802  #endif  #endif
2803            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO);
2804            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT);
2805          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
2806          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
2807          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
2808            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT);
2809          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
2810          m_pClient = NULL;          m_pClient = NULL;
2811    

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

  ViewVC Help
Powered by ViewVC