aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2015-03-07 09:23:03 -0800
committerGerald Combs <gerald@wireshark.org>2015-03-08 16:16:30 +0000
commit87c0df36c80f129a7e15015fc5b16872a42e1e94 (patch)
treeacc645ec2cda56650d3835777231172cc004ed74 /ui
parentcf5f2c90f7c215e647720660f73473b9e16d65cb (diff)
Qt: Paint elided LableStack text by hand.
Change-Id: I9481598f59531c219a20209429e6ff876ba50cf0 Reviewed-on: https://code.wireshark.org/review/7591 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/label_stack.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/ui/qt/label_stack.cpp b/ui/qt/label_stack.cpp
index c7e27532f9..5db56945e0 100644
--- a/ui/qt/label_stack.cpp
+++ b/ui/qt/label_stack.cpp
@@ -24,6 +24,7 @@
#include <QContextMenuEvent>
#include <QPainter>
#include <QMouseEvent>
+#include <QStyleOption>
#include "tango_colors.h"
@@ -143,14 +144,18 @@ void LabelStack::paintEvent(QPaintEvent *event)
return;
}
- // Other "elided label" examples draw the label text by hand,
- // reimplementing QLabel::paintEvent. Disabling updates and letting
- // QLabel do the work for us seems to work, however.
+ QFrame::paintEvent(event);
+
QString elided_text = fontMetrics().elidedText(text(), Qt::ElideMiddle, width());
- QString full_text = text();
- setText(elided_text);
- QLabel::paintEvent(event);
- setText(full_text);
+ QPainter painter(this);
+ QRect contents_rect = contentsRect();
+ QStyleOption opt;
+
+ contents_rect.adjust(margin(), margin(), -margin(), -margin());
+ opt.initFrom(this);
+
+ style()->drawItemText(&painter, contents_rect, alignment(), opt.palette,
+ isEnabled(), elided_text, foregroundRole());
}
void LabelStack::popText(int ctx) {