Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite EffectSelectDialog to add effect groups and delete Qt Designer UI file #7024

Merged
merged 8 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 61 additions & 20 deletions include/EffectSelectDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* EffectSelectDialog.h - 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
*
Expand All @@ -22,52 +23,92 @@
*
*/

#ifndef LMMS_GUI_EFFECT_SELECT_DIALOG_H
#define LMMS_GUI_EFFECT_SELECT_DIALOG_H
#ifndef EFFECT_SELECT_DIALOG_H
#define EFFECT_SELECT_DIALOG_H

#include "Effect.h"

#include <QDialog>
#include <QHeaderView>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QPushButton>
#include <QRegExp>
#include <QScrollArea>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTableView>

#include "Effect.h"
namespace lmms::gui
{

class DualColumnFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
DualColumnFilterProxyModel(QObject* parent = nullptr) : QSortFilterProxyModel(parent)
{
m_effectTypeFilter = "";
}

namespace Ui { class EffectSelectDialog; }
void setEffectTypeFilter(const QString& filter)
{
m_effectTypeFilter = filter;
invalidateFilter();
}

namespace lmms::gui
{
protected:
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
{
QModelIndex nameIndex = sourceModel()->index(source_row, 0, source_parent);
QModelIndex typeIndex = sourceModel()->index(source_row, 1, source_parent);

QString name = sourceModel()->data(nameIndex, Qt::DisplayRole).toString();
QString type = sourceModel()->data(typeIndex, Qt::DisplayRole).toString();

QRegExp nameRegExp(filterRegExp());
nameRegExp.setCaseSensitivity(Qt::CaseInsensitive);

bool nameFilterPassed = nameRegExp.indexIn(name) != -1;
bool typeFilterPassed = (m_effectTypeFilter.isEmpty() || type.contains(m_effectTypeFilter, Qt::CaseInsensitive));

return nameFilterPassed && typeFilterPassed;
}

private:
QString m_effectTypeFilter;
};


class EffectSelectDialog : public QDialog
{
Q_OBJECT
public:
EffectSelectDialog( QWidget * _parent );
EffectSelectDialog(QWidget* _parent);
~EffectSelectDialog() override;

Effect * instantiateSelectedPlugin( EffectChain * _parent );

Effect* instantiateSelectedPlugin(EffectChain* _parent);

protected slots:
void acceptSelection();
void rowChanged( const QModelIndex &, const QModelIndex & );
void sortAgain();
void rowChanged(const QModelIndex&, const QModelIndex&);
void updateSelection();


bool eventFilter(QObject* obj, QEvent* event) override;

private:
Ui::EffectSelectDialog * ui;

EffectKeyList m_effectKeys;
EffectKey m_currentSelection;

QStandardItemModel m_sourceModel;
QSortFilterProxyModel m_model;
QWidget * m_descriptionWidget;

} ;

DualColumnFilterProxyModel m_model;
QWidget* m_descriptionWidget;
QTableView* m_pluginList;
QScrollArea* m_scrollArea;
QLineEdit* m_filterEdit;
};

} // namespace lmms::gui

#endif // LMMS_GUI_EFFECT_SELECT_DIALOG_H
#endif

1 change: 0 additions & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ SET(LMMS_SRCS
set(LMMS_UIS
${LMMS_UIS}
gui/modals/about_dialog.ui
gui/modals/EffectSelectDialog.ui
gui/modals/export_project.ui

PARENT_SCOPE
Expand Down
Loading