aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-06-10 11:16:10 -0700
committerGerald Combs <gerald@wireshark.org>2016-06-12 17:15:09 +0000
commitaaba30a3a97a7703f2401a19db30ce9bedacc59b (patch)
tree4cddc8580cebd336f035cffc6e3cfa30cbd4cc28
parenta5ff5c2d60ec018ae86a1343f91be2658464a25c (diff)
Qt: Draw a border around inactive+selected packet list items.
Try to make inactive+selected packet list items more visible by drawing a border around them. Make an exception for Windows 7 and Vista if a theme is active. Bug: 12010 Change-Id: I974069dda92588b80772f577f319569751ff3347 Reviewed-on: https://code.wireshark.org/review/15816 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/packet_list.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 47e60d9668..ebb8eb26b9 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -74,6 +74,11 @@
#include <QTimerEvent>
#include <QTreeWidget>
+#ifdef Q_OS_WIN
+#include "wsutil/file_util.h"
+#include <QSysInfo>
+#endif
+
// To do:
// - Fix "apply as filter" behavior.
// - Add colorize conversation.
@@ -378,6 +383,60 @@ PacketList::PacketList(QWidget *parent) :
g_assert(gbl_cur_packet_list == NULL);
gbl_cur_packet_list = this;
+ bool style_inactive_selected = true;
+
+#ifdef Q_OS_WIN // && Qt version >= 4.8.6
+ if (QSysInfo::WinVersion() < QSysInfo::WV_WINDOWS8) {
+ // See if we're running Vista or 7 and we have a theme applied.
+ HMODULE uxtheme_lib = (HMODULE) ws_load_library("uxtheme.dll");
+
+ if (uxtheme_lib) {
+ typedef BOOL (WINAPI *IsAppThemedHandler)(void);
+ typedef BOOL (WINAPI *IsThemeActiveHandler)(void);
+
+ IsAppThemedHandler PIsAppThemed = (IsAppThemedHandler) GetProcAddress(uxtheme_lib, "IsAppThemed");
+ IsThemeActiveHandler PIsThemeActive = (IsThemeActiveHandler) GetProcAddress(uxtheme_lib, "IsThemeActive");
+ if (PIsAppThemed && PIsAppThemed() && PIsThemeActive && PIsThemeActive()) {
+ style_inactive_selected = false;
+ }
+ }
+ }
+#endif
+
+ if (style_inactive_selected) {
+ // XXX Style the protocol tree as well?
+ QPalette inactive_pal = palette();
+ inactive_pal.setCurrentColorGroup(QPalette::Inactive);
+ QColor border = QColor::fromRgb(ColorUtils::alphaBlend(
+ inactive_pal.highlightedText(),
+ inactive_pal.highlight(),
+ 0.25));
+ QColor shadow = QColor::fromRgb(ColorUtils::alphaBlend(
+ inactive_pal.highlightedText(),
+ inactive_pal.highlight(),
+ 0.07));
+ setStyleSheet(QString(
+ "QTreeView::item:selected:first:!active {"
+ " border-left: 1px solid %1;"
+ "}"
+ "QTreeView::item:selected:last:!active {"
+ " border-right: 1px solid %1;"
+ "}"
+ "QTreeView::item:selected:!active {"
+ " border-top: 1px solid %1;"
+ " border-bottom: 1px solid %1;"
+ " color: %2;"
+ // Try to approximate a subtle box shadow.
+ " background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1"
+ " stop: 0 %4, stop: 0.2 %3, stop: 0.8 %3, stop: 1 %4);"
+ "}")
+ .arg(border.name())
+ .arg(inactive_pal.highlightedText().color().name())
+ .arg(inactive_pal.highlight().color().name())
+ .arg(shadow.name())
+ );
+ }
+
connect(packet_list_model_, SIGNAL(goToPacket(int)), this, SLOT(goToPacket(int)));
connect(packet_list_model_, SIGNAL(itemHeightChanged(const QModelIndex&)), this, SLOT(updateRowHeights(const QModelIndex&)));
connect(wsApp, SIGNAL(addressResolutionChanged()), this, SLOT(redrawVisiblePackets()));