]> granicus.if.org Git - transmission/commitdiff
Fix progress bar width with Breeze style (Qt client)
authorMike Gelfand <mikedld@mikedld.com>
Sat, 3 Feb 2018 19:36:54 +0000 (22:36 +0300)
committerMike Gelfand <mikedld@mikedld.com>
Sat, 3 Feb 2018 19:36:54 +0000 (22:36 +0300)
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

index 51173a46a4c697ae1e6b2e5d77738f9efee11a66..5316202ec8cead102da4f72e8aaaebd6a33865bf 100644 (file)
@@ -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);