diff options
author | Roland Knall <rknall@gmail.com> | 2021-09-13 17:00:48 +0200 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-09-13 15:33:46 +0000 |
commit | 19f3a82ff85fc513e414400866c5bff9f28acf55 (patch) | |
tree | fce0ce4fa21a211fbadb30df0bdef079369fedc1 /ui/qt | |
parent | 3cb302f05b0b8e16b97d4ada5c3027641d9b4a3c (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/qt')
-rw-r--r-- | ui/qt/byte_view_tab.cpp | 3 | ||||
-rw-r--r-- | ui/qt/byte_view_tab.h | 1 | ||||
-rw-r--r-- | ui/qt/widgets/byte_view_text.cpp | 21 | ||||
-rw-r--r-- | ui/qt/widgets/byte_view_text.h | 4 |
4 files changed, 26 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); }; |