From b5adbaef7882c8c8c9a7a0f4bed08ea26f94ca59 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 29 Jun 2015 02:02:58 +0800 Subject: [PATCH 1/5] Fix availability bar & progress bar height being too small on high DPI displays --- src/gui/properties/downloadedpiecesbar.cpp | 2 -- src/gui/properties/downloadedpiecesbar.h | 2 -- src/gui/properties/pieceavailabilitybar.cpp | 2 -- src/gui/properties/pieceavailabilitybar.h | 3 --- src/gui/properties/propertieswidget.cpp | 12 ++++++++++++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gui/properties/downloadedpiecesbar.cpp b/src/gui/properties/downloadedpiecesbar.cpp index e0764507e..c4f6fac17 100644 --- a/src/gui/properties/downloadedpiecesbar.cpp +++ b/src/gui/properties/downloadedpiecesbar.cpp @@ -33,8 +33,6 @@ DownloadedPiecesBar::DownloadedPiecesBar(QWidget *parent): QWidget(parent) { - setFixedHeight(BAR_HEIGHT); - m_bgColor = 0xffffff; m_borderColor = palette().color(QPalette::Dark).rgb(); m_pieceColor = 0x0000ff; diff --git a/src/gui/properties/downloadedpiecesbar.h b/src/gui/properties/downloadedpiecesbar.h index 7f4af7c83..74ce1a5cf 100644 --- a/src/gui/properties/downloadedpiecesbar.h +++ b/src/gui/properties/downloadedpiecesbar.h @@ -37,8 +37,6 @@ #include #include -#define BAR_HEIGHT 18 - class DownloadedPiecesBar: public QWidget { Q_OBJECT Q_DISABLE_COPY(DownloadedPiecesBar) diff --git a/src/gui/properties/pieceavailabilitybar.cpp b/src/gui/properties/pieceavailabilitybar.cpp index 0b968ea15..0f2b17087 100644 --- a/src/gui/properties/pieceavailabilitybar.cpp +++ b/src/gui/properties/pieceavailabilitybar.cpp @@ -36,8 +36,6 @@ PieceAvailabilityBar::PieceAvailabilityBar(QWidget *parent) : QWidget(parent) { - setFixedHeight(BAR_HEIGHT); - m_bgColor = 0xffffff; m_borderColor = palette().color(QPalette::Dark).rgb(); m_pieceColor = 0x0000ff; diff --git a/src/gui/properties/pieceavailabilitybar.h b/src/gui/properties/pieceavailabilitybar.h index 52e78dc3f..6d8e2142b 100644 --- a/src/gui/properties/pieceavailabilitybar.h +++ b/src/gui/properties/pieceavailabilitybar.h @@ -35,9 +35,6 @@ #include #include -#define BAR_HEIGHT 18 - - class PieceAvailabilityBar: public QWidget { Q_OBJECT diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index c738673c4..4cea02a0a 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -102,12 +102,24 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra connect(filesList->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); connect(filesList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + // set bar height relative to screen dpi + int barHeight = devicePixelRatio() * 18; +#else + // set bar height relative to font height + QFont defFont; + QFontMetrics fMetrics(defFont, 0); // need to be device-dependent + int barHeight = fMetrics.height() * 5 / 4; +#endif + // Downloaded pieces progress bar downloaded_pieces = new DownloadedPiecesBar(this); ProgressHLayout->insertWidget(1, downloaded_pieces); + downloaded_pieces->setFixedHeight(barHeight); // Pieces availability bar pieces_availability = new PieceAvailabilityBar(this); ProgressHLayout_2->insertWidget(1, pieces_availability); + pieces_availability->setFixedHeight(barHeight); // Tracker list trackerList = new TrackerList(this); connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp())); From f530bb75378d465c0437867112b28498eab0be1f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 29 Jun 2015 02:33:43 +0800 Subject: [PATCH 2/5] Fix availability label & progress label clipped on high DPI displays, closes #3237. --- src/gui/properties/propertieswidget.cpp | 10 +- src/gui/properties/propertieswidget.ui | 537 ++++++++++-------------- 2 files changed, 231 insertions(+), 316 deletions(-) diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 4cea02a0a..59f60c96b 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -113,13 +113,19 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra #endif // Downloaded pieces progress bar + tempProgressBarArea->setVisible(false); downloaded_pieces = new DownloadedPiecesBar(this); - ProgressHLayout->insertWidget(1, downloaded_pieces); + groupBarLayout->addWidget(downloaded_pieces, 0, 1); downloaded_pieces->setFixedHeight(barHeight); + downloaded_pieces->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + // Pieces availability bar + tempAvailabilityBarArea->setVisible(false); pieces_availability = new PieceAvailabilityBar(this); - ProgressHLayout_2->insertWidget(1, pieces_availability); + groupBarLayout->addWidget(pieces_availability, 1, 1); pieces_availability->setFixedHeight(barHeight); + pieces_availability->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + // Tracker list trackerList = new TrackerList(this); connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp())); diff --git a/src/gui/properties/propertieswidget.ui b/src/gui/properties/propertieswidget.ui index 2340f5e32..7ad836036 100644 --- a/src/gui/properties/propertieswidget.ui +++ b/src/gui/properties/propertieswidget.ui @@ -10,14 +10,20 @@ 452 - - Form - 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -25,22 +31,25 @@ 0 - + 0 - + + 0 + + + 0 + + + 0 + + 0 - - - 0 - 0 - - true @@ -55,137 +64,16 @@ - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Progress: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 50 - 16777215 - - - - - - - Qt::PlainText - - - Qt::AlignLeading - - - 0 - - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Availability: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 50 - 16777215 - - - - - - - Qt::PlainText - - - Qt::AlignLeading - - - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Transfer - - + + + + 4 + + + 4 + - + 0 @@ -193,31 +81,28 @@ - Time Active: + Progress: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - - - Qt::PlainText - - + + 0 @@ -225,31 +110,77 @@ - ETA: + Availability: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - - + + Qt::PlainText + + + + + + + Qt::PlainText + + + + Qt::PlainText - - + + + + + + + Qt::Horizontal + + + + + + + Transfer + + + + 4 + + + 4 + + + + + + 0 + 0 + + + + Qt::PlainText + + + + + 0 @@ -257,31 +188,28 @@ - Connections: + Upload Speed: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 0 0 - - - Qt::PlainText - - + + 0 @@ -289,63 +217,57 @@ - Downloaded: + Peers: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - + Connections: - - Qt::PlainText + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - - Uploaded: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + Qt::PlainText - - + + 0 0 - - - Qt::PlainText - - + + 0 @@ -353,63 +275,57 @@ - Seeds: + Download Limit: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - + Share Ratio: - - Qt::PlainText + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - - Download Speed: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + Qt::PlainText - - + + 0 0 - - - Qt::PlainText - - + + 0 @@ -417,31 +333,31 @@ - Upload Speed: + Downloaded: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - + Upload Limit: - - Qt::PlainText + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 0 @@ -449,31 +365,41 @@ - Peers: + Last Seen Complete: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 0 0 - - + + Qt::PlainText + + + + + + + + 0 + 0 + Qt::PlainText - - + + 0 @@ -481,31 +407,28 @@ - Download Limit: + Reannounce In: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 0 0 - - - Qt::PlainText - - + + 0 @@ -513,63 +436,70 @@ - Upload Limit: + Seeds: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - + Download Speed: - - Qt::PlainText + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - - Wasted: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + Qt::PlainText - + 0 0 - - + + Qt::PlainText + + + + + + + + 0 + 0 + Qt::PlainText - - + + 0 @@ -577,31 +507,41 @@ - Share Ratio: + Uploaded: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 0 0 - - + + Qt::PlainText + + + + + + + + 0 + 0 + Qt::PlainText - - + + 0 @@ -609,31 +549,28 @@ - Reannounce In: + Time Active: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 0 0 - - - Qt::PlainText - - + + 0 @@ -641,26 +578,26 @@ - Last Seen Complete: + ETA: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + 0 0 - + Wasted: - - Qt::PlainText + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -668,17 +605,17 @@ - - - - 0 - 0 - - + Information + + 4 + + + 2 + @@ -703,9 +640,6 @@ 0 - - - Qt::PlainText @@ -735,9 +669,6 @@ 0 - - - Qt::PlainText @@ -767,9 +698,6 @@ 0 - - - Qt::PlainText @@ -799,9 +727,6 @@ 0 - - - Qt::PlainText @@ -831,9 +756,6 @@ 0 - - - Qt::PlainText @@ -863,9 +785,6 @@ 0 - - - Qt::PlainText @@ -895,9 +814,6 @@ 0 - - - Qt::PlainText @@ -930,15 +846,9 @@ 0 - - - Qt::PlainText - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - true @@ -1000,7 +910,7 @@ - + @@ -1169,8 +1079,7 @@ - - + From 421b45c5537692585342ea127793952eb5aae362 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 29 Jun 2015 16:01:00 +0800 Subject: [PATCH 3/5] Add tooltips/legend for availability bar & progress bar --- src/gui/properties/downloadedpiecesbar.cpp | 2 ++ src/gui/properties/pieceavailabilitybar.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gui/properties/downloadedpiecesbar.cpp b/src/gui/properties/downloadedpiecesbar.cpp index c4f6fac17..eb799662a 100644 --- a/src/gui/properties/downloadedpiecesbar.cpp +++ b/src/gui/properties/downloadedpiecesbar.cpp @@ -33,6 +33,8 @@ DownloadedPiecesBar::DownloadedPiecesBar(QWidget *parent): QWidget(parent) { + setToolTip(QString("%1\n%2\n%3").arg(tr("White: Missing pieces")).arg(tr("Green: Partial pieces")).arg(tr("Blue: Completed pieces"))); + m_bgColor = 0xffffff; m_borderColor = palette().color(QPalette::Dark).rgb(); m_pieceColor = 0x0000ff; diff --git a/src/gui/properties/pieceavailabilitybar.cpp b/src/gui/properties/pieceavailabilitybar.cpp index 0f2b17087..830810a02 100644 --- a/src/gui/properties/pieceavailabilitybar.cpp +++ b/src/gui/properties/pieceavailabilitybar.cpp @@ -36,6 +36,8 @@ PieceAvailabilityBar::PieceAvailabilityBar(QWidget *parent) : QWidget(parent) { + setToolTip(QString("%1\n%2").arg(tr("White: Unavailable pieces")).arg(tr("Blue: Available pieces"))); + m_bgColor = 0xffffff; m_borderColor = palette().color(QPalette::Dark).rgb(); m_pieceColor = 0x0000ff; From c6a6f85a5eca0d2a6c89405b29223af29968425c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 1 Jul 2015 01:17:51 +0800 Subject: [PATCH 4/5] Use theme color for background in PropertiesWidget --- src/gui/properties/propertieswidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 59f60c96b..663d0c9b0 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -66,6 +66,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList): QWidget(parent), transferList(transferList), main_window(main_window), m_torrent(0) { setupUi(this); + setAutoFillBackground(true); // Icons trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); From 7e6dfa759ca6ed22ae7a0c8f1db3c4fdbfb68768 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 12 Jul 2015 18:08:35 +0800 Subject: [PATCH 5/5] Replace horizontal line with border --- src/gui/properties/propertieswidget.cpp | 7 +++---- src/gui/properties/propertieswidget.ui | 9 +-------- src/gui/properties/proptabbar.cpp | 5 +++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 663d0c9b0..b673d1285 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -68,10 +68,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra setupUi(this); setAutoFillBackground(true); - // Icons - trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); - trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down")); - state = VISIBLE; // Set Properties list model @@ -129,6 +125,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra // Tracker list trackerList = new TrackerList(this); + trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); + trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down")); connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp())); connect(trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown())); horizontalLayout_trackers->insertWidget(0, trackerList); @@ -146,6 +144,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra speed_layout->addWidget(speedWidget); // Tab bar m_tabBar = new PropTabBar(); + m_tabBar->setContentsMargins(0, 5, 0, 0); verticalLayout->addLayout(m_tabBar); connect(m_tabBar, SIGNAL(tabChanged(int)), stackedProperties, SLOT(setCurrentIndex(int))); connect(m_tabBar, SIGNAL(tabChanged(int)), this, SLOT(saveSettings())); diff --git a/src/gui/properties/propertieswidget.ui b/src/gui/properties/propertieswidget.ui index 7ad836036..920f003ec 100644 --- a/src/gui/properties/propertieswidget.ui +++ b/src/gui/properties/propertieswidget.ui @@ -59,7 +59,7 @@ 0 0 549 - 447 + 450 @@ -1083,13 +1083,6 @@ - - - - Qt::Horizontal - - - diff --git a/src/gui/properties/proptabbar.cpp b/src/gui/properties/proptabbar.cpp index 5b0b2c591..11be20734 100644 --- a/src/gui/properties/proptabbar.cpp +++ b/src/gui/properties/proptabbar.cpp @@ -39,7 +39,8 @@ PropTabBar::PropTabBar(QWidget *parent) : QHBoxLayout(parent), m_currentIndex(-1) { - setSpacing(2); + setAlignment(Qt::AlignLeft | Qt::AlignCenter); + setSpacing(3); m_btnGroup = new QButtonGroup(this); // General tab QPushButton *main_infos_button = new QPushButton(GuiIconProvider::instance()->getIcon("document-properties"), tr("General"), parent); @@ -63,7 +64,7 @@ PropTabBar::PropTabBar(QWidget *parent) : addWidget(files_button); m_btnGroup->addButton(files_button, FILES_TAB); // Spacer - addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); + addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); // Speed tab QPushButton *speed_button = new QPushButton(GuiIconProvider::instance()->getIcon("office-chart-line"), tr("Speed"), parent); addWidget(speed_button);