From 34cb5efb7279f19b4d1ee05ca565ad13b2bdc297 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 8 Nov 2010 18:17:54 +0000 Subject: [PATCH] Show the connection settings when clicking on the connection status icon --- src/GUI.cpp | 9 ++++++++- src/GUI.h | 1 + src/options_imp.cpp | 5 +++++ src/options_imp.h | 1 + src/statusbar.h | 18 +++++++++++------- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 7173d4bc5..1f240984c 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -193,6 +193,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), for createKeyboardShortcuts(); // Create status bar status_bar = new StatusBar(QMainWindow::statusBar(), BTSession); + connect(status_bar->connectionStatusButton(), SIGNAL(clicked()), SLOT(showConnectionSettings())); connect(actionUse_alternative_speed_limits, SIGNAL(triggered()), status_bar, SLOT(toggleAlternativeSpeeds())); #ifdef Q_WS_MAC @@ -1254,5 +1255,11 @@ void GUI::handleUpdateInstalled(QString error_msg) void GUI::on_actionDonate_money_triggered() { - QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=163414")); + QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=163414")); +} + +void GUI::showConnectionSettings() +{ + on_actionOptions_triggered(); + options->showConnectionTab(); } diff --git a/src/GUI.h b/src/GUI.h index b653f1dfd..4049e622b 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -105,6 +105,7 @@ protected slots: void defineUILockPassword(); bool unlockUI(); void notifyOfUpdate(QString); + void showConnectionSettings(); // Keyboard shortcuts void createKeyboardShortcuts(); void displayTransferTab() const; diff --git a/src/options_imp.cpp b/src/options_imp.cpp index b1c72646a..f8d69a49d 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -1309,3 +1309,8 @@ QString options_imp::webUiPassword() const { return textWebUiPassword->text(); } + +void options_imp::showConnectionTab() +{ + tabSelection->setCurrentRow(2); +} diff --git a/src/options_imp.h b/src/options_imp.h index a411a581f..be43f2444 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -158,6 +158,7 @@ protected slots: public slots: void setLocale(QString locale); void useStyle(); + void showConnectionTab(); signals: void status_changed() const; diff --git a/src/statusbar.h b/src/statusbar.h index 9fcca4dd9..c669af3d3 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -56,10 +56,10 @@ public: layout->setContentsMargins(0,0,0,0); container->setLayout(layout); - connecStatusLblIcon = new QLabel(); + connecStatusLblIcon = new QPushButton(); + connecStatusLblIcon->setFlat(true); connecStatusLblIcon->setFixedWidth(22); - connecStatusLblIcon->setFrameShape(QFrame::NoFrame); - connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png"))); + connecStatusLblIcon->setIcon(QIcon(":/Icons/skin/firewalled.png")); connecStatusLblIcon->setToolTip(QString::fromUtf8("")+tr("Connection status:")+QString::fromUtf8("
")+QString::fromUtf8("")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("")); dlSpeedLbl = new QPushButton(tr("D: %1 B/s - T: %2", "Download speed: x B/s - Transferred: x MiB").arg("0.0").arg(misc::friendlyUnit(0))); //dlSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); @@ -145,6 +145,10 @@ public: delete container; } + QPushButton* connectionStatusButton() const { + return connecStatusLblIcon; + } + public slots: void showRestartRequired() { // Restart required notification @@ -169,15 +173,15 @@ public slots: // Update connection status const session_status sessionStatus = BTSession->getSessionStatus(); if(!BTSession->getSession()->is_listening()) { - connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/disconnected.png"))); + connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/disconnected.png"))); connecStatusLblIcon->setToolTip(QString::fromUtf8("")+tr("Connection Status:")+QString::fromUtf8("
")+tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections.")); } else { if(sessionStatus.has_incoming_connections) { // Connection OK - connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/connected.png"))); + connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/connected.png"))); connecStatusLblIcon->setToolTip(QString::fromUtf8("")+tr("Connection Status:")+QString::fromUtf8("
")+tr("Online")); }else{ - connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png"))); + connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/firewalled.png"))); connecStatusLblIcon->setToolTip(QString::fromUtf8("")+tr("Connection status:")+QString::fromUtf8("
")+QString::fromUtf8("")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("")); } } @@ -254,7 +258,7 @@ private: QFrame *statusSep2; QFrame *statusSep3; QFrame *statusSep4; - QLabel *connecStatusLblIcon; + QPushButton *connecStatusLblIcon; QPushButton *altSpeedsBtn; QTimer *refreshTimer; QWidget *container;