diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-04-28 13:15:36 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-05-01 10:24:07 +0000 |
commit | 552ef8b1f4bc5ced263c82253ed21793ca8e5d5e (patch) | |
tree | ab6e44f9cae1f299266e2000bd7ff9d5e5fc1659 /ui/qt/capture_file_dialog.h | |
parent | 6e4caf3d90862c36c451f48abe7533fa92ecf58b (diff) |
Qt: improve extension selection in Save As dialog
The default Qt behavior for extension adjustment is quite bad. When the
file type filter is changed, the extension always becomes "gz" because
"pcap.gz" happens to be the first extension in the list. It also did not
check that the last suffix is actually a valid extension (e.g.
"capture.2018.01" became "capture.2018.gz").
Improvements:
- Respect the "compression" checkbox when adjusting the filename.
- Replace the extension only if it is a known one, append otherwise.
- Use a better default extension (from "wtap_default_file_extension").
Affects only macOS and Linux since Windows has its own native dialog.
See also https://bugreports.qt.io/browse/QTBUG-67993
Bug: 14600
Change-Id: I8cd0788f2abac0c6d7e29490b1ebb381f5a926d0
Reviewed-on: https://code.wireshark.org/review/27186
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/capture_file_dialog.h')
-rw-r--r-- | ui/qt/capture_file_dialog.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h index 1bbf23fa12..72c144de03 100644 --- a/ui/qt/capture_file_dialog.h +++ b/ui/qt/capture_file_dialog.h @@ -80,7 +80,7 @@ private: void addDisplayFilterEdit(); void addPreview(QVBoxLayout &v_box); QString fileExtensionType(int et, bool extension_globs = true); - QString fileType(int ft, bool extension_globs = true); + QString fileType(int ft, QStringList &suffixes); QStringList buildFileOpenTypeList(void); QVBoxLayout left_v_box_; @@ -99,7 +99,8 @@ private: QRadioButton merge_append_; QComboBox format_type_; - QHash<QString, int>type_hash_; + QHash<QString, int> type_hash_; + QHash<QString, QStringList> type_suffixes_; void addGzipControls(QVBoxLayout &v_box); void addRangeControls(QVBoxLayout &v_box, packet_range_t *range); @@ -133,6 +134,7 @@ public slots: private slots: #if !defined(Q_OS_WIN) + void fixFilenameExtension(); void preview(const QString & path); void on_buttonBox_helpRequested(); #endif // Q_OS_WIN |