From 991f066618ddcb60f3aa5b361271f38550baf0a6 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sat, 3 Feb 2018 22:36:54 +0300 Subject: [PATCH] Fix progress bar width with Breeze style (Qt client) In compact torrents view, use BAR_WIDTH as groove area width instead of total progress bar width, to improve the appearance in case progress text is drawn outside of the groove area (because of style settings). Initial patch provided by dubhater. Fixes: #491 --- qt/TorrentDelegateMin.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/qt/TorrentDelegateMin.cc b/qt/TorrentDelegateMin.cc index 51173a46a..5316202ec 100644 --- a/qt/TorrentDelegateMin.cc +++ b/qt/TorrentDelegateMin.cc @@ -6,6 +6,8 @@ * */ +#include + #include #include #include @@ -103,13 +105,20 @@ ItemLayout::ItemLayout(QString const& nameText, QString const& statusText, QIcon QFontMetrics const statusFM(statusFont); QSize const statusSize(statusFM.size(0, myStatusText)); - QRect baseRect(topLeft, QSize(width, qMax(iconSize, qMax(nameSize.height(), qMax(statusSize.height(), - static_cast(BAR_HEIGHT)))))); + QStyleOptionProgressBar barStyle; + barStyle.rect = QRect(0, 0, BAR_WIDTH, BAR_HEIGHT); + barStyle.maximum = 100; + barStyle.progress = 100; + barStyle.textVisible = true; + QSize const barSize(barStyle.rect.width() * 2 - style->subElementRect(QStyle::SE_ProgressBarGroove, &barStyle).width(), + barStyle.rect.height()); + + QRect baseRect(topLeft, QSize(width, std::max({iconSize, nameSize.height(), statusSize.height(), barSize.height()}))); iconRect = style->alignedRect(direction, Qt::AlignLeft | Qt::AlignVCenter, QSize(iconSize, iconSize), baseRect); emblemRect = style->alignedRect(direction, Qt::AlignRight | Qt::AlignBottom, emblemIcon.actualSize(iconRect.size() / 2, QIcon::Normal, QIcon::On), iconRect); - barRect = style->alignedRect(direction, Qt::AlignRight | Qt::AlignVCenter, QSize(BAR_WIDTH, BAR_HEIGHT), baseRect); + barRect = style->alignedRect(direction, Qt::AlignRight | Qt::AlignVCenter, barSize, baseRect); Utils::narrowRect(baseRect, iconRect.width() + GUI_PAD, barRect.width() + GUI_PAD, direction); statusRect = style->alignedRect(direction, Qt::AlignRight | Qt::AlignVCenter, QSize(statusSize.width(), baseRect.height()), baseRect);