aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/stock_icon.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-07-10 16:15:55 -0700
committerGerald Combs <gerald@wireshark.org>2015-07-11 00:41:01 +0000
commitd564ea9bea6ba07ac601ca555609677b498845dd (patch)
tree1410ba5423017cf45c959e302a30e919475d6c88 /ui/qt/stock_icon.cpp
parent44408ed5d9f39f49e871f302c97a6044c0fe4e7e (diff)
Qt: Add Colorize Conversation menu items.
Add the "View→Colorize Conversation" menu similar to the GTK+ UI. Add the "Reset" item under the "Colorize Conversation" menu instead of the top-level "View" menu. Make sure the "Reset" shortcut is Ctrl+Space even on OS X. Normally Qt would convert it to Cmd+Space, but that's used by Spotlight. Add StockIcon::colorIcon and use it to create filled square icons. Change-Id: I2af9e26d025cdaf97482422bbb9440e28e18d1ac Reviewed-on: https://code.wireshark.org/review/9595 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/stock_icon.cpp')
-rw-r--r--ui/qt/stock_icon.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/qt/stock_icon.cpp b/ui/qt/stock_icon.cpp
index 86e953e3dd..8c6929fa1a 100644
--- a/ui/qt/stock_icon.cpp
+++ b/ui/qt/stock_icon.cpp
@@ -53,6 +53,8 @@
#include "wireshark_application.h"
#include <QFile>
+#include <QFontMetrics>
+#include <QPainter>
#include <QStyle>
QString path_pfx_ = ":/icons/toolbar/";
@@ -92,6 +94,32 @@ StockIcon::StockIcon(const char *icon_name) :
}
}
+// Create a square icon filled with the specified color.
+QIcon StockIcon::colorIcon(const QRgb bg_color, const QRgb fg_color, const QString glyph)
+{
+ QList<int> sizes = QList<int>() << 12 << 16 << 24 << 32 << 48;
+ QIcon color_icon;
+
+ foreach (int size, sizes) {
+ QPixmap pm(size, size);
+ QPainter painter(&pm);
+ QRect border(0, 0, size - 1, size - 1);
+ painter.setPen(fg_color);
+ painter.setBrush(QColor(bg_color));
+ painter.drawRect(border);
+
+ if (!glyph.isEmpty()) {
+ QFont font(wsApp->font());
+ font.setPointSizeF(size * 2.0 / 3.0);
+ QRectF bounding = painter.boundingRect(pm.rect(), glyph, Qt::AlignHCenter | Qt::AlignVCenter);
+ painter.drawText(bounding, glyph);
+ }
+
+ color_icon.addPixmap(pm);
+ }
+ return color_icon;
+}
+
/*
* Editor modelines
*