mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
- FEATURE: Allow to drag'n drop plugin to list for install/update
- Added some debug
This commit is contained in:
parent
e3214a9b6a
commit
2c27f952e2
5 changed files with 101 additions and 53 deletions
2
TODO
2
TODO
|
@ -49,7 +49,6 @@
|
||||||
- valgrind --tool=memcheck --leak-check=full src/qbittorrent (Looks ok)
|
- valgrind --tool=memcheck --leak-check=full src/qbittorrent (Looks ok)
|
||||||
- 128m 29m 16m S 4.8 2.9 0:02.28 qbittorrent
|
- 128m 29m 16m S 4.8 2.9 0:02.28 qbittorrent
|
||||||
* beta 7
|
* beta 7
|
||||||
- Allow to drag'n drop plugins
|
|
||||||
- read icon meta in xhtml pages when favicon.ico can't be downloaded?
|
- read icon meta in xhtml pages when favicon.ico can't be downloaded?
|
||||||
- Translations update (IN PROGRESS)
|
- Translations update (IN PROGRESS)
|
||||||
- Wait for some bug fixes in libtorrent :
|
- Wait for some bug fixes in libtorrent :
|
||||||
|
@ -78,6 +77,7 @@ LANGUAGES UPDATED:
|
||||||
|
|
||||||
beta6->beta7 changelog:
|
beta6->beta7 changelog:
|
||||||
- FEATURE: Made search engine plugin install more reliable
|
- FEATURE: Made search engine plugin install more reliable
|
||||||
|
- FEATURE: Allow to drag'n drop plugin to list for install/update
|
||||||
- BUGFIX: Updated man page / README / INSTALL
|
- BUGFIX: Updated man page / README / INSTALL
|
||||||
- BUGFIX: Paused torrents could be displayed as connected for a sec after checking
|
- BUGFIX: Paused torrents could be displayed as connected for a sec after checking
|
||||||
- BUGFIX: 'Unknown' is now displayed in search results columns where value is -1
|
- BUGFIX: 'Unknown' is now displayed in search results columns where value is -1
|
||||||
|
|
|
@ -553,6 +553,10 @@ void GUI::dropEvent(QDropEvent *event) {
|
||||||
|
|
||||||
// Decode if we accept drag 'n drop or not
|
// Decode if we accept drag 'n drop or not
|
||||||
void GUI::dragEnterEvent(QDragEnterEvent *event) {
|
void GUI::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
|
QString mime;
|
||||||
|
foreach(mime, event->mimeData()->formats()){
|
||||||
|
qDebug("mimeData: %s", mime.toUtf8().data());
|
||||||
|
}
|
||||||
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain"))) {
|
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain"))) {
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
<height>254</height>
|
<height>254</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="acceptDrops" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Search plugins</string>
|
<string>Search plugins</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QDropEvent>
|
||||||
|
|
||||||
#ifdef HAVE_MAGICK
|
#ifdef HAVE_MAGICK
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
|
@ -67,6 +68,33 @@ engineSelectDlg::~engineSelectDlg() {
|
||||||
qDebug("Engine plugins dialog destroyed");
|
qDebug("Engine plugins dialog destroyed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void engineSelectDlg::dropEvent(QDropEvent *event) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n"));
|
||||||
|
QString file;
|
||||||
|
foreach(file, files) {
|
||||||
|
qDebug("dropped %s", file.toUtf8().data());
|
||||||
|
file = file.replace("file://", "");
|
||||||
|
if(file.startsWith("http://") || file.startsWith("https://") || file.startsWith("ftp://")) {
|
||||||
|
downloader->downloadUrl(file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(file.endsWith(".py"))
|
||||||
|
installPlugin(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode if we accept drag 'n drop or not
|
||||||
|
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
|
QString mime;
|
||||||
|
foreach(mime, event->mimeData()->formats()){
|
||||||
|
qDebug("mimeData: %s", mime.toUtf8().data());
|
||||||
|
}
|
||||||
|
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain"))) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void engineSelectDlg::loadSettings() {
|
void engineSelectDlg::loadSettings() {
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
known_engines = settings.value(QString::fromUtf8("SearchEngines/knownEngines"), QStringList()).toStringList();
|
known_engines = settings.value(QString::fromUtf8("SearchEngines/knownEngines"), QStringList()).toStringList();
|
||||||
|
@ -293,19 +321,14 @@ bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) con
|
||||||
return (new_version > old_version);
|
return (new_version > old_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void engineSelectDlg::on_installButton_clicked() {
|
void engineSelectDlg::installPlugin(QString path) {
|
||||||
QStringList pathsList = QFileDialog::getOpenFileNames(0,
|
if(!path.endsWith(".py")) return;
|
||||||
tr("Select search plugins"), QDir::homePath(),
|
|
||||||
tr("qBittorrent search plugins")+QString::fromUtf8(" (*.py)"));
|
|
||||||
QString path;
|
|
||||||
foreach(path, pathsList) {
|
|
||||||
if(!path.endsWith(".py")) continue;
|
|
||||||
float new_version = misc::getPluginVersion(path);
|
float new_version = misc::getPluginVersion(path);
|
||||||
QString plugin_name = path.split(QDir::separator()).last();
|
QString plugin_name = path.split(QDir::separator()).last();
|
||||||
plugin_name.replace(".py", "");
|
plugin_name.replace(".py", "");
|
||||||
if(!isUpdateNeeded(plugin_name, new_version)) {
|
if(!isUpdateNeeded(plugin_name, new_version)) {
|
||||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
// Process with install
|
// Process with install
|
||||||
QString dest_path = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py";
|
QString dest_path = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py";
|
||||||
|
@ -343,12 +366,21 @@ void engineSelectDlg::on_installButton_clicked() {
|
||||||
loadSupportedSearchEngines();
|
loadSupportedSearchEngines();
|
||||||
if(update) {
|
if(update) {
|
||||||
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.toUtf8().data()));
|
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.toUtf8().data()));
|
||||||
continue;
|
return;
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void engineSelectDlg::on_installButton_clicked() {
|
||||||
|
QStringList pathsList = QFileDialog::getOpenFileNames(0,
|
||||||
|
tr("Select search plugins"), QDir::homePath(),
|
||||||
|
tr("qBittorrent search plugins")+QString::fromUtf8(" (*.py)"));
|
||||||
|
QString path;
|
||||||
|
foreach(path, pathsList) {
|
||||||
|
installPlugin(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateServer) {
|
bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateServer) {
|
||||||
|
@ -397,6 +429,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateSer
|
||||||
}
|
}
|
||||||
|
|
||||||
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||||
|
qDebug("engineSelectDlg received %s", url.toUtf8().data());
|
||||||
if(url.endsWith("favicon.ico")){
|
if(url.endsWith("favicon.ico")){
|
||||||
// Icon downloaded
|
// Icon downloaded
|
||||||
QImage fileIcon;
|
QImage fileIcon;
|
||||||
|
@ -442,10 +475,11 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(url.endsWith(".zip")) {
|
if(url.endsWith(".zip") || url.endsWith(".py")) {
|
||||||
// a plugin update has been downloaded
|
// a plugin update has been downloaded
|
||||||
QString plugin_name = url.split('/').last();
|
QString plugin_name = url.split('/').last();
|
||||||
plugin_name.replace(".zip", "");
|
plugin_name.replace(".zip", "");
|
||||||
|
plugin_name.replace(".py", "");
|
||||||
QString dest_path = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py";
|
QString dest_path = misc::qBittorrentPath()+"search_engine"+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py";
|
||||||
bool new_plugin = false;
|
bool new_plugin = false;
|
||||||
if(QFile::exists(dest_path)) {
|
if(QFile::exists(dest_path)) {
|
||||||
|
@ -460,10 +494,12 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||||
if(new_plugin) {
|
if(new_plugin) {
|
||||||
// if it is new, refresh the list of plugins
|
// if it is new, refresh the list of plugins
|
||||||
loadSupportedSearchEngines();
|
loadSupportedSearchEngines();
|
||||||
}
|
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||||
|
} else {
|
||||||
QMessageBox::information(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("%1 search plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
QMessageBox::information(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("%1 search plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
||||||
if(url.endsWith("favicon.ico")){
|
if(url.endsWith("favicon.ico")){
|
||||||
|
@ -480,10 +516,11 @@ void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
||||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable."));
|
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(url.endsWith(".zip")) {
|
if(url.endsWith(".zip") || url.endsWith(".py")) {
|
||||||
// a plugin update download has been failed
|
// a plugin update download has been failed
|
||||||
QString plugin_name = url.split('/').last();
|
QString plugin_name = url.split('/').last();
|
||||||
plugin_name.replace(".zip", "");
|
plugin_name.replace(".zip", "");
|
||||||
|
plugin_name.replace(".py", "");
|
||||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin update failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin update failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "ui_engineSelect.h"
|
#include "ui_engineSelect.h"
|
||||||
|
|
||||||
class downloadThread;
|
class downloadThread;
|
||||||
|
class QDropEvent;
|
||||||
|
|
||||||
class engineSelectDlg : public QDialog, public Ui::engineSelect{
|
class engineSelectDlg : public QDialog, public Ui::engineSelect{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -65,6 +66,9 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{
|
||||||
void on_actionUninstall_triggered();
|
void on_actionUninstall_triggered();
|
||||||
void on_updateButton_clicked();
|
void on_updateButton_clicked();
|
||||||
void on_installButton_clicked();
|
void on_installButton_clicked();
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void installPlugin(QString plugin_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue