From 291762d0af8cd49a19c6fc73fce317ee20816a17 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 24 Jun 2016 10:52:44 -0700 Subject: [PATCH] Qt: Try to fix un-maximize behavior on OS X. On OS X, create dialogs with valid parents so that we don't trigger QTBUG-46701. Document QDialog's "on top", maximize, and minimize behaviors. Bug: 12544 Change-Id: I32c0ef01dba3f7132e5fd0cd61f9feb654b92009 Reviewed-on: https://code.wireshark.org/review/16127 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/geometry_state_dialog.cpp | 7 ------ ui/qt/geometry_state_dialog.h | 38 ++++++++++++++++++++++++++++++++- ui/qt/wireshark_dialog.cpp | 4 ++-- ui/qt/wireshark_dialog.h | 2 +- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ui/qt/geometry_state_dialog.cpp b/ui/qt/geometry_state_dialog.cpp index 95469ae4a8..a934a4e10f 100644 --- a/ui/qt/geometry_state_dialog.cpp +++ b/ui/qt/geometry_state_dialog.cpp @@ -24,13 +24,6 @@ #include "ui/recent.h" #include "ui/ui_util.h" - -GeometryStateDialog::GeometryStateDialog(QWidget *parent, Qt::WindowFlags f) : - QDialog(parent, f) -{ - -} - GeometryStateDialog::~GeometryStateDialog() { saveGeometry(); diff --git a/ui/qt/geometry_state_dialog.h b/ui/qt/geometry_state_dialog.h index 24b2de4a93..28ef1c5450 100644 --- a/ui/qt/geometry_state_dialog.h +++ b/ui/qt/geometry_state_dialog.h @@ -29,7 +29,43 @@ class GeometryStateDialog : public QDialog Q_OBJECT public: - explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = 0); + +// As discussed in change 7072, QDialogs have different minimize and "on +// top" behaviors depending on their parents, flags, and platforms. +// +// W = Windows, L = Linux, X = OS X +// +// QDialog(parent) +// +// W,L: Always on top, no minimize button. +// X: Independent, no minimize button. +// +// QDialog(parent, Qt::Window) +// +// W: Always on top, minimize button. Minimizes to a small title bar +// attached to the taskbar and not the taskbar itself. (The GTK+ +// UI used to do this.) +// L: Always on top, minimize button. +// X: Independent, minimize button. +// +// QDialog(NULL) +// +// W, L, X: Independent, no minimize button. +// +// QDialog(NULL, Qt::Window) +// +// W, L, X: Independent, minimize button. +// +// Additionally, maximized, parent-less dialogs can close to a black screen +// on OS X: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=12544 +// +// Pass in the parent on OS X and NULL elsewhere so that we have an +// independent window that un-maximizes correctly. +#ifdef Q_OS_MAC + explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = 0) : QDialog(parent, f) {} +#else + explicit GeometryStateDialog(QWidget *, Qt::WindowFlags f = 0) : QDialog(NULL, f) {} +#endif ~GeometryStateDialog(); protected: diff --git a/ui/qt/wireshark_dialog.cpp b/ui/qt/wireshark_dialog.cpp index ba5cd12bb1..c7d8d5a5f2 100644 --- a/ui/qt/wireshark_dialog.cpp +++ b/ui/qt/wireshark_dialog.cpp @@ -41,8 +41,8 @@ // - Use a dynamic property + Q_PROPERTY for the subtitle. // - Make our nested event loop more robust. See tryDeleteLater for details. -WiresharkDialog::WiresharkDialog(QWidget &, CaptureFile &capture_file) : - GeometryStateDialog(NULL, Qt::Window), +WiresharkDialog::WiresharkDialog(QWidget &parent, CaptureFile &capture_file) : + GeometryStateDialog(&parent, Qt::Window), cap_file_(capture_file), file_closed_(false), retap_depth_(0), diff --git a/ui/qt/wireshark_dialog.h b/ui/qt/wireshark_dialog.h index 9cae588ecf..d9482c7606 100644 --- a/ui/qt/wireshark_dialog.h +++ b/ui/qt/wireshark_dialog.h @@ -47,7 +47,7 @@ class WiresharkDialog : public GeometryStateDialog public: // XXX Unlike the entire QWidget API, parent is mandatory here. - explicit WiresharkDialog(QWidget &, CaptureFile &capture_file); + explicit WiresharkDialog(QWidget &parent, CaptureFile &capture_file); signals: