예제 #1
0
/**
 * Create or recreate the Mixer GUI elements
 *
 * @param saveConfig  Whether to save all View configurations before recreating
 * @param forceNewTab To enforce opening a new tab, even when the profileList in the kmixrc is empty.
 *                    It should only be set to "true" in case of a Hotplug (because then the user definitely expects a new Tab to show).
 */
void
KMixWindow::recreateGUI(bool saveConfig, const QString& mixerId,
    bool forceNewTab)
{
  // -1- Remember which of the tabs is currently selected for restoration for re-insertion
  int oldTabPosition = m_wsMixers->currentIndex();

  if (saveConfig)
    saveViewConfig();  // save the state before recreating

  // -2- RECREATE THE ALREADY EXISTING TABS **********************************
  QMap<Mixer*, bool> mixerHasProfile;

  // -2a- Build a list of all active profiles in the main window (that means: from all tabs)
  QList<GUIProfile*> activeGuiProfiles;
  for (int i = 0; i < m_wsMixers->count(); ++i)
    {
      KMixerWidget* kmw = dynamic_cast<KMixerWidget*>(m_wsMixers->widget(i));
      if (kmw)
        {
          activeGuiProfiles.append(kmw->getGuiprof());
        }
    }

  // TODO The following loop is a bit buggy, as it iterates over all cached Profiles. But that is wrong for Tabs that got closed.
  //       I need to loop over something else, e.g. a  profile list built from the currently open Tabs.
  //       Or (if it that is easier) I might discard the Profile from the cache on "close-tab" (but that must also include unplug actions).
  foreach( GUIProfile* guiprof, activeGuiProfiles){
  KMixerWidget* kmw = findKMWforTab(guiprof->getId());
  Mixer *mixer = Mixer::findMixer( guiprof->getMixerId() );
  if ( mixer == 0 )
    {
      kError() << "MixerToolBox::find() hasn't found the Mixer for the profile " << guiprof->getId();
      continue;
    }
  mixerHasProfile[mixer] = true;
  if ( kmw == 0 )
    {
      // does not yet exist => create
      addMixerWidget(mixer->id(), guiprof->getId(), -1);
    }
  else
    {
      // did exist => remove and insert new guiprof at old position
      int indexOfTab = m_wsMixers->indexOf(kmw);
      if ( indexOfTab != -1 ) m_wsMixers->removeTab(indexOfTab);
      delete kmw;
      addMixerWidget(mixer->id(), guiprof->getId(), indexOfTab);
    }
} // Loop over all GUIProfile's
예제 #2
0
void KMixDockWidget::handleNewMaster(int soundcard_id, QString& channel_id) // !! @todo rework parameters
{
  //kdDebug(67100) << "KMixDockWidget::handleNewMaster() soundcard_id=" << soundcard_id << " , channel_id=" << channel_id << endl;
  Mixer *mixer = Mixer::mixers().at(soundcard_id);
  if ( mixer == 0 ) {
    kdError(67100) << "KMixDockWidget::createPage(): Invalid Mixer (soundcard_id=" << soundcard_id << ")" << endl;
    return; // can not happen
  }
  m_mixer = mixer;
  Mixer::setMasterCard(mixer->id()); // We must save this information "somewhere".
  Mixer::setMasterCardDevice( channel_id );
  createMasterVolWidget();
}
예제 #3
0
/**
 * Create basic widgets of the Dialog.
 */
void DialogSelectMaster::createWidgets(Mixer *ptr_mixer)
{
    m_mainFrame = new QWidget( this );
    setMainWidget( m_mainFrame );
    _layout = new QVBoxLayout(m_mainFrame);
    _layout->setMargin(0);

    if ( Mixer::mixers().count() > 1 ) {
        // More than one Mixer => show Combo-Box to select Mixer
        // Mixer widget line
        QHBoxLayout* mixerNameLayout = new QHBoxLayout();
        _layout->addItem( mixerNameLayout );
        mixerNameLayout->setMargin(0);
        mixerNameLayout->setSpacing(KDialog::spacingHint());
    
        QLabel *qlbl = new QLabel( i18n("Current mixer:"), m_mainFrame );
        mixerNameLayout->addWidget(qlbl);
        qlbl->setFixedHeight(qlbl->sizeHint().height());
    
        m_cMixer = new KComboBox( false, m_mainFrame);
        m_cMixer->setObjectName( QLatin1String( "mixerCombo" ) );
        m_cMixer->setFixedHeight(m_cMixer->sizeHint().height());
        connect( m_cMixer, SIGNAL(activated(int)), this, SLOT(createPageByID(int)) );

        for( int i =0; i<Mixer::mixers().count(); i++ )
        {
            Mixer *mixer = (Mixer::mixers())[i];
            m_cMixer->addItem( mixer->readableName(), mixer->id() );
         } // end for all_Mixers
        // Make the current Mixer the current item in the ComboBox
        int findIndex = m_cMixer->findData( ptr_mixer->id() );
        if ( findIndex != -1 ) m_cMixer->setCurrentIndex( findIndex );
        
    
        m_cMixer->setToolTip( i18n("Current mixer" ) );
        mixerNameLayout->addWidget(m_cMixer, 1);
        _layout->addSpacing(KDialog::spacingHint());

    } // end if (more_than_1_Mixer)