From 4d8a264fb8f6ca57b7715394ed253f2e8f1e1936 Mon Sep 17 00:00:00 2001
From: Jens Bache-Wiig <jbache@trolltech.com>
Date: Fri, 12 Mar 2010 14:30:23 +0100
Subject: [PATCH] Fix text elliding issue with progress bar
This fixes a problem where the text would clip
if it didnt fit after the progress bar had
completed.
---
.../coreplugin/progressmanager/progressbar.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/plugins/coreplugin/progressmanager/progressbar.cpp b/src/plugins/coreplugin/progressmanager/progressbar.cpp
index dd4787d6fa7..1d70c9783ce 100644
--- a/src/plugins/coreplugin/progressmanager/progressbar.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressbar.cpp
@@ -157,16 +157,16 @@ void ProgressBar::paintEvent(QPaintEvent *)
p.setPen(Utils::StyleHelper::sidebarHighlight());
p.drawLine(1, 1, size().width(), 1);
- QRect textBounds = fontMetrics().boundingRect(m_title);
+ QRect textBounds = fm.boundingRect(m_title);
textBounds.moveCenter(rect().center());
-
+ int buttonWidth = value() < maximum() ? CANCEL_WIDTH : 0;
int alignment = Qt::AlignHCenter;
- int textSpace = rect().width() - CANCEL_WIDTH - 8;
+ int textSpace = rect().width() - buttonWidth - 8;
// If there is not enough room when centered, we left align and
// elide the text
QString elidedtitle = m_title;
- if (value() < maximum() && !m_error && textBounds.right() > textSpace) {
+ if (!m_error && textBounds.right() > textSpace) {
alignment = Qt::AlignLeft;
elidedtitle = fm.elidedText(m_title, Qt::ElideRight, textSpace);
}
@@ -230,8 +230,8 @@ void ProgressBar::paintEvent(QPaintEvent *)
// Draw cancel button
if (value() < maximum() && !m_error) {
QRect parentRect = parentWidget()->rect(); // ### Move to parent
- QRect cancelRect(parentRect.right() - CANCEL_WIDTH - 2,
- parentRect.top() + 4, CANCEL_WIDTH, CANCEL_WIDTH);
+ QRect cancelRect(parentRect.right() - buttonWidth - 2,
+ parentRect.top() + 4, buttonWidth, CANCEL_WIDTH);
bool hover = cancelRect.contains(mapFromGlobal(QCursor::pos()));
p.setPen(QPen(QColor(0, 0, 0, 20), 4));
--
GitLab