2013-02-08 01:16:46 +00:00
|
|
|
/* module_preferences_scroll_area.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-02-08 01:16:46 +00:00
|
|
|
|
|
|
|
#include "module_preferences_scroll_area.h"
|
2015-06-25 16:17:03 +00:00
|
|
|
#include <ui_module_preferences_scroll_area.h>
|
2017-07-05 14:56:45 +00:00
|
|
|
#include <ui/qt/widgets/syntax_line_edit.h>
|
2023-11-01 13:55:14 +00:00
|
|
|
#include <ui/qt/widgets/dissector_syntax_line_edit.h>
|
2018-05-16 00:02:26 +00:00
|
|
|
#include "ui/qt/widgets/wireshark_file_dialog.h"
|
2017-07-25 14:15:18 +00:00
|
|
|
#include <ui/qt/utils/qt_ui_utils.h>
|
2013-07-25 23:49:47 +00:00
|
|
|
#include "uat_dialog.h"
|
2022-02-01 03:30:09 +00:00
|
|
|
#include "main_application.h"
|
2022-11-01 10:01:35 +00:00
|
|
|
#include "ui/qt/main_window.h"
|
2013-02-08 01:16:46 +00:00
|
|
|
|
2017-07-25 14:15:18 +00:00
|
|
|
#include <ui/qt/utils/variant_pointer.h>
|
2017-01-11 12:55:23 +00:00
|
|
|
|
2013-02-08 01:16:46 +00:00
|
|
|
#include <epan/prefs-int.h>
|
|
|
|
|
2015-10-04 17:10:29 +00:00
|
|
|
#include <wsutil/utf8_entities.h>
|
2015-07-31 17:34:43 +00:00
|
|
|
|
2013-02-08 01:16:46 +00:00
|
|
|
#include <QAbstractButton>
|
|
|
|
#include <QButtonGroup>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
2022-11-01 10:01:35 +00:00
|
|
|
#include <QMainWindow>
|
2013-02-08 01:16:46 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QSpacerItem>
|
2021-11-25 11:20:25 +00:00
|
|
|
#include <QRegularExpression>
|
2013-02-08 01:16:46 +00:00
|
|
|
|
|
|
|
const char *pref_prop_ = "pref_ptr";
|
|
|
|
|
2015-02-24 18:31:29 +00:00
|
|
|
// Escape our ampersands so that Qt won't try to interpret them as
|
|
|
|
// mnemonics.
|
|
|
|
static const QString title_to_shortcut(const char *title) {
|
|
|
|
QString shortcut_str(title);
|
|
|
|
shortcut_str.replace('&', "&&");
|
|
|
|
return shortcut_str;
|
|
|
|
}
|
|
|
|
|
2022-02-03 22:31:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
QVBoxLayout *layout;
|
|
|
|
QString moduleName;
|
|
|
|
} prefSearchData;
|
2015-02-24 18:31:29 +00:00
|
|
|
|
2013-02-08 01:16:46 +00:00
|
|
|
extern "C" {
|
|
|
|
// Callbacks prefs routines
|
|
|
|
|
2016-09-29 18:25:52 +00:00
|
|
|
/* Add a single preference to the QVBoxLayout of a preference page */
|
2013-02-08 01:16:46 +00:00
|
|
|
static guint
|
2022-02-03 22:31:33 +00:00
|
|
|
pref_show(pref_t *pref, gpointer user_data)
|
2013-02-08 01:16:46 +00:00
|
|
|
{
|
2022-02-03 22:31:33 +00:00
|
|
|
prefSearchData * data = static_cast<prefSearchData *>(user_data);
|
|
|
|
|
|
|
|
if (!pref || !data) return 0;
|
2013-02-08 01:16:46 +00:00
|
|
|
|
2022-02-03 22:31:33 +00:00
|
|
|
QVBoxLayout *vb = data->layout;
|
2015-05-27 23:15:03 +00:00
|
|
|
|
|
|
|
// Convert the pref description from plain text to rich text.
|
2017-01-07 13:52:23 +00:00
|
|
|
QString description = html_escape(prefs_get_description(pref));
|
2022-02-03 22:31:33 +00:00
|
|
|
QString name = QString("%1.%2").arg(data->moduleName).arg(prefs_get_name(pref));
|
|
|
|
description.replace('\n', "<br/>");
|
|
|
|
QString tooltip = QString("<span>%1</span><br/><br/>%2").arg(description).arg(name);
|
2013-02-08 01:16:46 +00:00
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_type(pref)) {
|
2013-02-08 01:16:46 +00:00
|
|
|
case PREF_UINT:
|
|
|
|
{
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
2017-01-07 13:52:23 +00:00
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
|
|
|
hb->addWidget(label);
|
2013-02-08 01:16:46 +00:00
|
|
|
QLineEdit *uint_le = new QLineEdit();
|
2013-12-14 00:07:27 +00:00
|
|
|
uint_le->setToolTip(tooltip);
|
2017-01-11 12:55:23 +00:00
|
|
|
uint_le->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 01:16:46 +00:00
|
|
|
uint_le->setMinimumWidth(uint_le->fontMetrics().height() * 8);
|
|
|
|
hb->addWidget(uint_le);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PREF_BOOL:
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
QCheckBox *bool_cb = new QCheckBox(title_to_shortcut(prefs_get_title(pref)));
|
2013-12-14 00:07:27 +00:00
|
|
|
bool_cb->setToolTip(tooltip);
|
2017-01-11 12:55:23 +00:00
|
|
|
bool_cb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 01:16:46 +00:00
|
|
|
vb->addWidget(bool_cb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PREF_ENUM:
|
|
|
|
{
|
|
|
|
const enum_val_t *ev;
|
2018-03-01 12:42:09 +00:00
|
|
|
ev = prefs_get_enumvals(pref);
|
|
|
|
if (!ev || !ev->description)
|
|
|
|
return 0;
|
2013-02-08 01:16:46 +00:00
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_enum_radiobuttons(pref)) {
|
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
|
|
|
vb->addWidget(label);
|
2015-10-04 09:31:19 +00:00
|
|
|
QButtonGroup *enum_bg = new QButtonGroup(vb);
|
2018-03-01 12:42:09 +00:00
|
|
|
while (ev->description) {
|
2015-02-24 18:31:29 +00:00
|
|
|
QRadioButton *enum_rb = new QRadioButton(title_to_shortcut(ev->description));
|
2013-12-14 00:07:27 +00:00
|
|
|
enum_rb->setToolTip(tooltip);
|
2013-02-08 01:16:46 +00:00
|
|
|
QStyleOption style_opt;
|
2017-01-11 12:55:23 +00:00
|
|
|
enum_rb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 01:16:46 +00:00
|
|
|
enum_rb->setStyleSheet(QString(
|
|
|
|
"QRadioButton {"
|
|
|
|
" margin-left: %1px;"
|
|
|
|
"}"
|
|
|
|
)
|
|
|
|
.arg(enum_rb->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left()));
|
|
|
|
enum_bg->addButton(enum_rb, ev->value);
|
|
|
|
vb->addWidget(enum_rb);
|
2018-03-01 12:42:09 +00:00
|
|
|
ev++;
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
|
|
|
QComboBox *enum_cb = new QComboBox();
|
2013-12-14 00:07:27 +00:00
|
|
|
enum_cb->setToolTip(tooltip);
|
2017-01-11 12:55:23 +00:00
|
|
|
enum_cb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2017-01-07 13:52:23 +00:00
|
|
|
for (ev = prefs_get_enumvals(pref); ev && ev->description; ev++) {
|
2013-02-08 01:16:46 +00:00
|
|
|
enum_cb->addItem(ev->description, QVariant(ev->value));
|
|
|
|
}
|
2022-02-03 22:31:33 +00:00
|
|
|
QLabel * lbl = new QLabel(prefs_get_title(pref));
|
|
|
|
lbl->setToolTip(tooltip);
|
|
|
|
hb->addWidget(lbl);
|
2013-02-08 01:16:46 +00:00
|
|
|
hb->addWidget(enum_cb);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PREF_STRING:
|
|
|
|
{
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
2017-01-07 13:52:23 +00:00
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
|
|
|
hb->addWidget(label);
|
2013-02-08 01:16:46 +00:00
|
|
|
QLineEdit *string_le = new QLineEdit();
|
2013-12-14 00:07:27 +00:00
|
|
|
string_le->setToolTip(tooltip);
|
2017-01-11 12:55:23 +00:00
|
|
|
string_le->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 01:16:46 +00:00
|
|
|
string_le->setMinimumWidth(string_le->fontMetrics().height() * 20);
|
|
|
|
hb->addWidget(string_le);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
2021-12-30 16:03:15 +00:00
|
|
|
case PREF_PASSWORD:
|
|
|
|
{
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
|
|
|
label->setToolTip(tooltip);
|
|
|
|
hb->addWidget(label);
|
|
|
|
QLineEdit *string_le = new QLineEdit();
|
|
|
|
string_le->setToolTip(tooltip);
|
|
|
|
string_le->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
|
|
|
string_le->setMinimumWidth(string_le->fontMetrics().height() * 20);
|
|
|
|
string_le->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
|
|
|
hb->addWidget(string_le);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
2023-11-01 13:55:14 +00:00
|
|
|
case PREF_DISSECTOR:
|
|
|
|
{
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
|
|
|
label->setToolTip(tooltip);
|
|
|
|
hb->addWidget(label);
|
|
|
|
QLineEdit *string_le = new DissectorSyntaxLineEdit();
|
|
|
|
string_le->setToolTip(tooltip);
|
|
|
|
string_le->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
|
|
|
string_le->setMinimumWidth(string_le->fontMetrics().height() * 20);
|
|
|
|
hb->addWidget(string_le);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
2016-10-07 20:25:01 +00:00
|
|
|
case PREF_DECODE_AS_RANGE:
|
2013-02-08 01:16:46 +00:00
|
|
|
case PREF_RANGE:
|
|
|
|
{
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
2017-01-07 13:52:23 +00:00
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
|
|
|
hb->addWidget(label);
|
2013-02-08 01:16:46 +00:00
|
|
|
SyntaxLineEdit *range_se = new SyntaxLineEdit();
|
2013-12-14 00:07:27 +00:00
|
|
|
range_se->setToolTip(tooltip);
|
2017-01-11 12:55:23 +00:00
|
|
|
range_se->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 01:16:46 +00:00
|
|
|
range_se->setMinimumWidth(range_se->fontMetrics().height() * 20);
|
|
|
|
hb->addWidget(range_se);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PREF_STATIC_TEXT:
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
2016-09-12 08:53:16 +00:00
|
|
|
label->setWordWrap(true);
|
2013-12-14 00:07:27 +00:00
|
|
|
vb->addWidget(label);
|
2013-02-08 01:16:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PREF_UAT:
|
|
|
|
{
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
2017-01-07 13:52:23 +00:00
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
|
|
|
hb->addWidget(label);
|
2020-09-29 00:40:05 +00:00
|
|
|
QPushButton *uat_pb = new QPushButton(QObject::tr("Edit…"));
|
2013-12-14 00:07:27 +00:00
|
|
|
uat_pb->setToolTip(tooltip);
|
2017-01-11 12:55:23 +00:00
|
|
|
uat_pb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 01:16:46 +00:00
|
|
|
hb->addWidget(uat_pb);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
2017-04-14 09:33:57 +00:00
|
|
|
case PREF_SAVE_FILENAME:
|
|
|
|
case PREF_OPEN_FILENAME:
|
2013-02-08 18:07:34 +00:00
|
|
|
case PREF_DIRNAME:
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
2013-12-14 00:07:27 +00:00
|
|
|
label->setToolTip(tooltip);
|
|
|
|
vb->addWidget(label);
|
2013-02-08 18:07:34 +00:00
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
|
|
|
QLineEdit *path_le = new QLineEdit();
|
2013-12-14 00:07:27 +00:00
|
|
|
path_le->setToolTip(tooltip);
|
2013-02-08 18:07:34 +00:00
|
|
|
QStyleOption style_opt;
|
2017-01-11 12:55:23 +00:00
|
|
|
path_le->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 18:07:34 +00:00
|
|
|
path_le->setMinimumWidth(path_le->fontMetrics().height() * 20);
|
|
|
|
path_le->setStyleSheet(QString(
|
|
|
|
"QLineEdit {"
|
|
|
|
" margin-left: %1px;"
|
|
|
|
"}"
|
|
|
|
)
|
|
|
|
.arg(path_le->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left()));
|
|
|
|
hb->addWidget(path_le);
|
2020-09-29 00:40:05 +00:00
|
|
|
QPushButton *path_pb = new QPushButton(QObject::tr("Browse…"));
|
2017-01-11 12:55:23 +00:00
|
|
|
path_pb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
2013-02-08 18:07:34 +00:00
|
|
|
hb->addWidget(path_pb);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
break;
|
|
|
|
}
|
2013-02-08 01:16:46 +00:00
|
|
|
case PREF_COLOR:
|
|
|
|
{
|
|
|
|
// XXX - Not needed yet. When it is needed we can add a label + QFrame which pops up a
|
|
|
|
// color picker similar to the Font and Colors prefs.
|
|
|
|
break;
|
|
|
|
}
|
2022-11-01 10:01:35 +00:00
|
|
|
case PREF_PROTO_TCP_SNDAMB_ENUM:
|
|
|
|
{
|
|
|
|
const enum_val_t *ev;
|
|
|
|
ev = prefs_get_enumvals(pref);
|
|
|
|
if (!ev || !ev->description)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (prefs_get_enum_radiobuttons(pref)) {
|
|
|
|
QLabel *label = new QLabel(prefs_get_title(pref));
|
|
|
|
label->setToolTip(tooltip);
|
|
|
|
vb->addWidget(label);
|
|
|
|
QButtonGroup *enum_bg = new QButtonGroup(vb);
|
|
|
|
while (ev->description) {
|
|
|
|
QRadioButton *enum_rb = new QRadioButton(title_to_shortcut(ev->description));
|
|
|
|
enum_rb->setToolTip(tooltip);
|
|
|
|
QStyleOption style_opt;
|
|
|
|
enum_rb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
|
|
|
enum_rb->setStyleSheet(QString(
|
|
|
|
"QRadioButton {"
|
|
|
|
" margin-left: %1px;"
|
|
|
|
"}"
|
|
|
|
)
|
|
|
|
.arg(enum_rb->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left()));
|
|
|
|
enum_bg->addButton(enum_rb, ev->value);
|
|
|
|
vb->addWidget(enum_rb);
|
|
|
|
ev++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QHBoxLayout *hb = new QHBoxLayout();
|
|
|
|
QComboBox *enum_cb = new QComboBox();
|
|
|
|
enum_cb->setToolTip(tooltip);
|
|
|
|
enum_cb->setProperty(pref_prop_, VariantPointer<pref_t>::asQVariant(pref));
|
|
|
|
for (ev = prefs_get_enumvals(pref); ev && ev->description; ev++) {
|
|
|
|
enum_cb->addItem(ev->description, QVariant(ev->value));
|
|
|
|
}
|
|
|
|
QLabel * lbl = new QLabel(prefs_get_title(pref));
|
|
|
|
lbl->setToolTip(tooltip);
|
|
|
|
hb->addWidget(lbl);
|
|
|
|
hb->addWidget(enum_cb);
|
|
|
|
hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
vb->addLayout(hb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-02-08 01:16:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidget *parent) :
|
|
|
|
QScrollArea(parent),
|
|
|
|
ui(new Ui::ModulePreferencesScrollArea),
|
|
|
|
module_(module)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
if (!module) return;
|
|
|
|
|
2014-11-21 23:23:24 +00:00
|
|
|
/* Show the preference's description at the top of the page */
|
|
|
|
QFont font;
|
|
|
|
font.setBold(TRUE);
|
|
|
|
QLabel *label = new QLabel(module->description);
|
|
|
|
label->setFont(font);
|
|
|
|
ui->verticalLayout->addWidget(label);
|
|
|
|
|
2023-10-28 01:02:21 +00:00
|
|
|
prefSearchData searchData;
|
|
|
|
searchData.layout = ui->verticalLayout;
|
|
|
|
searchData.moduleName = module->name;
|
2022-02-03 22:31:33 +00:00
|
|
|
|
2013-02-08 01:16:46 +00:00
|
|
|
/* Add items for each of the preferences */
|
2023-10-28 01:02:21 +00:00
|
|
|
prefs_pref_foreach(module, pref_show, &searchData);
|
2013-02-08 01:16:46 +00:00
|
|
|
|
|
|
|
foreach (QLineEdit *le, findChildren<QLineEdit *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(le->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_type(pref)) {
|
2013-02-08 18:07:34 +00:00
|
|
|
case PREF_UINT:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(le, &QLineEdit::textEdited, this, &ModulePreferencesScrollArea::uintLineEditTextEdited);
|
2013-02-08 18:07:34 +00:00
|
|
|
break;
|
|
|
|
case PREF_STRING:
|
2017-04-14 09:33:57 +00:00
|
|
|
case PREF_SAVE_FILENAME:
|
|
|
|
case PREF_OPEN_FILENAME:
|
2013-02-08 18:07:34 +00:00
|
|
|
case PREF_DIRNAME:
|
2021-12-30 16:03:15 +00:00
|
|
|
case PREF_PASSWORD:
|
2023-11-01 13:55:14 +00:00
|
|
|
case PREF_DISSECTOR:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(le, &QLineEdit::textEdited, this, &ModulePreferencesScrollArea::stringLineEditTextEdited);
|
2013-02-08 18:07:34 +00:00
|
|
|
break;
|
|
|
|
case PREF_RANGE:
|
2016-10-07 20:25:01 +00:00
|
|
|
case PREF_DECODE_AS_RANGE:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(le, &QLineEdit::textEdited, this, &ModulePreferencesScrollArea::rangeSyntaxLineEditTextEdited);
|
2013-02-08 18:07:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QCheckBox *cb, findChildren<QCheckBox *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(cb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_type(pref) == PREF_BOOL) {
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(cb, &QCheckBox::toggled, this, &ModulePreferencesScrollArea::boolCheckBoxToggled);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 18:07:34 +00:00
|
|
|
foreach (QRadioButton *rb, findChildren<QRadioButton *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(rb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_type(pref) == PREF_ENUM && prefs_get_enum_radiobuttons(pref)) {
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(rb, &QRadioButton::toggled, this, &ModulePreferencesScrollArea::enumRadioButtonToggled);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 18:07:34 +00:00
|
|
|
foreach (QComboBox *combo, findChildren<QComboBox *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(combo->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_type(pref) == PREF_ENUM && !prefs_get_enum_radiobuttons(pref)) {
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &ModulePreferencesScrollArea::enumComboBoxCurrentIndexChanged);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-01 10:01:35 +00:00
|
|
|
foreach (QComboBox *combo, findChildren<QComboBox *>()) {
|
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(combo->property(pref_prop_));
|
|
|
|
if (!pref) continue;
|
|
|
|
|
|
|
|
if (prefs_get_type(pref) == PREF_PROTO_TCP_SNDAMB_ENUM && !prefs_get_enum_radiobuttons(pref)) {
|
|
|
|
connect(combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &ModulePreferencesScrollArea::enumComboBoxCurrentIndexChanged_PROTO_TCP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 18:07:34 +00:00
|
|
|
foreach (QPushButton *pb, findChildren<QPushButton *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(pb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
switch (prefs_get_type(pref)) {
|
|
|
|
case PREF_UAT:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(pb, &QPushButton::clicked, this, &ModulePreferencesScrollArea::uatPushButtonClicked);
|
2017-01-07 13:52:23 +00:00
|
|
|
break;
|
2017-04-14 09:33:57 +00:00
|
|
|
case PREF_SAVE_FILENAME:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(pb, &QPushButton::clicked, this, &ModulePreferencesScrollArea::saveFilenamePushButtonClicked);
|
2017-04-14 09:33:57 +00:00
|
|
|
break;
|
|
|
|
case PREF_OPEN_FILENAME:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(pb, &QPushButton::clicked, this, &ModulePreferencesScrollArea::openFilenamePushButtonClicked);
|
2017-01-07 13:52:23 +00:00
|
|
|
break;
|
|
|
|
case PREF_DIRNAME:
|
2018-12-19 18:24:49 +00:00
|
|
|
connect(pb, &QPushButton::clicked, this, &ModulePreferencesScrollArea::dirnamePushButtonClicked);
|
2017-01-07 13:52:23 +00:00
|
|
|
break;
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->verticalLayout->addSpacerItem(new QSpacerItem(10, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
}
|
|
|
|
|
|
|
|
ModulePreferencesScrollArea::~ModulePreferencesScrollArea()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-02-24 18:31:29 +00:00
|
|
|
void ModulePreferencesScrollArea::showEvent(QShowEvent *)
|
2013-02-08 01:16:46 +00:00
|
|
|
{
|
|
|
|
updateWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::resizeEvent(QResizeEvent *evt)
|
|
|
|
{
|
|
|
|
QScrollArea::resizeEvent(evt);
|
|
|
|
|
|
|
|
if (verticalScrollBar()->isVisible()) {
|
|
|
|
setFrameStyle(QFrame::StyledPanel);
|
|
|
|
} else {
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::updateWidgets()
|
|
|
|
{
|
|
|
|
foreach (QLineEdit *le, findChildren<QLineEdit *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(le->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2021-11-25 11:20:25 +00:00
|
|
|
le->setText(gchar_free_to_qstring(prefs_pref_to_str(pref, pref_stashed)).remove(QRegularExpression("\n\t")));
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QCheckBox *cb, findChildren<QCheckBox *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(cb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_type(pref) == PREF_BOOL) {
|
|
|
|
cb->setChecked(prefs_get_bool_value(pref, pref_stashed));
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QRadioButton *enum_rb, findChildren<QRadioButton *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_rb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
|
|
|
QButtonGroup *enum_bg = enum_rb->group();
|
|
|
|
if (!enum_bg) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_type(pref) == PREF_ENUM && prefs_get_enum_radiobuttons(pref)) {
|
|
|
|
if (prefs_get_enum_value(pref, pref_stashed) == enum_bg->id(enum_rb)) {
|
2013-02-08 01:16:46 +00:00
|
|
|
enum_rb->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QComboBox *enum_cb, findChildren<QComboBox *>()) {
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_cb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) continue;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_type(pref) == PREF_ENUM && !prefs_get_enum_radiobuttons(pref)) {
|
2013-02-08 01:16:46 +00:00
|
|
|
for (int i = 0; i < enum_cb->count(); i++) {
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_enum_value(pref, pref_stashed) == enum_cb->itemData(i).toInt()) {
|
2013-02-08 01:16:46 +00:00
|
|
|
enum_cb->setCurrentIndex(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-01 10:01:35 +00:00
|
|
|
|
|
|
|
if (prefs_get_type(pref) == PREF_PROTO_TCP_SNDAMB_ENUM && !prefs_get_enum_radiobuttons(pref)) {
|
Prefs: Fix TCP sequence analysis override pref handling
When a preference dialog is used, we don't want to write to each
frame data the value of the TCP sequence analysis override preference
immediately, because that means that the changes take effect even
if the dialog is Rejected. The redissection isn't triggered, but that's
worse in some ways, because it puts things in an inconsistent state.
Instead, stash the list of frame datas to possibly override in the
pref, and then override them when unstashing preferences. Delete
the least when cleaning the preferences. (Storing the pointers should be
fine, because the preference dialogs are modal.)
This also allows us to correctly have the TCP sequence analysis
override preference report whether or not any frame data's
override value was changed, and avoids doing a full redissection
any time the preference dialog is opened, even if nothing is changed.
The TCP sequence analysis override preference doesn't need to
be written to a file or read from the file or command line, because
it's different for every frame, and reset to default (0) for each
new frame when a file is read.
Related to #17629
2023-10-28 09:58:53 +00:00
|
|
|
if (prefs_get_list_value(pref, pref_stashed) == NULL) {
|
|
|
|
/* We haven't added a list of frames that could have their
|
|
|
|
* analysis changed. Set the current value to whatever the
|
|
|
|
* first selected frame has for its its TCP Sequence Analysis
|
|
|
|
* override.
|
|
|
|
*/
|
|
|
|
MainWindow* topWidget = qobject_cast<MainWindow*>(mainApp->mainWindow());
|
|
|
|
/* Ensure there is one unique or multiple selections. See issue 18642 */
|
|
|
|
if (topWidget->hasSelection() || topWidget->hasUniqueSelection()) {
|
|
|
|
frame_data * fdata = topWidget->frameDataForRow((topWidget->selectedRows()).at(0));
|
|
|
|
enum_cb->setCurrentIndex(enum_cb->findData(fdata->tcp_snd_manual_analysis));
|
|
|
|
QList<int> rows = topWidget->selectedRows();
|
|
|
|
foreach (int row, rows) {
|
|
|
|
frame_data * fdata = topWidget->frameDataForRow(row);
|
|
|
|
prefs_add_list_value(pref, fdata, pref_stashed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* The initial value was already set from the selected frames,
|
|
|
|
* use the current value from when the CB was changed. */
|
|
|
|
enum_cb->setCurrentIndex(enum_cb->findData(prefs_get_enum_value(pref, pref_current)));
|
2023-04-05 16:36:40 +00:00
|
|
|
}
|
2022-11-01 10:01:35 +00:00
|
|
|
}
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::uintLineEditTextEdited(const QString &new_str)
|
|
|
|
{
|
|
|
|
QLineEdit *uint_le = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (!uint_le) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(uint_le->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
|
|
|
bool ok;
|
2015-09-04 19:49:11 +00:00
|
|
|
uint new_uint = new_str.toUInt(&ok, 0);
|
2013-02-08 01:16:46 +00:00
|
|
|
if (ok) {
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_uint_value(pref, new_uint, pref_stashed);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::boolCheckBoxToggled(bool checked)
|
|
|
|
{
|
|
|
|
QCheckBox *bool_cb = qobject_cast<QCheckBox*>(sender());
|
|
|
|
if (!bool_cb) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(bool_cb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_bool_value(pref, checked, pref_stashed);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::enumRadioButtonToggled(bool checked)
|
|
|
|
{
|
|
|
|
if (!checked) return;
|
|
|
|
QRadioButton *enum_rb = qobject_cast<QRadioButton*>(sender());
|
|
|
|
if (!enum_rb) return;
|
|
|
|
|
|
|
|
QButtonGroup *enum_bg = enum_rb->group();
|
|
|
|
if (!enum_bg) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_rb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
|
|
|
if (enum_bg->checkedId() >= 0) {
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref, enum_bg->checkedId(), pref_stashed);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::enumComboBoxCurrentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
QComboBox *enum_cb = qobject_cast<QComboBox*>(sender());
|
|
|
|
if (!enum_cb) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_cb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_enum_value(pref, enum_cb->itemData(index).toInt(), pref_stashed);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::stringLineEditTextEdited(const QString &new_str)
|
|
|
|
{
|
|
|
|
QLineEdit *string_le = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (!string_le) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(string_le->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_string_value(pref, new_str.toStdString().c_str(), pref_stashed);
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ModulePreferencesScrollArea::rangeSyntaxLineEditTextEdited(const QString &new_str)
|
|
|
|
{
|
|
|
|
SyntaxLineEdit *range_se = qobject_cast<SyntaxLineEdit*>(sender());
|
|
|
|
if (!range_se) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(range_se->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2017-01-04 15:57:25 +00:00
|
|
|
if (prefs_set_stashed_range_value(pref, new_str.toUtf8().constData())) {
|
2013-02-08 01:16:46 +00:00
|
|
|
if (new_str.isEmpty()) {
|
|
|
|
range_se->setSyntaxState(SyntaxLineEdit::Empty);
|
|
|
|
} else {
|
|
|
|
range_se->setSyntaxState(SyntaxLineEdit::Valid);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
range_se->setSyntaxState(SyntaxLineEdit::Invalid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 17:20:02 +00:00
|
|
|
void ModulePreferencesScrollArea::uatPushButtonClicked()
|
2013-02-08 01:16:46 +00:00
|
|
|
{
|
|
|
|
QPushButton *uat_pb = qobject_cast<QPushButton*>(sender());
|
|
|
|
if (!uat_pb) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(uat_pb->property(pref_prop_));
|
2013-02-08 01:16:46 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2019-09-29 09:39:40 +00:00
|
|
|
UatDialog *uat_dlg = new UatDialog(this, prefs_get_uat_value(pref));
|
|
|
|
uat_dlg->setWindowModality(Qt::ApplicationModal);
|
|
|
|
uat_dlg->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
uat_dlg->show();
|
2013-02-08 01:16:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 17:20:02 +00:00
|
|
|
void ModulePreferencesScrollArea::saveFilenamePushButtonClicked()
|
2013-02-08 18:07:34 +00:00
|
|
|
{
|
|
|
|
QPushButton *filename_pb = qobject_cast<QPushButton*>(sender());
|
|
|
|
if (!filename_pb) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(filename_pb->property(pref_prop_));
|
2013-02-08 18:07:34 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2022-02-01 03:30:09 +00:00
|
|
|
QString filename = WiresharkFileDialog::getSaveFileName(this, mainApp->windowTitleString(prefs_get_title(pref)),
|
2017-04-14 09:33:57 +00:00
|
|
|
prefs_get_string_value(pref, pref_stashed));
|
|
|
|
|
|
|
|
if (!filename.isEmpty()) {
|
|
|
|
prefs_set_string_value(pref, QDir::toNativeSeparators(filename).toStdString().c_str(), pref_stashed);
|
|
|
|
updateWidgets();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 17:20:02 +00:00
|
|
|
void ModulePreferencesScrollArea::openFilenamePushButtonClicked()
|
2017-04-14 09:33:57 +00:00
|
|
|
{
|
|
|
|
QPushButton *filename_pb = qobject_cast<QPushButton*>(sender());
|
|
|
|
if (!filename_pb) return;
|
|
|
|
|
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(filename_pb->property(pref_prop_));
|
|
|
|
if (!pref) return;
|
2013-02-08 18:07:34 +00:00
|
|
|
|
2022-02-01 03:30:09 +00:00
|
|
|
QString filename = WiresharkFileDialog::getOpenFileName(this, mainApp->windowTitleString(prefs_get_title(pref)),
|
2017-04-14 09:33:57 +00:00
|
|
|
prefs_get_string_value(pref, pref_stashed));
|
2013-02-08 18:07:34 +00:00
|
|
|
if (!filename.isEmpty()) {
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_string_value(pref, QDir::toNativeSeparators(filename).toStdString().c_str(), pref_stashed);
|
2013-02-08 18:07:34 +00:00
|
|
|
updateWidgets();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 17:20:02 +00:00
|
|
|
void ModulePreferencesScrollArea::dirnamePushButtonClicked()
|
2013-02-08 18:07:34 +00:00
|
|
|
{
|
|
|
|
QPushButton *dirname_pb = qobject_cast<QPushButton*>(sender());
|
|
|
|
if (!dirname_pb) return;
|
|
|
|
|
2017-01-11 12:55:23 +00:00
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(dirname_pb->property(pref_prop_));
|
2013-02-08 18:07:34 +00:00
|
|
|
if (!pref) return;
|
|
|
|
|
2022-02-01 03:30:09 +00:00
|
|
|
QString dirname = WiresharkFileDialog::getExistingDirectory(this, mainApp->windowTitleString(prefs_get_title(pref)),
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_get_string_value(pref, pref_stashed));
|
2013-02-08 18:07:34 +00:00
|
|
|
|
|
|
|
if (!dirname.isEmpty()) {
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_string_value(pref, QDir::toNativeSeparators(dirname).toStdString().c_str(), pref_stashed);
|
2013-02-08 18:07:34 +00:00
|
|
|
updateWidgets();
|
|
|
|
}
|
|
|
|
}
|
2022-11-01 10:01:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dedicated event handling for TCP SEQ Analysis overriding.
|
|
|
|
*/
|
|
|
|
void ModulePreferencesScrollArea::enumComboBoxCurrentIndexChanged_PROTO_TCP(int index)
|
|
|
|
{
|
|
|
|
QComboBox *enum_cb = qobject_cast<QComboBox*>(sender());
|
|
|
|
if (!enum_cb) return;
|
|
|
|
|
|
|
|
pref_t *pref = VariantPointer<pref_t>::asPtr(enum_cb->property(pref_prop_));
|
|
|
|
if (!pref) return;
|
|
|
|
|
Prefs: Fix TCP sequence analysis override pref handling
When a preference dialog is used, we don't want to write to each
frame data the value of the TCP sequence analysis override preference
immediately, because that means that the changes take effect even
if the dialog is Rejected. The redissection isn't triggered, but that's
worse in some ways, because it puts things in an inconsistent state.
Instead, stash the list of frame datas to possibly override in the
pref, and then override them when unstashing preferences. Delete
the least when cleaning the preferences. (Storing the pointers should be
fine, because the preference dialogs are modal.)
This also allows us to correctly have the TCP sequence analysis
override preference report whether or not any frame data's
override value was changed, and avoids doing a full redissection
any time the preference dialog is opened, even if nothing is changed.
The TCP sequence analysis override preference doesn't need to
be written to a file or read from the file or command line, because
it's different for every frame, and reset to default (0) for each
new frame when a file is read.
Related to #17629
2023-10-28 09:58:53 +00:00
|
|
|
// Store the index value in the current value, not the stashed value.
|
|
|
|
// We use the stashed value to store the frame data pointers.
|
2022-11-01 10:01:35 +00:00
|
|
|
prefs_set_enum_value(pref, enum_cb->itemData(index).toInt(), pref_current);
|
|
|
|
//prefs_set_enum_value(pref, enum_cb->itemData(index).toInt(), pref_stashed);
|
|
|
|
}
|