aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-03-16 19:46:08 +0100
committerGerald Combs <gerald@wireshark.org>2018-03-18 00:30:49 +0000
commitc1b7c8f9d2d1e5c6177062acc589800e2b1237e9 (patch)
tree0b7b05a1731e0a4243ce81479ce3a524b9bdaab7 /ui
parent401e335b7ff1c0df7c7c6442573ec243274692fb (diff)
Qt: ensure field is visible on selection from bytes view
Ensure that a selected field (via selectedFieldChanged) becomes visible in the packet details view when selected from the bytes view (or when found via a search). As making a field always visible seems a desirable feature (and in the interest of simplifying preferences), enable this by default using the smarter EnsureVisible hint. Remove the associated preferences and mark them GTK+ only. Change-Id: I05a918c1e09135c0b4e10f04024bff092756e55c Fixes: v2.5.0rc0-2383-g6b2764a41e ("ProtoTree behavior fixes.") Reviewed-on: https://code.wireshark.org/review/26509 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/main_window_preferences_frame.cpp19
-rw-r--r--ui/qt/main_window_preferences_frame.h2
-rw-r--r--ui/qt/main_window_preferences_frame.ui44
-rw-r--r--ui/qt/proto_tree.cpp13
4 files changed, 5 insertions, 73 deletions
diff --git a/ui/qt/main_window_preferences_frame.cpp b/ui/qt/main_window_preferences_frame.cpp
index f83b86e0e6..5b99023a44 100644
--- a/ui/qt/main_window_preferences_frame.cpp
+++ b/ui/qt/main_window_preferences_frame.cpp
@@ -35,8 +35,6 @@ MainWindowPreferencesFrame::MainWindowPreferencesFrame(QWidget *parent) :
pref_recent_df_entries_max_ = prefFromPrefPtr(&prefs.gui_recent_df_entries_max);
pref_recent_files_count_max_ = prefFromPrefPtr(&prefs.gui_recent_files_count_max);
pref_ask_unsaved_ = prefFromPrefPtr(&prefs.gui_ask_unsaved);
- pref_auto_scroll_on_expand_ = prefFromPrefPtr(&prefs.gui_auto_scroll_on_expand);
- pref_auto_scroll_percentage_ = prefFromPrefPtr(&prefs.gui_auto_scroll_percentage);
pref_toolbar_main_style_ = prefFromPrefPtr(&prefs.gui_toolbar_main_style);
pref_toolbar_filter_style_ = prefFromPrefPtr(&prefs.gui_toolbar_filter_style);
@@ -51,12 +49,9 @@ MainWindowPreferencesFrame::MainWindowPreferencesFrame(QWidget *parent) :
ui->maxFilterLineEdit->setStyleSheet(indent_ss);
ui->maxRecentLineEdit->setStyleSheet(indent_ss);
- ui->autoScrollPercentageLabel->setStyleSheet(indent_ss);
-
int num_entry_width = ui->maxFilterLineEdit->fontMetrics().height() * 3;
ui->maxFilterLineEdit->setMaximumWidth(num_entry_width);
ui->maxRecentLineEdit->setMaximumWidth(num_entry_width);
- ui->autoScrollPercentageLineEdit->setMaximumWidth(num_entry_width);
QString globalLanguagesPath(QString(get_datafile_dir()) + "/languages/");
QString userLanguagesPath(gchar_free_to_qstring(get_persconffile_path("languages/", FALSE)));
@@ -128,8 +123,6 @@ void MainWindowPreferencesFrame::updateWidgets()
ui->maxRecentLineEdit->setText(QString::number(prefs_get_uint_value_real(pref_recent_files_count_max_, pref_stashed)));
ui->confirmUnsavedCheckBox->setChecked(prefs_get_bool_value(pref_ask_unsaved_, pref_stashed));
- ui->autoScrollCheckBox->setChecked(prefs_get_bool_value(pref_auto_scroll_on_expand_, pref_stashed));
- ui->autoScrollPercentageLineEdit->setText(QString::number(prefs_get_uint_value_real(pref_auto_scroll_on_expand_, pref_stashed)));
ui->mainToolbarComboBox->setCurrentIndex(prefs_get_enum_value(pref_toolbar_main_style_, pref_stashed));
@@ -196,18 +189,6 @@ void MainWindowPreferencesFrame::on_confirmUnsavedCheckBox_toggled(bool checked)
prefs_set_bool_value(pref_ask_unsaved_, checked, pref_stashed);
}
-void MainWindowPreferencesFrame::on_autoScrollCheckBox_toggled(bool checked)
-{
- prefs_set_bool_value(pref_auto_scroll_on_expand_, checked, pref_stashed);
-}
-
-void MainWindowPreferencesFrame::on_autoScrollPercentageLineEdit_textEdited(const QString &new_pct)
-{
- prefs_set_uint_value(pref_auto_scroll_percentage_, new_pct.toUInt(), pref_stashed);
- prefs_set_bool_value(pref_auto_scroll_on_expand_, TRUE, pref_stashed);
- ui->autoScrollCheckBox->setChecked(true);
-}
-
void MainWindowPreferencesFrame::on_mainToolbarComboBox_currentIndexChanged(int index)
{
prefs_set_enum_value(pref_toolbar_main_style_, index, pref_stashed);
diff --git a/ui/qt/main_window_preferences_frame.h b/ui/qt/main_window_preferences_frame.h
index 0ae4fb7353..20f9368e4a 100644
--- a/ui/qt/main_window_preferences_frame.h
+++ b/ui/qt/main_window_preferences_frame.h
@@ -55,8 +55,6 @@ private slots:
void on_maxFilterLineEdit_textEdited(const QString &new_max);
void on_maxRecentLineEdit_textEdited(const QString &new_max);
void on_confirmUnsavedCheckBox_toggled(bool checked);
- void on_autoScrollCheckBox_toggled(bool checked);
- void on_autoScrollPercentageLineEdit_textEdited(const QString &new_pct);
void on_mainToolbarComboBox_currentIndexChanged(int index);
void on_languageComboBox_currentIndexChanged(int index);
};
diff --git a/ui/qt/main_window_preferences_frame.ui b/ui/qt/main_window_preferences_frame.ui
index 18cc5e762f..9824bbd80c 100644
--- a/ui/qt/main_window_preferences_frame.ui
+++ b/ui/qt/main_window_preferences_frame.ui
@@ -155,50 +155,6 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="autoScrollCheckBox">
- <property name="toolTip">
- <string>If checked the packet detail items will be automatically scrolled when they are expanded.</string>
- </property>
- <property name="text">
- <string>Automatically scroll packet details</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,1">
- <item>
- <widget class="QLabel" name="autoScrollPercentageLabel">
- <property name="toolTip">
- <string>Percentage distance from the top to scroll packet details.</string>
- </property>
- <property name="text">
- <string>Packet detail scroll percentage:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="autoScrollPercentageLineEdit">
- <property name="toolTip">
- <string>Percentage distance from the top to scroll packet details.</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index 6b25f7156d..a088b4f876 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -278,17 +278,12 @@ void ProtoTree::emitRelatedFrame(int related_frame, ft_framenum_type_t framenum_
void ProtoTree::autoScrollTo(const QModelIndex &index)
{
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
- if (!index.isValid() || !prefs.gui_auto_scroll_on_expand) {
+ if (!index.isValid()) {
return;
}
- ScrollHint scroll_hint = PositionAtTop;
- if (prefs.gui_auto_scroll_percentage > 66) {
- scroll_hint = PositionAtBottom;
- } else if (prefs.gui_auto_scroll_percentage >= 33) {
- scroll_hint = PositionAtCenter;
- }
- scrollTo(index, scroll_hint);
+ // ensure item is visible (expanding its parents as needed).
+ scrollTo(index);
}
// XXX We select the first match, which might not be the desired item.
@@ -432,6 +427,8 @@ void ProtoTree::itemDoubleClicked(const QModelIndex &index) {
}
}
+// Select a field and bring it into view. Intended to be called by external
+// components (such as the byte view).
void ProtoTree::selectedFieldChanged(FieldInformation *finfo)
{
if (finfo && finfo->parent() == this) {