Пример #1
0
KPushButton * PostWidget::addButton(const QString & objName, const QString & toolTip, const KIcon & icon)
{
    KPushButton * button = new KPushButton(icon, QString(), _mainWidget);
    button->setObjectName(objName);
    button->setToolTip(toolTip);
    button->setIconSize(QSize(16,16));
    button->setMinimumSize(QSize(20, 20));
    button->setMaximumSize(QSize(20, 20));
    button->setFlat(true);
    button->setVisible(false);
    button->setCursor(Qt::PointingHandCursor);

    d->mUiButtons.insert(objName, button);
    d->buttonsLayout->addWidget( button, 1, d->mUiButtons.count() );
    return button;
}
ConfigBackendsPage::ConfigBackendsPage( Config *_config, QWidget *parent )
    : ConfigPageBase( parent ),
    config( _config )
{
    QVBoxLayout *box = new QVBoxLayout( this );

    QFont groupFont;
    groupFont.setBold( true );

    QLabel *lCdRipper = new QLabel( i18n("CD ripper"), this );
    lCdRipper->setFont( groupFont );
    box->addWidget( lCdRipper );

    box->addSpacing( ConfigDialogSpacingSmall );

    QHBoxLayout *ripperBox = new QHBoxLayout();
    ripperBox->addSpacing( ConfigDialogOffset );
    box->addLayout( ripperBox );
    QLabel *lSelectorRipper = new QLabel( i18n("Use plugin:"), this );
    ripperBox->addWidget( lSelectorRipper );
    ripperBox->setStretchFactor( lSelectorRipper, 2 );
    cSelectorRipper = new KComboBox( this );
    cSelectorRipper->addItems( config->data.backends.rippers );
    ripperBox->addWidget( cSelectorRipper );
    ripperBox->setStretchFactor( cSelectorRipper, 1 );
    connect( cSelectorRipper, SIGNAL(activated(int)), this, SLOT(somethingChanged()) );
    connect( cSelectorRipper, SIGNAL(activated(const QString&)), this, SLOT(ripperChanged(const QString&)) );
    pConfigureRipper = new KPushButton( KIcon("configure"), "", this );
    pConfigureRipper->setFixedSize( cSelectorRipper->sizeHint().height(), cSelectorRipper->sizeHint().height() );
    pConfigureRipper->setFlat( true );
    ripperBox->addWidget( pConfigureRipper );
    ripperBox->setStretchFactor( pConfigureRipper, 1 );
    connect( pConfigureRipper, SIGNAL(clicked()), this, SLOT(configureRipper()) );

    box->addSpacing( ConfigDialogSpacingBig );

    QLabel *lFilters = new QLabel( i18n("Filters"), this );
    lFilters->setFont( groupFont );
    box->addWidget( lFilters );

    box->addSpacing( ConfigDialogSpacingSmall );

    QHBoxLayout *filterBox = new QHBoxLayout();
    filterBox->addSpacing( ConfigDialogOffset );
    box->addLayout( filterBox );
    QGridLayout *filterGrid = new QGridLayout();

    int row = 0;
    foreach( const QString filterPluginName, config->data.backends.filters )
    {
        if( row == 0 )
        {
            QLabel *lSelectorFilter = new QLabel( i18n("Enable plugins:"), this );
            filterGrid->addWidget( lSelectorFilter, row, 0 );
        }

        QCheckBox *newCheckBox = new QCheckBox( filterPluginName, this );
        newCheckBox->setChecked( config->data.backends.enabledFilters.contains(filterPluginName) );
        filterGrid->addWidget( newCheckBox, row, 1 );
        filterCheckBoxes.append( newCheckBox );
        connect( newCheckBox, SIGNAL(stateChanged(int)), this, SLOT(somethingChanged()) );

        KPushButton *newConfigButton = new KPushButton( KIcon("configure"), "", this );
        newConfigButton->setFixedSize( cSelectorRipper->sizeHint().height(), cSelectorRipper->sizeHint().height() );
        newConfigButton->setFlat( true );
        filterGrid->addWidget( newConfigButton, row, 2 );
        connect( newConfigButton, SIGNAL(clicked()), this, SLOT(configureFilter()) );
        filterConfigButtons.append( newConfigButton );

        FilterPlugin *plugin = qobject_cast<FilterPlugin*>(config->pluginLoader()->backendPluginByName(filterPluginName));
        if( plugin )
        {
            newConfigButton->setEnabled( plugin->isConfigSupported(BackendPlugin::General,"") );
        }
        else
        {
            newConfigButton->setEnabled( false );
        }

        if( newConfigButton->isEnabled() )
            newConfigButton->setToolTip( i18n("Configure %1 ...",filterPluginName) );

        row++;
    }

    filterGrid->setColumnStretch( 0, 2 );
    filterGrid->setColumnStretch( 1, 1 );
    filterBox->addLayout( filterGrid );

    box->addSpacing( ConfigDialogSpacingBig );

    QLabel *lPriorities = new QLabel( i18n("Priorities"), this );
    lPriorities->setFont( groupFont );
    box->addWidget( lPriorities );

    box->addSpacing( ConfigDialogSpacingSmall );

    QVBoxLayout *formatBox = new QVBoxLayout();
    box->addLayout( formatBox, 1 );

    QHBoxLayout *formatSelectorBox = new QHBoxLayout();
    formatSelectorBox->addSpacing( ConfigDialogOffset );
    formatBox->addLayout( formatSelectorBox );
    QLabel *lSelectorFormat = new QLabel( i18n("Configure plugin priorities for format:"), this );
    formatSelectorBox->addWidget( lSelectorFormat );
    cSelectorFormat = new KComboBox( this );
    cSelectorFormat->addItems( config->pluginLoader()->formatList(PluginLoader::Possibilities(PluginLoader::Encode|PluginLoader::Decode|PluginLoader::ReplayGain),PluginLoader::CompressionType(PluginLoader::InferiorQuality|PluginLoader::Lossy|PluginLoader::Lossless|PluginLoader::Hybrid)) );
    cSelectorFormat->removeItem( cSelectorFormat->findText("wav") );
    cSelectorFormat->removeItem( cSelectorFormat->findText("audio cd") );
    formatSelectorBox->addWidget( cSelectorFormat );
    connect( cSelectorFormat, SIGNAL(activated(const QString&)), this, SLOT(formatChanged(const QString&)) );
    formatSelectorBox->addStretch();

    QHBoxLayout *formatBackendsBox = new QHBoxLayout();
    formatBackendsBox->addSpacing( ConfigDialogOffset );
    formatBox->addLayout( formatBackendsBox );
    decoderList = new BackendsListWidget( i18n("Decoder"), config, this );
    formatBackendsBox->addWidget( decoderList );
    connect( decoderList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) );
    encoderList = new BackendsListWidget( i18n("Encoder"), config, this );
    formatBackendsBox->addWidget( encoderList );
    connect( encoderList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) );
    replaygainList = new BackendsListWidget( i18n("Replay Gain"), config, this );
    formatBackendsBox->addWidget( replaygainList );
    connect( replaygainList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) );

    QHBoxLayout *optimizationsBox = new QHBoxLayout();
    optimizationsBox->addSpacing( ConfigDialogOffset );
    formatBox->addLayout( optimizationsBox );
    optimizationsBox->addStretch();
    pShowOptimizations = new KPushButton( KIcon("games-solve"), i18n("Show possible optimizations"), this );
    optimizationsBox->addWidget( pShowOptimizations );
    connect( pShowOptimizations, SIGNAL(clicked()), this, SLOT(showOptimizations()) );
    optimizationsBox->addStretch();

    box->addStretch( 2 );

    ripperChanged( cSelectorRipper->currentText() );
    formatChanged( cSelectorFormat->currentText() );
}