Ejemplo n.º 1
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()) );
}
Ejemplo n.º 2
0
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 );
}
Ejemplo n.º 3
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();
}