mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
[Search] Add seperator for categories & plugins
Sort categories & plugins entries Rename & reorder entries Use full name for plugins
This commit is contained in:
parent
231262ad8e
commit
a52f9d4ef9
@ -295,6 +295,11 @@ QString SearchEngine::categoryFullName(const QString &categoryName)
|
||||
return tr(m_categoryNames.value(categoryName).toUtf8().constData());
|
||||
}
|
||||
|
||||
QString SearchEngine::pluginFullName(const QString &pluginName)
|
||||
{
|
||||
return pluginInfo(pluginName) ? pluginInfo(pluginName)->fullName : QString();
|
||||
}
|
||||
|
||||
QString SearchEngine::pluginsLocation()
|
||||
{
|
||||
return QString("%1/engines").arg(engineLocation());
|
||||
|
@ -86,6 +86,7 @@ public:
|
||||
|
||||
static qreal getPluginVersion(QString filePath);
|
||||
static QString categoryFullName(const QString &categoryName);
|
||||
QString pluginFullName(const QString &pluginName);
|
||||
static QString pluginsLocation();
|
||||
|
||||
signals:
|
||||
|
@ -121,27 +121,43 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
||||
fillPluginComboBox();
|
||||
|
||||
connect(m_searchPattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString)));
|
||||
connect(selectPlugin, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(selectMultipleBox(const QString &)));
|
||||
connect(selectPlugin, SIGNAL(currentIndexChanged(int)), this, SLOT(selectMultipleBox(int)));
|
||||
}
|
||||
|
||||
void SearchWidget::fillCatCombobox()
|
||||
{
|
||||
comboCategory->clear();
|
||||
comboCategory->addItem(SearchEngine::categoryFullName("all"), QVariant("all"));
|
||||
foreach (QString cat, m_searchEngine->supportedCategories()) {
|
||||
qDebug("Supported category: %s", qPrintable(cat));
|
||||
comboCategory->addItem(SearchEngine::categoryFullName(cat), QVariant(cat));
|
||||
comboCategory->insertSeparator(1);
|
||||
|
||||
using QStrPair = QPair<QString, QString>;
|
||||
QList<QStrPair> tmpList;
|
||||
foreach (const QString &cat, m_searchEngine->supportedCategories())
|
||||
tmpList << qMakePair(SearchEngine::categoryFullName(cat), cat);
|
||||
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } );
|
||||
|
||||
foreach (const QStrPair &p, tmpList) {
|
||||
qDebug("Supported category: %s", qPrintable(p.second));
|
||||
comboCategory->addItem(p.first, QVariant(p.second));
|
||||
}
|
||||
}
|
||||
|
||||
void SearchWidget::fillPluginComboBox()
|
||||
{
|
||||
selectPlugin->clear();
|
||||
selectPlugin->addItem(tr("All enabled"), QVariant("enabled"));
|
||||
selectPlugin->addItem(tr("All plugins"), QVariant("all"));
|
||||
foreach (QString name, m_searchEngine->enabledPlugins())
|
||||
selectPlugin->addItem(name, QVariant(name));
|
||||
selectPlugin->addItem(tr("Multiple..."), QVariant("multi"));
|
||||
selectPlugin->addItem(tr("Only enabled"), QVariant("enabled"));
|
||||
selectPlugin->addItem(tr("Select..."), QVariant("multi"));
|
||||
selectPlugin->insertSeparator(3);
|
||||
|
||||
using QStrPair = QPair<QString, QString>;
|
||||
QList<QStrPair> tmpList;
|
||||
foreach (const QString &name, m_searchEngine->enabledPlugins())
|
||||
tmpList << qMakePair(m_searchEngine->pluginFullName(name), name);
|
||||
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } );
|
||||
|
||||
foreach (const QStrPair &p, tmpList)
|
||||
selectPlugin->addItem(p.first, QVariant(p.second));
|
||||
}
|
||||
|
||||
QString SearchWidget::selectedCategory() const
|
||||
@ -180,9 +196,10 @@ void SearchWidget::tab_changed(int t)
|
||||
}
|
||||
}
|
||||
|
||||
void SearchWidget::selectMultipleBox(const QString &text)
|
||||
void SearchWidget::selectMultipleBox(int index)
|
||||
{
|
||||
if (text == tr("Multiple..."))
|
||||
Q_UNUSED(index);
|
||||
if (selectedPlugin() == "multi")
|
||||
on_pluginsButton_clicked();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ private slots:
|
||||
void searchStarted();
|
||||
void searchFinished(bool cancelled);
|
||||
void searchFailed();
|
||||
void selectMultipleBox(const QString &text);
|
||||
void selectMultipleBox(int index);
|
||||
|
||||
void saveResultsColumnsWidth();
|
||||
void fillCatCombobox();
|
||||
|
Loading…
x
Reference in New Issue
Block a user