HACK: 1. try to match RowsetProperties
[wireshark-wip.git] / ui / qt / capture_preferences_frame.cpp
blobff430f97e039eba46776d0086bee549423c287e7
1 /* capture_preferences_frame.cpp
3 * $Id$
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "config.h"
26 #include <glib.h>
28 #include "capture_preferences_frame.h"
29 #include "ui_capture_preferences_frame.h"
31 #include <QSpacerItem>
33 #include "capture_ui_utils.h"
34 #include "ui/ui_util.h"
36 #include <cstdio>
37 #include <epan/prefs-int.h>
39 CapturePreferencesFrame::CapturePreferencesFrame(QWidget *parent) :
40 QFrame(parent),
41 ui(new Ui::CapturePreferencesFrame)
43 ui->setupUi(this);
45 pref_device_ = prefFromPrefPtr(&prefs.capture_device);
46 pref_prom_mode_ = prefFromPrefPtr(&prefs.capture_prom_mode);
47 pref_pcap_ng_ = prefFromPrefPtr(&prefs.capture_pcap_ng);
48 pref_real_time_ = prefFromPrefPtr(&prefs.capture_real_time);
49 pref_auto_scroll_ = prefFromPrefPtr(&prefs.capture_auto_scroll);
50 pref_show_info_ = prefFromPrefPtr(&prefs.capture_show_info);
52 // Setting the left margin via a style sheet clobbers its
53 // appearance.
54 int margin = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
55 QRect geom = ui->defaultInterfaceSpacer->geometry();
56 geom.setWidth(margin);
57 ui->defaultInterfaceSpacer->setGeometry(geom);
60 CapturePreferencesFrame::~CapturePreferencesFrame()
62 delete ui;
65 void CapturePreferencesFrame::showEvent(QShowEvent *evt)
67 Q_UNUSED(evt);
68 updateWidgets();
71 void CapturePreferencesFrame::updateWidgets()
73 #ifdef HAVE_LIBPCAP
74 GList *if_list, *combo_list, *combo_entry;
75 int err;
77 ui->defaultInterfaceComboBox->clear();
78 if_list = capture_interface_list(&err, NULL,main_window_update);
79 combo_list = build_capture_combo_list(if_list, FALSE);
80 free_interface_list(if_list);
81 for (combo_entry = combo_list; combo_entry != NULL && combo_entry->data != NULL; combo_entry = g_list_next(combo_entry)) {
82 ui->defaultInterfaceComboBox->addItem(QString((const char *)combo_entry->data));
85 if (pref_device_->stashed_val.string) {
86 ui->defaultInterfaceComboBox->setEditText(pref_device_->stashed_val.string);
87 } else {
88 ui->defaultInterfaceComboBox->clearEditText();
91 ui->capturePromModeCheckBox->setChecked(pref_prom_mode_->stashed_val.boolval);
92 ui->capturePcapNgCheckBox->setChecked(pref_pcap_ng_->stashed_val.boolval);
93 ui->captureRealTimeCheckBox->setChecked(pref_real_time_->stashed_val.boolval);
94 ui->captureAutoScrollCheckBox->setChecked(pref_auto_scroll_->stashed_val.boolval);
95 ui->captureShowInfoCheckBox->setChecked(pref_show_info_->stashed_val.boolval);
96 #endif // HAVE_LIBPCAP
99 void CapturePreferencesFrame::on_defaultInterfaceComboBox_editTextChanged(const QString &new_iface)
101 g_free((void *)pref_device_->stashed_val.string);
102 pref_device_->stashed_val.string = g_strdup(new_iface.toUtf8().constData());
105 void CapturePreferencesFrame::on_capturePromModeCheckBox_toggled(bool checked)
107 pref_prom_mode_->stashed_val.boolval = checked;
110 void CapturePreferencesFrame::on_capturePcapNgCheckBox_toggled(bool checked)
112 pref_pcap_ng_->stashed_val.boolval = checked;
115 void CapturePreferencesFrame::on_captureRealTimeCheckBox_toggled(bool checked)
117 pref_real_time_->stashed_val.boolval = checked;
120 void CapturePreferencesFrame::on_captureAutoScrollCheckBox_toggled(bool checked)
122 pref_auto_scroll_->stashed_val.boolval = checked;
125 void CapturePreferencesFrame::on_captureShowInfoCheckBox_toggled(bool checked)
127 pref_show_info_->stashed_val.boolval = checked;
131 * Editor modelines
133 * Local Variables:
134 * c-basic-offset: 4
135 * tab-width: 8
136 * indent-tabs-mode: nil
137 * End:
139 * ex: set shiftwidth=4 tabstop=8 expandtab:
140 * :indentSize=4:tabSize=8:noTabs=true: