1 /* capture_preferences_frame.cpp
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.
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"
37 #include <epan/prefs-int.h>
39 CapturePreferencesFrame::CapturePreferencesFrame(QWidget
*parent
) :
41 ui(new Ui::CapturePreferencesFrame
)
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
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()
65 void CapturePreferencesFrame::showEvent(QShowEvent
*evt
)
71 void CapturePreferencesFrame::updateWidgets()
74 GList
*if_list
, *combo_list
, *combo_entry
;
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
);
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
;
136 * indent-tabs-mode: nil
139 * ex: set shiftwidth=4 tabstop=8 expandtab:
140 * :indentSize=4:tabSize=8:noTabs=true: