Skip to content

Commit

Permalink
Rewrite EffectSelectDialog to add effect groups and delete Qt Designe…
Browse files Browse the repository at this point in the history
…r UI file (LMMS#7024)
  • Loading branch information
LostRobotMusic authored Feb 19, 2024
1 parent 876a36c commit 360254f
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 251 deletions.
76 changes: 57 additions & 19 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 @@ -25,49 +26,86 @@
#ifndef LMMS_GUI_EFFECT_SELECT_DIALOG_H
#define LMMS_GUI_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)
{
}

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 = type.contains(m_effectTypeFilter, Qt::CaseInsensitive);

return nameFilterPassed && typeFilterPassed;
}

private:
QString m_effectTypeFilter;
};


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

Effect * instantiateSelectedPlugin( EffectChain * _parent );
EffectSelectDialog(QWidget* 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 @@ -132,7 +132,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

0 comments on commit 360254f

Please sign in to comment.