3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef CAPTURE_FILE_DIALOG_H
11 #define CAPTURE_FILE_DIALOG_H
13 #include <ui/qt/widgets/wireshark_file_dialog.h>
15 #include <ui/qt/widgets/display_filter_edit.h>
16 #include <ui/qt/widgets/compression_group_box.h>
17 #include "packet_range_group_box.h"
18 #include "ui/help_url.h"
20 #include <ui/packet_range.h>
22 #include <ui/qt/models/packet_list_record.h>
25 #include "ui/file_dialog.h"
27 #include <QVBoxLayout>
29 #include <QRadioButton>
31 #include <QDialogButtonBox>
34 class CaptureFileDialog
: public WiresharkFileDialog
36 // The GTK+ Open Capture File dialog has the following elements and features:
37 // - The ability to select a capture file from a list of known extensions
38 // - A display filter entry
39 // - Name resolution checkboxes
40 // - Capture file preview information
41 // Ideally we should provide similar functionality here.
43 // You can subclass QFileDialog (which we've done here) and add widgets as
46 // https://web.archive.org/web/20100528190736/http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
48 // However, Qt's idea of what a file dialog looks like isn't what Microsoft
49 // and Apple think a file dialog looks like.
51 // On Windows, we should probably use the Common Item Dialog:
53 // https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog
55 // We currently use GetOpenFileNam in ui/win32/file_dlg_win32.c.
57 // On macOS we should use NSOpenPanel and NSSavePanel:
59 // https://developer.apple.com/documentation/appkit/nsopenpanel?language=objc
60 // https://developer.apple.com/documentation/appkit/nssavepanel?language=objc
62 // On other platforms we should fall back to QFileDialog (or maybe
63 // KDE's or GTK+/GNOME's file dialog, as appropriate for the desktop
64 // environment being used, if QFileDialog doesn't do so with various
67 // Yes, that's four implementations of the same window.
69 // If a plain native open file dialog is good enough we can just the static
70 // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
71 // "explicit" below has the same effect.)
75 explicit CaptureFileDialog(QWidget
*parent
= NULL
, capture_file
*cf
= NULL
);
76 static check_savability_t
checkSaveAsWithComments(QWidget
*
77 , capture_file
*cf
, int file_type
);
80 int selectedFileType();
81 wtap_compression_type
compressionType();
84 capture_file
*cap_file_
;
86 void addMergeControls(QVBoxLayout
&v_box
);
87 void addFormatTypeSelector(QVBoxLayout
&v_box
);
88 void addDisplayFilterEdit(QString
&display_filter
);
89 void addPreview(QVBoxLayout
&v_box
);
90 QString
fileExtensionType(int et
, bool extension_globs
= true);
91 QString
fileType(int ft
, QStringList
&suffixes
);
92 QStringList
buildFileOpenTypeList(void);
94 QVBoxLayout left_v_box_
;
95 QVBoxLayout right_v_box_
;
97 DisplayFilterEdit
* display_filter_edit_
;
100 QLabel preview_format_
;
101 QLabel preview_size_
;
102 QLabel preview_first_elapsed_
;
103 QList
<QLabel
*> preview_labels_
;
105 QRadioButton merge_prepend_
;
106 QRadioButton merge_chrono_
;
107 QRadioButton merge_append_
;
109 QComboBox format_type_
;
110 QHash
<QString
, int> type_hash_
;
111 QHash
<QString
, QStringList
> type_suffixes_
;
113 void addGzipControls(QVBoxLayout
&v_box
);
114 void addRangeControls(QVBoxLayout
&v_box
, packet_range_t
*range
, QString selRange
= QString());
115 QDialogButtonBox
*addHelpButton(topic_action_e help_topic
);
117 QStringList
buildFileSaveAsTypeList(bool must_support_comments
);
121 CompressionGroupBox compress_group_box_
;
123 PacketRangeGroupBox packet_range_group_box_
;
124 QPushButton
*save_bt_
;
125 topic_action_e help_topic_
;
131 void accept() Q_DECL_OVERRIDE
;
132 int exec() Q_DECL_OVERRIDE
;
133 int open(QString
&file_name
, unsigned int &type
, QString
&display_filter
);
134 check_savability_t
saveAs(QString
&file_name
, bool must_support_comments
);
135 check_savability_t
exportSelectedPackets(QString
&file_name
, packet_range_t
*range
, QString selRange
= QString());
136 int merge(QString
&file_name
, QString
&display_filter
);
139 void fixFilenameExtension();
140 void preview(const QString
& path
);
141 void on_buttonBox_helpRequested();
144 #endif // CAPTURE_FILE_DIALOG_H