/[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 1698 by schoenebeck, Sat Feb 16 19:41:05 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 551  void MainForm::customEvent(QEvent* pCust Line 552  void MainForm::customEvent(QEvent* pCust
552          // For the time being, just pump it to messages.          // For the time being, just pump it to messages.
553          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
554                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);
555                  if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) {                  switch (pEvent->event()) {
556                          int iChannelID = pEvent->data().toInt();                          case LSCP_EVENT_CHANNEL_INFO: {
557                          ChannelStrip *pChannelStrip = channelStrip(iChannelID);                                  int iChannelID = pEvent->data().toInt();
558                          if (pChannelStrip)                                  ChannelStrip *pChannelStrip = channelStrip(iChannelID);
559                                  channelStripChanged(pChannelStrip);                                  if (pChannelStrip)
560                  } else {                                          channelStripChanged(pChannelStrip);
561                          appendMessagesColor(tr("Notify event: %1 data: %2")                                  break;
562                                  .arg(::lscp_event_to_text(pEvent->event()))                          }
563                                  .arg(pEvent->data()), "#996699");                          case LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT:
564                                    DeviceStatusForm::onDevicesChanged();
565                                    updateViewMidiDeviceStatusMenu();
566                                    break; //TODO: refresh device dialog as well
567    #if CONFIG_LSCP_CHANNEL_MIDI
568                            case LSCP_EVENT_CHANNEL_MIDI: {
569                                    const int iChannelID = pEvent->data().section(' ', 0, 0).toInt();
570                                    ChannelStrip *pChannelStrip = channelStrip(iChannelID);
571                                    if (pChannelStrip)
572                                            pChannelStrip->midiArrived();
573                                    break;
574                            }
575    #endif
576    #if CONFIG_LSCP_DEVICE_MIDI
577                            case LSCP_EVENT_DEVICE_MIDI: {
578                                    const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt();
579                                    const int iPortID   = pEvent->data().section(' ', 1, 1).toInt();
580                                    DeviceStatusForm* pDeviceStatusForm =
581                                            DeviceStatusForm::getInstance(iDeviceID);
582                                    if (pDeviceStatusForm)
583                                            pDeviceStatusForm->midiArrived(iPortID);
584                                    break;
585                            }
586    #endif
587                            default:
588                                    appendMessagesColor(tr("Notify event: %1 data: %2")
589                                            .arg(::lscp_event_to_text(pEvent->event()))
590                                            .arg(pEvent->data()), "#996699");
591                  }                  }
592          }          }
593  }  }
594    
595    void MainForm::updateViewMidiDeviceStatusMenu() {
596            m_ui.viewMidiDeviceStatusMenu->clear();
597            const std::map<int, DeviceStatusForm*> statusForms =
598                    DeviceStatusForm::getInstances();
599            for (
600                    std::map<int, DeviceStatusForm*>::const_iterator iter = statusForms.begin();
601                    iter != statusForms.end(); ++iter
602            ) {
603                    DeviceStatusForm* pForm = iter->second;
604                    m_ui.viewMidiDeviceStatusMenu->addAction(
605                            pForm->visibleAction()
606                    );
607            }
608    }
609    
610  // Context menu event handler.  // Context menu event handler.
611  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )  void MainForm::contextMenuEvent( QContextMenuEvent *pEvent )
612  {  {
# Line 2605  bool MainForm::startClient (void) Line 2648  bool MainForm::startClient (void)
2648    
2649          // Subscribe to channel info change notifications...          // Subscribe to channel info change notifications...
2650          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)          if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK)
2651                  appendMessagesClient("lscp_client_subscribe");                  appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)");
2652    
2653            DeviceStatusForm::onDevicesChanged(); // initialize
2654            updateViewMidiDeviceStatusMenu();
2655            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT) != LSCP_OK)
2656                    appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)");
2657    
2658    #if CONFIG_LSCP_CHANNEL_MIDI
2659            // Subscribe to channel MIDI data notifications...
2660            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK)
2661                    appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)");
2662    #endif
2663    
2664    #if CONFIG_LSCP_DEVICE_MIDI
2665            // Subscribe to channel MIDI data notifications...
2666            if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK)
2667                    appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)");
2668    #endif
2669    
2670          // We may stop scheduling around.          // We may stop scheduling around.
2671          stopSchedule();          stopSchedule();
# Line 2659  void MainForm::stopClient (void) Line 2719  void MainForm::stopClient (void)
2719          closeSession(false);          closeSession(false);
2720    
2721          // Close us as a client...          // Close us as a client...
2722    #if CONFIG_LSCP_DEVICE_MIDI
2723            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI);
2724    #endif
2725    #if CONFIG_LSCP_CHANNEL_MIDI
2726            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI);
2727    #endif
2728            ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT);
2729          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);          ::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO);
2730          ::lscp_client_destroy(m_pClient);          ::lscp_client_destroy(m_pClient);
2731          m_pClient = NULL;          m_pClient = NULL;

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

  ViewVC Help
Powered by ViewVC