Mercurial > hg > svgui
changeset 1293:6dd15b5c14f9 plugin-path-config
Various logic fixes, and use new setter-class structures
author | Chris Cannam |
---|---|
date | Fri, 25 May 2018 16:05:51 +0100 |
parents | 41824255ddf2 |
children | 9f9a7edd7d89 |
files | widgets/PluginPathConfigurator.cpp widgets/PluginPathConfigurator.h widgets/PluginReviewDialog.cpp |
diffstat | 3 files changed, 25 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/PluginPathConfigurator.cpp Fri May 25 13:39:08 2018 +0100 +++ b/widgets/PluginPathConfigurator.cpp Fri May 25 16:05:51 2018 +0100 @@ -26,6 +26,8 @@ #include "IconLoader.h" #include "WidgetScale.h" +#include "plugin/PluginPathSetter.h" + PluginPathConfigurator::PluginPathConfigurator(QWidget *parent) : QFrame(parent) { @@ -59,7 +61,7 @@ buttons->addWidget(m_delete); m_reset = new QPushButton; - m_reset->setText(tr("Reset")); + m_reset->setText(tr("Reset to Default")); m_reset->setToolTip(tr("Reset the list for this plugin type to its default")); connect(m_reset, SIGNAL(clicked()), this, SLOT(resetClicked())); buttons->addWidget(m_reset); @@ -85,7 +87,7 @@ this, SLOT(currentLocationChanged(int))); ++row; - m_layout->addLayout(buttons, row, 0, Qt::AlignLeft); + m_layout->addLayout(buttons, row, 0, 1, 2, Qt::AlignLeft); m_seePlugins = new QPushButton; m_seePlugins->setText(tr("Review plugins...")); @@ -106,12 +108,11 @@ } void -PluginPathConfigurator::setPaths(Paths paths) +PluginPathConfigurator::setPaths(PluginPathSetter::Paths paths) { m_paths = paths; - if (m_originalPaths.empty()) { - m_originalPaths = paths; - } + + m_defaultPaths = PluginPathSetter::getDefaultPaths(); m_pluginTypeSelector->clear(); for (const auto &p: paths) { @@ -169,7 +170,7 @@ m_up->setEnabled(i > 0); m_down->setEnabled(i >= 0 && i + 1 < path.size()); m_delete->setEnabled(i >= 0 && i < path.size()); - m_reset->setEnabled(path != m_originalPaths.at(type).directories); + m_reset->setEnabled(path != m_defaultPaths.at(type).directories); } void @@ -189,7 +190,7 @@ newEntry.useEnvVariable = useEnvVariable; m_paths[type] = newEntry; - emit pathsChanged(m_paths); + emit pathsChanged(); } void @@ -218,7 +219,7 @@ populateFor(type, current - 1); - emit pathsChanged(m_paths); + emit pathsChanged(); } void @@ -247,7 +248,7 @@ populateFor(type, current + 1); - emit pathsChanged(m_paths); + emit pathsChanged(); } void @@ -266,7 +267,7 @@ populateFor(type, newEntry.directories.size() - 1); - emit pathsChanged(m_paths); + emit pathsChanged(); } void @@ -291,17 +292,17 @@ populateFor(type, current < newPath.size() ? current : current-1); - emit pathsChanged(m_paths); + emit pathsChanged(); } void PluginPathConfigurator::resetClicked() { QString type = m_pluginTypeSelector->currentText(); - m_paths[type] = m_originalPaths[type]; + m_paths[type] = m_defaultPaths[type]; populateFor(type, -1); - emit pathsChanged(m_paths); + emit pathsChanged(); } void
--- a/widgets/PluginPathConfigurator.h Fri May 25 13:39:08 2018 +0100 +++ b/widgets/PluginPathConfigurator.h Fri May 25 16:05:51 2018 +0100 @@ -26,6 +26,8 @@ class QComboBox; class QCheckBox; +#include "plugin/PluginPathSetter.h" + class PluginPathConfigurator : public QFrame { Q_OBJECT @@ -34,23 +36,11 @@ PluginPathConfigurator(QWidget *parent = 0); ~PluginPathConfigurator(); - // Text used to identify a plugin type to the user. - // e.g. "LADSPA", "Vamp", or potentially transliterations thereof - typedef QString PluginTypeLabel; - - struct PathConfig { - QStringList directories; - QString envVariable; // e.g. "LADSPA_PATH" etc - bool useEnvVariable; // true if env variable overrides directories list - }; - - typedef std::map<PluginTypeLabel, PathConfig> Paths; - - void setPaths(Paths paths); - Paths getPaths() const; + void setPaths(PluginPathSetter::Paths paths); + PluginPathSetter::Paths getPaths() const { return m_paths; } signals: - void pathsChanged(const Paths &paths); + void pathsChanged(); private slots: void upClicked(); @@ -76,8 +66,8 @@ QPushButton *m_reset; QCheckBox *m_envOverride; - Paths m_paths; - Paths m_originalPaths; + PluginPathSetter::Paths m_paths; + PluginPathSetter::Paths m_defaultPaths; void populate(); void populateFor(QString type, int makeCurrent);
--- a/widgets/PluginReviewDialog.cpp Fri May 25 13:39:08 2018 +0100 +++ b/widgets/PluginReviewDialog.cpp Fri May 25 16:05:51 2018 +0100 @@ -65,9 +65,9 @@ m_table->setColumnCount(5); QStringList headers; - int typeCol = 0, libCol = 1, nameCol = 2, idCol = 3, dirCol = 4; - headers << tr("Type") << tr("Library") << tr("Name") - << tr("Identifier") << tr("Location"); + int typeCol = 0, libCol = 1, idCol = 2, dirCol = 3, nameCol = 4; + headers << tr("Type") << tr("Library") + << tr("Identifier") << tr("Found in") << tr("Name"); m_table->setHorizontalHeaderLabels(headers); int row = 0;