Add interface prefs. Adjust some spacing and resize behavior.
authorGerald Combs <gerald@wireshark.org>
Fri, 1 Feb 2013 00:14:15 +0000 (00:14 -0000)
committerGerald Combs <gerald@wireshark.org>
Fri, 1 Feb 2013 00:14:15 +0000 (00:14 -0000)
svn path=/trunk/; revision=47403

ui/qt/CMakeLists.txt
ui/qt/Makefile.am
ui/qt/Makefile.common
ui/qt/QtShark.pro
ui/qt/capture_preferences_frame.cpp [new file with mode: 0644]
ui/qt/capture_preferences_frame.h [new file with mode: 0644]
ui/qt/capture_preferences_frame.ui [new file with mode: 0644]
ui/qt/main_window_preferences_frame.ui
ui/qt/preferences_dialog.cpp
ui/qt/preferences_dialog.ui

index db8f3063c6c51d79b023f3187ab1ec8b915c24e6..13556e1f6a8d251878755eecc6e03bab7c823218 100644 (file)
@@ -32,6 +32,7 @@ set(QTSHARK_H_SRC
        capture_interface_dialog.h
        color_dialog.h
        color_utils.h
+       capture_preferences_frame.h
        column_preferences_frame.h
        display_filter_combo.h
        display_filter_edit.h
@@ -80,6 +81,7 @@ set(QTSHARK_CPP_SRC
        capture_interface_dialog.cpp
        color_dialog.cpp
        color_utils.cpp
+       capture_preferences_frame.cpp
        column_preferences_frame.cpp
        display_filter_combo.cpp
        display_filter_edit.cpp
@@ -124,6 +126,7 @@ set(QTSHARK_SRC
 )
 
 set(QTSHARK_UI
+       capture_preferences_frame.ui
        column_preferences_frame.ui
        export_object_dialog.ui
        file_set_dialog.ui
index 7fe01cba0dd7f2cc32cd88372f962ef5f1cdb3c8..6ab2094d1444380bd594f1811fb4dc0b1a15a76c 100644 (file)
@@ -83,6 +83,8 @@ ui_%.h: %.ui
 #moc_%.cpp: %.h
 #      moc $< -o $@
 
+capture_preferences_frame.cpp capture_preferences_frame.h: ui_capture_preferences_frame.h
+
 column_preferences_frame.cpp column_preferences_frame.h: ui_column_preferences_frame.h
 
 export_object_dialog.cpp export_object_dialog.h: ui_export_object_dialog.h
index 613434597ec55fb4f7d0848c52eade932c0b6c3b..40fbdb53d0fbe91cd8c077489810ed48e1086990 100644 (file)
@@ -31,6 +31,7 @@ GENERATED_HEADER_FILES =
 
 # Generated header files that we don't want in the distribution.
 GENERATED_NODIST_HEADER_FILES = \
+       ui_capture_preferences_frame.h \
        ui_column_preferences_frame.h \
        ui_export_object_dialog.h \
        ui_file_set_dialog.h \
@@ -91,6 +92,7 @@ MOC_HDRS = \
        capture_interface_dialog.h \
        color_dialog.h \
        color_utils.h \
+       capture_preferences_frame.h \
        column_preferences_frame.h \
        display_filter_combo.h \
        display_filter_edit.h \
@@ -130,6 +132,7 @@ MOC_HDRS = \
 # .ui files.
 #
 UI_FILES = \
+       capture_preferences_frame.ui    \
        column_preferences_frame.ui     \
        export_object_dialog.ui         \
        file_set_dialog.ui              \
@@ -201,6 +204,7 @@ WIRESHARK_QT_SRC = \
        capture_interface_dialog.cpp \
        color_dialog.cpp \
        color_utils.cpp \
+       capture_preferences_frame.cpp \
        column_preferences_frame.cpp \
        display_filter_combo.cpp \
        display_filter_edit.cpp \
index 0f0eaf9b02555fdaa1d620336c642a96dd4133c1..5280dd79e9179eca0056a380cd06792605dd3a31 100644 (file)
@@ -202,7 +202,8 @@ FORMS += main_window.ui \
     main_window_preferences_frame.ui \
     layout_preferences_frame.ui \
     column_preferences_frame.ui \
-    font_color_preferences_frame.ui
+    font_color_preferences_frame.ui \
+    capture_preferences_frame.ui
 
 win32 { ## These should be in config.pri ??
     !isEmpty(PORTAUDIO_DIR) {
@@ -240,7 +241,8 @@ HEADERS += $$HEADERS_WS_C \
     main_window_preferences_frame.h \
     layout_preferences_frame.h \
     column_preferences_frame.h \
-    font_color_preferences_frame.h
+    font_color_preferences_frame.h \
+    capture_preferences_frame.h
 
 win32 {
     OBJECTS_WS_C = $$SOURCES_WS_C
@@ -462,4 +464,5 @@ SOURCES += \
     main_window_preferences_frame.cpp \
     layout_preferences_frame.cpp \
     column_preferences_frame.cpp \
-    font_color_preferences_frame.cpp
+    font_color_preferences_frame.cpp \
+    capture_preferences_frame.cpp
diff --git a/ui/qt/capture_preferences_frame.cpp b/ui/qt/capture_preferences_frame.cpp
new file mode 100644 (file)
index 0000000..d7d0a40
--- /dev/null
@@ -0,0 +1,137 @@
+/* capture_preferences_frame.cpp
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "capture_preferences_frame.h"
+#include "ui_capture_preferences_frame.h"
+
+#include <QSpacerItem>
+
+#include "capture_ui_utils.h"
+
+#include <epan/prefs-int.h>
+
+CapturePreferencesFrame::CapturePreferencesFrame(QWidget *parent) :
+    QFrame(parent),
+    ui(new Ui::CapturePreferencesFrame)
+{
+    ui->setupUi(this);
+
+    pref_device_ = prefFromPrefPtr(&prefs.capture_device);
+    pref_prom_mode_ = prefFromPrefPtr(&prefs.capture_prom_mode);
+    pref_pcap_ng_ = prefFromPrefPtr(&prefs.capture_pcap_ng);
+    pref_real_time_ = prefFromPrefPtr(&prefs.capture_real_time);
+    pref_auto_scroll_ = prefFromPrefPtr(&prefs.capture_auto_scroll);
+    pref_show_info_ = prefFromPrefPtr(&prefs.capture_show_info);
+
+    // Setting the left margin via a style sheet clobbers its
+    // appearance.
+    int margin = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
+    QRect geom = ui->defaultInterfaceSpacer->geometry();
+    geom.setWidth(margin);
+    ui->defaultInterfaceSpacer->setGeometry(geom);
+}
+
+CapturePreferencesFrame::~CapturePreferencesFrame()
+{
+    delete ui;
+}
+
+void CapturePreferencesFrame::showEvent(QShowEvent *evt)
+{
+    Q_UNUSED(evt);
+    updateWidgets();
+}
+
+void CapturePreferencesFrame::updateWidgets()
+{
+    GList *if_list, *combo_list, *combo_entry;
+    int err;
+
+    ui->defaultInterfaceComboBox->clear();
+    if_list = capture_interface_list(&err, NULL);
+    combo_list = build_capture_combo_list(if_list, FALSE);
+    free_interface_list(if_list);
+    for (combo_entry = combo_list; combo_entry != NULL && combo_entry->data != NULL; combo_entry = g_list_next(combo_entry)) {
+        ui->defaultInterfaceComboBox->addItem(QString((const char *)combo_entry->data));
+    }
+
+    if (pref_device_->stashed_val.string) {
+        ui->defaultInterfaceComboBox->setEditText(pref_device_->stashed_val.string);
+    } else {
+        ui->defaultInterfaceComboBox->clearEditText();
+    }
+
+    ui->capturePromModeCheckBox->setChecked(pref_prom_mode_->stashed_val.boolval);
+    ui->capturePcapNgCheckBox->setChecked(pref_pcap_ng_->stashed_val.boolval);
+    ui->captureRealTimeCheckBox->setChecked(pref_real_time_->stashed_val.boolval);
+    ui->captureAutoScrollCheckBox->setChecked(pref_auto_scroll_->stashed_val.boolval);
+    ui->captureShowInfoCheckBox->setChecked(pref_show_info_->stashed_val.boolval);
+}
+
+void CapturePreferencesFrame::on_defaultInterfaceComboBox_editTextChanged(const QString &new_iface)
+{
+    g_free((void *)pref_device_->stashed_val.string);
+    pref_device_->stashed_val.string = g_strdup(new_iface.toUtf8().constData());
+}
+
+void CapturePreferencesFrame::on_capturePromModeCheckBox_toggled(bool checked)
+{
+    pref_prom_mode_->stashed_val.boolval = checked;
+}
+
+void CapturePreferencesFrame::on_capturePcapNgCheckBox_toggled(bool checked)
+{
+    pref_pcap_ng_->stashed_val.boolval = checked;
+}
+
+void CapturePreferencesFrame::on_captureRealTimeCheckBox_toggled(bool checked)
+{
+    pref_real_time_->stashed_val.boolval = checked;
+}
+
+void CapturePreferencesFrame::on_captureAutoScrollCheckBox_toggled(bool checked)
+{
+    pref_auto_scroll_->stashed_val.boolval = checked;
+}
+
+void CapturePreferencesFrame::on_captureShowInfoCheckBox_toggled(bool checked)
+{
+    pref_show_info_->stashed_val.boolval = checked;
+}
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/capture_preferences_frame.h b/ui/qt/capture_preferences_frame.h
new file mode 100644 (file)
index 0000000..670253a
--- /dev/null
@@ -0,0 +1,67 @@
+/* capture_preferences_frame.h
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef CAPTURE_PREFERENCES_FRAME_H
+#define CAPTURE_PREFERENCES_FRAME_H
+
+#include "preferences_dialog.h"
+
+#include <QFrame>
+
+namespace Ui {
+class CapturePreferencesFrame;
+}
+
+class CapturePreferencesFrame : public QFrame
+{
+    Q_OBJECT
+    
+public:
+    explicit CapturePreferencesFrame(QWidget *parent = 0);
+    ~CapturePreferencesFrame();
+    
+protected:
+    void showEvent(QShowEvent *evt);
+
+private slots:
+    void on_defaultInterfaceComboBox_editTextChanged(const QString &new_iface);
+    void on_capturePromModeCheckBox_toggled(bool checked);
+    void on_capturePcapNgCheckBox_toggled(bool checked);
+    void on_captureRealTimeCheckBox_toggled(bool checked);
+    void on_captureAutoScrollCheckBox_toggled(bool checked);
+    void on_captureShowInfoCheckBox_toggled(bool checked);
+
+private:
+    Ui::CapturePreferencesFrame *ui;
+
+    pref_t *pref_device_;
+    pref_t *pref_prom_mode_;
+    pref_t *pref_pcap_ng_;
+    pref_t *pref_real_time_;
+    pref_t *pref_auto_scroll_;
+    pref_t *pref_show_info_;
+
+    void updateWidgets();
+};
+
+#endif // CAPTURE_PREFERENCES_FRAME_H
diff --git a/ui/qt/capture_preferences_frame.ui b/ui/qt/capture_preferences_frame.ui
new file mode 100644 (file)
index 0000000..0f76333
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CapturePreferencesFrame</class>
+ <widget class="QFrame" name="CapturePreferencesFrame">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>354</width>
+    <height>194</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>191</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Frame</string>
+  </property>
+  <property name="lineWidth">
+   <number>0</number>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Default interface</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="defaultInterfaceSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>18</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QComboBox" name="defaultInterfaceComboBox">
+       <property name="editable">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="capturePromModeCheckBox">
+     <property name="toolTip">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You probably want to enable this. Usually a network card will only capture the traffic sent to its own network address. If you want to capture all traffic that the network card can &amp;quot;see&amp;quot;, mark this option. See the FAQ for some more details of capturing packets from a switched network.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="text">
+      <string>Capture packets in promiscuous mode</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="capturePcapNgCheckBox">
+     <property name="toolTip">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Capture packets in the next-generation capture file format.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="text">
+      <string>Capture packets in pcap-ng format</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="captureRealTimeCheckBox">
+     <property name="toolTip">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Update the list of packets while capture is in progress. This can result in dropped packets on high-speed networks.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="text">
+      <string>Update list of packets in real time</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="captureAutoScrollCheckBox">
+     <property name="toolTip">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Keep the packet list scrolled to the bottom while capturing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="text">
+      <string>Automatic scrolling in live capture</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="captureShowInfoCheckBox">
+     <property name="toolTip">
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show the capture summary dialog while capturing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="text">
+      <string>Show the capture summary dialog while capturing</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>3</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index d036987b6597b5d4a3d552baac80f54e4d21aca6..7a4e8af51cb3b7701a0cd078f0dc79859a09c9e4 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>425</width>
-    <height>373</height>
+    <height>384</height>
    </rect>
   </property>
   <property name="sizePolicy">
     <verstretch>0</verstretch>
    </sizepolicy>
   </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>384</height>
+   </size>
+  </property>
   <property name="windowTitle">
    <string>Frame</string>
   </property>
      </item>
     </layout>
    </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>1</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <resources/>
index 24d43f9b45b035675b65bf2f5ab599ee20d5c735..cf40f1c0f11677460f0936a1d4fdd22c401b1334 100644 (file)
@@ -218,6 +218,9 @@ void PreferencesDialog::showEvent(QShowEvent *evt)
     int new_prefs_tree_width =  pd_ui_->prefsTree->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &style_opt).left();
     QList<int> sizes = pd_ui_->splitter->sizes();
 
+#ifdef Q_WS_WIN
+    new_prefs_tree_width *= 2;
+#endif
     pd_ui_->prefsTree->resizeColumnToContents(0);
     new_prefs_tree_width += pd_ui_->prefsTree->columnWidth(0);
     pd_ui_->prefsTree->setMinimumWidth(new_prefs_tree_width);
index cc710080c7f70cbd242f812c72bd2edac775e523..1ea043de7bf76fe698755857bc4cd53884ef5888 100644 (file)
@@ -61,9 +61,6 @@
        <property name="text">
         <string>Capture</string>
        </property>
-       <property name="flags">
-        <set>ItemIsDragEnabled|ItemIsUserCheckable</set>
-       </property>
       </item>
       <item>
        <property name="text">
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
-      <property name="currentIndex">
-       <number>0</number>
-      </property>
       <widget class="MainWindowPreferencesFrame" name="appearanceFrame"/>
       <widget class="LayoutPreferencesFrame" name="layoutFrame"/>
       <widget class="ColumnPreferencesFrame" name="columnFrame"/>
       <widget class="FontColorPreferencesFrame" name="fontandcolorFrame"/>
-      <widget class="QFrame" name="captureFrame"/>
+      <widget class="CapturePreferencesFrame" name="captureFrame"/>
       <widget class="QFrame" name="filterFrame"/>
       <widget class="QFrame" name="nameresolutionFrame"/>
       <widget class="QFrame" name="protocolsFrame"/>
    <header>font_color_preferences_frame.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>CapturePreferencesFrame</class>
+   <extends>QFrame</extends>
+   <header>capture_preferences_frame.h</header>
+   <container>1</container>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections>