Ejemplo n.º 1
0
void K3bWriterSelectionWidget::slotRefreshWriterSpeeds()
{
  if( writerDevice() ) {
    QValueList<int> speeds = k3bappcore->mediaCache()->writingSpeeds( writerDevice() );

    int lastSpeed = writerSpeed();

    clearSpeedCombo();

    m_comboSpeed->insertItem( i18n("Auto") );
    if( k3bappcore->mediaCache()->diskInfo( writerDevice() ).isDvdMedia() ) {
      m_comboSpeed->insertItem( i18n("Ignore") );
      d->haveIgnoreSpeed = true;
    }
    else
      d->haveIgnoreSpeed = false;

    if( !d->forceAutoSpeed ) {
      if( speeds.isEmpty() || writerDevice() == m_comboMedium->overrideDevice() ) {
	//
	// In case of the override device we do not know which medium will actually be used
	// So this is the only case in which we need to use the device's max writing speed
	//
	// But we need to know if it will be a CD or DVD medium. Since the override device
	// is only used for CD/DVD copy anyway we simply reply on the inserted medium's type.
	//
	int i = 1;
	int speed = ( k3bappcore->mediaCache()->diskInfo( writerDevice() ).isDvdMedia() ? 1385 : 175 );
	int max = writerDevice()->maxWriteSpeed();
	while( i*speed <= max ) {
	  insertSpeedItem( i*speed );
	  // a little hack to handle the stupid 2.4x DVD speed
	  if( i == 2 && speed == 1385 )
	    insertSpeedItem( (int)(2.4*1385.0) );
	  i = ( i == 1 ? 2 : i+2 );
	}

	//
	// Since we do not know the exact max writing speed if an override device is set (we can't becasue
	// the writer always returns the speed relative to the inserted medium) we allow the user to specify
	// the speed manually
	//
	m_comboSpeed->insertItem( i18n("More...") );
	d->haveManualSpeed = true;
      }
      else {
	for( QValueList<int>::iterator it = speeds.begin(); it != speeds.end(); ++it )
	  insertSpeedItem( *it );
      }
    }

    // try to reload last set speed
    if( d->lastSetSpeed == -1 )
      setSpeed( lastSpeed );
    else
      setSpeed( d->lastSetSpeed );
  }

  m_comboSpeed->setEnabled( writerDevice() != 0 );
}
Ejemplo n.º 2
0
void K3b::WriterSelectionWidget::slotSpeedChanged( int s )
{
    // the last item is the manual speed selection item
    if( d->haveManualSpeed && s == s_moreSpeedValue ) {
        slotManualSpeed();
    }
    else {
        d->lastSetSpeed = s;

        if( K3b::Device::Device* dev = writerDevice() )
            dev->setCurrentWriteSpeed( writerSpeed() );
    }
}
Ejemplo n.º 3
0
void K3bWriterSelectionWidget::slotSpeedChanged( int s )
{
  // the last item is the manual speed selection item
  if( d->haveManualSpeed && s == m_comboSpeed->count() - 1 ) {
    slotManualSpeed();
  }
  else {
    d->lastSetSpeed = d->indexSpeedMap[s];

    if( K3bDevice::Device* dev = writerDevice() )
      dev->setCurrentWriteSpeed( writerSpeed() );
  }
}
Ejemplo n.º 4
0
void K3b::WriterSelectionWidget::saveConfig( KConfigGroup c )
{
    c.writeEntry( "writing_speed", writerSpeed() );
    c.writeEntry( "writer_device", writerDevice() ? writerDevice()->blockDeviceName() : QString() );
    c.writeEntry( "writing_app", m_comboWritingApp->currentText() );
}
Ejemplo n.º 5
0
void K3b::WriterSelectionWidget::slotRefreshWriterSpeeds()
{
    if( writerDevice() ) {
        QList<int> speeds = k3bappcore->mediaCache()->writingSpeeds( writerDevice() );

        int lastSpeed = writerSpeed();

        clearSpeedCombo();

        m_comboSpeed->insertItem( s_autoSpeedValue, i18n("Auto") );
        if( Device::isDvdMedia( k3bappcore->mediaCache()->diskInfo( writerDevice() ).mediaType() ) ) {
            m_comboSpeed->insertItem( s_ignoreSpeedValue, i18n("Ignore") );
            d->haveIgnoreSpeed = true;
        }
        else
            d->haveIgnoreSpeed = false;

        if( !d->forceAutoSpeed ) {
            if( speeds.isEmpty() || writerDevice() == m_comboMedium->overrideDevice() ) {
                //
                // In case of the override device we do not know which medium will actually be used
                // So this is the only case in which we need to use the device's max writing speed
                //
                // But we need to know if it will be a CD or DVD medium. Since the override device
                // is only used for CD/DVD copy anyway we simply reply on the inserted medium's type.
                //
                int x1Speed = K3b::Device::SPEED_FACTOR_CD;
                if( Device::isDvdMedia( k3bappcore->mediaCache()->diskInfo( writerDevice() ).mediaType() ) ) {
                    x1Speed = K3b::Device::SPEED_FACTOR_DVD;
                }
                else if( Device::isBdMedia( k3bappcore->mediaCache()->diskInfo( writerDevice() ).mediaType() ) ) {
                    x1Speed = K3b::Device::SPEED_FACTOR_BD;
                }

                const int max = writerDevice()->maxWriteSpeed();
                for( int i = 1; i*x1Speed <= max; i = ( i == 1 ? 2 : i+2 ) ) {
                    insertSpeedItem( i*x1Speed );
                    // a little hack to handle the stupid 2.4x DVD speed
                    if( i == 2 && x1Speed == K3b::Device::SPEED_FACTOR_DVD )
                        insertSpeedItem( (int)(2.4*( double )K3b::Device::SPEED_FACTOR_DVD) );
                }
            }
            else {
                for( QList<int>::iterator it = speeds.begin(); it != speeds.end(); ++it )
                    insertSpeedItem( *it );
            }
        }


        //
        // Although most devices return all speeds properly there are still some dumb ones around
        // that don't. Users of those will need the possibility to set the speed manually even if
        // a medium is inserted.
        //
        if ( !d->forceAutoSpeed ) {
            m_comboSpeed->insertItem( s_moreSpeedValue, i18n("More...") );
            d->haveManualSpeed = true;
        }
        else {
            d->haveManualSpeed = false;
        }


        // try to reload last set speed
        if( d->lastSetSpeed == -1 )
            setSpeed( lastSpeed );
        else
            setSpeed( d->lastSetSpeed );
    }

    m_comboSpeed->setEnabled( writerDevice() != 0 );
}
Ejemplo n.º 6
0
void K3bWriterSelectionWidget::saveConfig( KConfigBase* c )
{
  c->writeEntry( "writing_speed", writerSpeed() );
  c->writeEntry( "writer_device", writerDevice() ? writerDevice()->devicename() : QString::null );
  c->writeEntry( "writing_app", m_comboWritingApp->currentText() );
}