Exemple #1
0
bool OptionsDetailed::setCurrentConversionOptions( const ConversionOptions *conversionOptions )
{
    if( !conversionOptions )
        return false;

    cFormat->setCurrentIndex( cFormat->findText(conversionOptions->codecName) );
    formatChanged( cFormat->currentText() );
    if( conversionOptions->codecName != "wav" )
    {
        cPlugin->setCurrentIndex( cPlugin->findText(conversionOptions->pluginName) );
        encoderChanged( cPlugin->currentText() );
    }
    outputDirectory->setMode( (OutputDirectory::Mode)conversionOptions->outputDirectoryMode );
    outputDirectory->setDirectory( conversionOptions->outputDirectory );
    cReplayGain->setChecked( conversionOptions->replaygain );

    bool succeeded = true;

    if( conversionOptions->codecName == "wav" )
        succeeded = true;
    else if( wPlugin )
        succeeded = wPlugin->setCurrentConversionOptions( conversionOptions );
    else
        succeeded = false;

    QStringList usedFilter;
    foreach( const FilterOptions *filterOptions, conversionOptions->filterOptions )
    {
        bool filterSucceeded = false;
        for( int i=0; i<wFilter.size(); i++ )
        {
            FilterWidget *widget = wFilter.keys().at(i);
            FilterPlugin *plugin = wFilter.values().at(i);
            if( widget && plugin && filterOptions->pluginName == plugin->name() )
            {
                filterSucceeded = widget->setCurrentFilterOptions( filterOptions );
                usedFilter.append( filterOptions->pluginName );
                break;
            }
        }
        if( !filterSucceeded )
            succeeded = false;
    }
    // if a filter is disabled, its FilterOptions is 0 thus it won't be added to ConversionOptions, but we need to update the widget so it won't show false data
    for( int i=0; i<wFilter.size(); i++ )
    {
        FilterWidget *widget = wFilter.keys().at(i);
        FilterPlugin *plugin = wFilter.values().at(i);
        if( widget && plugin && !usedFilter.contains(plugin->name()) )
        {
            widget->setCurrentFilterOptions( 0 );
        }
    }

    return succeeded;
}
Exemple #2
0
void OptionsDetailed::resetFilterOptions()
{
    for( int i=0; i<wFilter.size(); i++ )
    {
        FilterWidget *widget = wFilter.keys().at(i);
        if( widget )
        {
            widget->setCurrentFilterOptions( 0 );
        }
    }
}