Hide tabs when only one is visible

This commit is contained in:
Christophe Dumez 2010-06-22 14:18:43 +00:00
parent 39b32bf1cd
commit 9e575e45b7
5 changed files with 92 additions and 40 deletions

View file

@ -10,6 +10,7 @@
- FEATURE: Added error state for torrents (error is displayed in a tooltip) - FEATURE: Added error state for torrents (error is displayed in a tooltip)
- FEATURE: Added filter for paused/error torrents - FEATURE: Added filter for paused/error torrents
- FEATURE: Add Check/Uncheck all feature in Web UI - FEATURE: Add Check/Uncheck all feature in Web UI
- FEATURE: Search engine can now be disabled
- BUGFIX: Hide seeding torrents files priorities in Web UI - BUGFIX: Hide seeding torrents files priorities in Web UI
- BUGFIX: The user can disable permanently recursive torrent download - BUGFIX: The user can disable permanently recursive torrent download
- COSMETIC: Display peers country name in tooltip - COSMETIC: Display peers country name in tooltip

View file

@ -63,6 +63,7 @@
#include "transferlistfilterswidget.h" #include "transferlistfilterswidget.h"
#include "propertieswidget.h" #include "propertieswidget.h"
#include "statusbar.h" #include "statusbar.h"
#include "HidableTabWidget.h"
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
#include "qmacapplication.h" #include "qmacapplication.h"
void qt_mac_set_dock_menu(QMenu *menu); void qt_mac_set_dock_menu(QMenu *menu);
@ -125,7 +126,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
#endif #endif
qDebug("create tabWidget"); qDebug("create tabWidget");
tabs = new QTabWidget(); tabs = new HidableTabWidget();
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tab_changed(int))); connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tab_changed(int)));
vSplitter = new QSplitter(Qt::Horizontal); vSplitter = new QSplitter(Qt::Horizontal);
//vSplitter->setChildrenCollapsible(false); //vSplitter->setChildrenCollapsible(false);
@ -182,10 +183,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
actionSpeed_in_title_bar->setChecked(Preferences::speedInTitleBar()); actionSpeed_in_title_bar->setChecked(Preferences::speedInTitleBar());
actionRSS_Reader->setChecked(Preferences::isRSSEnabled()); actionRSS_Reader->setChecked(Preferences::isRSSEnabled());
actionSearch_engine->setChecked(Preferences::isSearchEnabled()); actionSearch_engine->setChecked(Preferences::isSearchEnabled());
if(actionSearch_engine->isChecked()) displaySearchTab(actionSearch_engine->isChecked());
displaySearchTab(true); displayRSSTab(actionRSS_Reader->isChecked());
if(actionRSS_Reader->isChecked())
displayRSSTab(true);
show(); show();
@ -297,10 +296,13 @@ void GUI::displayRSSTab(bool enable) {
int index_tab = tabs->addTab(rssWidget, tr("RSS")); int index_tab = tabs->addTab(rssWidget, tr("RSS"));
tabs->setTabIcon(index_tab, QIcon(QString::fromUtf8(":/Icons/rss32.png"))); tabs->setTabIcon(index_tab, QIcon(QString::fromUtf8(":/Icons/rss32.png")));
} }
tabs->showTabBar(true);
} else { } else {
if(rssWidget) { if(rssWidget) {
delete rssWidget; delete rssWidget;
} }
if(!searchEngine)
tabs->showTabBar(false);
} }
} }
@ -311,10 +313,13 @@ void GUI::displaySearchTab(bool enable) {
searchEngine = new SearchEngine(this, BTSession); searchEngine = new SearchEngine(this, BTSession);
tabs->insertTab(1, searchEngine, QIcon(QString::fromUtf8(":/Icons/oxygen/edit-find.png")), tr("Search")); tabs->insertTab(1, searchEngine, QIcon(QString::fromUtf8(":/Icons/oxygen/edit-find.png")), tr("Search"));
} }
tabs->showTabBar(true);
} else { } else {
if(searchEngine) { if(searchEngine) {
delete searchEngine; delete searchEngine;
} }
if(!rssWidget)
tabs->showTabBar(false);
} }
} }
@ -447,17 +452,17 @@ void GUI::askRecursiveTorrentDownloadConfirmation(QTorrentHandle &h) {
QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(h.name())); QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(h.name()));
QPushButton *yes = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole); QPushButton *yes = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole);
/*QPushButton *no = */confirmBox.addButton(tr("No"), QMessageBox::NoRole); /*QPushButton *no = */confirmBox.addButton(tr("No"), QMessageBox::NoRole);
QPushButton *never = confirmBox.addButton(tr("Never"), QMessageBox::NoRole); QPushButton *never = confirmBox.addButton(tr("Never"), QMessageBox::NoRole);
confirmBox.exec(); confirmBox.exec();
if(confirmBox.clickedButton() == 0) return; if(confirmBox.clickedButton() == 0) return;
if(confirmBox.clickedButton() == yes) { if(confirmBox.clickedButton() == yes) {
BTSession->recursiveTorrentDownload(h); BTSession->recursiveTorrentDownload(h);
return; return;
} }
if(confirmBox.clickedButton() == never) { if(confirmBox.clickedButton() == never) {
Preferences::disableRecursiveDownload(); Preferences::disableRecursiveDownload();
} }
} }
void GUI::handleDownloadFromUrlFailure(QString url, QString reason) const{ void GUI::handleDownloadFromUrlFailure(QString url, QString reason) const{
// Display a message box // Display a message box
@ -884,20 +889,20 @@ void GUI::updateGUI() {
void GUI::showNotificationBaloon(QString title, QString msg) const { void GUI::showNotificationBaloon(QString title, QString msg) const {
#ifdef WITH_LIBNOTIFY #ifdef WITH_LIBNOTIFY
if (notify_init ("summary-body")) { if (notify_init ("summary-body")) {
NotifyNotification* notification; NotifyNotification* notification;
notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent", 0); notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent", 0);
gboolean success = notify_notification_show (notification, NULL); gboolean success = notify_notification_show (notification, NULL);
g_object_unref(G_OBJECT(notification)); g_object_unref(G_OBJECT(notification));
notify_uninit (); notify_uninit ();
if(success) { if(success) {
return; return;
}
} }
}
#endif #endif
#ifndef Q_WS_MAC #ifndef Q_WS_MAC
if(systrayIcon && QSystemTrayIcon::supportsMessages()) if(systrayIcon && QSystemTrayIcon::supportsMessages())
systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON); systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
#endif #endif
} }
@ -956,7 +961,7 @@ void GUI::createSystrayDelayed() {
} }
void GUI::updateAltSpeedsBtn(bool alternative) { void GUI::updateAltSpeedsBtn(bool alternative) {
actionUse_alternative_speed_limits->setChecked(alternative); actionUse_alternative_speed_limits->setChecked(alternative);
} }
QMenu* GUI::getTrayIconMenu() { QMenu* GUI::getTrayIconMenu() {
@ -1007,18 +1012,18 @@ void GUI::on_actionOptions_triggered() {
} }
void GUI::on_actionTop_tool_bar_triggered() { void GUI::on_actionTop_tool_bar_triggered() {
bool is_visible = static_cast<QAction*>(sender())->isChecked(); bool is_visible = static_cast<QAction*>(sender())->isChecked();
toolBar->setVisible(is_visible); toolBar->setVisible(is_visible);
Preferences::setToolbarDisplayed(is_visible); Preferences::setToolbarDisplayed(is_visible);
} }
void GUI::on_actionSpeed_in_title_bar_triggered() { void GUI::on_actionSpeed_in_title_bar_triggered() {
displaySpeedInTitle = static_cast<QAction*>(sender())->isChecked(); displaySpeedInTitle = static_cast<QAction*>(sender())->isChecked();
Preferences::showSpeedInTitleBar(displaySpeedInTitle); Preferences::showSpeedInTitleBar(displaySpeedInTitle);
if(displaySpeedInTitle) if(displaySpeedInTitle)
updateGUI(); updateGUI();
else else
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION))); setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION)));
} }
void GUI::on_actionRSS_Reader_triggered() { void GUI::on_actionRSS_Reader_triggered() {

View file

@ -58,6 +58,7 @@ class consoleDlg;
class about; class about;
class createtorrent; class createtorrent;
class downloadFromURL; class downloadFromURL;
class HidableTabWidget;
class GUI : public QMainWindow, private Ui::MainWindow{ class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT Q_OBJECT
@ -136,7 +137,7 @@ private:
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed? QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
// GUI related // GUI related
QTimer *guiUpdater; QTimer *guiUpdater;
QTabWidget *tabs; HidableTabWidget *tabs;
StatusBar *status_bar; StatusBar *status_bar;
QPointer<options_imp> options; QPointer<options_imp> options;
QPointer<consoleDlg> console; QPointer<consoleDlg> console;

44
src/HidableTabWidget.h Normal file
View file

@ -0,0 +1,44 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef HIDABLETABWIDGET_H
#define HIDABLETABWIDGET_H
#include <QTabWidget>
#include <QTabBar>
class HidableTabWidget : public QTabWidget {
public:
void showTabBar(bool show) {
tabBar()->setVisible(show);
}
};
#endif // HIDABLETABWIDGET_H

View file

@ -329,7 +329,9 @@ contains(DEFINES, DISABLE_GUI) {
pieceavailabilitybar.h \ pieceavailabilitybar.h \
advancedsettings.h \ advancedsettings.h \
cookiesdlg.h \ cookiesdlg.h \
rsssettings.h rsssettings.h \
HidableTabWidget.h
macx { macx {
HEADERS += qmacapplication.h HEADERS += qmacapplication.h
} }
@ -401,4 +403,3 @@ SOURCES += main.cpp \
} }
DESTDIR = . DESTDIR = .