summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtElidingLabel.cpp5
-rw-r--r--Swift/QtUI/QtElidingLabel.h1
2 files changed, 5 insertions, 1 deletions
diff --git a/Swift/QtUI/QtElidingLabel.cpp b/Swift/QtUI/QtElidingLabel.cpp
index 475aa3b..3d53006 100644
--- a/Swift/QtUI/QtElidingLabel.cpp
+++ b/Swift/QtUI/QtElidingLabel.cpp
@@ -38,9 +38,12 @@ void QtElidingLabel::paintEvent(QPaintEvent* event) {
dirty_ = dirty_ || rect != lastRect_;
if (dirty_) {
lastRect_ = rect;
- if (fontMetrics().width(fullText_) > rect.width()) {
+ int fontWidth = fontMetrics().width(fullText_);
+ if (fontWidth > rect.width()) {
QString elidedText(fontMetrics().elidedText(fullText_, Qt::ElideRight, rect.width(), Qt::TextShowMnemonic));
QLabel::setText(elidedText);
+ } else {
+ QLabel::setText(fullText_);
}
dirty_ = false;
}
diff --git a/Swift/QtUI/QtElidingLabel.h b/Swift/QtUI/QtElidingLabel.h
index 79701ec..0bf2231 100644
--- a/Swift/QtUI/QtElidingLabel.h
+++ b/Swift/QtUI/QtElidingLabel.h
@@ -18,6 +18,7 @@ namespace Swift {
virtual ~QtElidingLabel();
virtual void paintEvent(QPaintEvent* event);
+
private:
void setSizes();
bool dirty_;