Qt: Add preference for show file load time in the status bar
authorStig Bjørlykke <stig@bjorlykke.org>
Thu, 27 Jul 2017 21:10:42 +0000 (23:10 +0200)
committerAnders Broman <a.broman58@gmail.com>
Sat, 29 Jul 2017 05:39:37 +0000 (05:39 +0000)
This will leave more room for messages on smaller screens.  Set the
default OFF because this is probably only useful for developers.

Group Status Bar settings in the Layout frame.

Change-Id: Iea9a55b6c088aac10ee7680b1e8a882ed00c73be
Reviewed-on: https://code.wireshark.org/review/22824
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
docbook/release-notes.asciidoc
epan/prefs.c
epan/prefs.h
ui/qt/layout_preferences_frame.cpp
ui/qt/layout_preferences_frame.h
ui/qt/layout_preferences_frame.ui
ui/qt/main_status_bar.cpp

index 654c8c74ba4f17b811b6d6c96ada135680583221..73666b884f88c4beb3c1dec26be07385fb681290 100644 (file)
@@ -37,7 +37,9 @@ since version 2.4.0:
 * SMI private enterprise numbers are now read from the "enterprises.tsv" configuration file.
 * QUIC dissector is rename to G(oogle) QUIC (quic => gquic)
 * Selected packet number can now be shown in the Status Bar by enabling
-  Preferences -> Appearance -> Layout -> Show selected packet number in the Status Bar
+  Preferences -> Appearance -> Layout -> Show selected packet number
+* File load time in Status Bar is now disabled by default and can be enabled in
+  Preferences -> Appearance -> Layout -> Show file load time
 
 //=== Removed Dissectors
 
index febd18e39d1a71064f688c95433260f8c3980ba6..72fad4d59edcb6ef2f1625eb4184f647767215f7 100644 (file)
@@ -3300,6 +3300,11 @@ prefs_register_modules(void)
                                    "Show selected packet in the Status Bar",
                                    &prefs.gui_qt_show_selected_packet);
 
+    prefs_register_bool_preference(gui_layout_module, "show_file_load_time.enabled",
+                                   "Show file load time in the Status Bar",
+                                   "Show file load time in the Status Bar",
+                                   &prefs.gui_qt_show_file_load_time);
+
     prefs_register_bool_preference(gui_module, "packet_editor.enabled",
                                    "Enable Packet Editor",
                                    "Enable Packet Editor (Experimental)",
@@ -4048,6 +4053,7 @@ pre_init_prefs(void)
 
     prefs.gui_qt_packet_list_separator = FALSE;
     prefs.gui_qt_show_selected_packet = FALSE;
+    prefs.gui_qt_show_file_load_time = FALSE;
 
     if (prefs.col_list) {
         free_col_info(prefs.col_list);
index 81d441abf9f7835fdf0ad657641076d5101cc49d..54113623914701e5e6619a9fbfdc6d15f75d9434 100644 (file)
@@ -228,6 +228,7 @@ typedef struct _e_prefs {
   gboolean     unknown_colorfilters; /* Warn when saving unknown or obsolete color filters. */
   gboolean     gui_qt_packet_list_separator;
   gboolean     gui_qt_show_selected_packet;
+  gboolean     gui_qt_show_file_load_time;
   gboolean     gui_packet_editor; /* Enable Packet Editor */
   elide_mode_e gui_packet_list_elide_mode;
   gboolean     gui_packet_list_show_related;
index 1dcde93c7d5419c93677c51723151d226ce6c751..6ae2dc4d607dca5093b36752de96dec2cfa635da 100644 (file)
@@ -48,11 +48,23 @@ LayoutPreferencesFrame::LayoutPreferencesFrame(QWidget *parent) :
     ui->layout5ToolButton->setStyleSheet(image_pad_ss);
     ui->layout6ToolButton->setStyleSheet(image_pad_ss);
 
+    QStyleOption style_opt;
+    QString indent_ss = QString(
+             "QCheckBox {"
+             "  margin-left: %1px;"
+             "}"
+             ).arg(ui->packetListSeparatorCheckBox->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left());
+    ui->statusBarShowSelectedPacketCheckBox->setStyleSheet(indent_ss);
+    ui->statusBarShowFileLoadTimeCheckBox->setStyleSheet(indent_ss);
+
     pref_packet_list_separator_ = prefFromPrefPtr(&prefs.gui_qt_packet_list_separator);
     ui->packetListSeparatorCheckBox->setChecked(prefs_get_bool_value(pref_packet_list_separator_, pref_stashed));
 
     pref_show_selected_packet_ = prefFromPrefPtr(&prefs.gui_qt_show_selected_packet);
     ui->statusBarShowSelectedPacketCheckBox->setChecked(prefs_get_bool_value(pref_show_selected_packet_, pref_stashed));
+
+    pref_show_file_load_time_ = prefFromPrefPtr(&prefs.gui_qt_show_file_load_time);
+    ui->statusBarShowFileLoadTimeCheckBox->setChecked(prefs_get_bool_value(pref_show_file_load_time_, pref_stashed));
 }
 
 LayoutPreferencesFrame::~LayoutPreferencesFrame()
@@ -278,7 +290,6 @@ void LayoutPreferencesFrame::on_pane3NoneRadioButton_toggled(bool checked)
     prefs_set_enum_value(pref_layout_content_3_, layout_pane_content_none, pref_stashed);
 }
 
-
 void LayoutPreferencesFrame::on_restoreButtonBox_clicked(QAbstractButton *)
 {
     reset_stashed_pref(pref_layout_type_);
@@ -291,6 +302,7 @@ void LayoutPreferencesFrame::on_restoreButtonBox_clicked(QAbstractButton *)
 
     ui->packetListSeparatorCheckBox->setChecked(prefs_get_bool_value(pref_packet_list_separator_, pref_default));
     ui->statusBarShowSelectedPacketCheckBox->setChecked(prefs_get_bool_value(pref_show_selected_packet_, pref_default));
+    ui->statusBarShowFileLoadTimeCheckBox->setChecked(prefs_get_bool_value(pref_show_file_load_time_, pref_default));
 }
 
 void LayoutPreferencesFrame::on_packetListSeparatorCheckBox_toggled(bool checked)
@@ -303,6 +315,11 @@ void LayoutPreferencesFrame::on_statusBarShowSelectedPacketCheckBox_toggled(bool
     prefs_set_bool_value(pref_show_selected_packet_, (gboolean) checked, pref_stashed);
 }
 
+void LayoutPreferencesFrame::on_statusBarShowFileLoadTimeCheckBox_toggled(bool checked)
+{
+    prefs_set_bool_value(pref_show_file_load_time_, (gboolean) checked, pref_stashed);
+}
+
 /*
  * Editor modelines
  *
index bed0baeae83c1ed8fbbc6d173a142cceeb415644..c0dacbe76c84e3a46a02e261894c908f2a9e3079 100644 (file)
@@ -51,6 +51,7 @@ private:
     pref_t *pref_layout_content_3_;
     pref_t *pref_packet_list_separator_;
     pref_t *pref_show_selected_packet_;
+    pref_t *pref_show_file_load_time_;
 
     void updateWidgets();
 
@@ -76,7 +77,7 @@ private slots:
     void on_restoreButtonBox_clicked(QAbstractButton *button);
     void on_packetListSeparatorCheckBox_toggled(bool checked);
     void on_statusBarShowSelectedPacketCheckBox_toggled(bool checked);
-
+    void on_statusBarShowFileLoadTimeCheckBox_toggled(bool checked);
 };
 
 #endif // LAYOUT_PREFERENCES_FRAME_H
index 74b4a7d05d63a72bacb4c9f3428f87a1d45497e1..b5f2cd1f88e8196a9f0f8723317744da3f2d444b 100644 (file)
     </widget>
    </item>
    <item>
-    <widget class="QCheckBox" name="statusBarShowSelectedPacketCheckBox">
+    <spacer name="verticalSpacer_3">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>10</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <widget class="QLabel" name="statusBarSettings">
      <property name="text">
-      <string>Show selected packet number in the status bar</string>
+      <string>Status Bar settings:</string>
      </property>
     </widget>
    </item>
+   <item>
+    <layout class="QVBoxLayout" name="statusBarSettingsVerticalLayout">
+     <item>
+      <widget class="QCheckBox" name="statusBarShowSelectedPacketCheckBox">
+       <property name="text">
+        <string>Show selected packet number</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="statusBarShowFileLoadTimeCheckBox">
+       <property name="text">
+        <string>Show file load time</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
    <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
index b2d5c947e397b6aca092b577d20e0cf0530e49c9..7c1e29ba0568da5d002b7c280edcaa2b07bfd0f9 100644 (file)
@@ -463,7 +463,7 @@ void MainStatusBar::showCaptureStatistics()
                               .arg(cap_file_->ignored_count)
                               .arg((100.0*cap_file_->ignored_count)/cap_file_->count, 0, 'f', 1));
         }
-        if(!cap_file_->is_tempfile) {
+        if(prefs.gui_qt_show_file_load_time && !cap_file_->is_tempfile) {
             /* Loading an existing file */
             gulong computed_elapsed = cf_get_computed_elapsed(cap_file_);
             packets_str.append(QString(tr(" %1  Load time: %2:%3.%4"))