From 88c56d8250ffc8715b41d0a7442465015edb719a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 5 Jan 2010 22:31:06 +0000 Subject: [PATCH] - Added support for magnet links in search engine. Most search Web sites provides magnet links now and in the futures, they may provide only the magnet links. --- Changelog | 1 + src/GUI.h | 186 +++++++++++++++++++++---------------------- src/searchengine.cpp | 24 +++--- 3 files changed, 109 insertions(+), 102 deletions(-) diff --git a/Changelog b/Changelog index 51c4711fd..dda0aa948 100644 --- a/Changelog +++ b/Changelog @@ -12,6 +12,7 @@ - FEATURE: Torrents can be renamed in transfer list - FEATURE: Display torrent addition dialog for magnet links too - FEATURE: Files contained in a torrent are opened on double click (files panel) + - FEATURE: Added support for magnet links in search engine - BUGFIX: Use XDG folders (.cache, .local) instead of .qbittorrent - COSMETIC: Use checkboxes to filter torrent content instead of comboboxes - COSMETIC: Use alternating row colors in transfer list (set in program preferences) diff --git a/src/GUI.h b/src/GUI.h index 86b1fe212..e20c80ef8 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -59,104 +59,104 @@ class StatusBar; class GUI : public QMainWindow, private Ui::MainWindow{ Q_OBJECT - private: - // Bittorrent - Bittorrent *BTSession; - QList > unauthenticated_trackers; // Still needed? - // GUI related - QTimer *guiUpdater; - QTabWidget *tabs; - StatusBar *status_bar; - QPointer options; - QPointer systrayIcon; - QPointer systrayCreator; - QMenu *myTrayIconMenu; - TransferListWidget *transferList; - TransferListFiltersWidget *transferListFilters; - PropertiesWidget *properties; - bool displaySpeedInTitle; - bool force_exit; - // Keyboard shortcuts - QShortcut *switchSearchShortcut; - QShortcut *switchSearchShortcut2; - QShortcut *switchTransferShortcut; - QShortcut *switchRSSShortcut; - // Widgets - QAction *prioSeparator; - QAction *prioSeparator2; - QSplitter *hSplitter; - QSplitter *vSplitter; - // Search - SearchEngine *searchEngine; - // RSS - QPointer rssWidget; - // Misc - QLocalServer *localServer; +private: + // Bittorrent + Bittorrent *BTSession; + QList > unauthenticated_trackers; // Still needed? + // GUI related + QTimer *guiUpdater; + QTabWidget *tabs; + StatusBar *status_bar; + QPointer options; + QPointer systrayIcon; + QPointer systrayCreator; + QMenu *myTrayIconMenu; + TransferListWidget *transferList; + TransferListFiltersWidget *transferListFilters; + PropertiesWidget *properties; + bool displaySpeedInTitle; + bool force_exit; + // Keyboard shortcuts + QShortcut *switchSearchShortcut; + QShortcut *switchSearchShortcut2; + QShortcut *switchTransferShortcut; + QShortcut *switchRSSShortcut; + // Widgets + QAction *prioSeparator; + QAction *prioSeparator2; + QSplitter *hSplitter; + QSplitter *vSplitter; + // Search + SearchEngine *searchEngine; + // RSS + QPointer rssWidget; + // Misc + QLocalServer *localServer; - protected slots: - // GUI related slots - void dropEvent(QDropEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - void toggleVisibility(QSystemTrayIcon::ActivationReason e); - void on_actionAbout_triggered(); - void on_actionCreate_torrent_triggered(); - void on_actionWebsite_triggered() const; - void on_actionBugReport_triggered() const; - void on_actionShow_console_triggered(); - void readParamsOnSocket(); - void acceptConnection(); - void balloonClicked(); - void writeSettings(); - void readSettings(); - void on_actionExit_triggered(); - void createTrayIcon(); - void fullDiskError(QTorrentHandle& h, QString msg) const; - void handleDownloadFromUrlFailure(QString, QString) const; - void createSystrayDelayed(); - void tab_changed(int); - // Keyboard shortcuts - void createKeyboardShortcuts(); - void displayTransferTab() const; - void displaySearchTab() const; - void displayRSSTab() const; - // Torrent actions - void on_actionSet_global_upload_limit_triggered(); - void on_actionSet_global_download_limit_triggered(); - void on_actionDocumentation_triggered() const; - void on_actionOpen_triggered(); - void updateGUI(); - void loadPreferences(bool configure_session=true); - void processParams(const QStringList& params); - void addTorrent(QString path); - void addUnauthenticatedTracker(QPair tracker); - void processDownloadedFiles(QString path, QString url); - void downloadFromURLList(const QStringList& urls); - void finishedTorrent(QTorrentHandle& h) const; - // Options slots - void on_actionOptions_triggered(); - void optionsSaved(); - // HTTP slots - void on_actionDownload_from_URL_triggered(); +protected slots: + // GUI related slots + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + void toggleVisibility(QSystemTrayIcon::ActivationReason e); + void on_actionAbout_triggered(); + void on_actionCreate_torrent_triggered(); + void on_actionWebsite_triggered() const; + void on_actionBugReport_triggered() const; + void on_actionShow_console_triggered(); + void readParamsOnSocket(); + void acceptConnection(); + void balloonClicked(); + void writeSettings(); + void readSettings(); + void on_actionExit_triggered(); + void createTrayIcon(); + void fullDiskError(QTorrentHandle& h, QString msg) const; + void handleDownloadFromUrlFailure(QString, QString) const; + void createSystrayDelayed(); + void tab_changed(int); + // Keyboard shortcuts + void createKeyboardShortcuts(); + void displayTransferTab() const; + void displaySearchTab() const; + void displayRSSTab() const; + // Torrent actions + void on_actionSet_global_upload_limit_triggered(); + void on_actionSet_global_download_limit_triggered(); + void on_actionDocumentation_triggered() const; + void on_actionOpen_triggered(); + void updateGUI(); + void loadPreferences(bool configure_session=true); + void processParams(const QStringList& params); + void addTorrent(QString path); + void addUnauthenticatedTracker(QPair tracker); + void processDownloadedFiles(QString path, QString url); + void finishedTorrent(QTorrentHandle& h) const; + // Options slots + void on_actionOptions_triggered(); + void optionsSaved(); + // HTTP slots + void on_actionDownload_from_URL_triggered(); - public slots: - void trackerAuthenticationRequired(QTorrentHandle& h); - void setTabText(int index, QString text) const; - void showNotificationBaloon(QString title, QString msg) const; +public slots: + void trackerAuthenticationRequired(QTorrentHandle& h); + void setTabText(int index, QString text) const; + void showNotificationBaloon(QString title, QString msg) const; + void downloadFromURLList(const QStringList& urls); - protected: - void closeEvent(QCloseEvent *); - void showEvent(QShowEvent *); - bool event(QEvent * event); - void displayRSSTab(bool enable); +protected: + void closeEvent(QCloseEvent *); + void showEvent(QShowEvent *); + bool event(QEvent * event); + void displayRSSTab(bool enable); - public: - // Construct / Destruct - GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); - ~GUI(); - // Methods - int getCurrentTabIndex() const; - QPoint screenCenter() const; +public: + // Construct / Destruct + GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); + ~GUI(); + // Methods + int getCurrentTabIndex() const; + QPoint screenCenter() const; }; #endif diff --git a/src/searchengine.cpp b/src/searchengine.cpp index d94a3a602..1c69a4cc5 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -301,15 +301,21 @@ void SearchEngine::saveResultsColumnsWidth() { } void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) { - QProcess *downloadProcess = new QProcess(this); - connect(downloadProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(downloadFinished(int,QProcess::ExitStatus))); - downloaders << downloadProcess; - QStringList params; - params << misc::searchEngineLocation()+QDir::separator()+"nova2dl.py"; - params << engine_url; - params << torrent_url; - // Launch search - downloadProcess->start("python", params, QIODevice::ReadOnly); + if(torrent_url.startsWith("magnet:")) { + QStringList urls; + urls << torrent_url; + parent->downloadFromURLList(urls); + } else { + QProcess *downloadProcess = new QProcess(this); + connect(downloadProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(downloadFinished(int,QProcess::ExitStatus))); + downloaders << downloadProcess; + QStringList params; + params << misc::searchEngineLocation()+QDir::separator()+"nova2dl.py"; + params << engine_url; + params << torrent_url; + // Launch search + downloadProcess->start("python", params, QIODevice::ReadOnly); + } } void SearchEngine::searchStarted(){