From: Mike Gelfand Date: Sat, 3 Feb 2018 19:36:54 +0000 (+0300) Subject: Fix progress bar width with Breeze style (Qt client) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=991f066618ddcb60f3aa5b361271f38550baf0a6;p=transmission 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 --- 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);