Wireshark  4.3.0
The Wireshark network protocol analyzer
capture_file_dialog.h
Go to the documentation of this file.
1 
10 #ifndef CAPTURE_FILE_DIALOG_H
11 #define CAPTURE_FILE_DIALOG_H
12 
14 
16 #include "packet_range_group_box.h"
17 #include "ui/help_url.h"
18 
19 #include <ui/packet_range.h>
20 
22 #include "cfile.h"
23 
24 #include "ui/file_dialog.h"
25 
26 #include <QVBoxLayout>
27 #include <QLabel>
28 #include <QRadioButton>
29 #include <QCheckBox>
30 #include <QDialogButtonBox>
31 #include <QComboBox>
32 
34 {
35  // The GTK+ Open Capture File dialog has the following elements and features:
36  // - The ability to select a capture file from a list of known extensions
37  // - A display filter entry
38  // - Name resolution checkboxes
39  // - Capture file preview information
40  // Ideally we should provide similar functionality here.
41  //
42  // You can subclass QFileDialog (which we've done here) and add widgets as
43  // described at
44  //
45  // https://web.archive.org/web/20100528190736/http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
46  //
47  // However, Qt's idea of what a file dialog looks like isn't what Microsoft
48  // and Apple think a file dialog looks like.
49  //
50  // On Windows, we should probably use the Common Item Dialog:
51  //
52  // https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog
53  //
54  // We currently use GetOpenFileNam in ui/win32/file_dlg_win32.c.
55  //
56  // On macOS we should use NSOpenPanel and NSSavePanel:
57  //
58  // https://developer.apple.com/documentation/appkit/nsopenpanel?language=objc
59  // https://developer.apple.com/documentation/appkit/nssavepanel?language=objc
60  //
61  // On other platforms we should fall back to QFileDialog (or maybe
62  // KDE's or GTK+/GNOME's file dialog, as appropriate for the desktop
63  // environment being used, if QFileDialog doesn't do so with various
64  // platform plugins).
65  //
66  // Yes, that's four implementations of the same window.
67  //
68  // If a plain native open file dialog is good enough we can just the static
69  // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
70  // "explicit" below has the same effect.)
71 
72  Q_OBJECT
73 public:
74  explicit CaptureFileDialog(QWidget *parent = NULL, capture_file *cf = NULL);
75  static check_savability_t checkSaveAsWithComments(QWidget *
76  , capture_file *cf, int file_type);
77 
78  int mergeType();
79  int selectedFileType();
80  wtap_compression_type compressionType();
81 
82 private:
83  capture_file *cap_file_;
84 
85  void addMergeControls(QVBoxLayout &v_box);
86  void addFormatTypeSelector(QVBoxLayout &v_box);
87  void addDisplayFilterEdit(QString &display_filter);
88  void addPreview(QVBoxLayout &v_box);
89  QString fileExtensionType(int et, bool extension_globs = true);
90  QString fileType(int ft, QStringList &suffixes);
91  QStringList buildFileOpenTypeList(void);
92 
93  QVBoxLayout left_v_box_;
94  QVBoxLayout right_v_box_;
95 
96  DisplayFilterEdit* display_filter_edit_;
97  int last_row_;
98 
99  QLabel preview_format_;
100  QLabel preview_size_;
101  QLabel preview_first_elapsed_;
102  QList<QLabel *> preview_labels_;
103 
104  QRadioButton merge_prepend_;
105  QRadioButton merge_chrono_;
106  QRadioButton merge_append_;
107 
108  QComboBox format_type_;
109  QHash<QString, int> type_hash_;
110  QHash<QString, QStringList> type_suffixes_;
111 
112  void addGzipControls(QVBoxLayout &v_box);
113  void addRangeControls(QVBoxLayout &v_box, packet_range_t *range, QString selRange = QString());
114  QDialogButtonBox *addHelpButton(topic_action_e help_topic);
115 
116  QStringList buildFileSaveAsTypeList(bool must_support_comments);
117 
118  int default_ft_;
119 
120  QCheckBox compress_;
121 
122  PacketRangeGroupBox packet_range_group_box_;
123  QPushButton *save_bt_;
124  topic_action_e help_topic_;
125 
126 signals:
127 
128 public slots:
129 
130  void accept() Q_DECL_OVERRIDE;
131  int exec() Q_DECL_OVERRIDE;
132  int open(QString &file_name, unsigned int &type, QString &display_filter);
133  check_savability_t saveAs(QString &file_name, bool must_support_comments);
134  check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange = QString());
135  int merge(QString &file_name, QString &display_filter);
136 
137 private slots:
138  void fixFilenameExtension();
139  void preview(const QString & path);
140  void on_buttonBox_helpRequested();
141 };
142 
143 #endif // CAPTURE_FILE_DIALOG_H
Definition: capture_file_dialog.h:34
Definition: display_filter_edit.h:28
Definition: packet_range_group_box.h:29
The WiresharkFileDialog class.
Definition: wireshark_file_dialog.h:36
Definition: cfile.h:67
Definition: packet_range.h:39