Beispiel #1
0
void MediaImpl::createMediumEntry(KIO::UDSEntry &entry, const Medium &medium)
{
    kdDebug(1219) << "MediaProtocol::createMedium" << endl;

    QString url = "media:/" + medium.name();

    kdDebug(1219) << "url = " << url << ", mime = " << medium.mimeType() << endl;

    entry.clear();

    addAtom(entry, KIO::UDS_URL, 0, url);

    QString label = KIO::encodeFileName(medium.prettyLabel());
    addAtom(entry, KIO::UDS_NAME, 0, label);

    addAtom(entry, KIO::UDS_FILE_TYPE, S_IFDIR);

    addAtom(entry, KIO::UDS_MIME_TYPE, 0, medium.mimeType());
    addAtom(entry, KIO::UDS_GUESSED_MIME_TYPE, 0, "inode/directory");

    if(!medium.iconName().isEmpty())
    {
        addAtom(entry, KIO::UDS_ICON_NAME, 0, medium.iconName());
    }
    else
    {
        QString mime = medium.mimeType();
        QString icon = KMimeType::mimeType(mime)->icon(mime, false);
        addAtom(entry, KIO::UDS_ICON_NAME, 0, icon);
    }

    if(medium.needMounting())
    {
        addAtom(entry, KIO::UDS_ACCESS, 0400);
    }
    else
    {
        KURL url = medium.prettyBaseURL();
        entry += extractUrlInfos(url);
    }
}
Beispiel #2
0
DeviceConfigureDialog::DeviceConfigureDialog( const Medium &medium )
        : KDialogBase( amaroK::mainWindow(), "deviceconfiguredialog", true, QString("Select Plugin for " + medium.name()), Ok|Cancel, Ok, false )
{
    m_medium = new Medium( medium );
    kapp->setTopWidget( this );
    setCaption( kapp->makeStdCaption( i18n( "Configure Media Device" ) ) );
    showButtonApply( false );

    QVBox* vbox = makeVBoxMainWidget();
    vbox->setSpacing( KDialog::spacingHint() );

    QLabel *connectLabel = 0;
    m_connectEdit = 0;
    QLabel *disconnectLabel = 0;
    m_disconnectEdit = 0;
    m_transcodeCheck = 0;
    QButtonGroup *transcodeGroup = 0;
    m_transcodeAlways = 0;
    m_transcodeWhenNecessary = 0;
    m_transcodeRemove = 0;

    MediaDevice* device = MediaBrowser::instance()->deviceFromId( m_medium->id() );

    if( device )
    {
        device->loadConfig();

        // pre-connect/post-disconnect (mount/umount)
        connectLabel = new QLabel( vbox );
        connectLabel->setText( i18n( "Pre-&connect command:" ) );
        m_connectEdit = new HintLineEdit( device->m_preconnectcmd, vbox );
        m_connectEdit->setHint( i18n( "Example: mount %d" ) );
        connectLabel->setBuddy( m_connectEdit );
        QToolTip::add( m_connectEdit, i18n( "Set a command to be run before connecting to your device (e.g. a mount command) here.\n%d is replaced by the device node, %m by the mount point.\nEmpty commands are not executed." ) );

        disconnectLabel = new QLabel( vbox );
        disconnectLabel->setText( i18n( "Post-&disconnect command:" ) );
        m_disconnectEdit = new HintLineEdit( device->m_postdisconnectcmd, vbox );
        disconnectLabel->setBuddy( m_disconnectEdit );
        m_disconnectEdit->setHint( i18n( "Example: eject %d" ) );
        QToolTip::add( m_disconnectEdit, i18n( "Set a command to be run after disconnecting from your device (e.g. an eject command) here.\n%d is replaced by the device node, %m by the mount point.\nEmpty commands are not executed." ) );

        // transcode
        m_transcodeCheck = new QCheckBox( vbox );
        m_transcodeCheck->setText( i18n( "&Transcode before transferring to device" ) );
        m_transcodeCheck->setChecked( device->m_transcode );

        transcodeGroup = new QVButtonGroup( vbox );
        transcodeGroup->setTitle( i18n( "Transcode to preferred format for device" ) );
        m_transcodeAlways = new QRadioButton( transcodeGroup );
        m_transcodeAlways->setText( i18n( "Whenever possible" ) );
        m_transcodeAlways->setChecked( device->m_transcodeAlways );
        m_transcodeWhenNecessary = new QRadioButton( transcodeGroup );
        m_transcodeWhenNecessary->setText( i18n( "When necessary" ) );
        m_transcodeWhenNecessary->setChecked( !device->m_transcodeAlways );
        connect( m_transcodeCheck, SIGNAL(toggled( bool )),
                transcodeGroup, SLOT(setEnabled( bool )) );
        transcodeGroup->insert( m_transcodeAlways );
        transcodeGroup->insert( m_transcodeWhenNecessary );
        m_transcodeRemove = new QCheckBox( transcodeGroup );
        m_transcodeRemove->setText( i18n( "Remove transcoded files after transfer" ) );
        m_transcodeRemove->setChecked( device->m_transcodeRemove );

        const ScriptManager *sm = ScriptManager::instance();
        m_transcodeCheck->setEnabled( sm->transcodeScriptRunning() != QString::null );
        transcodeGroup->setEnabled( sm->transcodeScriptRunning() != QString::null && device->m_transcode );
        if( sm->transcodeScriptRunning().isNull() )
        {
            QToolTip::add( m_transcodeCheck, i18n( "For this feature, a script of type \"Transcode\" has to be running" ) );
            QToolTip::add( transcodeGroup, i18n( "For this feature, a script of type \"Transcode\" has to be running" ) );
        }

        device->addConfigElements( vbox );
    }

    m_accepted = false;
}