Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
geometry_state_dialog.h
Go to the documentation of this file.
1
10#ifndef GEOMETRY_STATE_DIALOG_H
11#define GEOMETRY_STATE_DIALOG_H
12
13#include <QDialog>
14#include <QSplitter>
15
16class GeometryStateDialog : public QDialog
17{
18public:
19
20// As discussed in change 7072, QDialogs have different minimize and "on
21// top" behaviors depending on their parents, flags, and platforms.
22//
23// W = Windows, L = Linux (and other non-macOS UN*Xes), X = macOS
24//
25// QDialog(parent)
26//
27// W,L: Always on top, no minimize button.
28// X: Independent, no minimize button.
29//
30// QDialog(parent, Qt::Window)
31//
32// W: Always on top, minimize button. Minimizes to a small title bar
33// attached to the taskbar and not the taskbar itself. (The GTK+
34// UI used to do this.)
35// L: Always on top, minimize button.
36// X: Independent, minimize button.
37//
38// QDialog(NULL)
39//
40// W, L, X: Independent, no minimize button.
41//
42// QDialog(NULL, Qt::Window)
43//
44// W, L, X: Independent, minimize button.
45//
46// Additionally, maximized, parent-less dialogs can close to a black screen
47// on macOS: https://gitlab.com/wireshark/wireshark/-/issues/12544
48// (aka https://bugreports.qt.io/browse/QTBUG-46701 ), which claims to
49// be fixed in Qt 6.2.0
50//
51// Pass in the parent on macOS and NULL elsewhere so that we have an
52// independent window that un-maximizes correctly.
53//
54// Pass Qt::Window as the flags that we have minimize and maximize buttons, as
55// this class is for dialogs where we want to remember user-set geometry.
56// (We're still at the mercy of the platform and Qt, e.g. recent GNOME defaults
57// to not having min or max buttons, instead requiring right-clicking on the
58// menu title bar to perform the minimize or maximize actions. We can't do
59// anything about that, though users can.)
60//
61// However, we want modal dialogs to always be on top of their parent.
62// On Linux with Mutter (and maybe some other window managers), an orphan
63// ApplicationModal dialog is not always on top, and it's confusing if a
64// modal dialog is behind other windows it blocks (Issue #19099). On Windows,
65// a modal orphan dialog is always on top, but setting the parent adds effects
66// like causing the modal dialog to shake if the blocked parent is clicked.
67// So when setting the dialog modal, set the parent if we haven't yet.
68
69#ifdef Q_OS_MAC
70 explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = Qt::Window) : QDialog(parent, f) {}
71#else
72 explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = Qt::Window) : QDialog(NULL, f), parent_(parent) {}
73#endif
75
76#ifndef Q_OS_MAC
77public:
78 void setWindowModality(Qt::WindowModality windowModality);
79#endif
80
81protected:
82 void loadGeometry(int width = 0, int height = 0, const QString &dialog_name = QString());
83 void loadSplitterState(QSplitter *splitter = nullptr);
84
85private:
86 void saveWindowGeometry();
87 void saveSplitterState(const QSplitter *splitter = nullptr);
88
89 QString dialog_name_;
90#ifndef Q_OS_MAC
91 QWidget *parent_;
92#endif
93};
94
95#endif // GEOMETRY_STATE_DIALOG_H
Definition geometry_state_dialog.h:17