Merge pull request #3178 from ngosang/search_version_32x

[Search engine] Show the version of search engines (v3_2_x)
This commit is contained in:
sledgehammer999 2015-06-13 02:23:53 +03:00
commit f46eafc9fd
2 changed files with 19 additions and 8 deletions

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>541</width> <width>600</width>
<height>254</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="acceptDrops"> <property name="acceptDrops">
@ -50,6 +50,11 @@
<string>Name</string> <string>Name</string>
</property> </property>
</column> </column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
<column> <column>
<property name="text"> <property name="text">
<string>Url</string> <string>Url</string>

View file

@ -46,14 +46,16 @@
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QMimeData> #include <QMimeData>
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID}; enum EngineColumns {ENGINE_NAME, ENGINE_VERSION, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
const QString UPDATE_URL = QString("https://raw.github.com/qbittorrent/qBittorrent/master/src/searchengine/") + (misc::pythonVersion() >= 3 ? "nova3" : "nova") + "/engines/"; const QString UPDATE_URL = QString("https://raw.github.com/qbittorrent/qBittorrent/master/src/searchengine/") + (misc::pythonVersion() >= 3 ? "nova3" : "nova") + "/engines/";
engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) { engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) {
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
pluginsTree->header()->resizeSection(0, 170); pluginsTree->setRootIsDecorated(false);
pluginsTree->header()->resizeSection(1, 220); pluginsTree->header()->resizeSection(0, 160);
pluginsTree->header()->resizeSection(1, 80);
pluginsTree->header()->resizeSection(2, 200);
pluginsTree->hideColumn(ENGINE_ID); pluginsTree->hideColumn(ENGINE_ID);
actionUninstall->setIcon(IconProvider::instance()->getIcon("list-remove")); actionUninstall->setIcon(IconProvider::instance()->getIcon("list-remove"));
connect(actionEnable, SIGNAL(toggled(bool)), this, SLOT(enableSelection(bool))); connect(actionEnable, SIGNAL(toggled(bool)), this, SLOT(enableSelection(bool)));
@ -270,11 +272,12 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
return; return;
} }
} }
// Install was successful, remove backup // Install was successful, remove backup and update plugin version
if (update) { if (update) {
fsutils::forceRemove(dest_path+".bak"); fsutils::forceRemove(dest_path+".bak");
} qreal version = SearchEngine::getPluginVersion(fsutils::searchEngineLocation() + "/engines/" + plugin_name + ".py");
if (update) { QTreeWidgetItem *item = findItemWithID(plugin_name);
item->setText(ENGINE_VERSION, QString::number(version, 'f', 2));
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name)); QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name));
return; return;
} else { } else {
@ -318,6 +321,9 @@ void engineSelectDlg::addNewEngine(QString engine_name) {
downloader->downloadUrl(engine->getUrl()+"/favicon.ico"); downloader->downloadUrl(engine->getUrl()+"/favicon.ico");
} }
} }
// Load version
qreal version = SearchEngine::getPluginVersion(fsutils::searchEngineLocation() + "/engines/" + engine->getName() + ".py");
item->setText(ENGINE_VERSION, QString::number(version, 'f', 2));
} }
void engineSelectDlg::on_installButton_clicked() { void engineSelectDlg::on_installButton_clicked() {