diff options
author | Gerald Combs <gerald@wireshark.org> | 2019-11-24 17:32:06 -0600 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-11-26 05:37:37 +0000 |
commit | f2dce23b408e277d5a2a243516fa267fe756ba53 (patch) | |
tree | 3bb38e4be02f02c67ab8adefdcc0b45be1e52d9e /ui/qt/widgets/wireshark_file_dialog.cpp | |
parent | 69201185adfc0359abe08f6ed6befbea93c63f94 (diff) |
Qt+macOS: Add /Volumes to the file dialog sidebar.
/Volumes is hidden on macOS, which means that it doesn't show up in Qt's
non-native file dialog. Add a constructor to WiresharkFileDialog that
adds /Volumes to the file dialog sidebar. Make CaptureFileDialog and
ExportDissectionDialog subclasses of WiresharkFileDialog.
Bug: 13840
Change-Id: I4d7da3948b203eb11fb64fa056eb42a448edf914
Reviewed-on: https://code.wireshark.org/review/35201
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/widgets/wireshark_file_dialog.cpp')
-rw-r--r-- | ui/qt/widgets/wireshark_file_dialog.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ui/qt/widgets/wireshark_file_dialog.cpp b/ui/qt/widgets/wireshark_file_dialog.cpp index 41defb905e..71410ebc3d 100644 --- a/ui/qt/widgets/wireshark_file_dialog.cpp +++ b/ui/qt/widgets/wireshark_file_dialog.cpp @@ -15,6 +15,32 @@ #include "ui/win32/file_dlg_win32.h" #endif // Q_OS_WIN + +WiresharkFileDialog::WiresharkFileDialog(QWidget *parent, const QString &caption, const QString &directory, const QString &filter) : + QFileDialog(parent, caption, directory, filter) +{ +#ifdef Q_OS_MAC + // Add /Volumes to the sidebar. We might want to call + // setFilter(QDir::Hidden | QDir::AllEntries) in addition to or instead + // of this as recommended in QTBUG-6805 and QTBUG-6875, but you can + // access hidden files in the Qt file dialog by right-clicking on the + // file list or simply typing in the path in the "File name:" entry. + + QList<QUrl> sb_urls = sidebarUrls(); + bool have_volumes = false; + QString volumes = "/Volumes"; + foreach (QUrl sbu, sb_urls) { + if (sbu.toLocalFile() == volumes) { + have_volumes = true; + } + } + if (! have_volumes) { + sb_urls << QUrl::fromLocalFile(volumes); + setSidebarUrls(sb_urls); + } +#endif +} + QString WiresharkFileDialog::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, Options options) { #ifdef Q_OS_WIN |