Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
WiresharkFileDialog Class Reference

The WiresharkFileDialog class. More...

#include <wireshark_file_dialog.h>

Inheritance diagram for WiresharkFileDialog:
CaptureFileDialog ExportDissectionDialog

Public Member Functions

 WiresharkFileDialog (QWidget *parent=nullptr, const QString &caption=QString(), const QString &directory=QString(), const QString &filter=QString())
 Constructs a Wireshark file dialog.
 
QString selectedNativePath () const
 Returns the selected file path in native OS format.
 

Static Public Member Functions

static QString getExistingDirectory (QWidget *parent=Q_NULLPTR, const QString &caption=QString(), const QString &dir=QString(), Options options=ShowDirsOnly)
 Presents a directory chooser dialog and returns the selected path.
 
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())
 Presents an open-file dialog and returns the selected file path.
 
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())
 Presents a save-file dialog and returns the chosen file path.
 

Detailed Description

The WiresharkFileDialog class.

Qt uses '/' as a universal path separator and converts to native path separators, i.e., '\' on Windows, only immediately before displaying a path to a user. This class can return the path with native path separators.

Qt <= 5.9 supports setting old (Windows 8.1) per-monitor DPI awareness via Qt:AA_EnableHighDpiScaling. We do this in main.cpp. In order for native dialogs to be rendered correctly we need to set per-monitor v2 awareness prior to creating the dialog. Qt doesn't render correctly when per-monitor v2 awareness is enabled, so we need to revert our thread context when we're done. The class functions below are simple wrappers around their QFileDialog equivalents that set PMv2 awareness before showing native dialogs on Windows and resets it afterward. They also return the result with native directory separators on Windows.

Constructor & Destructor Documentation

◆ WiresharkFileDialog()

WiresharkFileDialog::WiresharkFileDialog ( QWidget *  parent = nullptr,
const QString &  caption = QString(),
const QString &  directory = QString(),
const QString &  filter = QString() 
)

Constructs a Wireshark file dialog.

Parameters
parentThe parent widget.
captionThe dialog window title.
directoryThe initial directory shown in the dialog.
filterThe file type filter string (e.g. "Captures (*.pcap *.pcapng)").

Member Function Documentation

◆ getExistingDirectory()

QString WiresharkFileDialog::getExistingDirectory ( QWidget *  parent = Q_NULLPTR,
const QString &  caption = QString(),
const QString &  dir = QString(),
Options  options = ShowDirsOnly 
)
static

Presents a directory chooser dialog and returns the selected path.

Parameters
parentThe parent widget.
captionThe dialog window title.
dirThe initial directory to display.
optionsDialog behavior options (default: ShowDirsOnly).
Returns
The chosen directory path in native format, or an empty string if cancelled.

◆ getOpenFileName()

QString WiresharkFileDialog::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

Presents an open-file dialog and returns the selected file path.

Parameters
parentThe parent widget.
captionThe dialog window title.
dirThe initial directory to display.
filterThe file type filter string.
selectedFilterIf non-null, receives the filter the user selected.
optionsDialog behavior options.
Returns
The chosen file path in native format, or an empty string if cancelled.

◆ getSaveFileName()

QString WiresharkFileDialog::getSaveFileName ( QWidget *  parent = Q_NULLPTR,
const QString &  caption = QString(),
const QString &  dir = QString(),
const QString &  filter = QString(),
QString *  selectedFilter = Q_NULLPTR,
Options  options = Options() 
)
static

Presents a save-file dialog and returns the chosen file path.

Parameters
parentThe parent widget.
captionThe dialog window title.
dirThe initial directory to display.
filterThe file type filter string.
selectedFilterIf non-null, receives the filter the user selected.
optionsDialog behavior options.
Returns
The chosen file path in native format, or an empty string if cancelled.

◆ selectedNativePath()

QString WiresharkFileDialog::selectedNativePath ( ) const

Returns the selected file path in native OS format.

Returns
The selected path with native directory separators.

The documentation for this class was generated from the following files: