mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 23:37:59 +00:00
Merge pull request #2098 from DoumanAsh/int_search_combo
Add combo box for fast search engine switch
This commit is contained in:
commit
bbd0dfb298
@ -19,6 +19,9 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboCategory"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="selectEngine"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="search_button">
|
||||
<property name="maximumSize">
|
||||
|
@ -92,8 +92,10 @@ SearchEngine::SearchEngine(MainWindow* parent)
|
||||
supported_engines = new SupportedEngines();
|
||||
// Fill in category combobox
|
||||
fillCatCombobox();
|
||||
fillEngineComboBox();
|
||||
|
||||
connect(search_pattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString)));
|
||||
connect(selectEngine, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectMultipleBox(const QString&)));
|
||||
}
|
||||
|
||||
void SearchEngine::fillCatCombobox() {
|
||||
@ -106,10 +108,23 @@ void SearchEngine::fillCatCombobox() {
|
||||
}
|
||||
}
|
||||
|
||||
void SearchEngine::fillEngineComboBox() {
|
||||
selectEngine->clear();
|
||||
selectEngine->addItem("All enabled", QVariant("enabled"));
|
||||
selectEngine->addItem("All engines", QVariant("all"));
|
||||
foreach (QString engi, supported_engines->enginesEnabled())
|
||||
selectEngine->addItem(engi, QVariant(engi));
|
||||
selectEngine->addItem("Multiple...", QVariant("multi"));
|
||||
}
|
||||
|
||||
QString SearchEngine::selectedCategory() const {
|
||||
return comboCategory->itemData(comboCategory->currentIndex()).toString();
|
||||
}
|
||||
|
||||
QString SearchEngine::selectedEngine() const {
|
||||
return selectEngine->itemData(selectEngine->currentIndex()).toString();
|
||||
}
|
||||
|
||||
SearchEngine::~SearchEngine() {
|
||||
qDebug("Search destruction");
|
||||
searchProcess->kill();
|
||||
@ -131,21 +146,26 @@ SearchEngine::~SearchEngine() {
|
||||
void SearchEngine::tab_changed(int t)
|
||||
{//when we switch from a tab that is not empty to another that is empty the download button
|
||||
//doesn't have to be available
|
||||
if (t>-1)
|
||||
{//-1 = no more tab
|
||||
if (t>-1) {//-1 = no more tab
|
||||
if (all_tab.at(tabWidget->currentIndex())->getCurrentSearchListModel()->rowCount()) {
|
||||
download_button->setEnabled(true);
|
||||
goToDescBtn->setEnabled(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
download_button->setEnabled(false);
|
||||
goToDescBtn->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SearchEngine::selectMultipleBox(const QString &text) {
|
||||
if (text == "Multiple...") on_enginesButton_clicked();
|
||||
}
|
||||
|
||||
void SearchEngine::on_enginesButton_clicked() {
|
||||
engineSelectDlg *dlg = new engineSelectDlg(this, supported_engines);
|
||||
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillCatCombobox()));
|
||||
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillEngineComboBox()));
|
||||
}
|
||||
|
||||
void SearchEngine::searchTextEdited(QString) {
|
||||
@ -197,7 +217,10 @@ void SearchEngine::on_search_button_clicked() {
|
||||
QStringList params;
|
||||
search_stopped = false;
|
||||
params << fsutils::toNativePath(fsutils::searchEngineLocation() + "/nova2.py");
|
||||
params << supported_engines->enginesEnabled().join(",");
|
||||
if (selectedEngine() == "all") params << supported_engines->enginesAll().join(",");
|
||||
else if (selectedEngine() == "enabled") params << supported_engines->enginesEnabled().join(",");
|
||||
else if (selectedEngine() == "multi") params << supported_engines->enginesEnabled().join(",");
|
||||
else params << selectedEngine();
|
||||
qDebug("Search with category: %s", qPrintable(selectedCategory()));
|
||||
params << selectedCategory();
|
||||
params << pattern.split(" ");
|
||||
@ -231,6 +254,7 @@ void SearchEngine::saveResultsColumnsWidth() {
|
||||
if (!line.isEmpty()) {
|
||||
width_list = line.split(' ');
|
||||
}
|
||||
|
||||
for (short i=0; i<nbColumns; ++i) {
|
||||
if (treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) {
|
||||
// load the former width
|
||||
@ -428,6 +452,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSearchTab)
|
||||
currentSearchTab->getCurrentLabel()->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+QString::number(nb_search_results)+QString::fromUtf8(")</i>:"));
|
||||
search_button->setText(tr("Search"));
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
SearchEngine(MainWindow *mp_mainWindow);
|
||||
~SearchEngine();
|
||||
QString selectedCategory() const;
|
||||
QString selectedEngine() const;
|
||||
|
||||
static qreal getPluginVersion(QString filePath) {
|
||||
QFile plugin(filePath);
|
||||
@ -98,11 +99,13 @@ protected slots:
|
||||
void readSearchOutput();
|
||||
void searchStarted();
|
||||
void updateNova();
|
||||
void selectMultipleBox(const QString &text);
|
||||
void on_enginesButton_clicked();
|
||||
void propagateSectionResized(int index, int oldsize , int newsize);
|
||||
void saveResultsColumnsWidth();
|
||||
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
||||
void fillCatCombobox();
|
||||
void fillEngineComboBox();
|
||||
void searchTextEdited(QString);
|
||||
|
||||
private slots:
|
||||
|
@ -113,6 +113,12 @@ public:
|
||||
qDeleteAll(this->values());
|
||||
}
|
||||
|
||||
QStringList enginesAll() const {
|
||||
QStringList engines;
|
||||
foreach (const SupportedEngine *engine, values()) engines << engine->getName();
|
||||
return engines;
|
||||
}
|
||||
|
||||
QStringList enginesEnabled() const {
|
||||
QStringList engines;
|
||||
foreach (const SupportedEngine *engine, values()) {
|
||||
|
Loading…
Reference in New Issue
Block a user