diff --git a/dist/windows/qt.conf b/dist/windows/qt.conf
index bbe76d586..372600dc5 100644
--- a/dist/windows/qt.conf
+++ b/dist/windows/qt.conf
@@ -1,2 +1,5 @@
[Paths]
Translations = translations
+
+[Platforms]
+WindowsArguments = dpiawareness=1
diff --git a/src/app/application.cpp b/src/app/application.cpp
index 6b332cf4e..1a20c1f45 100644
--- a/src/app/application.cpp
+++ b/src/app/application.cpp
@@ -92,7 +92,9 @@ Application::Application(const QString &id, int &argc, char **argv)
setApplicationName("qBittorrent");
initializeTranslation();
#ifndef DISABLE_GUI
- setStyleSheet("QStatusBar::item { border-width: 0; }");
+#ifdef QBT_USES_QT5
+ setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support
+#endif // QBT_USES_QT5
setQuitOnLastWindowClosed(false);
#ifdef Q_OS_WIN
connect(this, SIGNAL(commitDataRequest(QSessionManager &)), this, SLOT(shutdownCleanup(QSessionManager &)), Qt::DirectConnection);
diff --git a/src/gui/about.qrc b/src/gui/about.qrc
index 147d23cdd..da886b454 100644
--- a/src/gui/about.qrc
+++ b/src/gui/about.qrc
@@ -5,4 +5,3 @@
translators.html
-
diff --git a/src/gui/about.ui b/src/gui/about.ui
index 4b676ae44..4d0a77cb5 100644
--- a/src/gui/about.ui
+++ b/src/gui/about.ui
@@ -7,66 +7,39 @@
0
0
- 504
- 320
+ 545
+ 295
-
-
- 504
- 320
-
-
About qBittorrent
-
+
-
-
+
-
-
-
- 22
- 22
-
-
-
-
- 22
- 22
-
-
-
-
+
+ :/icons/skin/qbittorrent32.png
-
-
-
- 0
- 0
-
-
- <h3><b>qBittorrent</b></h3>
-
-
- Qt::RichText
+ qBittorrent
-
-
+
Qt::Horizontal
- 40
- 20
+ 0
+ 0
@@ -78,16 +51,13 @@
0
-
+
About
-
+
-
-
-
-
:/icons/skin/mascot.png
@@ -101,18 +71,14 @@
0
-
-
+
+
+ 11
+
Qt::RichText
-
- true
-
-
- Qt::AlignCenter
-
true
@@ -123,250 +89,182 @@
-
+
Author
-
-
- 6
-
+
-
-
-
-
- 0
-
-
- 6
-
-
- 0
-
+
+
+ Current maintainer
+
+
+
-
+
+
+ Greece
+
+
+
+ -
+
+
+ <a href="mailto:sledgehammer999@qbittorrent.org">sledgehammer999@qbittorrent.org</a>
+
+
+ true
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
+
+
+ -
+
+
+ Nationality:
+
+
+
-
-
+
+
+ E-mail:
+
+
+
+ -
+
+
+ Name:
+
+
+
+ -
+
+
+ Sledgehammer999
+
+
+
+ -
+
- Qt::Vertical
+ Qt::Horizontal
- 20
- 40
+ 0
+ 0
- -
-
-
- QFrame::NoFrame
+
+
+
+ -
+
+
+ Original author
+
+
+
-
+
+
+ France
-
- 0
+
+
+ -
+
+
+ Christophe Dumez
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- France
-
-
-
- -
-
-
- Christophe Dumez
-
-
-
- -
-
-
- chris@qbittorrent.org
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- true
-
-
-
- Name:
-
-
-
- -
-
-
-
- true
-
-
-
- E-mail:
-
-
-
- -
-
-
-
- true
-
-
-
- Country:
-
-
-
-
- -
-
-
- QFrame::NoFrame
+
-
+
+
+ <a href="mailto:chris@qbittorrent.org">chris@qbittorrent.org</a>
-
- QFrame::Plain
+
+ true
-
- 0
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
-
-
-
-
-
- Greece
-
-
-
- -
-
-
- sledgehammer999@qbittorrent.org
-
-
-
- -
-
-
-
- true
-
-
-
- Country:
-
-
-
- -
-
-
-
- true
-
-
-
- Name:
-
-
-
- -
-
-
- Sledgehammer999
-
-
-
- -
-
-
-
- true
-
-
-
- E-mail:
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
- 75
- true
-
-
+
- Current maintainer
+ Name:
- -
-
-
-
- 75
- true
-
+
-
+
+
+ E-mail:
+
+
+ -
+
- Original author
+ Nationality:
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 0
+
+
+
+
-
+
- Thanks to
+ Special Thanks
-
-
- 6
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
-
@@ -377,13 +275,22 @@
-
+
- Translation
+ Translators
-
-
- 6
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
-
@@ -394,50 +301,70 @@
-
+
License
-
-
- 6
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
-
-
+
Libraries
-
+
-
-
-
- 0
- 0
-
-
- This version of qBittorrent was built against the following libraries:
-
-
- true
+ qBittorrent was built with the following libraries:
-
-
+
Qt::Horizontal
-
-
-
-
+
+
-
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 0
+ 0
+
+
+
+
+ -
Qt:
@@ -445,53 +372,68 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
- -
-
+
-
+
- Boost:
+ Libtorrent:
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
+
- -
-
+
-
+
-
+ Boost:
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
- -
-
-
-
+
-
+
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
- -
+
-
-
-
+
+ Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
-
-
-
- Libtorrent:
+
+
+ Qt::Horizontal
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ 0
+ 0
+
-
+
-
-
+
Qt::Horizontal
@@ -502,9 +444,6 @@
Qt::Vertical
-
- QSizePolicy::Expanding
-
0
diff --git a/src/gui/about_imp.h b/src/gui/about_imp.h
index d469ebcf8..c5a8fce65 100644
--- a/src/gui/about_imp.h
+++ b/src/gui/about_imp.h
@@ -33,67 +33,68 @@
#include "ui_about.h"
#include
-#include
#include
#include
#include "base/unicodestrings.h"
-class about : public QDialog, private Ui::AboutDlg{
- Q_OBJECT
+class about: public QDialog, private Ui::AboutDlg
+{
+ Q_OBJECT
- public:
- ~about() {
- qDebug("Deleting about dlg");
- }
+public:
+ about(QWidget *parent) : QDialog(parent)
+ {
+ setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ // Title
+ lb_name->setText("
qBittorrent " VERSION "
");
+
+ // About
+ QString aboutText = QString(
+ ""
+ "%1\n\n"
+ "%2\n\n"
+ "
"
+ "
")
+ .arg(tr("An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar."))
+ .arg(tr("Copyright %1 2006-2016 The qBittorrent project").arg(QString::fromUtf8(C_COPYRIGHT)))
+ .arg(tr("Home Page:"))
+ .arg(tr("Forum:"))
+ .arg(tr("Bug Tracker:"));
+ lb_about->setText(aboutText);
+
+ // Thanks
+ QFile thanksfile(":/thanks.html");
+ if (thanksfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ te_thanks->setHtml(QString::fromUtf8(thanksfile.readAll().constData()));
+ thanksfile.close();
+ }
+
+ // Translation
+ QFile translatorsfile(":/translators.html");
+ if (translatorsfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ te_translation->setHtml(QString::fromUtf8(translatorsfile.readAll().constData()));
+ translatorsfile.close();
+ }
+
+ // License
+ QFile licensefile(":/gpl.html");
+ if (licensefile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ te_license->setHtml(QString::fromUtf8(licensefile.readAll().constData()));
+ licensefile.close();
+ }
+
+ // Libraries
+ label_11->setText(QT_VERSION_STR);
+ label_12->setText(LIBTORRENT_VERSION);
+ label_13->setText(QString::number(BOOST_VERSION / 100000) + "." + QString::number((BOOST_VERSION / 100) % 1000) + "." + QString::number(BOOST_VERSION % 100));
- about(QWidget *parent): QDialog(parent) {
- setupUi(this);
- setAttribute(Qt::WA_DeleteOnClose);
- // About
- QString aboutText =
- QString::fromUtf8("") +
- tr("An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar.") +
- QString::fromUtf8("
") +
- trUtf8("Copyright %1 2006-2016 The qBittorrent project").arg(QString::fromUtf8(C_COPYRIGHT)) +
- QString::fromUtf8("
") +
- tr("Home Page: ") +
- QString::fromUtf8("http://www.qbittorrent.org
") +
- tr("Bug Tracker: ") +
- QString::fromUtf8("http://bugs.qbittorrent.org
") +
- tr("Forum: ") +
- QString::fromUtf8(
- "http://forum.qbittorrent.org
") +
- tr("IRC: #qbittorrent on Freenode") +
- QString::fromUtf8(
- "
");
- lb_about->setText(aboutText);
- // Set icons
- logo->setPixmap(QPixmap(QString::fromUtf8(":/icons/skin/qbittorrent22.png")));
- //Title
- lb_name->setText(QString::fromUtf8("qBittorrent")+QString::fromUtf8(" " VERSION"
"));
- // Thanks
- QFile thanksfile(":/thanks.html");
- if (thanksfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- te_thanks->setHtml(QString::fromUtf8(thanksfile.readAll().constData()));
- thanksfile.close();
- }
- // Translation
- QFile translatorsfile(":/translators.html");
- if (translatorsfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- te_translation->setHtml(QString::fromUtf8(translatorsfile.readAll().constData()));
- translatorsfile.close();
- }
- // License
- QFile licensefile(":/gpl.html");
- if (licensefile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- te_license->setHtml(QString::fromUtf8(licensefile.readAll().constData()));
- licensefile.close();
- }
- // Libraries
- label_11->setText(QT_VERSION_STR);
- label_12->setText(LIBTORRENT_VERSION);
- label_13->setText(QString::number(BOOST_VERSION / 100000) + "." + QString::number((BOOST_VERSION / 100) % 1000) + "." + QString::number(BOOST_VERSION % 100));
- show();
+ show();
}
};
diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp
index 66098cd50..cb95fab2c 100644
--- a/src/gui/addnewtorrentdialog.cpp
+++ b/src/gui/addnewtorrentdialog.cpp
@@ -266,28 +266,28 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event)
void AddNewTorrentDialog::showAdvancedSettings(bool show)
{
+ const int minimumW = minimumWidth();
+ setMinimumWidth(width()); // to remain the same width
if (show) {
ui->adv_button->setText(QString::fromUtf8(C_UP));
ui->settings_group->setVisible(true);
- ui->info_group->setVisible(true);
+ ui->infoGroup->setVisible(true);
if (m_hasMetadata && (m_torrentInfo.filesCount() > 1)) {
ui->content_tree->setVisible(true);
- setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
else {
ui->content_tree->setVisible(false);
- setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
}
static_cast(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button);
}
else {
ui->adv_button->setText(QString::fromUtf8(C_DOWN));
ui->settings_group->setVisible(false);
- ui->info_group->setVisible(false);
+ ui->infoGroup->setVisible(false);
ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(ui->never_show_cb) + 1)->widget());
- setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
}
- relayout();
+ adjustSize();
+ setMinimumWidth(minimumW);
}
void AddNewTorrentDialog::saveSavePathHistory() const
@@ -348,7 +348,7 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
QString size_string = torrent_size ? Utils::Misc::friendlyUnit(torrent_size) : QString(tr("Not Available", "This size is unavailable."));
size_string += " (";
- size_string += tr("Free disk space: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
+ size_string += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
ui->save_path_combo->itemData(
ui->save_path_combo->currentIndex()).toString())));
size_string += ")";
@@ -360,7 +360,6 @@ void AddNewTorrentDialog::onSavePathChanged(int index)
// Toggle default save path setting checkbox visibility
ui->default_save_path_cb->setChecked(false);
ui->default_save_path_cb->setVisible(QDir(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString()) != QDir(Preferences::instance()->getSavePath()));
- relayout();
// Remember index
m_oldIndex = index;
@@ -417,15 +416,6 @@ void AddNewTorrentDialog::browseButton_clicked()
connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int)));
}
-void AddNewTorrentDialog::relayout()
-{
- qApp->processEvents();
- int min_width = minimumWidth();
- setMinimumWidth(width());
- adjustSize();
- setMinimumWidth(min_width);
-}
-
void AddNewTorrentDialog::renameSelectedFile()
{
const QModelIndexList selectedIndexes = ui->content_tree->selectionModel()->selectedRows(0);
@@ -689,7 +679,7 @@ void AddNewTorrentDialog::setupTreeview()
// Set torrent information
ui->comment_lbl->setText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment()));
- ui->date_lbl->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleLongDate) : tr("Not available"));
+ ui->date_lbl->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available"));
// Prepare content tree
if (m_torrentInfo.filesCount() > 1) {
diff --git a/src/gui/addnewtorrentdialog.h b/src/gui/addnewtorrentdialog.h
index 8b1cd2576..5de761b87 100644
--- a/src/gui/addnewtorrentdialog.h
+++ b/src/gui/addnewtorrentdialog.h
@@ -68,7 +68,6 @@ private slots:
void displayContentTreeMenu(const QPoint&);
void updateDiskSpaceLabel();
void onSavePathChanged(int);
- void relayout();
void renameSelectedFile();
void setdialogPosition();
void updateMetadata(const BitTorrent::TorrentInfo &info);
diff --git a/src/gui/addnewtorrentdialog.ui b/src/gui/addnewtorrentdialog.ui
index f7c46efcb..ce727e72a 100644
--- a/src/gui/addnewtorrentdialog.ui
+++ b/src/gui/addnewtorrentdialog.ui
@@ -10,23 +10,11 @@
590
-
-
- 400
- 0
-
-
-
-
- 800
- 16777215
-
-
-
+
-
- Save as
+ Save at
-
@@ -34,21 +22,18 @@
-
-
+
0
0
+
+ QComboBox::AdjustToMinimumContentsLength
+
-
-
-
- 0
- 0
-
-
Browse...
@@ -88,28 +73,37 @@
Torrent settings
-
-
-
-
+
+
-
+
- Start torrent
-
-
- true
+ Set as default label
- -
-
-
-
+
-
+
+
-
+
+
+ 0
+ 0
+
+
- Label:
+ Set label:
- -
+
-
+
+
+ 140
+ 0
+
+
true
@@ -120,6 +114,16 @@
+ -
+
+
+ Start torrent
+
+
+ true
+
+
+
-
@@ -127,24 +131,43 @@
- -
-
-
- Set as default label
+
-
+
+
+ Qt::Horizontal
-
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 0
+ 0
+
+
+
-
-
+
- Torrent Information
+ Torrent information
-
+
-
-
+
-
@@ -153,27 +176,23 @@
-
-
-
- xx GB (xx GB available)
-
-
+
- -
+
-
Comment:
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
- -
+
-
Qt::RichText
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
true
@@ -185,28 +204,24 @@
- -
+
-
Date:
- -
-
-
- 02/03/2012 20:30
-
-
+
-
+
- -
+
-
- Info Hash:
+ Hash:
- -
+
-
Qt::TextSelectableByMouse
@@ -231,12 +246,25 @@
+ -
+
+
+ Qt::Vertical
+
+
+
+ 0
+ 0
+
+
+
+
-
-
-
+
0
0
@@ -256,33 +284,10 @@
-
-
-
- true
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
+
-
-
- Qt::Horizontal
-
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp
index 6c5af720d..1216ed5c3 100644
--- a/src/gui/advancedsettings.cpp
+++ b/src/gui/advancedsettings.cpp
@@ -97,6 +97,7 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
verticalHeader()->setVisible(false);
// etc.
setAlternatingRowColors(true);
+ setSelectionMode(QAbstractItemView::NoSelection);
setEditTriggers(QAbstractItemView::NoEditTriggers);
// Signals
connect(&spin_cache, SIGNAL(valueChanged(int)), SLOT(updateCacheSpinSuffix(int)));
diff --git a/src/gui/options.ui b/src/gui/options.ui
index 1144033b0..b6ced09e6 100644
--- a/src/gui/options.ui
+++ b/src/gui/options.ui
@@ -23,29 +23,11 @@
false
-
- false
+
+ Qt::ScrollBarAlwaysOff
-
-
- 32
- 32
-
-
-
- true
-
-
- QListView::Adjust
-
-
- 4
-
-
-
- 110
- 60
-
+
+ QListView::TopToBottom
QListView::IconMode
@@ -143,6 +125,9 @@
0
+
+ 0
+
0
@@ -162,7 +147,7 @@
0
0
- 480
+ 486
702
@@ -545,6 +530,9 @@
0
+
+ 0
+
0
@@ -1058,6 +1046,9 @@
0
+
+ 0
+
0
@@ -1972,6 +1963,9 @@
0
+
+ 0
+
0
@@ -2358,14 +2352,17 @@
-
-
+
+
0
0
+
+ 0
+
0
diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp
index 07f95fc3f..17a2c1e99 100644
--- a/src/gui/options_imp.cpp
+++ b/src/gui/options_imp.cpp
@@ -67,6 +67,7 @@ options_imp::options_imp(QWidget *parent)
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
+
// Icons
tabSelection->item(TAB_UI)->setIcon(GuiIconProvider::instance()->getIcon("preferences-desktop"));
tabSelection->item(TAB_BITTORRENT)->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network"));
@@ -79,6 +80,10 @@ options_imp::options_imp(QWidget *parent)
tabSelection->item(TAB_WEBUI)->setHidden(true);
#endif
tabSelection->item(TAB_ADVANCED)->setIcon(GuiIconProvider::instance()->getIcon("preferences-other"));
+ for (int i = 0; i < tabSelection->count(); ++i) {
+ tabSelection->item(i)->setSizeHint(QSize(96, 64)); // uniform size for all icons
+ }
+
IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh"));
hsplitter->setCollapsible(0, false);
diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp
index 211ec7811..177bf1e7e 100644
--- a/src/gui/statusbar.cpp
+++ b/src/gui/statusbar.cpp
@@ -30,6 +30,12 @@
#include "statusbar.h"
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
@@ -42,225 +48,242 @@
#include "base/logger.h"
StatusBar::StatusBar(QStatusBar *bar)
- : m_bar(bar)
+ : m_bar(bar)
{
- Preferences* const pref = Preferences::instance();
- connect(BitTorrent::Session::instance(), SIGNAL(speedLimitModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
- container = new QWidget(bar);
- layout = new QHBoxLayout(container);
- layout->setContentsMargins(0,0,0,0);
+ qApp->setStyleSheet("QStatusBar::item { border-width: 0; }");
- container->setLayout(layout);
- connecStatusLblIcon = new QPushButton(bar);
- connecStatusLblIcon->setFlat(true);
- connecStatusLblIcon->setFocusPolicy(Qt::NoFocus);
- connecStatusLblIcon->setCursor(Qt::PointingHandCursor);
- 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(bar);
- dlSpeedLbl->setIcon(QIcon(":/icons/skin/download.png"));
- connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed()));
- dlSpeedLbl->setFlat(true);
- dlSpeedLbl->setFocusPolicy(Qt::NoFocus);
- dlSpeedLbl->setCursor(Qt::PointingHandCursor);
+ Preferences* const pref = Preferences::instance();
+ connect(BitTorrent::Session::instance(), SIGNAL(speedLimitModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
+ container = new QWidget(bar);
+ layout = new QHBoxLayout(container);
+ layout->setContentsMargins(0, 0, 0, 0);
+
+ container->setLayout(layout);
+ connecStatusLblIcon = new QPushButton(bar);
+ connecStatusLblIcon->setFlat(true);
+ connecStatusLblIcon->setFocusPolicy(Qt::NoFocus);
+ connecStatusLblIcon->setCursor(Qt::PointingHandCursor);
+ 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(bar);
+ dlSpeedLbl->setIcon(QIcon(":/icons/skin/download.png"));
+ connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed()));
+ dlSpeedLbl->setFlat(true);
+ dlSpeedLbl->setFocusPolicy(Qt::NoFocus);
+ dlSpeedLbl->setCursor(Qt::PointingHandCursor);
- upSpeedLbl = new QPushButton(bar);
- upSpeedLbl->setIcon(QIcon(":/icons/skin/seeding.png"));
- connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed()));
- upSpeedLbl->setFlat(true);
- upSpeedLbl->setFocusPolicy(Qt::NoFocus);
- upSpeedLbl->setCursor(Qt::PointingHandCursor);
- DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar);
- DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
+ upSpeedLbl = new QPushButton(bar);
+ upSpeedLbl->setIcon(QIcon(":/icons/skin/seeding.png"));
+ connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed()));
+ upSpeedLbl->setFlat(true);
+ upSpeedLbl->setFocusPolicy(Qt::NoFocus);
+ upSpeedLbl->setCursor(Qt::PointingHandCursor);
+ DHTLbl = new QLabel(tr("DHT: %1 nodes").arg(0), bar);
+ DHTLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
- altSpeedsBtn = new QPushButton(bar);
- altSpeedsBtn->setFlat(true);
- altSpeedsBtn->setFocusPolicy(Qt::NoFocus);
- altSpeedsBtn->setCursor(Qt::PointingHandCursor);
- updateAltSpeedsBtn(pref->isAltBandwidthEnabled());
- connect(altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds()));
+ altSpeedsBtn = new QPushButton(bar);
+ altSpeedsBtn->setFlat(true);
+ altSpeedsBtn->setFocusPolicy(Qt::NoFocus);
+ altSpeedsBtn->setCursor(Qt::PointingHandCursor);
+ updateAltSpeedsBtn(pref->isAltBandwidthEnabled());
+ connect(altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds()));
- // Because on some platforms the default icon size is bigger
- // and it will result in taller/fatter statusbar, even if the
- // icons are actually 16x16
- connecStatusLblIcon->setIconSize(QSize(16, 16));
- dlSpeedLbl->setIconSize(QSize(16, 16));
- upSpeedLbl->setIconSize(QSize(16, 16));
- altSpeedsBtn->setIconSize(QSize(28, 16));
+ // Because on some platforms the default icon size is bigger
+ // and it will result in taller/fatter statusbar, even if the
+ // icons are actually 16x16
+ connecStatusLblIcon->setIconSize(QSize(16, 16));
+ dlSpeedLbl->setIconSize(QSize(16, 16));
+ upSpeedLbl->setIconSize(QSize(16, 16));
+ altSpeedsBtn->setIconSize(QSize(28, 16));
- // Set to the known maximum width(plus some padding)
- // so the speed widgets will take the rest of the space
- connecStatusLblIcon->setMaximumWidth(16 + 6);
- altSpeedsBtn->setMaximumWidth(28 + 6);
+ // Set to the known maximum width(plus some padding)
+ // so the speed widgets will take the rest of the space
+ connecStatusLblIcon->setMaximumWidth(16 + 6);
+ altSpeedsBtn->setMaximumWidth(28 + 6);
- statusSep1 = new QFrame(bar);
- statusSep1->setFrameStyle(QFrame::VLine);
- statusSep1->setFrameShadow(QFrame::Raised);
- statusSep2 = new QFrame(bar);
- statusSep2->setFrameStyle(QFrame::VLine);
- statusSep2->setFrameShadow(QFrame::Raised);
- statusSep3 = new QFrame(bar);
- statusSep3->setFrameStyle(QFrame::VLine);
- statusSep3->setFrameShadow(QFrame::Raised);
- statusSep4 = new QFrame(bar);
- statusSep4->setFrameStyle(QFrame::VLine);
- statusSep4->setFrameShadow(QFrame::Raised);
- layout->addWidget(DHTLbl);
- layout->addWidget(statusSep1);
- layout->addWidget(connecStatusLblIcon);
- layout->addWidget(statusSep2);
- layout->addWidget(altSpeedsBtn);
- layout->addWidget(statusSep4);
- layout->addWidget(dlSpeedLbl);
- layout->addWidget(statusSep3);
- layout->addWidget(upSpeedLbl);
+ statusSep1 = new QFrame(bar);
+ statusSep1->setFrameStyle(QFrame::VLine);
+ statusSep1->setFrameShadow(QFrame::Raised);
+ statusSep2 = new QFrame(bar);
+ statusSep2->setFrameStyle(QFrame::VLine);
+ statusSep2->setFrameShadow(QFrame::Raised);
+ statusSep3 = new QFrame(bar);
+ statusSep3->setFrameStyle(QFrame::VLine);
+ statusSep3->setFrameShadow(QFrame::Raised);
+ statusSep4 = new QFrame(bar);
+ statusSep4->setFrameStyle(QFrame::VLine);
+ statusSep4->setFrameShadow(QFrame::Raised);
+ layout->addWidget(DHTLbl);
+ layout->addWidget(statusSep1);
+ layout->addWidget(connecStatusLblIcon);
+ layout->addWidget(statusSep2);
+ layout->addWidget(altSpeedsBtn);
+ layout->addWidget(statusSep4);
+ layout->addWidget(dlSpeedLbl);
+ layout->addWidget(statusSep3);
+ layout->addWidget(upSpeedLbl);
- bar->addPermanentWidget(container);
- container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
- bar->setStyleSheet("QWidget {margin: 0;}");
- container->adjustSize();
- bar->adjustSize();
- // Is DHT enabled
- DHTLbl->setVisible(pref->isDHTEnabled());
- refreshTimer = new QTimer(bar);
- refreshStatusBar();
- connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));
- refreshTimer->start(1500);
+ bar->addPermanentWidget(container);
+ container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ bar->setStyleSheet("QWidget {margin: 0;}");
+ container->adjustSize();
+ bar->adjustSize();
+ // Is DHT enabled
+ DHTLbl->setVisible(pref->isDHTEnabled());
+ refreshTimer = new QTimer(bar);
+ refreshStatusBar();
+ connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar()));
+ refreshTimer->start(1500);
}
-StatusBar::~StatusBar() {
- qDebug() << Q_FUNC_INFO;
+StatusBar::~StatusBar()
+{
+ qDebug() << Q_FUNC_INFO;
}
-QPushButton* StatusBar::connectionStatusButton() const {
- return connecStatusLblIcon;
+QPushButton* StatusBar::connectionStatusButton() const
+{
+ return connecStatusLblIcon;
}
-void StatusBar::showRestartRequired() {
- // Restart required notification
- const QString restart_text = tr("qBittorrent needs to be restarted");
- QLabel *restartIconLbl = new QLabel(m_bar);
- restartIconLbl->setPixmap(QPixmap(":/icons/oxygen/dialog-warning.png").scaled(QSize(24,24)));
- restartIconLbl->setToolTip(restart_text);
- m_bar->insertWidget(0,restartIconLbl);
- QLabel *restartLbl = new QLabel(m_bar);
- restartLbl->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- m_bar->insertWidget(1, restartLbl);
- QFontMetrics fm(restartLbl->font());
- restartLbl->setText(fm.elidedText(restart_text, Qt::ElideRight, restartLbl->width()));
- Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL);
+void StatusBar::showRestartRequired()
+{
+ // Restart required notification
+ const QString restart_text = tr("qBittorrent needs to be restarted");
+ QLabel *restartIconLbl = new QLabel(m_bar);
+ restartIconLbl->setPixmap(QPixmap(":/icons/oxygen/dialog-warning.png").scaled(QSize(24, 24)));
+ restartIconLbl->setToolTip(restart_text);
+ m_bar->insertWidget(0, restartIconLbl);
+ QLabel *restartLbl = new QLabel(m_bar);
+ restartLbl->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ m_bar->insertWidget(1, restartLbl);
+ QFontMetrics fm(restartLbl->font());
+ restartLbl->setText(fm.elidedText(restart_text, Qt::ElideRight, restartLbl->width()));
+ Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL);
}
-void StatusBar::stopTimer() {
- refreshTimer->stop();
+void StatusBar::stopTimer()
+{
+ refreshTimer->stop();
}
-void StatusBar::refreshStatusBar() {
- // Update connection status
- const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status();
- if (!BitTorrent::Session::instance()->isListening()) {
- 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.hasIncomingConnections()) {
- // Connection OK
- connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png")));
- connecStatusLblIcon->setToolTip(QString::fromUtf8("")+tr("Connection Status:")+QString::fromUtf8("
")+tr("Online"));
- }else{
- 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(""));
+void StatusBar::refreshStatusBar()
+{
+ // Update connection status
+ const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status();
+ if (!BitTorrent::Session::instance()->isListening()) {
+ 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.hasIncomingConnections()) {
+ // Connection OK
+ connecStatusLblIcon->setIcon(QIcon(QString::fromUtf8(":/icons/skin/connected.png")));
+ connecStatusLblIcon->setToolTip(QString::fromUtf8("") + tr("Connection Status:") + QString::fromUtf8("
") + tr("Online"));
+ }
+ else {
+ 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(""));
+ }
}
- }
- // Update Number of DHT nodes
- if (BitTorrent::Session::instance()->isDHTEnabled()) {
- DHTLbl->setVisible(true);
- //statusSep1->setVisible(true);
- DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
- } else {
- DHTLbl->setVisible(false);
- //statusSep1->setVisible(false);
- }
- // Update speed labels
- QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true)+" ("+Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload())+")";
- int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
- if (speedLimit)
- speedLbl = "["+Utils::Misc::friendlyUnit(speedLimit, true)+"] " + speedLbl;
- dlSpeedLbl->setText(speedLbl);
- speedLimit = BitTorrent::Session::instance()->uploadRateLimit();
- speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true)+" ("+Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload())+")";
- if (speedLimit)
- speedLbl = "["+Utils::Misc::friendlyUnit(speedLimit, true)+"] " + speedLbl;
- upSpeedLbl->setText(speedLbl);
+ // Update Number of DHT nodes
+ if (BitTorrent::Session::instance()->isDHTEnabled()) {
+ DHTLbl->setVisible(true);
+ //statusSep1->setVisible(true);
+ DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes())));
+ }
+ else {
+ DHTLbl->setVisible(false);
+ //statusSep1->setVisible(false);
+ }
+ // Update speed labels
+ QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true) + " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")";
+ int speedLimit = BitTorrent::Session::instance()->downloadRateLimit();
+ if (speedLimit)
+ speedLbl = "[" + Utils::Misc::friendlyUnit(speedLimit, true) + "] " + speedLbl;
+ dlSpeedLbl->setText(speedLbl);
+ speedLimit = BitTorrent::Session::instance()->uploadRateLimit();
+ speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true) + " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")";
+ if (speedLimit)
+ speedLbl = "[" + Utils::Misc::friendlyUnit(speedLimit, true) + "] " + speedLbl;
+ upSpeedLbl->setText(speedLbl);
}
-void StatusBar::updateAltSpeedsBtn(bool alternative) {
- if (alternative) {
- altSpeedsBtn->setIcon(QIcon(":/icons/slow.png"));
- altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits"));
- altSpeedsBtn->setDown(true);
- } else {
- altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png"));
- altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
- altSpeedsBtn->setDown(false);
- }
- refreshStatusBar();
+void StatusBar::updateAltSpeedsBtn(bool alternative)
+{
+ if (alternative) {
+ altSpeedsBtn->setIcon(QIcon(":/icons/slow.png"));
+ altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits"));
+ altSpeedsBtn->setDown(true);
+ }
+ else {
+ altSpeedsBtn->setIcon(QIcon(":/icons/slow_off.png"));
+ altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
+ altSpeedsBtn->setDown(false);
+ }
+ refreshStatusBar();
}
-void StatusBar::toggleAlternativeSpeeds() {
- Preferences* const pref = Preferences::instance();
- if (pref->isSchedulerEnabled())
- m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000);
- BitTorrent::Session::instance()->changeSpeedLimitMode(!pref->isAltBandwidthEnabled());
+void StatusBar::toggleAlternativeSpeeds()
+{
+ Preferences* const pref = Preferences::instance();
+ if (pref->isSchedulerEnabled())
+ m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000);
+ BitTorrent::Session::instance()->changeSpeedLimitMode(!pref->isAltBandwidthEnabled());
}
-void StatusBar::capDownloadSpeed() {
- bool ok = false;
- int cur_limit = BitTorrent::Session::instance()->downloadRateLimit();
- long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit);
- if (ok) {
- Preferences* const pref = Preferences::instance();
- bool alt = pref->isAltBandwidthEnabled();
- if (new_limit <= 0) {
- qDebug("Setting global download rate limit to Unlimited");
- BitTorrent::Session::instance()->setDownloadRateLimit(-1);
- if (!alt)
- pref->setGlobalDownloadLimit(-1);
- else
- pref->setAltGlobalDownloadLimit(-1);
- } else {
- qDebug("Setting global download rate limit to %.1fKb/s", new_limit/1024.);
- BitTorrent::Session::instance()->setDownloadRateLimit(new_limit);
- if (!alt)
- pref->setGlobalDownloadLimit(new_limit/1024.);
- else
- pref->setAltGlobalDownloadLimit(new_limit/1024.);
+void StatusBar::capDownloadSpeed()
+{
+ bool ok = false;
+ int cur_limit = BitTorrent::Session::instance()->downloadRateLimit();
+ long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), cur_limit);
+ if (ok) {
+ Preferences* const pref = Preferences::instance();
+ bool alt = pref->isAltBandwidthEnabled();
+ if (new_limit <= 0) {
+ qDebug("Setting global download rate limit to Unlimited");
+ BitTorrent::Session::instance()->setDownloadRateLimit(-1);
+ if (!alt)
+ pref->setGlobalDownloadLimit(-1);
+ else
+ pref->setAltGlobalDownloadLimit(-1);
+ }
+ else {
+ qDebug("Setting global download rate limit to %.1fKb/s", new_limit / 1024.);
+ BitTorrent::Session::instance()->setDownloadRateLimit(new_limit);
+ if (!alt)
+ pref->setGlobalDownloadLimit(new_limit / 1024.);
+ else
+ pref->setAltGlobalDownloadLimit(new_limit / 1024.);
+ }
+ refreshStatusBar();
}
- refreshStatusBar();
- }
}
-void StatusBar::capUploadSpeed() {
- bool ok = false;
- int cur_limit = BitTorrent::Session::instance()->uploadRateLimit();
- long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit);
- if (ok) {
- Preferences* const pref = Preferences::instance();
- bool alt = pref->isAltBandwidthEnabled();
- if (new_limit <= 0) {
- qDebug("Setting global upload rate limit to Unlimited");
- BitTorrent::Session::instance()->setUploadRateLimit(-1);
- if (!alt)
- Preferences::instance()->setGlobalUploadLimit(-1);
- else
- Preferences::instance()->setAltGlobalUploadLimit(-1);
- } else {
- qDebug("Setting global upload rate limit to %.1fKb/s", new_limit/1024.);
- BitTorrent::Session::instance()->setUploadRateLimit(new_limit);
- if (!alt)
- Preferences::instance()->setGlobalUploadLimit(new_limit/1024.);
- else
- Preferences::instance()->setAltGlobalUploadLimit(new_limit/1024.);
+void StatusBar::capUploadSpeed()
+{
+ bool ok = false;
+ int cur_limit = BitTorrent::Session::instance()->uploadRateLimit();
+ long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), cur_limit);
+ if (ok) {
+ Preferences* const pref = Preferences::instance();
+ bool alt = pref->isAltBandwidthEnabled();
+ if (new_limit <= 0) {
+ qDebug("Setting global upload rate limit to Unlimited");
+ BitTorrent::Session::instance()->setUploadRateLimit(-1);
+ if (!alt)
+ Preferences::instance()->setGlobalUploadLimit(-1);
+ else
+ Preferences::instance()->setAltGlobalUploadLimit(-1);
+ }
+ else {
+ qDebug("Setting global upload rate limit to %.1fKb/s", new_limit / 1024.);
+ BitTorrent::Session::instance()->setUploadRateLimit(new_limit);
+ if (!alt)
+ Preferences::instance()->setGlobalUploadLimit(new_limit / 1024.);
+ else
+ Preferences::instance()->setAltGlobalUploadLimit(new_limit / 1024.);
+ }
+ refreshStatusBar();
}
- refreshStatusBar();
- }
}
diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h
index d8587d6d8..a5ad3be5f 100644
--- a/src/gui/statusbar.h
+++ b/src/gui/statusbar.h
@@ -31,47 +31,48 @@
#ifndef STATUSBAR_H
#define STATUSBAR_H
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include
-class StatusBar: public QObject {
- Q_OBJECT
+class QStatusBar;
+class QFrame;
+class QLabel;
+class QTimer;
+class QPushButton;
+class QHBoxLayout;
+
+class StatusBar: public QObject
+{
+ Q_OBJECT
public:
- StatusBar(QStatusBar *bar);
- ~StatusBar();
+ StatusBar(QStatusBar *bar);
+ ~StatusBar();
- QPushButton* connectionStatusButton() const;
+ QPushButton* connectionStatusButton() const;
public slots:
- void showRestartRequired();
- void stopTimer();
- void refreshStatusBar();
- void updateAltSpeedsBtn(bool alternative);
- void toggleAlternativeSpeeds();
- void capDownloadSpeed();
- void capUploadSpeed();
+ void showRestartRequired();
+ void stopTimer();
+ void refreshStatusBar();
+ void updateAltSpeedsBtn(bool alternative);
+ void toggleAlternativeSpeeds();
+ void capDownloadSpeed();
+ void capUploadSpeed();
private:
- QStatusBar *m_bar;
- QPushButton *dlSpeedLbl;
- QPushButton *upSpeedLbl;
- QLabel *DHTLbl;
- QFrame *statusSep1;
- QFrame *statusSep2;
- QFrame *statusSep3;
- QFrame *statusSep4;
- QPushButton *connecStatusLblIcon;
- QPushButton *altSpeedsBtn;
- QTimer *refreshTimer;
- QWidget *container;
- QHBoxLayout *layout;
-
+ QStatusBar *m_bar;
+ QPushButton *dlSpeedLbl;
+ QPushButton *upSpeedLbl;
+ QLabel *DHTLbl;
+ QFrame *statusSep1;
+ QFrame *statusSep2;
+ QFrame *statusSep3;
+ QFrame *statusSep4;
+ QPushButton *connecStatusLblIcon;
+ QPushButton *altSpeedsBtn;
+ QTimer *refreshTimer;
+ QWidget *container;
+ QHBoxLayout *layout;
};
#endif // STATUSBAR_H