FEATURE: Display close tab button into the tabs in search engine (Qt >= 4.5 only)

This commit is contained in:
Christophe Dumez 2009-11-26 21:11:37 +00:00
parent 77ded75613
commit 893c5e6784
5 changed files with 46 additions and 3 deletions

View file

@ -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)

5
configure vendored
View file

@ -273,7 +273,7 @@ cat >$1/modules.cpp <<EOT
#line 1 "qt4.qcm"
/*
-----BEGIN QCMOD-----
name: Qt >= 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);
}

View file

@ -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);
}

View file

@ -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(){

View file

@ -64,7 +64,9 @@ private:
SupportedEngines *supported_engines;
QTimer *searchTimeout;
SearchTab *currentSearchTab;
#ifndef QT_4_5
QPushButton *closeTab_button;
#endif
QList<SearchTab*> 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();