mirror of
https://github.com/transmission/transmission
synced 2024-12-23 00:04:06 +00:00
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
This commit is contained in:
parent
ee259c617f
commit
991f066618
1 changed files with 12 additions and 3 deletions
|
@ -6,6 +6,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
|
@ -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<int>(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);
|
||||
|
|
Loading…
Reference in a new issue