Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/framework/audioplugins/iknownaudiopluginsregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class IKnownAudioPluginsRegister : MODULE_CONTEXT_INTERFACE
virtual ~IKnownAudioPluginsRegister() = default;

virtual Ret load() = 0;
virtual Ret clear() = 0;

using PluginInfoAccepted = std::function<bool (const AudioPluginInfo& info)>;

Expand Down
11 changes: 11 additions & 0 deletions src/framework/audioplugins/internal/knownaudiopluginsregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ Ret KnownAudioPluginsRegister::load()
return muse::make_ok();
}

Ret KnownAudioPluginsRegister::clear()
{
m_pluginInfoMap.clear();
m_pluginPaths.clear();

Ret ret = writePluginsInfo();
m_pluginInfoListChanged.notify();

return ret;
}

AudioPluginInfoList KnownAudioPluginsRegister::pluginInfoList(PluginInfoAccepted accepted) const
{
if (!accepted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class KnownAudioPluginsRegister : public IKnownAudioPluginsRegister, public Cont
: Contextable(iocCtx) {}

Ret load() override;
Ret clear() override;

AudioPluginInfoList pluginInfoList(PluginInfoAccepted accepted = PluginInfoAccepted()) const override;
muse::async::Notification pluginInfoListChanged() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ PluginScanResult RegisterAudioPluginsScenario::scanPlugins() const
return result;
}

void RegisterAudioPluginsScenario::rescanAllPlugins()
{
TRACEFUNC;

Ret ret = knownPluginsRegister()->clear();
if (!ret) {
LOGE() << "Failed to clear plugins registry: " << ret.toString();
}

updatePluginsRegistry();
}

void RegisterAudioPluginsScenario::updatePluginsRegistry()
{
TRACEFUNC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class RegisterAudioPluginsScenario : public IRegisterAudioPluginsScenario, publi
PluginScanResult scanPlugins() const override;

void updatePluginsRegistry() override;
void rescanAllPlugins() override;

Ret registerNewPlugins(const io::paths_t& pluginPaths) override;
Ret unregisterRemovedPlugins(const audio::AudioResourceIdList& pluginIds) override;
Expand Down
1 change: 1 addition & 0 deletions src/framework/audioplugins/iregisteraudiopluginsscenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class IRegisterAudioPluginsScenario : MODULE_CONTEXT_INTERFACE
virtual PluginScanResult scanPlugins() const = 0;

virtual void updatePluginsRegistry() = 0;
virtual void rescanAllPlugins() = 0;

virtual Ret registerNewPlugins(const io::paths_t& pluginPaths) = 0;
virtual Ret unregisterRemovedPlugins(const audio::AudioResourceIdList& pluginIds) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ FoldersPreferencesModel::FoldersPreferencesModel(QObject* parent)
{
}

bool FoldersPreferencesModel::vstEnabled() const
{
#ifdef MUSE_MODULE_VST
return true;
#else
return false;
#endif
}

int FoldersPreferencesModel::rowCount(const QModelIndex&) const
{
return m_folders.count();
Expand Down Expand Up @@ -235,6 +244,13 @@ QModelIndex FoldersPreferencesModel::folderIndex(FoldersPreferencesModel::Folder
return QModelIndex();
}

void FoldersPreferencesModel::rescanVstPlugins()
{
if (registerAudioPluginsScenario()) {
registerAudioPluginsScenario()->rescanAllPlugins();
}
}

QString FoldersPreferencesModel::pathsToString(const io::paths_t& paths) const
{
return QString::fromStdString(io::pathsToString(paths));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,36 @@
#include "extensions/iextensionsconfiguration.h"
#include "audio/main/iaudioconfiguration.h"
#include "vst/ivstconfiguration.h"
#include "audioplugins/iregisteraudiopluginsscenario.h"

namespace mu::preferences {
class FoldersPreferencesModel : public QAbstractListModel, public muse::Contextable, public muse::async::Asyncable
{
Q_OBJECT
QML_ELEMENT;
QML_ELEMENT

Q_PROPERTY(bool vstEnabled READ vstEnabled CONSTANT)

muse::GlobalInject<muse::IGlobalConfiguration> globalConfiguration;
muse::GlobalInject<project::IProjectConfiguration> projectConfiguration;
muse::GlobalInject<notation::INotationConfiguration> notationConfiguration;
muse::GlobalInject<muse::extensions::IExtensionsConfiguration> extensionsConfiguration;
muse::GlobalInject<muse::audio::IAudioConfiguration> audioConfiguration;
muse::GlobalInject<muse::vst::IVstConfiguration> vstConfiguration;
muse::ContextInject<muse::audioplugins::IRegisterAudioPluginsScenario> registerAudioPluginsScenario = { this };

public:
explicit FoldersPreferencesModel(QObject* parent = nullptr);

bool vstEnabled() const;

int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
QHash<int, QByteArray> roleNames() const override;

Q_INVOKABLE void load();
Q_INVOKABLE void rescanVstPlugins();

private:
void setupConnections();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,23 @@ BaseSection {
}
}
}

RowLayout {
visible: root.model.vstEnabled
width: parent.width

Item { Layout.fillWidth: true }

FlatButton {
text: qsTrc("preferences", "Rescan VST3 plugins")

navigation.name: "rescanVstPluginsButton"
navigation.panel: root.navigation
navigation.row: view.count + 1

onClicked: {
Qt.callLater(root.model.rescanVstPlugins)
}
}
}
}
Loading