forked from osmocom/wireshark
Qt: Store recently used find packet settings
Store the last used find packet settings in the global recent file, and load this settings on startup. Change-Id: I38081311cb06b4f398f4dfb66b659ae7d26ccac2 Reviewed-on: https://code.wireshark.org/review/34512 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
parent
99ce98fe02
commit
b9be965b27
|
@ -11,6 +11,7 @@
|
|||
#include <ui_search_frame.h>
|
||||
|
||||
#include "file.h"
|
||||
#include "ui/recent.h"
|
||||
|
||||
#include <epan/proto.h>
|
||||
#include <epan/strutil.h>
|
||||
|
@ -51,7 +52,9 @@ SearchFrame::SearchFrame(QWidget *parent) :
|
|||
w->setAttribute(Qt::WA_MacSmallSize, true);
|
||||
}
|
||||
#endif
|
||||
sf_ui_->searchTypeComboBox->setCurrentIndex(df_search_);
|
||||
|
||||
applyRecentSearchSettings();
|
||||
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
|
@ -160,6 +163,63 @@ bool SearchFrame::regexCompile()
|
|||
return regex_ ? true : false;
|
||||
}
|
||||
|
||||
void SearchFrame::applyRecentSearchSettings()
|
||||
{
|
||||
int search_in_idx = in_packet_list_;
|
||||
int char_encoding_idx = narrow_and_wide_chars_;
|
||||
int search_type_idx = df_search_;
|
||||
|
||||
switch (recent.gui_search_in) {
|
||||
case SEARCH_IN_PACKET_LIST:
|
||||
search_in_idx = in_packet_list_;
|
||||
break;
|
||||
case SEARCH_IN_PACKET_DETAILS:
|
||||
search_in_idx = in_proto_tree_;
|
||||
break;
|
||||
case SEARCH_IN_PACKET_BYTES:
|
||||
search_in_idx = in_bytes_;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (recent.gui_search_char_set) {
|
||||
case SEARCH_CHAR_SET_NARROW_AND_WIDE:
|
||||
char_encoding_idx = narrow_and_wide_chars_;
|
||||
break;
|
||||
case SEARCH_CHAR_SET_NARROW:
|
||||
char_encoding_idx = narrow_chars_;
|
||||
break;
|
||||
case SEARCH_CHAR_SET_WIDE:
|
||||
char_encoding_idx = wide_chars_;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (recent.gui_search_type) {
|
||||
case SEARCH_TYPE_DISPLAY_FILTER:
|
||||
search_type_idx = df_search_;
|
||||
break;
|
||||
case SEARCH_TYPE_HEX_VALUE:
|
||||
search_type_idx = hex_search_;
|
||||
break;
|
||||
case SEARCH_TYPE_STRING:
|
||||
search_type_idx = string_search_;
|
||||
break;
|
||||
case SEARCH_TYPE_REGEX:
|
||||
search_type_idx = regex_search_;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sf_ui_->searchInComboBox->setCurrentIndex(search_in_idx);
|
||||
sf_ui_->charEncodingComboBox->setCurrentIndex(char_encoding_idx);
|
||||
sf_ui_->caseCheckBox->setChecked(recent.gui_search_case_sensitive);
|
||||
sf_ui_->searchTypeComboBox->setCurrentIndex(search_type_idx);
|
||||
}
|
||||
|
||||
void SearchFrame::updateWidgets()
|
||||
{
|
||||
if (cap_file_) {
|
||||
|
@ -219,13 +279,65 @@ void SearchFrame::updateWidgets()
|
|||
}
|
||||
}
|
||||
|
||||
void SearchFrame::on_caseCheckBox_toggled(bool)
|
||||
void SearchFrame::on_searchInComboBox_currentIndexChanged(int idx)
|
||||
{
|
||||
switch (idx) {
|
||||
case in_packet_list_:
|
||||
recent.gui_search_in = SEARCH_IN_PACKET_LIST;
|
||||
break;
|
||||
case in_proto_tree_:
|
||||
recent.gui_search_in = SEARCH_IN_PACKET_DETAILS;
|
||||
break;
|
||||
case in_bytes_:
|
||||
recent.gui_search_in = SEARCH_IN_PACKET_BYTES;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchFrame::on_charEncodingComboBox_currentIndexChanged(int idx)
|
||||
{
|
||||
switch (idx) {
|
||||
case narrow_and_wide_chars_:
|
||||
recent.gui_search_char_set = SEARCH_CHAR_SET_NARROW_AND_WIDE;
|
||||
break;
|
||||
case narrow_chars_:
|
||||
recent.gui_search_char_set = SEARCH_CHAR_SET_NARROW;
|
||||
break;
|
||||
case wide_chars_:
|
||||
recent.gui_search_char_set = SEARCH_CHAR_SET_WIDE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchFrame::on_caseCheckBox_toggled(bool checked)
|
||||
{
|
||||
recent.gui_search_case_sensitive = checked;
|
||||
regexCompile();
|
||||
}
|
||||
|
||||
void SearchFrame::on_searchTypeComboBox_currentIndexChanged(int)
|
||||
void SearchFrame::on_searchTypeComboBox_currentIndexChanged(int idx)
|
||||
{
|
||||
switch (idx) {
|
||||
case df_search_:
|
||||
recent.gui_search_type = SEARCH_TYPE_DISPLAY_FILTER;
|
||||
break;
|
||||
case hex_search_:
|
||||
recent.gui_search_type = SEARCH_TYPE_HEX_VALUE;
|
||||
break;
|
||||
case string_search_:
|
||||
recent.gui_search_type = SEARCH_TYPE_STRING;
|
||||
break;
|
||||
case regex_search_:
|
||||
recent.gui_search_type = SEARCH_TYPE_REGEX;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ protected:
|
|||
|
||||
private:
|
||||
bool regexCompile();
|
||||
void applyRecentSearchSettings();
|
||||
void updateWidgets();
|
||||
|
||||
Ui::SearchFrame *sf_ui_;
|
||||
|
@ -53,8 +54,10 @@ private:
|
|||
QString regex_error_;
|
||||
|
||||
private slots:
|
||||
void on_caseCheckBox_toggled(bool);
|
||||
void on_searchTypeComboBox_currentIndexChanged(int);
|
||||
void on_searchInComboBox_currentIndexChanged(int idx);
|
||||
void on_charEncodingComboBox_currentIndexChanged(int idx);
|
||||
void on_caseCheckBox_toggled(bool checked);
|
||||
void on_searchTypeComboBox_currentIndexChanged(int idx);
|
||||
void on_searchLineEdit_textChanged(const QString &);
|
||||
void on_findButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
|
|
44
ui/recent.c
44
ui/recent.c
|
@ -61,6 +61,10 @@
|
|||
#define RECENT_GUI_CUSTOM_COLORS "gui.custom_colors"
|
||||
#define RECENT_GUI_TOOLBAR_SHOW "gui.additional_toolbar_show"
|
||||
#define RECENT_GUI_INTERFACE_TOOLBAR_SHOW "gui.interface_toolbar_show"
|
||||
#define RECENT_GUI_SEARCH_IN "gui.search_in"
|
||||
#define RECENT_GUI_SEARCH_CHAR_SET "gui.search_char_set"
|
||||
#define RECENT_GUI_SEARCH_CASE_SENSITIVE "gui.search_case_sensitive"
|
||||
#define RECENT_GUI_SEARCH_TYPE "gui.search_type"
|
||||
|
||||
#define RECENT_GUI_GEOMETRY "gui.geom."
|
||||
|
||||
|
@ -118,6 +122,28 @@ static const value_string bytes_encoding_type_values[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string search_in_values[] = {
|
||||
{ SEARCH_IN_PACKET_LIST, "PACKET_LIST" },
|
||||
{ SEARCH_IN_PACKET_DETAILS, "PACKET_DETAILS" },
|
||||
{ SEARCH_IN_PACKET_BYTES, "PACKET_BYTES" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string search_char_set_values[] = {
|
||||
{ SEARCH_CHAR_SET_NARROW_AND_WIDE, "NARROW_AND_WIDE" },
|
||||
{ SEARCH_CHAR_SET_NARROW, "NARROW" },
|
||||
{ SEARCH_CHAR_SET_WIDE, "WIDE" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string search_type_values[] = {
|
||||
{ SEARCH_TYPE_DISPLAY_FILTER, "DISPLAY_FILTER" },
|
||||
{ SEARCH_TYPE_HEX_VALUE, "HEX_VALUE" },
|
||||
{ SEARCH_TYPE_STRING, "STRING" },
|
||||
{ SEARCH_TYPE_REGEX, "REGEX" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
free_col_width_data(gpointer data, gpointer user_data _U_)
|
||||
{
|
||||
|
@ -716,6 +742,16 @@ write_recent(void)
|
|||
RECENT_KEY_PRIVS_WARN_IF_NO_NPF,
|
||||
recent.privs_warn_if_no_npf);
|
||||
|
||||
write_recent_enum(rf, "Find packet search in", RECENT_GUI_SEARCH_IN, search_in_values,
|
||||
recent.gui_search_in);
|
||||
write_recent_enum(rf, "Find packet character set", RECENT_GUI_SEARCH_CHAR_SET, search_char_set_values,
|
||||
recent.gui_search_char_set);
|
||||
write_recent_boolean(rf, "Find packet case sensitive search",
|
||||
RECENT_GUI_SEARCH_CASE_SENSITIVE,
|
||||
recent.gui_search_case_sensitive);
|
||||
write_recent_enum(rf, "Find packet search type", RECENT_GUI_SEARCH_TYPE, search_type_values,
|
||||
recent.gui_search_type);
|
||||
|
||||
window_geom_recent_write_all(rf);
|
||||
|
||||
fprintf(rf, "\n# Custom colors.\n");
|
||||
|
@ -969,6 +1005,14 @@ read_set_recent_common_pair_static(gchar *key, const gchar *value,
|
|||
parse_recent_boolean(value, &recent.privs_warn_if_elevated);
|
||||
} else if (strcmp(key, RECENT_KEY_PRIVS_WARN_IF_NO_NPF) == 0) {
|
||||
parse_recent_boolean(value, &recent.privs_warn_if_no_npf);
|
||||
} else if (strcmp(key, RECENT_GUI_SEARCH_IN) == 0) {
|
||||
recent.gui_search_in = (search_in_type)str_to_val(value, search_in_values, SEARCH_IN_PACKET_LIST);
|
||||
} else if (strcmp(key, RECENT_GUI_SEARCH_CHAR_SET) == 0) {
|
||||
recent.gui_search_char_set = (search_char_set_type)str_to_val(value, search_char_set_values, SEARCH_CHAR_SET_NARROW_AND_WIDE);
|
||||
} else if (strcmp(key, RECENT_GUI_SEARCH_CASE_SENSITIVE) == 0) {
|
||||
parse_recent_boolean(value, &recent.gui_search_case_sensitive);
|
||||
} else if (strcmp(key, RECENT_GUI_SEARCH_TYPE) == 0) {
|
||||
recent.gui_search_type = (search_type_type)str_to_val(value, search_type_values, SEARCH_TYPE_DISPLAY_FILTER);
|
||||
} else if (strcmp(key, RECENT_GUI_CUSTOM_COLORS) == 0) {
|
||||
recent.custom_colors = prefs_get_string_list(value);
|
||||
}
|
||||
|
|
24
ui/recent.h
24
ui/recent.h
|
@ -62,6 +62,25 @@ typedef enum {
|
|||
BYTES_ENC_EBCDIC
|
||||
} bytes_encoding_type;
|
||||
|
||||
typedef enum {
|
||||
SEARCH_IN_PACKET_LIST,
|
||||
SEARCH_IN_PACKET_DETAILS,
|
||||
SEARCH_IN_PACKET_BYTES
|
||||
} search_in_type;
|
||||
|
||||
typedef enum {
|
||||
SEARCH_CHAR_SET_NARROW_AND_WIDE,
|
||||
SEARCH_CHAR_SET_NARROW,
|
||||
SEARCH_CHAR_SET_WIDE
|
||||
} search_char_set_type;
|
||||
|
||||
typedef enum {
|
||||
SEARCH_TYPE_DISPLAY_FILTER,
|
||||
SEARCH_TYPE_HEX_VALUE,
|
||||
SEARCH_TYPE_STRING,
|
||||
SEARCH_TYPE_REGEX
|
||||
} search_type_type;
|
||||
|
||||
/** Recent settings. */
|
||||
typedef struct recent_settings_tag {
|
||||
gboolean main_toolbar_show;
|
||||
|
@ -79,6 +98,11 @@ typedef struct recent_settings_tag {
|
|||
bytes_view_type gui_bytes_view;
|
||||
bytes_encoding_type gui_bytes_encoding;
|
||||
|
||||
search_in_type gui_search_in;
|
||||
search_char_set_type gui_search_char_set;
|
||||
gboolean gui_search_case_sensitive;
|
||||
search_type_type gui_search_type;
|
||||
|
||||
gint gui_geometry_main_x;
|
||||
gint gui_geometry_main_y;
|
||||
gint gui_geometry_main_width;
|
||||
|
|
Loading…
Reference in New Issue