/[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 1626 by schoenebeck, Sat Jan 5 13:29:11 2008 UTC revision 1699 by schoenebeck, Sun Feb 17 10:46:17 2008 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 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
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 33  Line 33 
33  #include "qsamplerInstrumentListForm.h"  #include "qsamplerInstrumentListForm.h"
34  #include "qsamplerDeviceForm.h"  #include "qsamplerDeviceForm.h"
35  #include "qsamplerOptionsForm.h"  #include "qsamplerOptionsForm.h"
36    #include "qsamplerDeviceStatusForm.h"
37    
38  #include <QApplication>  #include <QApplication>
39  #include <QWorkspace>  #include <QWorkspace>
# Line 481  bool MainForm::queryClose (void) Line 482  bool MainForm::queryClose (void)
482    
483  void MainForm::closeEvent ( QCloseEvent *pCloseEvent )  void MainForm::closeEvent ( QCloseEvent *pCloseEvent )
484  {  {
485          if (queryClose())          if (queryClose()) {
486                    DeviceStatusForm::deleteAllInstances();
487                  pCloseEvent->accept();                  pCloseEvent->accept();
488          else          } else
489                  pCloseEvent->ignore();                  pCloseEvent->ignore();
490  }  }
491    
# Line 551  void MainForm::customEvent(QEvent* pCust Line 553  void MainForm::customEvent(QEvent* pCust
553          // For the time being, just pump it to messages.          // For the time being, just pump it to messages.
554          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
555                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);
556                  if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) {                  switch (pEvent->event()) {
557                          int iChannelID = pEvent->data().toInt();                          case LSCP_EVENT_CHANNEL_INFO: {
558                          ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  int iChannelID = pEvent->data().toInt();
559                          if (pChannelStrip)                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
560                                  channelStripChanged(pChannelStrip);                                  if (pChannelStrip)
561                  } else {                                          channelStripChanged(pChannelStrip);
562                          appendMessagesColor(tr("Notify event: %1 data: %2")                                  break;
563                                  .arg(::lscp_event_to_text(pEvent->event()))                          }
564                                  .arg(pEvent->data()), "#996699");                          case LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT:
565                                    if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
566                                    DeviceStatusForm::onDevicesChanged();
567                                    updateViewMidiDeviceStatusMenu();
568                                    break;
569                            case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: {
570                                    if (m_pDeviceForm) m_pDeviceForm->refreshDevices();
571                                    const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();
572                                    DeviceStatusForm::onDeviceChanged(iDeviceID);
573                                    break;
574                            }
575    #if CONFIG_LSCP_CHANNEL_MIDI
576                            case LSCP_EVENT_CHANNEL_MIDI: {
577                                    const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();
578                                    ChannelStrip *pChannelStrip = channelStrip(iChannelID);
579                                    if (pChannelStrip)
580                                            pChannelStrip->midiArrived();
581                                    break;
582                            }
583    #endif
584    #if CONFIG_LSCP_DEVICE_MIDI
585                            case LSCP_EVENT_DEVICE_MIDI: {
586                                    const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();
587                                    const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();
588                                    DeviceStatusForm* pDeviceStatusForm =
589                                            DeviceStatusForm::getInstance(iDeviceID);
590                                    if (pDeviceStatusForm)
591                                            pDeviceStatusForm->midiArrived(iPortID);
592                                    break;
593                            }
594    #endif
595                            default:
596                                    appendMessagesColor(tr("Notify event: %1 data: %2")
597                                            .arg(::lscp_event_to_text(pEvent->event()))
598                                            .arg(pEvent->data()), "#996699");
599                  }                  }
600          }          }
601  }  }
602    
603    void MainForm::updateViewMidiDeviceStatusMenu() {
604            m_ui.viewMidiDeviceStatusMenu->clear();
605            const std::map<int, DeviceStatusForm*> statusForms =
606                    DeviceStatusForm::getInstances();
607            for (
608                    std::map<int, DeviceStatusForm*>::const_iterator iter = statusForms.begin();
609                    iter != statusForms.end(); ++iter
610            ) {
611                    DeviceStatusForm* pForm = iter->second;
612                    m_ui.viewMidiDeviceStatusMenu->addAction(
613                            pForm->visibleAction()
614                    );
615            }
616    }
617    
618  // Context menu event handler.  // Context menu event handler.
619  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )
620  {  {
# Line 2605  bool MainForm::startClient (void) Line 2656  bool MainForm::startClient (void)
2656    
2657          // Subscribe to channel info change notifications...          // Subscribe to channel info change notifications...
2658          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)
2659                  appendMessagesClient("lscp_client_subscribe");                  appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)");
2660    
2661            DeviceStatusForm::onDevicesChanged(); // initialize
2662            updateViewMidiDeviceStatusMenu();
2663            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT) != LSCP_OK)
2664                    appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)");
2665            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO) != LSCP_OK)
2666                    appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)");
2667    
2668    #if CONFIG_LSCP_CHANNEL_MIDI
2669            // Subscribe to channel MIDI data notifications...
2670            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK)
2671                    appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)");
2672    #endif
2673    
2674    #if CONFIG_LSCP_DEVICE_MIDI
2675            // Subscribe to channel MIDI data notifications...
2676            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK)
2677                    appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)");
2678    #endif
2679    
2680          // We may stop scheduling around.          // We may stop scheduling around.
2681          stopSchedule();          stopSchedule();
# Line 2659  void MainForm::stopClient (void) Line 2729  void MainForm::stopClient (void)
2729          closeSession(false);          closeSession(false);
2730    
2731          // Close us as a client...          // Close us as a client...
2732    #if CONFIG_LSCP_DEVICE_MIDI
2733            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI);
2734    #endif
2735    #if CONFIG_LSCP_CHANNEL_MIDI
2736            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI);
2737    #endif
2738            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO);
2739            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
2740          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
2741          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
2742          m_pClient = NULL;          m_pClient = NULL;

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

  ViewVC Help
Powered by ViewVC