forked from osmocom/wireshark
Qt: Add hover style to packet list and proto tree
Highlight the row in packet list and proto tree when mouse hovers above the row. This mimics the behaviour on Windows. Change-Id: I28461f9d7740269bad39893597232fe775f77a86 Reviewed-on: https://code.wireshark.org/review/32619 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
009283a68b
commit
fc56f23303
|
@ -73,6 +73,11 @@ void RelatedPacketDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||
QColor fg;
|
||||
if (cg == QPalette::Normal && !(option_vi.state & QStyle::State_Active))
|
||||
cg = QPalette::Inactive;
|
||||
#if !defined(Q_OS_WIN)
|
||||
if (option_vi.state & QStyle::State_MouseOver) {
|
||||
fg = QApplication::palette().text().color();
|
||||
} else
|
||||
#endif
|
||||
if (option_vi.state & QStyle::State_Selected) {
|
||||
fg = option_vi.palette.color(cg, QPalette::HighlightedText);
|
||||
} else {
|
||||
|
|
|
@ -297,6 +297,23 @@ void PacketList::colorsChanged()
|
|||
" background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1 stop: 0 %4, stop: 0.5 %3, stop: 1 %4);"
|
||||
"}";
|
||||
|
||||
QString hover_style;
|
||||
#if !defined(Q_OS_WIN)
|
||||
#if defined(Q_OS_MAC)
|
||||
QPalette default_pal = QApplication::palette();
|
||||
default_pal.setCurrentColorGroup(QPalette::Active);
|
||||
QColor hover_color = default_pal.highlight().color();
|
||||
#else
|
||||
QColor hover_color = ColorUtils::alphaBlend(palette().window(), palette().highlight(), 0.5);
|
||||
#endif
|
||||
|
||||
hover_style = QString(
|
||||
"QTreeView:item:hover {"
|
||||
" background-color: %1;"
|
||||
" color: palette(text);"
|
||||
"}").arg(hover_color.name());
|
||||
#endif
|
||||
|
||||
QString active_style = QString();
|
||||
QString inactive_style = QString();
|
||||
|
||||
|
@ -391,7 +408,7 @@ void PacketList::colorsChanged()
|
|||
}
|
||||
|
||||
// Set the style sheet
|
||||
setStyleSheet(active_style + inactive_style);
|
||||
setStyleSheet(active_style + inactive_style + hover_style);
|
||||
}
|
||||
|
||||
void PacketList::drawRow (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <epan/ftypes/ftypes.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#include <ui/qt/utils/color_utils.h>
|
||||
#include <ui/qt/utils/variant_pointer.h>
|
||||
#include <ui/qt/utils/wireshark_mime_data.h>
|
||||
#include <ui/qt/widgets/drag_label.h>
|
||||
|
@ -48,6 +49,22 @@ ProtoTree::ProtoTree(QWidget *parent, epan_dissect_t *edt_fixed) :
|
|||
// similar to PacketListModel::data.
|
||||
setHeaderHidden(true);
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
#if defined(Q_OS_MAC)
|
||||
QPalette default_pal = QApplication::palette();
|
||||
default_pal.setCurrentColorGroup(QPalette::Active);
|
||||
QColor hover_color = default_pal.highlight().color();
|
||||
#else
|
||||
QColor hover_color = ColorUtils::alphaBlend(palette().window(), palette().highlight(), 0.5);
|
||||
#endif
|
||||
|
||||
setStyleSheet(QString(
|
||||
"QTreeView:item:hover {"
|
||||
" background-color: %1;"
|
||||
" color: palette(text);"
|
||||
"}").arg(hover_color.name()));
|
||||
#endif
|
||||
|
||||
// Shrink down to a small but nonzero size in the main splitter.
|
||||
int one_em = fontMetrics().height();
|
||||
setMinimumSize(one_em, one_em);
|
||||
|
|
Loading…
Reference in New Issue