aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2021-09-13 17:00:48 +0200
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-09-13 15:33:46 +0000
commit19f3a82ff85fc513e414400866c5bff9f28acf55 (patch)
treefce0ce4fa21a211fbadb30df0bdef079369fedc1 /ui
parent3cb302f05b0b8e16b97d4ada5c3027641d9b4a3c (diff)
Qt: ByteView make hover configurable
Allow the hover selection to be either configured via context menu or by pressing the Ctrl key while moving the mouse. The configuration is stored via profile
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/byte_view_tab.cpp3
-rw-r--r--ui/qt/byte_view_tab.h1
-rw-r--r--ui/qt/widgets/byte_view_text.cpp21
-rw-r--r--ui/qt/widgets/byte_view_text.h4
-rw-r--r--ui/recent.c8
-rw-r--r--ui/recent.h1
6 files changed, 35 insertions, 3 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp
index efb2cb1add..e7af2fd30a 100644
--- a/ui/qt/byte_view_tab.cpp
+++ b/ui/qt/byte_view_tab.cpp
@@ -33,7 +33,8 @@ ByteViewTab::ByteViewTab(QWidget *parent, epan_dissect_t *edt_fixed) :
QTabWidget(parent),
cap_file_(0),
is_fixed_packet_(edt_fixed != NULL),
- edt_(edt_fixed)
+ edt_(edt_fixed),
+ disable_hover_(false)
{
setAccessibleName(tr("Packet bytes"));
setTabPosition(QTabWidget::South);
diff --git a/ui/qt/byte_view_tab.h b/ui/qt/byte_view_tab.h
index f408ddb8eb..74745282fa 100644
--- a/ui/qt/byte_view_tab.h
+++ b/ui/qt/byte_view_tab.h
@@ -53,6 +53,7 @@ private:
packet in the packet dialog and false if the
packet dissection context can change. */
epan_dissect_t *edt_; /* Packet dissection result for the currently selected packet. */
+ bool disable_hover_;
void setTabsVisible();
ByteViewText * findByteViewTextForTvb(tvbuff_t * search, int * idx = 0);
diff --git a/ui/qt/widgets/byte_view_text.cpp b/ui/qt/widgets/byte_view_text.cpp
index f89150f8bd..391fde4dc7 100644
--- a/ui/qt/widgets/byte_view_text.cpp
+++ b/ui/qt/widgets/byte_view_text.cpp
@@ -58,7 +58,8 @@ ByteViewText::ByteViewText(const QByteArray &data, packet_char_enc encoding, QWi
show_ascii_(true),
row_width_(recent.gui_bytes_view == BYTES_HEX ? 16 : 8),
font_width_(0),
- line_height_(0)
+ line_height_(0),
+ allow_hover_selection_(false)
{
layout_->setCacheEnabled(true);
@@ -82,6 +83,13 @@ ByteViewText::~ByteViewText()
void ByteViewText::createContextMenu()
{
+
+ action_allow_hover_selection_ = ctx_menu_.addAction(tr("Allow hover selection"));
+ action_allow_hover_selection_->setCheckable(true);
+ action_allow_hover_selection_->setChecked(true);
+ connect(action_allow_hover_selection_, &QAction::toggled, this, &ByteViewText::toggleHoverAllowed);
+ ctx_menu_.addSeparator();
+
QActionGroup * copy_actions = DataPrinter::copyActions(this);
ctx_menu_.addActions(copy_actions->actions());
ctx_menu_.addSeparator();
@@ -119,8 +127,16 @@ void ByteViewText::createContextMenu()
connect(encoding_actions, &QActionGroup::triggered, this, &ByteViewText::setCharacterEncoding);
}
+void ByteViewText::toggleHoverAllowed(bool checked)
+{
+ allow_hover_selection_ = ! checked;
+}
+
void ByteViewText::updateContextMenu()
{
+
+ action_allow_hover_selection_->setChecked(recent.gui_allow_hover_selection);
+
switch (recent.gui_bytes_view) {
case BYTES_HEX:
action_bytes_hex_->setChecked(true);
@@ -315,7 +331,8 @@ void ByteViewText::mousePressEvent (QMouseEvent *event) {
void ByteViewText::mouseMoveEvent(QMouseEvent *event)
{
- if (marked_byte_offset_ >= 0) {
+ if (marked_byte_offset_ >= 0 || allow_hover_selection_ ||
+ (!allow_hover_selection_ && event->modifiers() & Qt::ControlModifier)) {
return;
}
diff --git a/ui/qt/widgets/byte_view_text.h b/ui/qt/widgets/byte_view_text.h
index 784dbc7e05..a8082a9afe 100644
--- a/ui/qt/widgets/byte_view_text.h
+++ b/ui/qt/widgets/byte_view_text.h
@@ -125,10 +125,13 @@ private:
int line_height_; // Font line spacing
QList<QRect> hover_outlines_; // Hovered byte outlines.
+ bool allow_hover_selection_;
+
// Data selection
QVector<int> x_pos_to_column_;
// Context menu actions
+ QAction *action_allow_hover_selection_;
QAction *action_bytes_hex_;
QAction *action_bytes_bits_;
QAction *action_bytes_enc_from_packet_;
@@ -139,6 +142,7 @@ private slots:
void copyBytes(bool);
void setHexDisplayFormat(QAction *action);
void setCharacterEncoding(QAction *action);
+ void toggleHoverAllowed(bool);
};
diff --git a/ui/recent.c b/ui/recent.c
index 1ce6f084be..d3d5d5ec52 100644
--- a/ui/recent.c
+++ b/ui/recent.c
@@ -44,6 +44,7 @@
#define RECENT_GUI_ZOOM_LEVEL "gui.zoom_level"
#define RECENT_GUI_BYTES_VIEW "gui.bytes_view"
#define RECENT_GUI_BYTES_ENCODING "gui.bytes_encoding"
+#define RECENT_GUI_ALLOW_HOVER_SELECTION "gui.allow_hover_selection"
#define RECENT_GUI_PACKET_DIAGRAM_FIELD_VALUES "gui.packet_diagram_field_values"
#define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x"
#define RECENT_GUI_GEOMETRY_MAIN_Y "gui.geometry_main_y"
@@ -887,6 +888,10 @@ write_profile_recent(void)
RECENT_GUI_PACKET_DIAGRAM_FIELD_VALUES,
recent.gui_packet_diagram_field_values);
+ write_recent_boolean(rf, "Allow hover selection in byte view",
+ RECENT_GUI_ALLOW_HOVER_SELECTION,
+ recent.gui_allow_hover_selection);
+
fprintf(rf, "\n# Main window upper (or leftmost) pane size.\n");
fprintf(rf, "# Decimal number.\n");
if (recent.gui_geometry_main_upper_pane != 0) {
@@ -1092,6 +1097,8 @@ read_set_recent_pair_static(gchar *key, const gchar *value,
(bytes_encoding_type)str_to_val(value, bytes_encoding_type_values, BYTES_ENC_FROM_PACKET);
} else if (strcmp(key, RECENT_GUI_PACKET_DIAGRAM_FIELD_VALUES) == 0) {
parse_recent_boolean(value, &recent.gui_packet_diagram_field_values);
+ } else if (strcmp(key, RECENT_GUI_ALLOW_HOVER_SELECTION) == 0) {
+ parse_recent_boolean(value, &recent.gui_allow_hover_selection);
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED) == 0) {
parse_recent_boolean(value, &recent.gui_geometry_main_maximized);
} else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_UPPER_PANE) == 0) {
@@ -1346,6 +1353,7 @@ recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
recent.gui_zoom_level = 0;
recent.gui_bytes_view = BYTES_HEX;
recent.gui_bytes_encoding = BYTES_ENC_FROM_PACKET;
+ recent.gui_allow_hover_selection = TRUE;
/* pane size of zero will autodetect */
recent.gui_geometry_main_upper_pane = 0;
diff --git a/ui/recent.h b/ui/recent.h
index beda760e90..b14334f21b 100644
--- a/ui/recent.h
+++ b/ui/recent.h
@@ -100,6 +100,7 @@ typedef struct recent_settings_tag {
bytes_view_type gui_bytes_view;
bytes_encoding_type gui_bytes_encoding;
gboolean gui_packet_diagram_field_values;
+ gboolean gui_allow_hover_selection;
search_in_type gui_search_in;
search_char_set_type gui_search_char_set;