Wireshark  4.3.0
The Wireshark network protocol analyzer
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 
16 class GeometryStateDialog : public QDialog
17 {
18 public:
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 #ifdef Q_OS_MAC
62  explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = Qt::Window) : QDialog(parent, f) {}
63 #else
64  explicit GeometryStateDialog(QWidget *, Qt::WindowFlags f = Qt::Window) : QDialog(NULL, f) {}
65 #endif
67 
68 protected:
69  void loadGeometry(int width = 0, int height = 0, const QString &dialog_name = QString());
70  void loadSplitterState(QSplitter *splitter = nullptr);
71 
72 private:
73  void saveWindowGeometry();
74  void saveSplitterState(const QSplitter *splitter = nullptr);
75 
76  QString dialog_name_;
77 };
78 
79 #endif // GEOMETRY_STATE_DIALOG_H
Definition: geometry_state_dialog.h:17