aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/capture_file_dialog.cpp12
-rw-r--r--ui/qt/capture_file_dialog.h5
-rw-r--r--ui/qt/export_dissection_dialog.cpp4
-rw-r--r--ui/qt/export_dissection_dialog.h4
-rw-r--r--ui/qt/widgets/wireshark_file_dialog.cpp26
-rw-r--r--ui/qt/widgets/wireshark_file_dialog.h1
6 files changed, 40 insertions, 12 deletions
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index 6bdc06e5c8..99cbac9520 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -45,7 +45,7 @@
#include <wireshark_application.h>
CaptureFileDialog::CaptureFileDialog(QWidget *parent, capture_file *cf, QString &display_filter) :
- QFileDialog(parent),
+ WiresharkFileDialog(parent),
cap_file_(cf),
display_filter_(display_filter),
#if !defined(Q_OS_WIN)
@@ -236,7 +236,7 @@ void CaptureFileDialog::accept()
setFocus();
fixFilenameExtension();
}
- QFileDialog::accept();
+ WiresharkFileDialog::accept();
}
#endif // ! Q_OS_WIN
@@ -687,7 +687,7 @@ int CaptureFileDialog::open(QString &file_name, unsigned int &type) {
selectFile(file_name);
}
- if (QFileDialog::exec() && selectedFiles().length() > 0) {
+ if (WiresharkFileDialog::exec() && selectedFiles().length() > 0) {
file_name = selectedFiles()[0];
type = format_type_.currentIndex();
display_filter_.append(display_filter_edit_->text());
@@ -718,7 +718,7 @@ check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_suppo
}
connect(this, &QFileDialog::filterSelected, this, &CaptureFileDialog::fixFilenameExtension);
- if (QFileDialog::exec() && selectedFiles().length() > 0) {
+ if (WiresharkFileDialog::exec() && selectedFiles().length() > 0) {
file_name = selectedFiles()[0];
return checkSaveAsWithComments(this, cap_file_, selectedFileType());
}
@@ -754,7 +754,7 @@ check_savability_t CaptureFileDialog::exportSelectedPackets(QString &file_name,
}
connect(this, &QFileDialog::filterSelected, this, &CaptureFileDialog::fixFilenameExtension);
- if (QFileDialog::exec() && selectedFiles().length() > 0) {
+ if (WiresharkFileDialog::exec() && selectedFiles().length() > 0) {
file_name = selectedFiles()[0];
return checkSaveAsWithComments(this, cap_file_, selectedFileType());
}
@@ -777,7 +777,7 @@ int CaptureFileDialog::merge(QString &file_name) {
// Grow the dialog to account for the extra widgets.
resize(width(), height() + right_v_box_.minimumSize().height() + display_filter_edit_->minimumSize().height());
- if (QFileDialog::exec() && selectedFiles().length() > 0) {
+ if (WiresharkFileDialog::exec() && selectedFiles().length() > 0) {
file_name.append(selectedFiles()[0]);
display_filter_.append(display_filter_edit_->text());
diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h
index 92cb3f47cf..30bd619cf2 100644
--- a/ui/qt/capture_file_dialog.h
+++ b/ui/qt/capture_file_dialog.h
@@ -10,6 +10,8 @@
#ifndef CAPTURE_FILE_DIALOG_H
#define CAPTURE_FILE_DIALOG_H
+#include <ui/qt/widgets/wireshark_file_dialog.h>
+
#ifndef Q_OS_WIN
#include <ui/qt/widgets/display_filter_edit.h>
#include "packet_range_group_box.h"
@@ -23,7 +25,6 @@
#include "ui/file_dialog.h"
-#include <QFileDialog>
#include <QVBoxLayout>
#include <QLabel>
#include <QRadioButton>
@@ -31,7 +32,7 @@
#include <QDialogButtonBox>
#include <QComboBox>
-class CaptureFileDialog : public QFileDialog
+class CaptureFileDialog : public WiresharkFileDialog
{
// The GTK+ Open Capture File dialog has the following elements and features:
// - The ability to select a capture file from a list of known extensions
diff --git a/ui/qt/export_dissection_dialog.cpp b/ui/qt/export_dissection_dialog.cpp
index 507d4c75e5..4ba50a6f58 100644
--- a/ui/qt/export_dissection_dialog.cpp
+++ b/ui/qt/export_dissection_dialog.cpp
@@ -47,7 +47,7 @@ static const QStringList export_extensions = QStringList()
#endif
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type, QString selRange):
- QFileDialog(parent),
+ WiresharkFileDialog(parent),
export_type_(export_type),
cap_file_(cap_file)
#if !defined(Q_OS_WIN)
@@ -159,7 +159,7 @@ void ExportDissectionDialog::show()
{
#if !defined(Q_OS_WIN)
if (cap_file_) {
- QFileDialog::show();
+ WiresharkFileDialog::show();
}
#else // Q_OS_WIN
win32_export_file((HWND)parentWidget()->effectiveWinId(), cap_file_, export_type_);
diff --git a/ui/qt/export_dissection_dialog.h b/ui/qt/export_dissection_dialog.h
index 17f5bea990..0911e5b3a4 100644
--- a/ui/qt/export_dissection_dialog.h
+++ b/ui/qt/export_dissection_dialog.h
@@ -18,16 +18,16 @@
#include "epan/print.h"
#include "ui/file_dialog.h"
+#include <ui/qt/widgets/wireshark_file_dialog.h>
#ifndef Q_OS_WIN
#include "packet_range_group_box.h"
#include "packet_format_group_box.h"
#endif // Q_OS_WIN
-#include <QFileDialog>
#include <QMap>
-class ExportDissectionDialog : public QFileDialog
+class ExportDissectionDialog : public WiresharkFileDialog
{
Q_OBJECT
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
diff --git a/ui/qt/widgets/wireshark_file_dialog.h b/ui/qt/widgets/wireshark_file_dialog.h
index 29aa4544e8..9dd0e57c65 100644
--- a/ui/qt/widgets/wireshark_file_dialog.h
+++ b/ui/qt/widgets/wireshark_file_dialog.h
@@ -29,6 +29,7 @@
class WiresharkFileDialog : public QFileDialog
{
public:
+ WiresharkFileDialog(QWidget *parent = nullptr, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString());
static QString getExistingDirectory(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QString &dir = QString(), Options options = ShowDirsOnly);
static QString getOpenFileName(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = Q_NULLPTR, Options options = Options());
static QString getSaveFileName(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = Q_NULLPTR, Options options = Options());