summaryrefslogtreecommitdiff
path: root/ui/qt/percent_bar_delegate.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-08-30 12:12:33 -0700
committerAnders Broman <a.broman58@gmail.com>2016-09-02 20:01:51 +0000
commit893e0e96084fe0e559310d117fb953ddf08c0d6e (patch)
treea27f387583ce012c3d2cb7eff2540260fca39e84 /ui/qt/percent_bar_delegate.cpp
parent2ddb46dbee7fbb06014a39bc87586b45453a7eaa (diff)
downloadwireshark-893e0e96084fe0e559310d117fb953ddf08c0d6e.tar.gz
Qt: Add a timeline indicator to conversations.
Add a timeline indicator to the Start and Duration columns in the Conversations dialog. Add tooltips to the columns that explain what's going on. Round the timeline rect corners and do the same for Prototocol Hierarchy Statistics. This should hopefully differentiate the graph bars from a text selection and IMHO it looks better. Update the PHS and Conversations images in the User's Guide. Change-Id: I61d6c25843be522cc444e01ba77cb5b1e991fa36 Reviewed-on: https://code.wireshark.org/review/17396 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/percent_bar_delegate.cpp')
-rw-r--r--ui/qt/percent_bar_delegate.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/ui/qt/percent_bar_delegate.cpp b/ui/qt/percent_bar_delegate.cpp
index 76517de85e..31555aec38 100644
--- a/ui/qt/percent_bar_delegate.cpp
+++ b/ui/qt/percent_bar_delegate.cpp
@@ -35,7 +35,9 @@ void PercentBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
QStyleOptionViewItem option_vi = option;
QStyledItemDelegate::initStyleOption(&option_vi, index);
- QStyledItemDelegate::paint(painter, option, index);
+ // Paint our rect with no text using the current style, then draw our
+ // bar and text over it.
+ QStyledItemDelegate::paint(painter, option, QModelIndex());
bool ok = false;
double value = index.data(Qt::UserRole).toDouble(&ok);
@@ -45,8 +47,6 @@ void PercentBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
return;
}
- painter->save();
-
if (QApplication::style()->objectName().contains("vista")) {
// QWindowsVistaStyle::drawControl does this internally. Unfortunately there
// doesn't appear to be a more general way to do this.
@@ -54,29 +54,35 @@ void PercentBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
option_vi.palette.color(QPalette::Active, QPalette::Text));
}
- QColor bar_color = ColorUtils::alphaBlend(option_vi.palette.windowText(),
- option_vi.palette.window(), bar_blend_);
QPalette::ColorGroup cg = option_vi.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
+ QColor text_color = option_vi.palette.color(cg, QPalette::Text);
+ QColor bar_color = ColorUtils::alphaBlend(option_vi.palette.windowText(),
+ option_vi.palette.window(), bar_blend_);
+
if (cg == QPalette::Normal && !(option_vi.state & QStyle::State_Active))
cg = QPalette::Inactive;
if (option_vi.state & QStyle::State_Selected) {
- painter->setPen(option_vi.palette.color(cg, QPalette::HighlightedText));
+ text_color = option_vi.palette.color(cg, QPalette::HighlightedText);
bar_color = ColorUtils::alphaBlend(option_vi.palette.color(cg, QPalette::Window),
option_vi.palette.color(cg, QPalette::Highlight),
bar_blend_);
- } else {
- painter->setPen(option_vi.palette.color(cg, QPalette::Text));
}
+ painter->save();
+ int border_radius = 3; // We use 3 px elsewhere, e.g. filter combos.
QRect pct_rect = option.rect;
pct_rect.adjust(1, 1, -1, -1);
pct_rect.setWidth(((pct_rect.width() * value) / 100.0) + 0.5);
- painter->fillRect(pct_rect, bar_color);
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(bar_color);
+ painter->drawRoundedRect(pct_rect, border_radius, border_radius);
+ painter->restore();
+ painter->save();
QString pct_str = QString::number(value, 'f', 1);
+ painter->setPen(text_color);
painter->drawText(option.rect, Qt::AlignCenter, pct_str);
-
painter->restore();
}