Exemple #1
0
void K3b::DeviceMenu::Private::_k_aboutToShow()
{
    K3b::Medium medium = k3bcore->mediaCache()->medium( k3bappcore->appDeviceManager()->currentDevice() );

    actionContinueMultisession->setVisible(
        medium.content() == K3b::Medium::ContentData &&
        medium.diskInfo().appendable() );

    // non-empty cd/dvd/bd: copy
    actionCopy->setVisible( !medium.diskInfo().empty() );

    // rewritable: erase/format
    actionFormat->setVisible (
        !medium.diskInfo().empty() &&
        medium.diskInfo().rewritable() &&
        medium.diskInfo().mediaType() != K3b::Device::MEDIA_DVD_PLUS_RW );

    // audio content: rip audio
    actionRipAudio->setVisible( medium.content() & K3b::Medium::ContentAudio );

    // video dvd: videodvd rip
    actionRipVideoDVD->setVisible( medium.content() & K3b::Medium::ContentVideoDVD );

    // video cd: vcd rip
    actionRipVcd->setVisible( medium.content() & K3b::Medium::ContentVideoCD );
}
void K3b::WriterSelectionWidget::slotNewBurnMedium( K3b::Device::Device* dev )
{
    //
    // Try to select a medium that is better suited than the current one
    //
    if( dev && dev != writerDevice() ) {
        K3b::Medium medium = k3bappcore->mediaCache()->medium( dev );

        //
        // Always prefer newly inserted media over the override device
        //
        if( writerDevice() == m_comboMedium->overrideDevice() ) {
            setWriterDevice( dev );
        }

        //
        // Prefer an empty medium over one that has to be erased
        //
        else if( wantedMediumState() & K3b::Device::STATE_EMPTY &&
                 !k3bappcore->mediaCache()->diskInfo( writerDevice() ).empty() &&
                 medium.diskInfo().empty() ) {
            setWriterDevice( dev );
        }
    }
}
void K3b::DataMultisessionImportDialog::addMedium( const K3b::Medium& medium )
{
    QTreeWidgetItem* mediumItem = new QTreeWidgetItem( d->sessionView );
    QFont fnt( mediumItem->font(0) );
    fnt.setBold( true );
    mediumItem->setText( 0, medium.shortString() );
    mediumItem->setFont( 0, fnt );
    mediumItem->setIcon( 0, QIcon::fromTheme("media-optical-recordable") );

    const K3b::Device::Toc& toc = medium.toc();
    QTreeWidgetItem* sessionItem = 0;
    int lastSession = 0;
    for ( K3b::Device::Toc::const_iterator it = toc.begin(); it != toc.end(); ++it ) {
        const K3b::Device::Track& track = *it;

        if( track.session() != lastSession ) {
            lastSession = track.session();
            QString sessionInfo;
            if ( track.type() == K3b::Device::Track::TYPE_DATA ) {
                K3b::Iso9660 iso( medium.device(), track.firstSector().lba() );
                if ( iso.open() ) {
                    sessionInfo = iso.primaryDescriptor().volumeId;
                }
            }
            else {
                int numAudioTracks = 1;
                while ( it != toc.end()
                        && ( *it ).type() == K3b::Device::Track::TYPE_AUDIO
                        && ( *it ).session() == lastSession ) {
                    ++it;
                    ++numAudioTracks;
                }
                --it;
                sessionInfo = i18np("1 audio track", "%1 audio tracks", numAudioTracks );
            }

            sessionItem = new QTreeWidgetItem( mediumItem, sessionItem );
            sessionItem->setText( 0, i18n( "Session %1", lastSession )
                                     + ( sessionInfo.isEmpty() ? QString() : " (" + sessionInfo + ')' ) );
            if ( track.type() == K3b::Device::Track::TYPE_AUDIO )
                sessionItem->setIcon( 0, QIcon::fromTheme( "audio-x-generic" ) );
            else
                sessionItem->setIcon( 0, QIcon::fromTheme( "application-x-tar" ) );

            d->sessions.insert( sessionItem, SessionInfo( lastSession, medium.device() ) );
        }
    }

    if( 0 == lastSession ) {
        // the medium item in case we have no session info (will always use the last session)
        d->sessions.insert( mediumItem, SessionInfo( 0, medium.device() ) );
    }
    else {
        // we have a session item, there is no need to select the medium as a whole
        mediumItem->setFlags( mediumItem->flags() ^ Qt::ItemIsSelectable );
    }

    mediumItem->setExpanded( true );
}
 QString mediumToolTip( const K3b::Medium& m ) const {
     if( m.device() == m_overrideDevice )
         return m_overrideToolTip;
     else {
         QString s = K3b::MediaSelectionComboBox::mediumToolTip( m );
         if( !m.diskInfo().empty() && !(wantedMediumState() & m.diskInfo().diskState()) )
             s.append( "<p><i>" + i18n("Medium will be overwritten.") + "</i>" );
         return s;
     }
 }
Exemple #5
0
K3b::AudioRippingDialog::AudioRippingDialog( const K3b::Medium& medium,
                                              const KCDDB::CDInfo& entry,
                                              const QList<int>& tracks,
                                              QWidget *parent )
    : K3b::InteractionDialog( parent,
                            QString(),
                            QString(),
                            START_BUTTON|CANCEL_BUTTON,
                            START_BUTTON,
                            "Audio Ripping" ), // config group
      m_medium( medium ),
      m_cddbEntry( entry ),
      m_trackNumbers( tracks )
{
    d = new Private();

    setupGui();
    setupContextHelp();

    K3b::Msf length;
    K3b::Device::Toc toc = medium.toc();
    for( QList<int>::const_iterator it = m_trackNumbers.constBegin();
         it != m_trackNumbers.constEnd(); ++it ) {
        length += toc[*it].length();
    }
    setTitle( i18n("CD Ripping"),
              i18np("1 track (%2)", "%1 tracks (%2)",
                    m_trackNumbers.count(),length.toString()) );
}
void K3b::DataMultisessionImportDialog::updateMedia()
{
    d->sessionView->clear();
    d->sessions.clear();

    QList<K3b::Device::Device*> devices = k3bcore->deviceManager()->allDevices();

    bool haveMedium = false;
    for( QList<K3b::Device::Device *>::const_iterator it = devices.constBegin();
         it != devices.constEnd(); ++it ) {
        K3b::Medium medium = k3bappcore->mediaCache()->medium( *it );

        if ( medium.diskInfo().mediaType() & K3b::Device::MEDIA_WRITABLE &&
             medium.diskInfo().diskState() == K3b::Device::STATE_INCOMPLETE ) {
            addMedium( medium );
            haveMedium = true;
        }
        else if ( !medium.diskInfo().empty() &&
                  medium.diskInfo().mediaType() & ( K3b::Device::MEDIA_DVD_PLUS_RW|K3b::Device::MEDIA_DVD_RW_OVWR ) ) {
            addMedium( medium );
            haveMedium = true;
        }
    }

    if ( !haveMedium ) {
        QTreeWidgetItem* noMediaItem = new QTreeWidgetItem( d->sessionView );
        QFont fnt( noMediaItem->font(0) );
        fnt.setItalic( true );
        noMediaItem->setText( 0, i18n( "Please insert an appendable medium" ) );
        noMediaItem->setFont( 0, fnt );
    }
    else if( QTreeWidgetItem* firstMedium = d->sessionView->topLevelItem(0) ) {
        if( firstMedium->childCount() > 0 )
            d->sessionView->setCurrentItem( firstMedium->child( firstMedium->childCount()-1 ) );
        else
            d->sessionView->setCurrentItem( firstMedium );
    }

    d->sessionView->setEnabled( haveMedium );
}
Exemple #7
0
void K3b::DirView::showMediumInfo( const K3b::Medium& medium )
{
    if( !d->contextMediaInfoRequested ||
            medium.diskInfo().diskState() == K3b::Device::STATE_EMPTY ||
            medium.diskInfo().diskState() == K3b::Device::STATE_NO_MEDIA ) {

        // show cd info
        d->setCurrentView( d->infoView );
        d->infoView->reload( medium );
        return;
    }

#ifdef ENABLE_DVD_RIPPING
    else if( medium.content() & K3b::Medium::ContentVideoDVD ) {
        d->movieView->reload( medium );
        d->setCurrentView( d->movieView );
        return;
    }
#endif

    else if( medium.content() & K3b::Medium::ContentVideoCD ) {
        if( k3bcore ->externalBinManager() ->foundBin( "vcdxrip" ) ) {
            d->setCurrentView( d->videoView );
            d->videoView->reload( medium );
        }
        else {
            KMessageBox::sorry( this, i18n("K3b uses vcdxrip from the vcdimager package to rip Video CDs. "
                                           "Please make sure it is installed.") );
            k3bappcore->appDeviceManager()->mountDisk( medium.device() );
        }
    }

    else if( medium.content() & K3b::Medium::ContentAudio ) {
        d->setCurrentView( d->cdView );
        d->cdView->reload( medium );
    }

    else if( medium.content() & K3b::Medium::ContentData ) {
        k3bappcore->appDeviceManager()->mountDisk( medium.device() );
    }

    else {
        // show cd info
        d->setCurrentView( d->infoView );
        d->infoView->reload( medium );
    }

    d->contextMediaInfoRequested = false;
}
KIO::filesize_t K3b::MediaCopyDialog::neededSize() const
{
    K3b::Medium medium = k3bappcore->mediaCache()->medium( m_comboSourceDevice->selectedDevice() );

    if( medium.diskInfo().diskState() == K3b::Device::STATE_NO_MEDIA )
        return 0;
    else if( medium.diskInfo().mediaType() & (K3b::Device::MEDIA_DVD_RW_OVWR|K3b::Device::MEDIA_DVD_PLUS_RW) )
        return (KIO::filesize_t)medium.iso9660Descriptor().volumeSpaceSize * (KIO::filesize_t)2048;
    else if ( m_comboCopyMode->currentIndex() == 0 )
        return medium.diskInfo().size().mode1Bytes();
    else
        return medium.diskInfo().size().rawBytes();
}
 QString mediumString( const K3b::Medium& m ) const {
     if( m.device() == m_overrideDevice )
         return m_overrideString;
     else
         return K3b::MediaSelectionComboBox::mediumString( m );
 }
 bool showMedium( const K3b::Medium& m ) const {
     return ( m.device() == m_overrideDevice ||
              K3b::MediaSelectionComboBox::showMedium( m ) );
 }
void K3b::ImageWritingDialog::toggleAll()
{

    K3b::Medium medium = k3bappcore->mediaCache()->medium( d->writerSelectionWidget->writerDevice() );

    // set usable writing apps
    // for now we only restrict ourselves in case of CD images
    switch( d->currentImageType() ) {
    case IMAGE_CDRDAO_TOC:
        d->writerSelectionWidget->setSupportedWritingApps( K3b::WritingAppCdrdao );
        break;
    case IMAGE_CDRECORD_CLONE:
        d->writerSelectionWidget->setSupportedWritingApps( K3b::WritingAppCdrecord );
        break;
    default: {
        K3b::WritingApps apps = K3b::WritingAppCdrecord;
        if ( d->currentImageType() == IMAGE_ISO ) {
            // DVD/BD is always ISO here
            apps |= K3b::WritingAppGrowisofs;
        }
        if ( K3b::Device::isCdMedia( medium.diskInfo().mediaType() ) )
            apps |= K3b::WritingAppCdrdao;

        d->writerSelectionWidget->setSupportedWritingApps( apps );
        break;
    }
    }

    // set a wanted media type (DVD/BD -> only ISO)
    if ( d->currentImageType() == IMAGE_ISO ||
         d->currentImageType() == IMAGE_UNKNOWN ) {
        d->writerSelectionWidget->setWantedMediumType( K3b::Device::MEDIA_WRITABLE );
    }
    else {
        d->writerSelectionWidget->setWantedMediumType( K3b::Device::MEDIA_WRITABLE_CD );
    }

    // set wanted image size
    if ( d->currentImageType() == IMAGE_ISO )
        d->writerSelectionWidget->setWantedMediumSize( K3b::filesize( KUrl(d->imagePath()) )/2048 );
    else
        d->writerSelectionWidget->setWantedMediumSize( Msf() );

    // cdrecord clone and cue both need DAO
    if( d->writerSelectionWidget->writingApp() != K3b::WritingAppCdrdao
        && ( d->currentImageType() == IMAGE_ISO ||
             d->currentImageType() == IMAGE_AUDIO_CUE ) )
        d->writingModeWidget->determineSupportedModesFromMedium( medium );
    else
        d->writingModeWidget->setSupportedModes( K3b::WritingModeSao );

    // enable the Write-Button if we found a valid image or the user forced an image type
    setButtonEnabled( START_BUTTON, d->writerSelectionWidget->writerDevice()
                      && d->currentImageType() != IMAGE_UNKNOWN
                      && QFile::exists( d->imagePath() ) );

    // some stuff is only available for iso images
    if( d->currentImageType() == IMAGE_ISO ) {
        d->checkVerify->show();
        if( !d->advancedTabVisible ) {
            d->advancedTabIndex = d->optionTabbed->addTab( d->advancedTab, i18n("Advanced") );
        }
        d->advancedTabVisible = true;
        if( d->checkDummy->isChecked() ) {
            d->checkVerify->setEnabled( false );
            d->checkVerify->setChecked( false );
        }
        else
            d->checkVerify->setEnabled( true );
    }
    else {
        if( d->advancedTabVisible ) {
            d->optionTabbed->removeTab( d->advancedTabIndex );
        }
        d->advancedTabVisible = false;
        d->checkVerify->hide();
    }


    // and some other stuff only makes sense for audio cues
    if( d->currentImageType() == IMAGE_AUDIO_CUE ) {
        if( !d->tempPathTabVisible )
            d->tempPathTabIndex = d->optionTabbed->addTab( d->tempPathTab, i18n("&Image") );
        d->tempPathTabVisible = true;
        d->tempDirSelectionWidget->setDisabled( !d->checkCacheImage->isChecked() );
    }
    else {
        if( d->tempPathTabVisible ) {
            d->optionTabbed->removeTab( d->tempPathTabIndex );
        }
        d->tempPathTabVisible = false;
    }
    d->checkCacheImage->setVisible( d->currentImageType() == IMAGE_AUDIO_CUE );

    d->spinCopies->setEnabled( !d->checkDummy->isChecked() );


    if( QTreeWidgetItem* item = d->infoView->topLevelItem( 0 ) ) {
        item->setForeground( 1,
                             d->currentImageType() != d->foundImageType
                             ? d->negativeTextColor : d->normalTextColor );
    }
}
Exemple #12
0
void K3b::MediaCopyDialog::toggleAll()
{
    updateOverrideDevice();

    K3b::Device::Device* readDev = m_comboSourceDevice->selectedDevice();
    K3b::Device::Device* burnDev = m_writerSelectionWidget->writerDevice();
    K3b::Medium sourceMedium = k3bappcore->mediaCache()->medium( readDev );
    K3b::Medium burnMedium = k3bappcore->mediaCache()->medium( burnDev );

    if ( burnDev ) {
        if( readDev != burnDev &&
            burnMedium.diskInfo().mediaType() & K3b::Device::MEDIA_DVD_PLUS_ALL ) {
            // no simulation support for DVD+R(W) media
            m_checkSimulate->setChecked(false);
            m_checkSimulate->setEnabled(false);
        }
        else {
            m_checkSimulate->setDisabled( m_checkOnlyCreateImage->isChecked() );
        }
    }
    else {
        m_checkSimulate->setEnabled( !m_checkOnlyCreateImage->isChecked() );
    }

    m_checkDeleteImages->setEnabled( !m_checkOnlyCreateImage->isChecked() && m_checkCacheImage->isChecked() );
    m_spinCopies->setDisabled( m_checkSimulate->isChecked() || m_checkOnlyCreateImage->isChecked() );
    m_tempDirSelectionWidget->setDisabled( !m_checkCacheImage->isChecked() && !m_checkOnlyCreateImage->isChecked() );
    m_writerSelectionWidget->setDisabled( m_checkOnlyCreateImage->isChecked() );
    m_checkCacheImage->setEnabled( !m_checkOnlyCreateImage->isChecked() );
    m_writingModeWidget->setEnabled( !m_checkOnlyCreateImage->isChecked() );

    // FIXME: no verification for CD yet
    m_checkVerifyData->setDisabled( sourceMedium.diskInfo().mediaType() & K3b::Device::MEDIA_CD_ALL ||
                                    sourceMedium.content() & K3b::Medium::ContentAudio ||
                                    m_checkSimulate->isChecked() );

    // we can only clone single session CDs
    if( K3b::Device::isCdMedia( sourceMedium.diskInfo().mediaType() ) ) {
        m_writerSelectionWidget->setWantedMediumType( K3b::Device::MEDIA_WRITABLE_CD );
        m_writerSelectionWidget->setSupportedWritingApps( K3b::WritingAppCdrecord );

        if ( sourceMedium.toc().sessions() == 1 ) {
            m_comboCopyMode->setEnabled( true );
        }
        else {
            m_comboCopyMode->setEnabled( false );
            m_comboCopyMode->setCurrentIndex( 0 );
        }
    }
    else {
        m_writerSelectionWidget->setSupportedWritingApps( K3b::WritingAppGrowisofs|K3b::WritingAppCdrecord );

        m_comboCopyMode->setEnabled( false );
        m_comboCopyMode->setCurrentIndex( 0 );

        // FIXME: at some point the media combo should also handle media sizes!

        if ( K3b::Device::isDvdMedia( sourceMedium.diskInfo().mediaType() ) ) {
            m_writerSelectionWidget->setWantedMediumType( sourceMedium.diskInfo().numLayers() > 1 &&
                                                          sourceMedium.diskInfo().size() > MediaSizeDvd4Gb
                                                          ? K3b::Device::MEDIA_WRITABLE_DVD_DL
                                                          : K3b::Device::MEDIA_WRITABLE_DVD );
        }
        else if( Device::isBdMedia( sourceMedium.diskInfo().mediaType() ) ) {
            // FIXME: do the same single layer/dual layer thing like with DVD
            m_writerSelectionWidget->setWantedMediumType( K3b::Device::MEDIA_WRITABLE_BD );
        }
        else {
            // generic media request in case we have no source medium
            m_writerSelectionWidget->setWantedMediumType( K3b::Device::MEDIA_WRITABLE );
        }
    }

    // CD Cloning
    if( m_comboCopyMode->currentIndex() == 1 ) {
        // cdrecord does not support cloning on-the-fly
        m_checkCacheImage->setChecked(true);
        m_checkCacheImage->setEnabled(false);

        m_writingModeWidget->setSupportedModes( K3b::WritingModeRaw );
    }

    // Normal CD/DVD/Blu-ray copy
    else {
        //
        // If the same device is used for reading and writing all we can present is a fuzzy
        // selection of the writing mode
        //
        if( burnDev == readDev ) {
            K3b::WritingModes modes = 0;
            if ( sourceMedium.diskInfo().mediaType() & K3b::Device::MEDIA_CD_ALL ) {
                modes = K3b::WritingModeTao|K3b::WritingModeSao|K3b::WritingModeRaw;
            }
            else if ( sourceMedium.diskInfo().mediaType() & K3b::Device::MEDIA_DVD_ALL ) {
                // only auto for DVD+R(W)
                if( burnDev->writeCapabilities() & (K3b::Device::MEDIA_DVD_R|K3b::Device::MEDIA_DVD_RW) ) {
                    modes |= K3b::WritingModeSao|K3b::WritingModeRestrictedOverwrite;
                    if( burnDev->featureCurrent( K3b::Device::FEATURE_INCREMENTAL_STREAMING_WRITABLE ) != 0 )
                        modes |= K3b::WritingModeIncrementalSequential;
                }

                // TODO: once we have layer jump support: this is where it goes
//               if ( burnDev->supportsWritingMode( K3b::Device::WRITING_MODE_LAYER_JUMP ) ) {
//                   modes |= K3b::Device::WRITING_MODE_LAYER_JUMP;
//               }
            }
            else if ( sourceMedium.diskInfo().mediaType() & K3b::Device::MEDIA_BD_ALL ) {
                // no modes, only auto
            }

            m_writingModeWidget->setSupportedModes( modes );
        }
        else {
            m_writingModeWidget->determineSupportedModesFromMedium( burnDev );
        }
    }

    m_tempDirSelectionWidget->setNeededSize( neededSize() );

    if( sourceMedium.toc().contentType() == K3b::Device::DATA &&
        sourceMedium.toc().count() == 1 ) {
        m_tempDirSelectionWidget->setSelectionMode( K3b::TempDirSelectionWidget::FILE );
        QString mediumName = sourceMedium.volumeId().toLower();
        if ( mediumName.isEmpty() )
            mediumName = "k3bimage";
        m_tempDirSelectionWidget->setDefaultImageFileName( mediumName + QLatin1String(".iso"), true );
    }
    else {
        m_tempDirSelectionWidget->setSelectionMode( K3b::TempDirSelectionWidget::DIR );

        if ( sourceMedium.content() & K3b::Medium::ContentData && !sourceMedium.volumeId().isEmpty() ) {
            m_tempDirSelectionWidget->setTempPath( m_tempDirSelectionWidget->tempDirectory() + sourceMedium.volumeId().toLower() );
        }
        else if ( sourceMedium.content() & K3b::Medium::ContentAudio && !sourceMedium.cdText().title().isEmpty() ) {
            m_tempDirSelectionWidget->setTempPath( m_tempDirSelectionWidget->tempDirectory() + sourceMedium.cdText().title() );
        }
        else {
            m_tempDirSelectionWidget->setTempPath( m_tempDirSelectionWidget->tempDirectory() ); // let the copy job figure it out
        }
    }

    m_groupAdvancedAudioOptions->setEnabled( sourceMedium.content() & K3b::Medium::ContentAudio && m_comboCopyMode->currentIndex() == 0 );
    m_groupAdvancedDataOptions->setEnabled( sourceMedium.content() & K3b::Medium::ContentData );

    setButtonEnabled( START_BUTTON,
                      m_comboSourceDevice->selectedDevice() &&
                      (burnDev || m_checkOnlyCreateImage->isChecked()) );

    K3b::InteractionDialog::toggleAll();
}
Exemple #13
0
void K3b::MediaCopyDialog::slotStartClicked()
{
    //
    // Let's check the available size
    //
    if( m_checkCacheImage->isChecked() || m_checkOnlyCreateImage->isChecked() ) {
        if( neededSize() > m_tempDirSelectionWidget->freeTempSpace() ) {
            if( KMessageBox::warningContinueCancel( this, i18n("There does not seem to be enough free space in the temporary folder. "
                                                               "Write anyway?") ) == KMessageBox::Cancel )
                return;
        }
    }

    K3b::Device::Device* readDev = m_comboSourceDevice->selectedDevice();
    K3b::Device::Device* burnDev = m_writerSelectionWidget->writerDevice();
    K3b::Medium sourceMedium = k3bappcore->mediaCache()->medium( readDev );
    K3b::Medium burnMedium = k3bappcore->mediaCache()->medium( burnDev );

    K3b::JobProgressDialog* dlg = 0;
    if( m_checkOnlyCreateImage->isChecked() ) {
        dlg = new K3b::JobProgressDialog( parentWidget() );
    }
    else {
        dlg = new K3b::BurnProgressDialog( parentWidget() );
    }

    K3b::BurnJob* burnJob = 0;

    if( m_comboCopyMode->currentIndex() == 1 ) {

        //
        // check for m_tempDirSelectionWidget->tempPath() and
        // m_tempDirSelectionWidget-tempPath() + ".toc"
        //
        if( QFileInfo( m_tempDirSelectionWidget->tempPath() ).isFile() ) {
            if( KMessageBox::warningContinueCancel( this,
                                                    i18n("Do you want to overwrite %1?",m_tempDirSelectionWidget->tempPath()),
                                                    i18n("File Exists"),
                                                    KStandardGuiItem::overwrite() )
                != KMessageBox::Continue )
                return;
        }

        if( QFileInfo( m_tempDirSelectionWidget->tempPath() + ".toc" ).isFile() ) {
            if( KMessageBox::warningContinueCancel( this,
                                                    i18n("Do you want to overwrite %1?",m_tempDirSelectionWidget->tempPath() + ".toc"),
                                                    i18n("File Exists"),
                                                    KStandardGuiItem::overwrite() )
                != KMessageBox::Continue )
                return;
        }

        K3b::CloneJob* job = new K3b::CloneJob( dlg, this );

        job->setWriterDevice( m_writerSelectionWidget->writerDevice() );
        job->setReaderDevice( m_comboSourceDevice->selectedDevice() );
        job->setImagePath( m_tempDirSelectionWidget->tempPath() );
        job->setNoCorrection( m_checkNoCorrection->isChecked() );
        job->setRemoveImageFiles( m_checkDeleteImages->isChecked() && !m_checkOnlyCreateImage->isChecked() );
        job->setOnlyCreateImage( m_checkOnlyCreateImage->isChecked() );
        job->setSimulate( m_checkSimulate->isChecked() );
        job->setWriteSpeed( m_writerSelectionWidget->writerSpeed() );
        job->setCopies( m_checkSimulate->isChecked() ? 1 : m_spinCopies->value() );
        job->setReadRetries( m_spinDataRetries->value() );

        burnJob = job;
    }
    else if ( sourceMedium.diskInfo().mediaType() & K3b::Device::MEDIA_CD_ALL ) {
        K3b::CdCopyJob* job = new K3b::CdCopyJob( dlg, this );

        job->setWriterDevice( m_writerSelectionWidget->writerDevice() );
        job->setReaderDevice( m_comboSourceDevice->selectedDevice() );
        job->setSpeed( m_writerSelectionWidget->writerSpeed() );
        job->setSimulate( m_checkSimulate->isChecked() );
        job->setOnTheFly( !m_checkCacheImage->isChecked() );
        job->setKeepImage( !m_checkDeleteImages->isChecked() || m_checkOnlyCreateImage->isChecked() );
        job->setOnlyCreateImage( m_checkOnlyCreateImage->isChecked() );
        job->setTempPath( m_tempDirSelectionWidget->plainTempPath() );
        job->setCopies( m_checkSimulate->isChecked() ? 1 : m_spinCopies->value() );
        job->setParanoiaMode( m_comboParanoiaMode->currentText().toInt() );
        job->setDataReadRetries( m_spinDataRetries->value() );
        job->setAudioReadRetries( m_spinAudioRetries->value() );
        job->setCopyCdText( m_checkReadCdText->isChecked() );
        job->setIgnoreDataReadErrors( m_checkIgnoreDataReadErrors->isChecked() );
        job->setIgnoreAudioReadErrors( m_checkIgnoreAudioReadErrors->isChecked() );
        job->setNoCorrection( m_checkNoCorrection->isChecked() );
        job->setWritingMode( m_writingModeWidget->writingMode() );

        burnJob = job;
    }
    else if ( sourceMedium.diskInfo().mediaType() & ( K3b::Device::MEDIA_DVD_ALL|K3b::Device::MEDIA_BD_ALL ) ) {
        K3b::DvdCopyJob* job = new K3b::DvdCopyJob( dlg, this );

        job->setWriterDevice( m_writerSelectionWidget->writerDevice() );
        job->setReaderDevice( m_comboSourceDevice->selectedDevice() );
        job->setImagePath( m_tempDirSelectionWidget->tempPath() );
        job->setRemoveImageFiles( m_checkDeleteImages->isChecked() && !m_checkOnlyCreateImage->isChecked() );
        job->setOnlyCreateImage( m_checkOnlyCreateImage->isChecked() );
        job->setSimulate( m_checkSimulate->isChecked() );
        job->setOnTheFly( !m_checkCacheImage->isChecked() );
        job->setWriteSpeed( m_writerSelectionWidget->writerSpeed() );
        job->setCopies( m_checkSimulate->isChecked() ? 1 : m_spinCopies->value() );
        job->setWritingMode( m_writingModeWidget->writingMode() );
        job->setIgnoreReadErrors( m_checkIgnoreDataReadErrors->isChecked() );
        job->setReadRetries( m_spinDataRetries->value() );
        job->setVerifyData( m_checkVerifyData->isChecked() );

        burnJob = job;
    }
    else {
        // do not translate this as it is not intended to be included in the stable version!
        KMessageBox::sorry( this, "Ups", "No copy support for this source media type yet." );
        return;
    }

    hide();

    dlg->startJob( burnJob );

    delete dlg;
    delete burnJob;

    if( KConfigGroup( KGlobal::config(), "General Options" ).readEntry( "keep action dialogs open", false ) )
        show();
    else
        close();
}
Exemple #14
0
void K3b::FillStatusDisplay::slotMediumChanged( K3b::Device::Device* )
{
    if( d->actionAuto->isChecked() ) {
        //
        // now search for a usable medium
        // if we find exactly one usable or multiple with the same size
        // we use that size
        //
        K3b::Medium autoSelectedMedium;
        QList<K3b::Device::Device*> devs = k3bcore->deviceManager()->burningDevices();

        Q_FOREACH( K3b::Device::Device* dev, devs ) {
            const K3b::Medium medium = k3bappcore->mediaCache()->medium( dev );

            if( ( medium.diskInfo().empty() ||
                  medium.diskInfo().appendable() ||
                  medium.diskInfo().rewritable() ) &&
                ( medium.diskInfo().mediaType() & d->doc->supportedMediaTypes() ) ) {

                // We use a 10% margin to allow the user to fine-tune project sizes
                // However, if we have a bigger medium we always use that
                if ( ( double )d->doc->size() <= ( double )( medium.diskInfo().capacity().mode1Bytes() ) * 1.1 ) {

                    // first usable medium
                    if( !autoSelectedMedium.isValid() ) {
                        autoSelectedMedium = medium;
                    }

                    else {
                        // prefer the medium which can fit the whole doc
                        if ( d->doc->length() <= medium.diskInfo().capacity() &&
                             d->doc->length() > autoSelectedMedium.diskInfo().capacity() ) {
                            autoSelectedMedium = medium;
                        }

                        // roughly compare the sizes of the two usable media. If they match, carry on.
                        else if( medium.diskInfo().capacity().lba()/75/60
                                 != autoSelectedMedium.diskInfo().capacity().lba()/75/60 ) {
                            // different usable media -> fallback
                            autoSelectedMedium = K3b::Medium();
                            break;
                        }
                    }
                }
            }
        }

        if( autoSelectedMedium.isValid() ) {
            d->displayWidget->setCdSize( autoSelectedMedium.diskInfo().capacity().lba() );
        }
        else {
            bool haveDVD = !k3bcore->deviceManager()->dvdWriter().isEmpty();
            bool haveBD = !k3bcore->deviceManager()->blueRayWriters().isEmpty();


            // default fallback
            // we do not have BD- or HD-DVD only projects
            if( ( d->doc->supportedMediaTypes() & K3b::Device::MEDIA_CD_ALL &&
                  d->doc->length().lba() <= MediaSizeCd80Min ) ||
                !( d->doc->supportedMediaTypes() & ( K3b::Device::MEDIA_DVD_ALL|K3b::Device::MEDIA_BD_ALL ) ) ||
                ( !haveDVD && !haveBD ) ) {
                d->displayWidget->setCdSize( MediaSizeCd80Min );
            }
            else if ( haveDVD && (
                          ( d->doc->supportedMediaTypes() & K3b::Device::MEDIA_DVD_ALL &&
                            d->doc->length().lba() <= MediaSizeDvd8Gb ) ||
                          !( d->doc->supportedMediaTypes() & K3b::Device::MEDIA_BD_ALL ) ||
                          !haveBD ) ) {
                if( d->doc->length().lba() > MediaSizeDvd4Gb )
                    d->displayWidget->setCdSize( MediaSizeDvd8Gb );
                else
                    d->displayWidget->setCdSize( MediaSizeDvd4Gb );
            }
            else if ( d->doc->length().lba() <= MediaSizeBluRay25Gb ) {
                d->displayWidget->setCdSize( MediaSizeBluRay25Gb );
            }
            else {
                d->displayWidget->setCdSize( MediaSizeBluRay50Gb );
            }
        }
    }