Skip to content

Commit

Permalink
Qt: Store Show Packet Bytes settings in recent
Browse files Browse the repository at this point in the history
Store the Show Packt Bytes "Decode As" and "Show As" settings in
recent.

The options for "Show as" for Show Packet Bytes are a superset of the
"Show data as" for Follow Stream, and they're conceptually doing
the same thing. Use the same enum for both - Follow Stream doesn't
support all these options, but maybe it should in the future.

To do this, we break the strict correspondance between the index
in the respective comboboxes and the value of the enum. Use
findData when setting the current index so that this doesn't matter;
this also keeps us from having to be as strict about keeping new
entries in alphabetical order.

Fix #17796
  • Loading branch information
johnthacker committed Sep 24, 2023
1 parent 25aaafc commit 6738a87
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 121 deletions.
12 changes: 10 additions & 2 deletions ui/qt/follow_stream_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ static QMutex loop_break_mutex;
// Indicates that a Follow Stream is currently running
static gboolean isReadRunning;

Q_DECLARE_METATYPE(bytes_show_type)

FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, int proto_id) :
WiresharkDialog(parent, cf),
ui(new Ui::FollowStreamDialog),
Expand Down Expand Up @@ -111,7 +113,7 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, int pro
// UTF-8 is guaranteed to exist as a QTextCodec
cbcs->addItem(tr("UTF-8"), SHOW_CODEC);
cbcs->addItem(tr("YAML"), SHOW_YAML);
cbcs->setCurrentIndex(static_cast<int>(recent.gui_follow_show));
cbcs->setCurrentIndex(cbcs->findData(recent.gui_follow_show));
cbcs->blockSignals(false);

b_filter_out_ = ui->buttonBox->addButton(tr("Filter Out This Stream"), QDialogButtonBox::ActionRole);
Expand Down Expand Up @@ -359,7 +361,7 @@ void FollowStreamDialog::on_cbDirections_currentIndexChanged(int idx)
void FollowStreamDialog::on_cbCharset_currentIndexChanged(int idx)
{
if (idx < 0) return;
recent.gui_follow_show = static_cast<follow_show_type>(ui->cbCharset->itemData(idx).toInt());
recent.gui_follow_show = ui->cbCharset->currentData().value<bytes_show_type>();
readStream();
}

Expand Down Expand Up @@ -901,6 +903,12 @@ DIAG_ON(stringop-overread)
addText(ba, is_from_server, packet_num);
break;
}

default:
/* The other Show types are supported in Show Packet Bytes but
* not here in Follow. (XXX: Maybe some could be added?)
*/
ws_assert_not_reached();
}

if (last_packet_ == 0) {
Expand Down
Loading

0 comments on commit 6738a87

Please sign in to comment.