diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-06-30 09:24:57 -0700 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2016-07-01 06:02:31 +0000 |
commit | 250f248fd917eb556f6e6838cf9a45385e00e358 (patch) | |
tree | 3059104a8fa18ebc114907d930230b6a11e51ecc /ui/qt/byte_view_text.cpp | |
parent | 5cf7fcdf0f62cf0d8617428141a26e6f280a45d0 (diff) | |
download | wireshark-250f248fd917eb556f6e6838cf9a45385e00e358.tar.gz wireshark-250f248fd917eb556f6e6838cf9a45385e00e358.tar.bz2 wireshark-250f248fd917eb556f6e6838cf9a45385e00e358.zip |
Qt: Add ASCII+EBCDIC actions to the byte view context menu.
Add actions to switch between ASCII and EBCDIC, similar to the hex and
bits items.
Bug: 5298
Change-Id: Ib601ac6e89411e6482f3e4172726e16a08fdbd2b
Reviewed-on: https://code.wireshark.org/review/16225
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'ui/qt/byte_view_text.cpp')
-rw-r--r-- | ui/qt/byte_view_text.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/ui/qt/byte_view_text.cpp b/ui/qt/byte_view_text.cpp index eca8360482..bcbd1bbdac 100644 --- a/ui/qt/byte_view_text.cpp +++ b/ui/qt/byte_view_text.cpp @@ -46,6 +46,7 @@ // QPainter::drawText for each individual character. Q_DECLARE_METATYPE(bytes_view_type) +Q_DECLARE_METATYPE(packet_char_enc) ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTreeWidget *tree_widget, packet_char_enc encoding) : QAbstractScrollArea(parent), @@ -53,8 +54,9 @@ ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTr proto_tree_(tree), tree_widget_(tree_widget), bold_highlight_(false), - encoding_(encoding), format_actions_(new QActionGroup(this)), + encoding_actions_(new QActionGroup(this)), + encoding_(encoding), hovered_byte_offset(-1), p_bound_(0, 0), f_bound_(0, 0), @@ -80,9 +82,25 @@ ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTr } ctx_menu_.addActions(format_actions_->actions()); + connect(format_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setHexDisplayFormat(QAction*))); + ctx_menu_.addSeparator(); - connect(format_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setHexDisplayFormat(QAction*))); + action = encoding_actions_->addAction(tr("Show bytes as ASCII")); + action->setData(qVariantFromValue(PACKET_CHAR_ENC_CHAR_ASCII)); + action->setCheckable(true); + if (encoding_ == PACKET_CHAR_ENC_CHAR_ASCII) { + action->setChecked(true); + } + action = encoding_actions_->addAction(tr("Show bytes as EBCDIC")); + action->setData(qVariantFromValue(PACKET_CHAR_ENC_CHAR_EBCDIC)); + action->setCheckable(true); + if (encoding_ == PACKET_CHAR_ENC_CHAR_EBCDIC) { + action->setChecked(true); + } + + ctx_menu_.addActions(encoding_actions_->actions()); + connect(encoding_actions_, SIGNAL(triggered(QAction*)), this, SLOT(setCharacterEncoding(QAction*))); setMouseTracking(true); @@ -96,12 +114,6 @@ ByteViewText::~ByteViewText() ctx_menu_.clear(); } -void ByteViewText::setEncoding(packet_char_enc encoding) -{ - encoding_ = encoding; - viewport()->update(); -} - bool ByteViewText::hasDataSource(const tvbuff_t *ds_tvb) { if (ds_tvb != NULL && ds_tvb == tvb_) return true; @@ -579,6 +591,16 @@ void ByteViewText::setHexDisplayFormat(QAction *action) viewport()->update(); } +void ByteViewText::setCharacterEncoding(QAction *action) +{ + if (!action) { + return; + } + + encoding_ = action->data().value<packet_char_enc>(); + viewport()->update(); +} + /* * Editor modelines * |