From b5adbaef7882c8c8c9a7a0f4bed08ea26f94ca59 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 29 Jun 2015 02:02:58 +0800 Subject: [PATCH] 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()));