From aaba30a3a97a7703f2401a19db30ce9bedacc59b Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 10 Jun 2016 11:16:10 -0700 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/qt/packet_list.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) 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 #include +#ifdef Q_OS_WIN +#include "wsutil/file_util.h" +#include +#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())); -- cgit v1.2.3