18 #include <QPushButton> 19 #include <QListWidget> 20 #include <QGridLayout> 24 #include <QFileDialog> 29 #include "plugin/PluginPathSetter.h" 37 QHBoxLayout *buttons =
new QHBoxLayout;
41 m_down->setToolTip(tr(
"Move the selected location later in the list"));
43 buttons->addWidget(
m_down);
45 m_up =
new QPushButton;
47 m_up->setToolTip(tr(
"Move the selected location earlier in the list"));
49 buttons->addWidget(
m_up);
51 m_add =
new QPushButton;
53 m_add->setToolTip(tr(
"Add a new location to the list"));
55 buttons->addWidget(
m_add);
59 m_delete->setToolTip(tr(
"Remove the selected location from the list"));
64 m_reset->setText(tr(
"Reset to Default"));
65 m_reset->setToolTip(tr(
"Reset the list for this plugin type to its default"));
69 buttons->addStretch(50);
79 m_header->setText(tr(
"Plugin locations for plugin type:"));
93 connect(
m_list, SIGNAL(currentRowChanged(
int)),
97 m_layout->addLayout(buttons, row, 0, 1, 3);
115 if (key.second == KnownPlugins::FormatNative) {
117 case KnownPlugins::VampPlugin:
119 case KnownPlugins::LADSPAPlugin:
121 case KnownPlugins::DSSIPlugin:
124 }
else if (key.second == KnownPlugins::FormatNonNative32Bit) {
126 case KnownPlugins::VampPlugin:
127 return tr(
"Vamp (32-bit)");
128 case KnownPlugins::LADSPAPlugin:
129 return tr(
"LADSPA (32-bit)");
130 case KnownPlugins::DSSIPlugin:
131 return tr(
"DSSI (32-bit)");
134 SVCERR <<
"PluginPathConfigurator::getLabelFor: WARNING: " 135 <<
"Unknown format value " << key.second << endl;
139 PluginPathSetter::TypeKey
148 SVCERR <<
"PluginPathConfigurator::getKeyForLabel: WARNING: " 149 <<
"Unrecognised label \"" << label <<
"\"" << endl;
150 return { KnownPlugins::VampPlugin, KnownPlugins::FormatNative };
161 for (
const auto &p: paths) {
182 QString envVariable =
m_paths.at(key).envVariable;
183 bool useEnvVariable =
m_paths.at(key).useEnvVariable;
184 QString envVarValue =
185 PluginPathSetter::getOriginalEnvironmentValue(envVariable);
186 QString currentValueRubric;
187 if (envVarValue == QString()) {
188 currentValueRubric = tr(
"(Variable is currently unset)");
190 if (envVarValue.length() > 100) {
191 QString envVarStart = envVarValue.left(95);
192 currentValueRubric = tr(
"(Current value begins: \"%1 ...\")")
195 currentValueRubric = tr(
"(Currently set to: \"%1\")")
200 (tr(
"Allow the %1 environment variable to take priority over this\n%2")
202 .arg(currentValueRubric));
203 m_envOverride->setCheckState(useEnvVariable ? Qt::Checked : Qt::Unchecked);
215 QStringList path =
m_paths.at(key).directories;
217 for (
int i = 0; i < path.size(); ++i) {
221 if (makeCurrent < path.size()) {
222 m_list->setCurrentRow(makeCurrent);
232 QStringList path =
m_paths.at(key).directories;
233 m_up->setEnabled(i > 0);
234 m_down->setEnabled(i >= 0 && i + 1 < path.size());
235 m_delete->setEnabled(i >= 0 && i < path.size());
248 bool useEnvVariable = (state == Qt::Checked);
253 auto newEntry =
m_paths.at(key);
254 newEntry.useEnvVariable = useEnvVariable;
265 QStringList path =
m_paths.at(key).directories;
267 int current =
m_list->currentRow();
268 if (current <= 0)
return;
271 for (
int i = 0; i < path.size(); ++i) {
272 if (i + 1 == current) {
273 newPath.push_back(path[i+1]);
274 newPath.push_back(path[i]);
277 newPath.push_back(path[i]);
281 auto newEntry =
m_paths.at(key);
282 newEntry.directories = newPath;
295 QStringList path =
m_paths.at(key).directories;
297 int current =
m_list->currentRow();
298 if (current < 0 || current + 1 >= path.size())
return;
301 for (
int i = 0; i < path.size(); ++i) {
303 newPath.push_back(path[i+1]);
304 newPath.push_back(path[i]);
307 newPath.push_back(path[i]);
311 auto newEntry =
m_paths.at(key);
312 newEntry.directories = newPath;
326 QString newDir = QFileDialog::getExistingDirectory
327 (
this, tr(
"Choose directory to add"));
329 if (newDir == QString())
return;
331 auto newEntry =
m_paths.at(key);
332 newEntry.directories.push_back(newDir);
345 QStringList path =
m_paths.at(key).directories;
347 int current =
m_list->currentRow();
348 if (current < 0)
return;
351 for (
int i = 0; i < path.size(); ++i) {
353 newPath.push_back(path[i]);
357 auto newEntry =
m_paths.at(key);
358 newEntry.directories = newPath;
361 populateFor(key, current < newPath.size() ? current : current-1);
QCheckBox * m_envOverride
~PluginPathConfigurator()
QPushButton * m_seePlugins
PluginPathConfigurator(QWidget *parent=0)
void envOverrideChanged(int)
void currentLocationChanged(int)
void setPaths(PluginPathSetter::Paths paths)
void populateFor(PluginPathSetter::TypeKey, int makeCurrent)
void currentTypeChanged(QString)
QString getLabelFor(PluginPathSetter::TypeKey)
PluginPathSetter::Paths m_defaultPaths
PluginPathSetter::Paths m_paths
QComboBox * m_pluginTypeSelector
PluginPathSetter::TypeKey getKeyForLabel(QString label)