Wireshark 4.7.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
19class GeometryStateDialog : public QDialog
20{
21public:
22
23// As discussed in change 7072, QDialogs have different minimize and "on
24// top" behaviors depending on their parents, flags, and platforms.
25//
26// W = Windows, L = Linux (and other non-macOS UN*Xes), X = macOS
27//
28// QDialog(parent)
29//
30// W,L: Always on top, no minimize button.
31// X: Independent, no minimize button.
32//
33// QDialog(parent, Qt::Window)
34//
35// W: Always on top, minimize button. Minimizes to a small title bar
36// attached to the taskbar and not the taskbar itself. (The GTK+
37// UI used to do this.)
38// L: Always on top, minimize button.
39// X: Independent, minimize button.
40//
41// QDialog(NULL)
42//
43// W, L, X: Independent, no minimize button.
44//
45// QDialog(NULL, Qt::Window)
46//
47// W, L, X: Independent, minimize button.
48//
49// Additionally, maximized, parent-less dialogs can close to a black screen
50// on macOS: https://gitlab.com/wireshark/wireshark/-/issues/12544
51// (aka https://bugreports.qt.io/browse/QTBUG-46701 ), which claims to
52// be fixed in Qt 6.2.0
53//
54// Pass in the parent on macOS and NULL elsewhere so that we have an
55// independent window that un-maximizes correctly.
56//
57// Pass Qt::Window as the flags that we have minimize and maximize buttons, as
58// this class is for dialogs where we want to remember user-set geometry.
59// (We're still at the mercy of the platform and Qt, e.g. recent GNOME defaults
60// to not having min or max buttons, instead requiring right-clicking on the
61// menu title bar to perform the minimize or maximize actions. We can't do
62// anything about that, though users can.)
63//
64// However, we want modal dialogs to always be on top of their parent.
65// On Linux with Mutter (and maybe some other window managers), an orphan
66// ApplicationModal dialog is not always on top, and it's confusing if a
67// modal dialog is behind other windows it blocks (Issue #19099). On Windows,
68// a modal orphan dialog is always on top, but setting the parent adds effects
69// like causing the modal dialog to shake if the blocked parent is clicked.
70// So when setting the dialog modal, set the parent if we haven't yet.
71
72#ifdef Q_OS_MAC
81 explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = Qt::Window) : QDialog(parent, f) {}
82#else
91 explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = Qt::Window) : QDialog(NULL, f), parent_(parent) {}
92#endif
97
98#ifndef Q_OS_MAC
99public:
104 void setWindowModality(Qt::WindowModality windowModality);
105#endif
106
107protected:
114 void loadGeometry(int width = 0, int height = 0, const QString &dialog_name = QString());
119 void loadSplitterState(QSplitter *splitter = nullptr);
120
121private:
125 void saveWindowGeometry();
130 void saveSplitterState(const QSplitter *splitter = nullptr);
131
133 QString dialog_name_;
134#ifndef Q_OS_MAC
135 QWidget *parent_;
136#endif
137};
138
139#endif // GEOMETRY_STATE_DIALOG_H
A dialog that remembers its geometry and splitter state.
Definition geometry_state_dialog.h:20
void loadGeometry(int width=0, int height=0, const QString &dialog_name=QString())
Loads the geometry and splitter state for the dialog.
Definition geometry_state_dialog.cpp:21
void setWindowModality(Qt::WindowModality windowModality)
Sets the window modality for the dialog. On non-macOS platforms, this also sets the parent to ensure ...
Definition geometry_state_dialog.cpp:59
~GeometryStateDialog()
Save the geometry and splitter state and then destroy the GeometryStateDialog.
Definition geometry_state_dialog.cpp:15
void loadSplitterState(QSplitter *splitter=nullptr)
Loads the state of a splitter for the dialog.
Definition geometry_state_dialog.cpp:72
GeometryStateDialog(QWidget *parent, Qt::WindowFlags f=Qt::Window)
Constructs a new GeometryStateDialog with the specified parent and window flags.
Definition geometry_state_dialog.h:91