# HG changeset patch # User Chris Cannam # Date 1527089075 -3600 # Node ID b5c71304286ea4feb794da1412c362f19c0905d0 # Parent 050eca637c1977dfd56212fcdc6a0a69a7b0f559 Add "Add" diff -r 050eca637c19 -r b5c71304286e widgets/PluginPathConfigurator.cpp --- a/widgets/PluginPathConfigurator.cpp Wed May 23 11:52:19 2018 +0100 +++ b/widgets/PluginPathConfigurator.cpp Wed May 23 16:24:35 2018 +0100 @@ -20,6 +20,7 @@ #include #include #include +#include #include "IconLoader.h" #include "WidgetScale.h" @@ -29,6 +30,38 @@ { m_layout = new QGridLayout; setLayout(m_layout); + + QHBoxLayout *buttons = new QHBoxLayout; + + m_down = new QPushButton; + m_down->setIcon(IconLoader().load("down")); + m_down->setToolTip(tr("Move the selected location later in the list")); + connect(m_down, SIGNAL(clicked()), this, SLOT(downClicked())); + buttons->addWidget(m_down); + + m_up = new QPushButton; + m_up->setIcon(IconLoader().load("up")); + m_up->setToolTip(tr("Move the selected location earlier in the list")); + connect(m_up, SIGNAL(clicked()), this, SLOT(upClicked())); + buttons->addWidget(m_up); + + m_add = new QPushButton; + m_add->setIcon(IconLoader().load("plus")); + m_add->setToolTip(tr("Move the selected location earlier in the list")); + connect(m_add, SIGNAL(clicked()), this, SLOT(addClicked())); + buttons->addWidget(m_add); + + m_delete = new QPushButton; + m_delete->setIcon(IconLoader().load("datadelete")); + m_delete->setToolTip(tr("Remove the selected location from the list")); + connect(m_delete, SIGNAL(clicked()), this, SLOT(deleteClicked())); + buttons->addWidget(m_delete); + + m_reset = new QPushButton; + m_reset->setText(tr("Reset")); + 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); int row = 0; @@ -42,7 +75,6 @@ this, SLOT(currentTypeChanged(QString))); m_layout->setColumnStretch(1, 10); - ++row; m_list = new QListWidget; @@ -51,40 +83,15 @@ connect(m_list, SIGNAL(currentRowChanged(int)), this, SLOT(currentLocationChanged(int))); ++row; - - QHBoxLayout *buttons = new QHBoxLayout; - - m_down = new QPushButton; - m_down->setIcon(IconLoader().load("down")); - m_down->setToolTip(tr("Move the selected location later in the list")); - connect(m_down, SIGNAL(clicked()), this, SLOT(downClicked())); - buttons->addWidget(m_down); - - m_up = new QPushButton; - m_up->setIcon(IconLoader().load("up")); - m_up->setToolTip(tr("Move the selected location earlier in the list")); - connect(m_up, SIGNAL(clicked()), this, SLOT(upClicked())); - buttons->addWidget(m_up); - - m_delete = new QPushButton; - m_delete->setIcon(IconLoader().load("datadelete")); - m_delete->setToolTip(tr("Remove the selected location from the list")); - connect(m_delete, SIGNAL(clicked()), this, SLOT(deleteClicked())); - buttons->addWidget(m_delete); - - m_reset = new QPushButton; - m_reset->setText(tr("Reset")); - 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); m_layout->addLayout(buttons, row, 2); ++row; - + m_envOverride = new QCheckBox; connect(m_envOverride, SIGNAL(stateChanged(int)), this, SLOT(envOverrideChanged(int))); m_layout->addWidget(m_envOverride, row, 0, 1, 3); + ++row; } PluginPathConfigurator::~PluginPathConfigurator() @@ -123,7 +130,7 @@ QString envVariable = m_paths.at(type).envVariable; bool useEnvVariable = m_paths.at(type).useEnvVariable; m_envOverride->setText - (tr("Allow the %1 environment variable to override this") + (tr("Allow the %1 environment variable to take priority over this") .arg(envVariable)); m_envOverride->setCheckState(useEnvVariable ? Qt::Checked : Qt::Unchecked); @@ -225,6 +232,23 @@ } void +PluginPathConfigurator::addClicked() +{ + QString type = m_pluginTypeSelector->currentText(); + + QString newDir = QFileDialog::getExistingDirectory + (this, tr("Choose directory to add")); + + if (newDir == QString()) return; + + auto newEntry = m_paths.at(type); + newEntry.directories.push_back(newDir); + m_paths[type] = newEntry; + + populateFor(type, newEntry.directories.size() - 1); +} + +void PluginPathConfigurator::deleteClicked() { QString type = m_pluginTypeSelector->currentText(); diff -r 050eca637c19 -r b5c71304286e widgets/PluginPathConfigurator.h --- a/widgets/PluginPathConfigurator.h Wed May 23 11:52:19 2018 +0100 +++ b/widgets/PluginPathConfigurator.h Wed May 23 16:24:35 2018 +0100 @@ -55,6 +55,7 @@ private slots: void upClicked(); void downClicked(); + void addClicked(); void deleteClicked(); void resetClicked(); void currentTypeChanged(QString); @@ -68,6 +69,7 @@ QListWidget *m_list; QPushButton *m_up; QPushButton *m_down; + QPushButton *m_add; QPushButton *m_delete; QPushButton *m_reset; QCheckBox *m_envOverride;