1 /* wireshark_file_dialog.h 2 * 3 * Wireshark - Network traffic analyzer 4 * By Gerald Combs <gerald@wireshark.org> 5 * Copyright 1998 Gerald Combs 6 * 7 * SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 10 #ifndef WIRESHARK_FILE_DIALOG_H 11 #define WIRESHARK_FILE_DIALOG_H 12 13 #include <QFileDialog> 14 15 /** 16 * @brief The WiresharkFileDialog class 17 * 18 * Qt <= 5.9 supports setting old (Windows 8.1) per-monitor DPI awareness 19 * via Qt:AA_EnableHighDpiScaling. We do this in main.cpp. In order for 20 * native dialogs to be rendered correctly we need to to set per-monitor 21 * *v2* awareness prior to creating the dialog. 22 * Qt doesn't render correctly when per-monitor v2 awareness is enabled, so 23 * we need to revert our thread context when we're done. 24 * The class functions below are simple wrappers around their QFileDialog 25 * equivalents that set PMv2 awareness before showing native dialogs on 26 * Windows and resets it afterward. 27 */ 28 29 class WiresharkFileDialog : public QFileDialog 30 { 31 public: 32 WiresharkFileDialog(QWidget *parent = nullptr, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString()); 33 static QString getExistingDirectory(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QString &dir = QString(), Options options = ShowDirsOnly); 34 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()); 35 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()); 36 }; 37 38 #endif // WIRESHARK_FILE_DIALOG_H 39