diff --git a/Changelog b/Changelog index a5be9359a..a7e5a20ee 100644 --- a/Changelog +++ b/Changelog @@ -19,6 +19,7 @@ - FEATURE: Added option to download first and last piece of a torrent main file first (for preview) - FEATURE: Graphically display piece availability in torrent properties - FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required) + - FEATURE: Display close tab button into the tabs in search engine (Qt >= 4.5 only) - FEATURE: Show official documentation when pressing F1 key - FEATURE: Announce to all trackers specified for a torrent (µTorrent behavior) (libtorrent >= v0.15 only) - FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only) diff --git a/configure b/configure index 98c8a3f5b..c855b34bd 100755 --- a/configure +++ b/configure @@ -273,7 +273,7 @@ cat >$1/modules.cpp <= 4.3 +name: Qt >= 4.4 -----END QCMOD----- */ class qc_qt4 : public ConfObj @@ -284,6 +284,9 @@ public: QString shortname() const { return "Qt 4.4"; } bool exec() { + if(QT_VERSION >= 0x040500) { + conf->addDefine("QT_4_5"); + } return(QT_VERSION >= 0x040400); } diff --git a/qcm/qt4.qcm b/qcm/qt4.qcm index 947e36a93..5866ebe5a 100644 --- a/qcm/qt4.qcm +++ b/qcm/qt4.qcm @@ -1,6 +1,6 @@ /* -----BEGIN QCMOD----- -name: Qt >= 4.3 +name: Qt >= 4.4 -----END QCMOD----- */ class qc_qt4 : public ConfObj @@ -11,6 +11,9 @@ public: QString shortname() const { return "Qt 4.4"; } bool exec() { + if(QT_VERSION >= 0x040500) { + conf->addDefine("QT_4_5"); + } return(QT_VERSION >= 0x040400); } diff --git a/src/searchengine.cpp b/src/searchengine.cpp index a4b47bb60..ae8c4cf0d 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -58,12 +58,17 @@ SearchEngine::SearchEngine(GUI *parent, Bittorrent *BTSession) : QWidget(parent) // new qCompleter to the search pattern startSearchHistory(); createCompleter(); +#ifdef QT_4_5 + tabWidget->setTabsClosable(true); + connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); +#else // Add close tab button closeTab_button = new QPushButton(); closeTab_button->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/tab-close.png"))); closeTab_button->setFlat(true); - connect(closeTab_button, SIGNAL(clicked()), this, SLOT(closeTab_button_clicked())); tabWidget->setCornerWidget(closeTab_button); + connect(closeTab_button, SIGNAL(clicked()), this, SLOT(closeTab_button_clicked())); +#endif // Boolean initialization search_stopped = false; // Creating Search Process @@ -113,6 +118,9 @@ SearchEngine::~SearchEngine(){ downloader->waitForFinished(); delete downloader; } +#ifndef QT_4_5 + delete closeTab_button; +#endif delete searchTimeout; delete searchProcess; delete supported_engines; @@ -214,7 +222,9 @@ void SearchEngine::on_search_button_clicked(){ all_tab.append(currentSearchTab); tabWidget->addTab(currentSearchTab, pattern); tabWidget->setCurrentWidget(currentSearchTab); +#ifndef QT_4_5 closeTab_button->setEnabled(true); +#endif // if the pattern is not in the pattern QStringList wordList = searchHistory.stringList(); if(wordList.indexOf(pattern) == -1){ @@ -490,6 +500,25 @@ void SearchEngine::appendSearchResult(QString line){ download_button->setEnabled(true); } +#ifdef QT_4_5 +void SearchEngine::closeTab(int index) { + if(index == tabWidget->indexOf(currentSearchTab)) { + qDebug("Deleted current search Tab"); + if(searchProcess->state() != QProcess::NotRunning){ + searchProcess->terminate(); + } + if(searchTimeout->isActive()) { + searchTimeout->stop(); + } + search_stopped = true; + currentSearchTab = 0; + } + delete all_tab.takeAt(tabWidget->currentIndex()); + if(!all_tab.size()) { + download_button->setEnabled(false); + } +} +#else // Clear search results list void SearchEngine::closeTab_button_clicked(){ if(all_tab.size()) { @@ -513,6 +542,7 @@ void SearchEngine::closeTab_button_clicked(){ } } } +#endif // Download selected items in search results list void SearchEngine::on_download_button_clicked(){ diff --git a/src/searchengine.h b/src/searchengine.h index 9df6a2652..61ce10d86 100644 --- a/src/searchengine.h +++ b/src/searchengine.h @@ -64,7 +64,9 @@ private: SupportedEngines *supported_engines; QTimer *searchTimeout; SearchTab *currentSearchTab; +#ifndef QT_4_5 QPushButton *closeTab_button; +#endif QList all_tab; // To store all tabs const SearchCategories full_cat_names; GUI *parent; @@ -104,7 +106,11 @@ protected slots: // Search slots void tab_changed(int);//to prevent the use of the download button when the tab is empty void on_search_button_clicked(); +#ifdef QT_4_5 + void closeTab(int index); +#else void closeTab_button_clicked(); +#endif void appendSearchResult(QString line); void searchFinished(int exitcode,QProcess::ExitStatus); void readSearchOutput();