From 17f712e3e0e1dae671c7603221e955d86215390d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 25 Nov 2009 22:03:05 +0000 Subject: [PATCH] - Made search engine use libnotify instead of qt notification when available. Note that a notification is displayed when a search request has finished and the search tab is not currently displayed (other tab is displayed or window is minimized/iconified) --- src/GUI.cpp | 4 ++-- src/searchengine.cpp | 8 ++++---- src/searchengine.h | 9 ++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index d045a5aa0..b6a2dd607 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -144,7 +144,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis connect(actionDecreasePriority, SIGNAL(triggered()), transferList, SLOT(decreasePrioSelectedTorrents())); // Search engine tab - searchEngine = new SearchEngine(BTSession, systrayIcon); + searchEngine = new SearchEngine(this, BTSession); tabs->addTab(searchEngine, QIcon(QString::fromUtf8(":/Icons/oxygen/edit-find.png")), tr("Search")); // Configure BT session according to options @@ -429,7 +429,7 @@ void GUI::previewFile(QString filePath) { QDesktopServices::openUrl(QString("file://")+filePath); } -int GUI::getCurrentTabIndex() const{ +int GUI::getCurrentTabIndex() const { if(isMinimized() || !isVisible()) return -1; return tabs->currentIndex(); diff --git a/src/searchengine.cpp b/src/searchengine.cpp index beaf6dbc2..a4b47bb60 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -49,11 +48,12 @@ #include "downloadthread.h" #include "misc.h" #include "searchlistdelegate.h" +#include "GUI.h" #define SEARCHHISTORY_MAXSIZE 50 /*SEARCH ENGINE START*/ -SearchEngine::SearchEngine(Bittorrent *BTSession, QSystemTrayIcon *systrayIcon) : QWidget(), BTSession(BTSession), systrayIcon(systrayIcon) { +SearchEngine::SearchEngine(GUI *parent, Bittorrent *BTSession) : QWidget(parent), BTSession(BTSession), parent(parent) { setupUi(this); // new qCompleter to the search pattern startSearchHistory(); @@ -428,8 +428,8 @@ void SearchEngine::updateNova() { void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ QSettings settings("qBittorrent", "qBittorrent"); bool useNotificationBalloons = settings.value("Preferences/General/NotificationBaloons", true).toBool(); - if(systrayIcon && useNotificationBalloons) { - systrayIcon->showMessage(tr("Search Engine"), tr("Search has finished"), QSystemTrayIcon::Information, TIME_TRAY_BALLOON); + if(useNotificationBalloons && parent->getCurrentTabIndex() != TAB_SEARCH) { + parent->showNotificationBaloon(tr("Search Engine"), tr("Search has finished")); } if(exitcode){ search_status->setText(tr("An error occured during search...")); diff --git a/src/searchengine.h b/src/searchengine.h index a37fda2ab..9df6a2652 100644 --- a/src/searchengine.h +++ b/src/searchengine.h @@ -31,8 +31,6 @@ #ifndef SEARCH_H #define SEARCH_H -#define TIME_TRAY_BALLOON 5000 - #include #include #include @@ -44,10 +42,10 @@ #include "supportedengines.h" class Bittorrent; -class QSystemTrayIcon; class downloadThread; class QTimer; class SearchEngine; +class GUI; class SearchEngine : public QWidget, public Ui::search_engine{ Q_OBJECT @@ -63,15 +61,16 @@ private: QPointer searchCompleter; QStringListModel searchHistory; Bittorrent *BTSession; - QSystemTrayIcon *systrayIcon; SupportedEngines *supported_engines; QTimer *searchTimeout; SearchTab *currentSearchTab; QPushButton *closeTab_button; QList all_tab; // To store all tabs const SearchCategories full_cat_names; + GUI *parent; + public: - SearchEngine(Bittorrent *BTSession, QSystemTrayIcon *systrayIcon); + SearchEngine(GUI *parent, Bittorrent *BTSession); ~SearchEngine(); QString selectedCategory() const;