|
|
|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
* EffectSelectDialog.cpp - dialog to choose effect plugin
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
|
|
|
* Copyright (c) 2023 Lost Robot <r94231/at/gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This file is part of LMMS - https://lmms.io
|
|
|
|
|
*
|
|
|
|
|
@@ -23,63 +24,62 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "EffectSelectDialog.h"
|
|
|
|
|
|
|
|
|
|
#include "ui_EffectSelectDialog.h"
|
|
|
|
|
|
|
|
|
|
#include "DummyEffect.h"
|
|
|
|
|
#include "EffectChain.h"
|
|
|
|
|
#include "embed.h"
|
|
|
|
|
#include "PluginFactory.h"
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QScrollArea>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace lmms::gui
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) :
|
|
|
|
|
QDialog( _parent ),
|
|
|
|
|
ui( new Ui::EffectSelectDialog ),
|
|
|
|
|
EffectSelectDialog::EffectSelectDialog(QWidget* parent) :
|
|
|
|
|
QDialog(parent),
|
|
|
|
|
m_effectKeys(),
|
|
|
|
|
m_currentSelection(),
|
|
|
|
|
m_sourceModel(),
|
|
|
|
|
m_model(),
|
|
|
|
|
m_descriptionWidget( nullptr )
|
|
|
|
|
m_descriptionWidget(nullptr),
|
|
|
|
|
m_pluginList(new QTableView(this)),
|
|
|
|
|
m_scrollArea(new QScrollArea(this))
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi( this );
|
|
|
|
|
|
|
|
|
|
setWindowIcon( embed::getIconPixmap( "setup_audio" ) );
|
|
|
|
|
|
|
|
|
|
// query effects
|
|
|
|
|
setWindowTitle(tr("Add effect"));
|
|
|
|
|
resize(640, 480);
|
|
|
|
|
|
|
|
|
|
setWindowIcon(embed::getIconPixmap("setup_audio"));
|
|
|
|
|
|
|
|
|
|
// Query effects
|
|
|
|
|
EffectKeyList subPluginEffectKeys;
|
|
|
|
|
|
|
|
|
|
for (const Plugin::Descriptor* desc: getPluginFactory()->descriptors(Plugin::Type::Effect))
|
|
|
|
|
for (const auto desc : getPluginFactory()->descriptors(Plugin::Type::Effect))
|
|
|
|
|
{
|
|
|
|
|
if( desc->subPluginFeatures )
|
|
|
|
|
if (desc->subPluginFeatures)
|
|
|
|
|
{
|
|
|
|
|
desc->subPluginFeatures->listSubPluginKeys(
|
|
|
|
|
desc,
|
|
|
|
|
subPluginEffectKeys );
|
|
|
|
|
desc->subPluginFeatures->listSubPluginKeys(desc, subPluginEffectKeys);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_effectKeys << EffectKey( desc, desc->name );
|
|
|
|
|
|
|
|
|
|
m_effectKeys << EffectKey(desc, desc->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_effectKeys += subPluginEffectKeys;
|
|
|
|
|
|
|
|
|
|
// and fill our source model
|
|
|
|
|
m_sourceModel.setHorizontalHeaderItem( 0, new QStandardItem( tr( "Name" ) ) );
|
|
|
|
|
m_sourceModel.setHorizontalHeaderItem( 1, new QStandardItem( tr( "Type" ) ) );
|
|
|
|
|
// Fill the source model
|
|
|
|
|
m_sourceModel.setHorizontalHeaderItem(0, new QStandardItem(tr("Name")));
|
|
|
|
|
m_sourceModel.setHorizontalHeaderItem(1, new QStandardItem(tr("Type")));
|
|
|
|
|
int row = 0;
|
|
|
|
|
for( EffectKeyList::ConstIterator it = m_effectKeys.begin();
|
|
|
|
|
it != m_effectKeys.end(); ++it )
|
|
|
|
|
for (EffectKeyList::ConstIterator it = m_effectKeys.begin(); it != m_effectKeys.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
QString name;
|
|
|
|
|
QString type;
|
|
|
|
|
if( it->desc->subPluginFeatures )
|
|
|
|
|
if (it->desc->subPluginFeatures)
|
|
|
|
|
{
|
|
|
|
|
name = it->displayName();
|
|
|
|
|
type = it->desc->displayName;
|
|
|
|
|
@@ -89,114 +89,148 @@ EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) :
|
|
|
|
|
name = it->desc->displayName;
|
|
|
|
|
type = "LMMS";
|
|
|
|
|
}
|
|
|
|
|
m_sourceModel.setItem( row, 0, new QStandardItem( name ) );
|
|
|
|
|
m_sourceModel.setItem( row, 1, new QStandardItem( type ) );
|
|
|
|
|
m_sourceModel.setItem(row, 0, new QStandardItem(name));
|
|
|
|
|
m_sourceModel.setItem(row, 1, new QStandardItem(type));
|
|
|
|
|
++row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setup filtering
|
|
|
|
|
m_model.setSourceModel( &m_sourceModel );
|
|
|
|
|
m_model.setFilterCaseSensitivity( Qt::CaseInsensitive );
|
|
|
|
|
// Setup filtering
|
|
|
|
|
m_model.setSourceModel(&m_sourceModel);
|
|
|
|
|
m_model.setFilterCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
|
|
|
|
|
|
ui->filterEdit->setPlaceholderText(tr("Search"));
|
|
|
|
|
ui->filterEdit->setClearButtonEnabled(true);
|
|
|
|
|
ui->filterEdit->addAction(embed::getIconPixmap("zoom"), QLineEdit::LeadingPosition);
|
|
|
|
|
QHBoxLayout* mainLayout = new QHBoxLayout(this);
|
|
|
|
|
|
|
|
|
|
connect(ui->filterEdit, &QLineEdit::textChanged, &m_model, &QSortFilterProxyModel::setFilterFixedString);
|
|
|
|
|
connect(ui->filterEdit, &QLineEdit::textChanged, this, &EffectSelectDialog::updateSelection);
|
|
|
|
|
connect(ui->filterEdit, &QLineEdit::textChanged, this, &EffectSelectDialog::sortAgain);
|
|
|
|
|
QVBoxLayout* leftSectionLayout = new QVBoxLayout();
|
|
|
|
|
|
|
|
|
|
ui->pluginList->setModel( &m_model );
|
|
|
|
|
QStringList buttonLabels = { tr("All"), "LMMS", "LADSPA", "LV2", "VST" };
|
|
|
|
|
QStringList buttonSearchString = { "", "LMMS", "LADSPA", "LV2", "VST" };
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < buttonLabels.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
const QString& label = buttonLabels[i];
|
|
|
|
|
const QString& searchString = buttonSearchString[i];
|
|
|
|
|
|
|
|
|
|
QPushButton* button = new QPushButton(label, this);
|
|
|
|
|
button->setFixedSize(50, 50);
|
|
|
|
|
button->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
leftSectionLayout->addWidget(button);
|
|
|
|
|
|
|
|
|
|
connect(button, &QPushButton::clicked, this, [this, searchString] {
|
|
|
|
|
m_model.setEffectTypeFilter(searchString);
|
|
|
|
|
updateSelection();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leftSectionLayout->addStretch();// Add stretch to the button layout to push buttons to the top
|
|
|
|
|
mainLayout->addLayout(leftSectionLayout);
|
|
|
|
|
|
|
|
|
|
m_filterEdit = new QLineEdit(this);
|
|
|
|
|
connect(m_filterEdit, &QLineEdit::textChanged, this, [this](const QString &text) {
|
|
|
|
|
m_model.setFilterRegExp(QRegExp(text, Qt::CaseInsensitive));
|
|
|
|
|
});
|
|
|
|
|
connect(m_filterEdit, &QLineEdit::textChanged, this, &EffectSelectDialog::updateSelection);
|
|
|
|
|
m_filterEdit->setFocus();
|
|
|
|
|
m_filterEdit->setFocusPolicy(Qt::StrongFocus);
|
|
|
|
|
m_filterEdit->setPlaceholderText(tr("Search"));
|
|
|
|
|
m_filterEdit->setClearButtonEnabled(true);
|
|
|
|
|
m_filterEdit->addAction(embed::getIconPixmap("zoom"), QLineEdit::LeadingPosition);
|
|
|
|
|
|
|
|
|
|
m_pluginList->setModel(&m_model);
|
|
|
|
|
m_pluginList->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
m_pluginList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
m_pluginList->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
m_pluginList->setSortingEnabled(true);
|
|
|
|
|
m_pluginList->sortByColumn(0, Qt::AscendingOrder); // Initial sort by column 0 (Name)
|
|
|
|
|
m_pluginList->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
|
m_pluginList->verticalHeader()->hide();
|
|
|
|
|
m_pluginList->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
|
|
|
|
m_pluginList->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
|
m_pluginList->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
|
|
|
|
|
// Scroll Area
|
|
|
|
|
m_scrollArea->setWidgetResizable(true);
|
|
|
|
|
QWidget* scrollAreaWidgetContents = new QWidget(m_scrollArea);
|
|
|
|
|
scrollAreaWidgetContents->setObjectName("scrollAreaWidgetContents");
|
|
|
|
|
m_scrollArea->setWidget(scrollAreaWidgetContents);
|
|
|
|
|
m_scrollArea->setMaximumHeight(180);
|
|
|
|
|
m_scrollArea->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
|
|
|
|
|
// Button Box
|
|
|
|
|
QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
|
|
|
|
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
|
|
|
|
buttonBox->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &EffectSelectDialog::acceptSelection);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &EffectSelectDialog::reject);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* rightSectionLayout = new QVBoxLayout();
|
|
|
|
|
rightSectionLayout->addWidget(m_filterEdit);
|
|
|
|
|
rightSectionLayout->addWidget(m_pluginList);
|
|
|
|
|
rightSectionLayout->addWidget(m_scrollArea);
|
|
|
|
|
rightSectionLayout->addWidget(buttonBox);
|
|
|
|
|
mainLayout->addLayout(rightSectionLayout);
|
|
|
|
|
|
|
|
|
|
setLayout(mainLayout);
|
|
|
|
|
|
|
|
|
|
// setup selection model
|
|
|
|
|
auto selectionModel = new QItemSelectionModel(&m_model);
|
|
|
|
|
ui->pluginList->setSelectionModel( selectionModel );
|
|
|
|
|
connect( selectionModel, SIGNAL( currentRowChanged( const QModelIndex&,
|
|
|
|
|
const QModelIndex & ) ),
|
|
|
|
|
SLOT( rowChanged( const QModelIndex &, const QModelIndex& ) ) );
|
|
|
|
|
connect( ui->pluginList, SIGNAL( doubleClicked( const QModelIndex& ) ),
|
|
|
|
|
SLOT(acceptSelection()));
|
|
|
|
|
m_pluginList->setSelectionModel(selectionModel);
|
|
|
|
|
connect(selectionModel, &QItemSelectionModel::currentRowChanged,
|
|
|
|
|
this, &EffectSelectDialog::rowChanged);
|
|
|
|
|
|
|
|
|
|
// try to accept current selection when pressing "OK"
|
|
|
|
|
connect( ui->buttonBox, SIGNAL(accepted()),
|
|
|
|
|
this, SLOT(acceptSelection()));
|
|
|
|
|
|
|
|
|
|
ui->filterEdit->setClearButtonEnabled( true );
|
|
|
|
|
ui->pluginList->verticalHeader()->setSectionResizeMode(
|
|
|
|
|
QHeaderView::ResizeToContents );
|
|
|
|
|
ui->pluginList->verticalHeader()->hide();
|
|
|
|
|
ui->pluginList->horizontalHeader()->setSectionResizeMode( 0,
|
|
|
|
|
QHeaderView::Stretch );
|
|
|
|
|
ui->pluginList->horizontalHeader()->setSectionResizeMode( 1,
|
|
|
|
|
QHeaderView::ResizeToContents );
|
|
|
|
|
ui->pluginList->sortByColumn( 0, Qt::AscendingOrder );
|
|
|
|
|
connect(m_pluginList, &QTableView::doubleClicked,
|
|
|
|
|
this, &EffectSelectDialog::acceptSelection);
|
|
|
|
|
|
|
|
|
|
setModal(true);
|
|
|
|
|
installEventFilter(this);
|
|
|
|
|
|
|
|
|
|
updateSelection();
|
|
|
|
|
show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EffectSelectDialog::~EffectSelectDialog()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Effect * EffectSelectDialog::instantiateSelectedPlugin( EffectChain * _parent )
|
|
|
|
|
Effect* EffectSelectDialog::instantiateSelectedPlugin(EffectChain* parent)
|
|
|
|
|
{
|
|
|
|
|
Effect* result = nullptr;
|
|
|
|
|
if(!m_currentSelection.name.isEmpty() && m_currentSelection.desc)
|
|
|
|
|
if (!m_currentSelection.name.isEmpty() && m_currentSelection.desc)
|
|
|
|
|
{
|
|
|
|
|
result = Effect::instantiate(m_currentSelection.desc->name,
|
|
|
|
|
_parent, &m_currentSelection);
|
|
|
|
|
result = Effect::instantiate(m_currentSelection.desc->name, parent, &m_currentSelection);
|
|
|
|
|
}
|
|
|
|
|
if(!result)
|
|
|
|
|
if (!result)
|
|
|
|
|
{
|
|
|
|
|
result = new DummyEffect(_parent, QDomElement());
|
|
|
|
|
result = new DummyEffect(parent, QDomElement());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EffectSelectDialog::acceptSelection()
|
|
|
|
|
{
|
|
|
|
|
if( m_currentSelection.isValid() )
|
|
|
|
|
if (m_currentSelection.isValid())
|
|
|
|
|
{
|
|
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EffectSelectDialog::rowChanged( const QModelIndex & _idx,
|
|
|
|
|
const QModelIndex & )
|
|
|
|
|
void EffectSelectDialog::rowChanged(const QModelIndex& idx, const QModelIndex&)
|
|
|
|
|
{
|
|
|
|
|
delete m_descriptionWidget;
|
|
|
|
|
m_descriptionWidget = nullptr;
|
|
|
|
|
|
|
|
|
|
if( m_model.mapToSource( _idx ).row() < 0 )
|
|
|
|
|
if (m_model.mapToSource(idx).row() < 0)
|
|
|
|
|
{
|
|
|
|
|
// invalidate current selection
|
|
|
|
|
// Invalidate current selection
|
|
|
|
|
m_currentSelection = Plugin::Descriptor::SubPluginFeatures::Key();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_currentSelection = m_effectKeys[m_model.mapToSource( _idx ).row()];
|
|
|
|
|
m_currentSelection = m_effectKeys[m_model.mapToSource(idx).row()];
|
|
|
|
|
}
|
|
|
|
|
if( m_currentSelection.desc )
|
|
|
|
|
if (m_currentSelection.desc)
|
|
|
|
|
{
|
|
|
|
|
m_descriptionWidget = new QWidget;
|
|
|
|
|
|
|
|
|
|
auto hbox = new QHBoxLayout(m_descriptionWidget);
|
|
|
|
|
hbox->setAlignment(Qt::AlignTop);
|
|
|
|
|
|
|
|
|
|
Plugin::Descriptor const & descriptor = *( m_currentSelection.desc );
|
|
|
|
|
Plugin::Descriptor const& descriptor = *(m_currentSelection.desc);
|
|
|
|
|
|
|
|
|
|
const PixmapLoader* pixLoa = m_currentSelection.logo();
|
|
|
|
|
if (pixLoa)
|
|
|
|
|
@@ -204,76 +238,88 @@ void EffectSelectDialog::rowChanged( const QModelIndex & _idx,
|
|
|
|
|
auto logoLabel = new QLabel(m_descriptionWidget);
|
|
|
|
|
logoLabel->setPixmap(pixLoa->pixmap());
|
|
|
|
|
logoLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
|
|
|
logoLabel->setMaximumSize(64, 64);
|
|
|
|
|
|
|
|
|
|
hbox->addWidget( logoLabel );
|
|
|
|
|
hbox->setAlignment( logoLabel, Qt::AlignTop);
|
|
|
|
|
hbox->addWidget(logoLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto textualInfoWidget = new QWidget(m_descriptionWidget);
|
|
|
|
|
|
|
|
|
|
hbox->addWidget(textualInfoWidget);
|
|
|
|
|
|
|
|
|
|
auto textWidgetLayout = new QVBoxLayout(textualInfoWidget);
|
|
|
|
|
textWidgetLayout->setContentsMargins(4, 4, 4, 4);
|
|
|
|
|
textWidgetLayout->setSpacing( 0 );
|
|
|
|
|
textWidgetLayout->setSpacing(8);
|
|
|
|
|
|
|
|
|
|
if ( m_currentSelection.desc->subPluginFeatures )
|
|
|
|
|
if (m_currentSelection.desc->subPluginFeatures)
|
|
|
|
|
{
|
|
|
|
|
auto subWidget = new QWidget(textualInfoWidget);
|
|
|
|
|
auto subLayout = new QVBoxLayout(subWidget);
|
|
|
|
|
subLayout->setContentsMargins(4, 4, 4, 4);
|
|
|
|
|
subLayout->setSpacing( 0 );
|
|
|
|
|
subLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
subLayout->setSpacing(8);
|
|
|
|
|
|
|
|
|
|
m_currentSelection.desc->subPluginFeatures->
|
|
|
|
|
fillDescriptionWidget( subWidget, &m_currentSelection );
|
|
|
|
|
for( QWidget * w : subWidget->findChildren<QWidget *>() )
|
|
|
|
|
fillDescriptionWidget(subWidget, &m_currentSelection);
|
|
|
|
|
for (QWidget* w : subWidget->findChildren<QWidget*>())
|
|
|
|
|
{
|
|
|
|
|
if( w->parent() == subWidget )
|
|
|
|
|
if (w->parent() == subWidget)
|
|
|
|
|
{
|
|
|
|
|
subLayout->addWidget( w );
|
|
|
|
|
subLayout->addWidget(w);
|
|
|
|
|
subLayout->setAlignment(w, QFlags<Qt::AlignmentFlag>(Qt::AlignTop | Qt::AlignLeft));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textWidgetLayout->addWidget(subWidget);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto label = new QLabel(m_descriptionWidget);
|
|
|
|
|
QString labelText = "<p><b>" + tr("Name") + ":</b> " + QString::fromUtf8(descriptor.displayName) + "</p>";
|
|
|
|
|
labelText += "<p><b>" + tr("Description") + ":</b> " + qApp->translate( "PluginBrowser", descriptor.description ) + "</p>";
|
|
|
|
|
labelText += "<p><b>" + tr("Description") + ":</b> " + qApp->translate("PluginBrowser", descriptor.description) + "</p>";
|
|
|
|
|
labelText += "<p><b>" + tr("Author") + ":</b> " + QString::fromUtf8(descriptor.author) + "</p>";
|
|
|
|
|
|
|
|
|
|
label->setText(labelText);
|
|
|
|
|
label->setWordWrap(true);
|
|
|
|
|
|
|
|
|
|
textWidgetLayout->addWidget(label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui->scrollArea->setWidget( m_descriptionWidget );
|
|
|
|
|
m_scrollArea->setWidget(m_descriptionWidget);
|
|
|
|
|
m_descriptionWidget->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EffectSelectDialog::sortAgain()
|
|
|
|
|
{
|
|
|
|
|
ui->pluginList->setSortingEnabled( ui->pluginList->isSortingEnabled() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EffectSelectDialog::updateSelection()
|
|
|
|
|
{
|
|
|
|
|
// no valid selection anymore due to changed filter?
|
|
|
|
|
if( ui->pluginList->selectionModel()->selection().size() <= 0 )
|
|
|
|
|
// No valid selection anymore due to changed filter?
|
|
|
|
|
if (m_pluginList->selectionModel()->selection().size() <= 0)
|
|
|
|
|
{
|
|
|
|
|
// then select our first item
|
|
|
|
|
ui->pluginList->selectionModel()->select( m_model.index( 0, 0 ),
|
|
|
|
|
QItemSelectionModel::ClearAndSelect
|
|
|
|
|
| QItemSelectionModel::Rows );
|
|
|
|
|
rowChanged( m_model.index( 0, 0 ), QModelIndex() );
|
|
|
|
|
// Then select our first item
|
|
|
|
|
m_pluginList->selectionModel()->
|
|
|
|
|
select(m_model.index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
|
|
|
|
rowChanged(m_model.index(0, 0), QModelIndex());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EffectSelectDialog::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (obj == this && event->type() == QEvent::KeyPress)
|
|
|
|
|
{
|
|
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
|
|
|
|
if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down)
|
|
|
|
|
{
|
|
|
|
|
QItemSelectionModel* selectionModel = m_pluginList->selectionModel();
|
|
|
|
|
int currentRow = selectionModel->currentIndex().row();
|
|
|
|
|
int newRow = (keyEvent->key() == Qt::Key_Up) ? currentRow - 1 : currentRow + 1;
|
|
|
|
|
int rowCount = m_pluginList->model()->rowCount();
|
|
|
|
|
newRow = qBound(0, newRow, rowCount - 1);
|
|
|
|
|
|
|
|
|
|
selectionModel->setCurrentIndex(m_pluginList->model()->index(newRow, 0),
|
|
|
|
|
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
|
|
|
|
m_pluginList->scrollTo(m_pluginList->model()->index(newRow, 0));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QDialog::eventFilter(obj, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace lmms::gui
|
|
|
|
|
|