//[-------------------------------------------------------]
//[ Public functions                                      ]
//[-------------------------------------------------------]
ClassListWidget::ClassListWidget(ClassListType listType,QWidget *parent, Qt::WindowFlags f): QWidget(parent, f)
, m_bFirstLevelAlwaysExpanded(listType == HierachicalView)
{
	QBoxLayout *boxLayout = new QVBoxLayout;
	setLayout(boxLayout);

	FilterWidget *filterWidget = new FilterWidget(this, FilterWidget::LayoutAlignNone);
	filterWidget->setRefuseFocus(true);
	
	connect(filterWidget, SIGNAL(filterChanged(QString)),this, SLOT(filterChanged(QString)));
	
	boxLayout->addWidget(filterWidget);
	
	m_pClassListModel = new ClassListModel(listType == HierachicalView, this);
	
	// Setup the sort and filter proxy model
	// The filtering is case insensitive
	m_pSortAndFilterProxyModel = new TreeSortAndFilterProxyModel(this);
	m_pSortAndFilterProxyModel->setSourceModel(m_pClassListModel);
	m_pSortAndFilterProxyModel->setDynamicSortFilter(true);
	m_pSortAndFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
	m_pSortAndFilterProxyModel->sort(0);
	
	m_pView = new QTreeView(this);
	m_pView->setModel(m_pSortAndFilterProxyModel);
	layout()->addWidget(m_pView);
	// Connect signal of QAbstractItemView directly to own signal, with this the class don't need to implement a slot to deliver the signal to the outside world.
	connect(m_pView, SIGNAL(activated(QModelIndex)), this, SIGNAL(activated(QModelIndex)));
	
	if(m_bFirstLevelAlwaysExpanded)
		m_pView->expandToDepth(0);
}
Beispiel #2
0
WidgetBox::WidgetBox(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags)
    : QDesignerWidgetBox(parent, flags),
      m_core(core),
      m_view(new WidgetBoxTreeWidget(m_core))
{

    QVBoxLayout *l = new QVBoxLayout(this);
    l->setMargin(0);
    l->setSpacing(0);

    // Prevent the filter from grabbing focus since Our view has Qt::NoFocus
    FilterWidget *filterWidget = new FilterWidget(0, FilterWidget::LayoutAlignNone);
    filterWidget->setRefuseFocus(true);
    connect(filterWidget, SIGNAL(filterChanged(QString)), m_view, SLOT(filter(QString)));

    QToolBar *toolBar = new QToolBar(this);
    toolBar->addWidget(filterWidget);
    l->addWidget(toolBar);

    // View
    connect(m_view, SIGNAL(pressed(QString,QString,QPoint)),
            this, SLOT(handleMousePress(QString,QString,QPoint)));
    l->addWidget(m_view);

    setAcceptDrops (true);
}
Beispiel #3
0
void FilterSortingArea::moveWidget(const FilterInfo &info, int beforeId)
{
    // find both widgets
    FilterWidget *filter = 0;
    // first, find the filter
    for (int i = 0; i < ui->layout->count(); i++) {
        FilterWidget *current =
            qobject_cast<FilterWidget *>(ui->layout->itemAt(i)->widget());
        if (!current)
            continue;
        if (current->filterId() == info.id) {
            filter = current;
            break;
        }
    }
    if (!filter) // filter was not found
        return;
    ui->layout->removeWidget(filter);
    update();
    // now, find the position
    int pos = ui->layout->indexOf(ui->outputs);
    for (int i = 0; i < ui->layout->count(); i++) {
        FilterWidget *current =
            qobject_cast<FilterWidget *>(ui->layout->itemAt(i)->widget());
        if (!current)
            continue;
        if (current->filterId() == beforeId) {
            pos = i;
            break;
        }
    }
    ui->layout->insertWidget(pos, filter);
    emit delayedUpdateReq();
}
Beispiel #4
0
int FilterSortingArea::dragAnimation(QDropEvent *event)
{
    int spacerIndex = ui->layout->indexOf(mEmptyWidget);
    for (int i = 0; i < ui->layout->count(); i++) {
        FilterWidget *filter =
            qobject_cast<FilterWidget *>(ui->layout->itemAt(i)->widget());
        if (filter) {
            if (filter->pos().y() > event->pos().y()) {
                if (spacerIndex != i - 1) {
                    ui->layout->insertWidget(i, mEmptyWidget);
                    if (!mEmptyWidget->isVisible())
                        mEmptyWidget->setVisible(true);
                    update();
                }
                return filter->filterId();
            }
        }
    }
    int index = ui->layout->indexOf(ui->outputs);
    if (spacerIndex != index - 1) {
        ui->layout->insertWidget(index, mEmptyWidget);
        if (!mEmptyWidget->isVisible())
            mEmptyWidget->setVisible(true);
        update();
    }
    return 0;
}
Beispiel #5
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;
}
Beispiel #6
0
void FilterSortingArea::dragEnterEvent(QDragEnterEvent *event)
{
    FilterWidget *filter = qobject_cast<FilterWidget *>(event->source());
    if (!filter)
        return;
    int moveId = filter->filterId();
    int beforeId = dragAnimation(event);
    if (moveId != 0 && !mInterface.canMove(moveId, beforeId))
        return;
    event->acceptProposedAction();
}
Beispiel #7
0
void OptionsDetailed::resetFilterOptions()
{
    for( int i=0; i<wFilter.size(); i++ )
    {
        FilterWidget *widget = wFilter.keys().at(i);
        if( widget )
        {
            widget->setCurrentFilterOptions( 0 );
        }
    }
}
Beispiel #8
0
QWidget *Filter::widget(QWidget *parent)
{
    FilterWidget * fw = new FilterWidget(parent);
    fw->setRadius(mRadius);
    fw->setEdgePreservation(mEdgePreservation);
    connect(this, SIGNAL(radiusChanged(int)), fw, SLOT(setRadius(int)));
    connect(this, SIGNAL(edgePreservationChanged(int)), fw, SLOT(setEdgePreservation(int)));
    connect(fw, SIGNAL(radiusChanged(int)), this, SLOT(setRadius(int)));
    connect(fw, SIGNAL(edgePreservationChanged(int)), this, SLOT(setEdgePreservation(int)));
    return fw;
}
Beispiel #9
0
static OSStatus FilterFieldEventHandler(EventHandlerCallRef handlerCallRef,
					EventRef event, void *userData)
{
	Q_UNUSED(handlerCallRef);
	FilterWidget *filter = (FilterWidget *) userData;
	OSType eventClass = GetEventClass(event);
	UInt32 eventKind = GetEventKind(event);

	if (eventClass == kEventClassSearchField && eventKind == kEventSearchFieldCancelClicked)
		filter->clear();
	else if (eventClass == kEventClassTextField && eventKind == kEventTextDidChange)
		filter->emitTextChanged();
	return (eventNotHandledErr);
}
Beispiel #10
0
QWidget *Filter::widget(QWidget *parent)
{
    FilterWidget * fw = new FilterWidget(parent);
    fw->setEnhanceChannelsSeparately(mEnhanceChannelsSeparately);
    fw->setAdjustMidtones(mAdjustMidtones);
    fw->setTargetColorShadows(mTargetColorShadows);
    fw->setTargetColorMidtones(mTargetColorMidtones);
    fw->setTargetColorHighlights(mTargetColorHighlights);
    fw->setClippingShadows(mClippingShadows);
    fw->setClippingHighlights(mClippingHighlights);
    connect(this, SIGNAL(enhanceChannelsSeparatelyChanged(bool)), fw, SLOT(setEnhanceChannelsSeparately(bool)));
    connect(this, SIGNAL(adjustMidtonesChanged(bool)), fw, SLOT(setAdjustMidtones(bool)));
    connect(this, SIGNAL(targetColorShadowsChanged(QColor)), fw, SLOT(setTargetColorShadows(QColor)));
    connect(this, SIGNAL(targetColorMidtonesChanged(QColor)), fw, SLOT(setTargetColorMidtones(QColor)));
    connect(this, SIGNAL(targetColorHighlightsChanged(QColor)), fw, SLOT(setTargetColorHighlights(QColor)));
    connect(this, SIGNAL(clippingShadowsChanged(double)), fw, SLOT(setClippingShadows(double)));
    connect(this, SIGNAL(clippingHighlightsChanged(double)), fw, SLOT(setClippingHighlights(double)));
    connect(fw, SIGNAL(enhanceChannelsSeparatelyChanged(bool)), this, SLOT(setEnhanceChannelsSeparately(bool)));
    connect(fw, SIGNAL(adjustMidtonesChanged(bool)), this, SLOT(setAdjustMidtones(bool)));
    connect(fw, SIGNAL(targetColorShadowsChanged(QColor)), this, SLOT(setTargetColorShadows(QColor)));
    connect(fw, SIGNAL(targetColorMidtonesChanged(QColor)), this, SLOT(setTargetColorMidtones(QColor)));
    connect(fw, SIGNAL(targetColorHighlightsChanged(QColor)), this, SLOT(setTargetColorHighlights(QColor)));
    connect(fw, SIGNAL(clippingShadowsChanged(double)), this, SLOT(setClippingShadows(double)));
    connect(fw, SIGNAL(clippingHighlightsChanged(double)), this, SLOT(setClippingHighlights(double)));
    return fw;
}
Beispiel #11
0
QWidget *Filter::widget(QWidget *parent)
{
    FilterWidget * fw = new FilterWidget(parent);
    fw->setColorMode(mColorMode);
    for (int i = 0; i < 5; i++)
    {
        fw->setAffectedChannel(i, mAffectedChannel[i]);
        fw->setThreshold(i, mThreshold[i]);
    }
    connect(this, SIGNAL(colorModeChanged(int)), fw, SLOT(setColorMode(int)));
    connect(this, SIGNAL(affectedChannelChanged(int,bool)), fw, SLOT(setAffectedChannel(int,bool)));
    connect(this, SIGNAL(thresholdChanged(int,int)), fw, SLOT(setThreshold(int,int)));
    connect(fw, SIGNAL(colorModeChanged(int)), this, SLOT(setColorMode(int)));
    connect(fw, SIGNAL(affectedChannelChanged(int,bool)), this, SLOT(setAffectedChannel(int,bool)));
    connect(fw, SIGNAL(thresholdChanged(int,int)), this, SLOT(setThreshold(int,int)));
    return fw;
}
Beispiel #12
0
ConversionOptions *OptionsDetailed::currentConversionOptions( bool saveLastUsed )
{
    if( wPlugin && currentPlugin )
    {
        ConversionOptions *conversionOptions = wPlugin->currentConversionOptions();
        if( conversionOptions )
        {
            conversionOptions->codecName = cFormat->currentText();
            if( conversionOptions->codecName != "wav" )
                conversionOptions->pluginName = currentPlugin->name();
            else
                conversionOptions->pluginName = "";
            conversionOptions->profile = wPlugin->currentProfile();
            conversionOptions->outputDirectoryMode = outputDirectory->mode();
            conversionOptions->outputDirectory = outputDirectory->directory();
            conversionOptions->outputFilesystem = outputDirectory->filesystem();
            conversionOptions->replaygain = cReplayGain->isEnabled() && cReplayGain->isChecked();

            for( int i=0; i<wFilter.size(); i++ )
            {
                FilterWidget *widget = wFilter.keys().at(i);
                FilterPlugin *plugin = wFilter.values().at(i);
                if( widget && plugin )
                {
                    FilterOptions *filterOptions = widget->currentFilterOptions();
                    if( filterOptions )
                    {
                        filterOptions->pluginName = plugin->name();
                        conversionOptions->filterOptions.append( filterOptions );
                    }
                }
            }

            if( saveLastUsed )
            {
                config->data.general.lastProfile = currentProfile();
                saveCustomProfile( true );
                config->data.general.lastFormat = cFormat->currentText();
            }

            return conversionOptions;
        }
    }

    return 0;
}
Beispiel #13
0
void FilterSortingArea::dropEvent(QDropEvent *event)
{
    FilterWidget *filter = qobject_cast<FilterWidget *>(event->source());
    if (!filter)
        return;
    int moveId = filter->filterId();
    int beforeId = dragAnimation(event);
    if (moveId != 0 && !mInterface.canMove(moveId, beforeId))
        return;
    event->acceptProposedAction();
    // need to clear the animation widget here, in case of new filter
    mEmptyWidget->hide();
    update();
    if (moveId > 0){
        emit moveFilterRequested(moveId, beforeId);
    } else {
        emit addFilterRequested(mProcessorId, filter->filterType(), beforeId);
    }
}
Beispiel #14
0
OptionsDetailed::OptionsDetailed( Config* _config, QWidget* parent )
    : QWidget( parent ),
    config( _config )
{
    const int fontHeight = QFontMetrics(QApplication::font()).boundingRect("M").size().height();

    int gridRow = 0;
    grid = new QGridLayout( this );

    QHBoxLayout *topBox = new QHBoxLayout();
    grid->addLayout( topBox, 0, 0 );

    QLabel *lFormat = new QLabel( i18n("Format:"), this );
    topBox->addWidget( lFormat );
    cFormat = new KComboBox( this );
    topBox->addWidget( cFormat );
    cFormat->addItems( config->pluginLoader()->formatList(PluginLoader::Encode,PluginLoader::CompressionType(PluginLoader::InferiorQuality|PluginLoader::Lossy|PluginLoader::Lossless|PluginLoader::Hybrid)) );
    connect( cFormat, SIGNAL(activated(const QString&)), this, SLOT(formatChanged(const QString&)) );
//     connect( cFormat, SIGNAL(activated(const QString&)), this, SLOT(somethingChanged()) );

    topBox->addStretch();

    lPlugin = new QLabel( i18n("Use Plugin:"), this );
    topBox->addWidget( lPlugin );
    cPlugin = new KComboBox( this );
    topBox->addWidget( cPlugin );
    cPlugin->setSizeAdjustPolicy( QComboBox::AdjustToContents );
    connect( cPlugin, SIGNAL(activated(const QString&)), this, SLOT(encoderChanged(const QString&)) );
    connect( cPlugin, SIGNAL(activated(const QString&)), this, SLOT(somethingChanged()) );
    pConfigurePlugin = new KPushButton( KIcon("configure"), "", this );
    pConfigurePlugin->setFixedSize( cPlugin->sizeHint().height(), cPlugin->sizeHint().height() );
    pConfigurePlugin->setFlat( true );
    topBox->addWidget( pConfigurePlugin );
    topBox->setStretchFactor( pConfigurePlugin, 1 );
    connect( pConfigurePlugin, SIGNAL(clicked()), this, SLOT(configurePlugin()) );

    // draw a horizontal line
    QFrame *lineFrame = new QFrame( this );
    lineFrame->setFrameShape( QFrame::HLine );
    lineFrame->setFrameShadow( QFrame::Sunken );
    lineFrame->setFixedHeight( fontHeight );
    grid->addWidget( lineFrame, 1, 0 );

    // prepare the plugin widget
    wPlugin = 0;
    grid->setRowStretch( 2, 1 );
    grid->setRowMinimumHeight( 2, 20 );
    gridRow = 3;

    // draw a horizontal line
    lineFrame = new QFrame( this );
    lineFrame->setFrameShape( QFrame::HLine );
    lineFrame->setFrameShadow( QFrame::Sunken );
    lineFrame->setFixedHeight( fontHeight );
    grid->addWidget( lineFrame, gridRow++, 0 );

    int filterCount = 0;
    foreach( const QString& pluginName, config->data.backends.enabledFilters )
    {
        FilterPlugin *plugin = qobject_cast<FilterPlugin*>(config->pluginLoader()->backendPluginByName(pluginName));
        if( !plugin )
            continue;

        FilterWidget *widget = plugin->newFilterWidget();
        if( !widget )
            continue;

        wFilter.insert( widget, plugin );
        connect( widget, SIGNAL(optionsChanged()), this, SLOT(somethingChanged()) );
        grid->addWidget( widget, gridRow++, 0 );
        widget->show();
        filterCount++;
    }
    if( filterCount > 0 )
    {
        // draw a horizontal line
        lineFrame = new QFrame( this );
        lineFrame->setFrameShape( QFrame::HLine );
        lineFrame->setFrameShadow( QFrame::Sunken );
        lineFrame->setFixedHeight( fontHeight );
        grid->addWidget( lineFrame, gridRow++, 0 );
    }

    // the output directory
    QHBoxLayout *middleBox = new QHBoxLayout( );
    grid->addLayout( middleBox, gridRow++, 0 );

    QLabel *lOutput = new QLabel( i18n("Destination:"), this );
    middleBox->addWidget( lOutput );
    outputDirectory = new OutputDirectory( config, this );
    middleBox->addWidget( outputDirectory );

    QHBoxLayout *bottomBox = new QHBoxLayout();
    grid->addLayout( bottomBox, gridRow++, 0 );

    cReplayGain = new QCheckBox( i18n("Calculate Replay Gain tags"), this );
    bottomBox->addWidget( cReplayGain );
    //connect( cReplayGain, SIGNAL(toggled(bool)), this, SLOT(somethingChanged()) );
    bottomBox->addStretch();
    lEstimSize = new QLabel( QString(QChar(8776))+"? B / min." );
    lEstimSize->hide(); // hide for now because most plugins report inaccurate data
    bottomBox->addWidget( lEstimSize );
    pProfileSave = new KPushButton( KIcon("document-save"), "", this );
    bottomBox->addWidget( pProfileSave );
    pProfileSave->setFixedWidth( pProfileSave->height() );
    pProfileSave->setToolTip( i18n("Save current options as a profile") );
    connect( pProfileSave, SIGNAL(clicked()), this, SLOT(saveCustomProfile()) );
    pProfileLoad = new QToolButton( this );
    bottomBox->addWidget( pProfileLoad );
    pProfileLoad->setIcon( KIcon("document-open") );
    pProfileLoad->setPopupMode( QToolButton::InstantPopup );
    pProfileLoad->setFixedWidth( pProfileLoad->height() );
    pProfileLoad->setToolTip( i18n("Load saved profiles") );
}