diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-02-06 10:36:27 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-02-06 23:23:02 +0000 |
commit | b3f3dd8d82d9b651f34886a3293056c612958aa2 (patch) | |
tree | 7c893353f68806598cc335b471af7c4f7b4acf4a | |
parent | 3b3ce87899ceaf2a491f29f63ae7c1261d667398 (diff) |
Qt: Fix preference change behavior.
Main window:
Keep track of our current layout and only change it if the preferences
change. This keeps the panes from resizing.
Re-select the current packet if the layout changes so that the proto
tree and byte view aren't left in an invalid state. This fixes a crash
similar to bug 10896.
Search frame:
Get rid of an invalid error message. Update coding style.
I don't think any of these fix bug 10921 since Xiaochuan seems to get a
crash immediately upon opening the dialog.
Change-Id: I0e880a50d3c9ac1c6ae6a01034b05fd2249444f4
Reviewed-on: https://code.wireshark.org/review/6989
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r-- | ui/qt/main_window.cpp | 1 | ||||
-rw-r--r-- | ui/qt/main_window.h | 1 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 12 | ||||
-rw-r--r-- | ui/qt/search_frame.cpp | 79 | ||||
-rw-r--r-- | ui/qt/search_frame.h | 6 |
5 files changed, 58 insertions, 41 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 5cf4ac2fa5..26e55f58bb 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -159,6 +159,7 @@ QMenu* MainWindow::findOrAddMenu(QMenu *parent_menu, QString& menu_text) { MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), main_ui_(new Ui::MainWindow), + cur_layout_(QVector<unsigned>()), df_combo_box_(new DisplayFilterCombo()), previous_focus_(NULL), show_hide_actions_(NULL), diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 97b341928e..68715457bf 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -108,6 +108,7 @@ private: QMenu *open_recent_menu_; QSplitter master_split_; QSplitter extra_split_; + QVector<unsigned> cur_layout_; MainWelcome *main_welcome_; DisplayFilterCombo *df_combo_box_; CaptureFile capture_file_; diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 4a2030c3e0..9d56954383 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -243,6 +243,12 @@ void MainWindow::filterPackets(QString& new_filter, bool force) void MainWindow::layoutPanes() { + QVector<unsigned> new_layout = QVector<unsigned>() << prefs.gui_layout_type + << prefs.gui_layout_content_1 + << prefs.gui_layout_content_2 + << prefs.gui_layout_content_3; + if (cur_layout_ == new_layout) return; + QSplitter *parents[3]; // Reparent all widgets and add them back in the proper order below. @@ -253,6 +259,8 @@ void MainWindow::layoutPanes() empty_pane_.setParent(main_ui_->mainStack); extra_split_.setParent(main_ui_->mainStack); + // XXX We should try to preserve geometries if we can, e.g. by + // checking to see if the layout type is the same. switch(prefs.gui_layout_type) { case(layout_type_2): case(layout_type_1): @@ -328,6 +336,10 @@ void MainWindow::layoutPanes() } widget->setVisible(show); } + if (capture_file_.isValid() && capture_file_.capFile()->current_row >= 0) { + cf_select_packet(capture_file_.capFile(), capture_file_.capFile()->current_row); + } + cur_layout_ = new_layout; } void MainWindow::layoutToolbars() diff --git a/ui/qt/search_frame.cpp b/ui/qt/search_frame.cpp index e07c6221c4..48729aece4 100644 --- a/ui/qt/search_frame.cpp +++ b/ui/qt/search_frame.cpp @@ -29,17 +29,23 @@ #include <QKeyEvent> #include <QCheckBox> -const int in_packet_list = 0; -const int in_proto_tree = 1; -const int in_bytes = 2; - -const int df_search = 0; -const int hex_search = 1; -const int string_search = 2; - -const int narrow_and_wide_chars = 0; -const int narrow_chars = 1; -const int wide_chars = 2; +enum { + in_packet_list_, + in_proto_tree_, + in_bytes_ +}; + +enum { + df_search_, + hex_search_, + string_search_ +}; + +enum { + narrow_and_wide_chars_, + narrow_chars_, + wide_chars_ +}; SearchFrame::SearchFrame(QWidget *parent) : AccordionFrame(parent), @@ -53,8 +59,8 @@ SearchFrame::SearchFrame(QWidget *parent) : w->setAttribute(Qt::WA_MacSmallSize, true); } #endif - sf_ui_->searchTypeComboBox->setCurrentIndex(0); - enableWidgets(); + sf_ui_->searchTypeComboBox->setCurrentIndex(df_search_); + updateWidgets(); } SearchFrame::~SearchFrame() @@ -99,15 +105,15 @@ void SearchFrame::setCaptureFile(capture_file *cf) if (!cf && isVisible()) { animatedHide(); } - enableWidgets(); + updateWidgets(); } void SearchFrame::findFrameWithFilter(QString &filter) { animatedShow(); sf_ui_->searchLineEdit->setText(filter); - sf_ui_->searchTypeComboBox->setCurrentIndex(0); - enableWidgets(); + sf_ui_->searchTypeComboBox->setCurrentIndex(df_search_); + updateWidgets(); } void SearchFrame::keyPressEvent(QKeyEvent *event) @@ -124,7 +130,7 @@ void SearchFrame::keyPressEvent(QKeyEvent *event) } } -void SearchFrame::enableWidgets() +void SearchFrame::updateWidgets() { if (cap_file_) { setEnabled(true); @@ -133,16 +139,16 @@ void SearchFrame::enableWidgets() return; } - bool enable = sf_ui_->searchTypeComboBox->currentIndex() == string_search; + bool enable = sf_ui_->searchTypeComboBox->currentIndex() == string_search_; sf_ui_->searchInComboBox->setEnabled(enable); sf_ui_->caseCheckBox->setEnabled(enable); sf_ui_->charEncodingComboBox->setEnabled(enable); switch (sf_ui_->searchTypeComboBox->currentIndex()) { - case df_search: + case df_search_: sf_ui_->searchLineEdit->checkDisplayFilter(sf_ui_->searchLineEdit->text()); break; - case hex_search: + case hex_search_: if (sf_ui_->searchLineEdit->text().isEmpty()) { sf_ui_->searchLineEdit->setSyntaxState(SyntaxLineEdit::Invalid); } else { @@ -157,7 +163,7 @@ void SearchFrame::enableWidgets() } } break; - case string_search: + case string_search_: if (sf_ui_->searchLineEdit->text().isEmpty()) { sf_ui_->searchLineEdit->setSyntaxState(SyntaxLineEdit::Invalid); } else { @@ -165,8 +171,7 @@ void SearchFrame::enableWidgets() } break; default: - QString err_string = tr("No valid search type selected. Please report this to the development team."); - emit pushFilterSyntaxStatus(err_string); + // currentIndex is probably -1. Nothing is selected or list is empty. return; } @@ -177,16 +182,14 @@ void SearchFrame::enableWidgets() } } -void SearchFrame::on_searchTypeComboBox_currentIndexChanged(int index) +void SearchFrame::on_searchTypeComboBox_currentIndexChanged(int) { - Q_UNUSED(index); - enableWidgets(); + updateWidgets(); } -void SearchFrame::on_searchLineEdit_textChanged(const QString &search_string) +void SearchFrame::on_searchLineEdit_textChanged(const QString &) { - Q_UNUSED(search_string); - enableWidgets(); + updateWidgets(); } void SearchFrame::on_findButton_clicked() @@ -211,7 +214,7 @@ void SearchFrame::on_findButton_clicked() cap_file_->scs_type = SCS_NARROW_AND_WIDE; switch (sf_ui_->searchTypeComboBox->currentIndex()) { - case df_search: + case df_search_: if (!dfilter_compile(sf_ui_->searchLineEdit->text().toUtf8().constData(), &dfp, NULL)) { err_string = tr("Invalid filter."); emit pushFilterSyntaxStatus(err_string); @@ -224,7 +227,7 @@ void SearchFrame::on_findButton_clicked() return; } break; - case hex_search: + case hex_search_: bytes = convert_string_to_hex(sf_ui_->searchLineEdit->text().toUtf8().constData(), &nbytes); if (bytes == NULL) { err_string = tr("That's not a valid hex string."); @@ -233,7 +236,7 @@ void SearchFrame::on_findButton_clicked() } cap_file_->hex = TRUE; break; - case string_search: + case string_search_: if (sf_ui_->searchLineEdit->text().isEmpty()) { err_string = tr("You didn't specify any text for which to search."); emit pushFilterSyntaxStatus(err_string); @@ -242,13 +245,13 @@ void SearchFrame::on_findButton_clicked() cap_file_->string = TRUE; cap_file_->case_type = sf_ui_->caseCheckBox->isChecked() ? FALSE : TRUE; switch (sf_ui_->charEncodingComboBox->currentIndex()) { - case narrow_and_wide_chars: + case narrow_and_wide_chars_: cap_file_->scs_type = SCS_NARROW_AND_WIDE; break; - case narrow_chars: + case narrow_chars_: cap_file_->scs_type = SCS_NARROW; break; - case wide_chars: + case wide_chars_: cap_file_->scs_type = SCS_WIDE; break; default: @@ -265,13 +268,13 @@ void SearchFrame::on_findButton_clicked() } switch (sf_ui_->searchInComboBox->currentIndex()) { - case in_packet_list: + case in_packet_list_: cap_file_->summary_data = TRUE; break; - case in_proto_tree: + case in_proto_tree_: cap_file_->decode_data = TRUE; break; - case in_bytes: + case in_bytes_: cap_file_->packet_data = TRUE; break; default: diff --git a/ui/qt/search_frame.h b/ui/qt/search_frame.h index db3b694d60..599209509b 100644 --- a/ui/qt/search_frame.h +++ b/ui/qt/search_frame.h @@ -54,14 +54,14 @@ protected: void keyPressEvent(QKeyEvent *event); private: - void enableWidgets(); + void updateWidgets(); Ui::SearchFrame *sf_ui_; capture_file *cap_file_; private slots: - void on_searchTypeComboBox_currentIndexChanged(int index); - void on_searchLineEdit_textChanged(const QString &search_string); + void on_searchTypeComboBox_currentIndexChanged(int); + void on_searchLineEdit_textChanged(const QString &); void on_findButton_clicked(); void on_cancelButton_clicked(); void changeEvent(QEvent* event); |