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 <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2016-06-24 10:52:44 -07:00 committed by Anders Broman
parent 974a530f8e
commit 291762d0af
4 changed files with 40 additions and 11 deletions

View File

@ -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();

View File

@ -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:

View File

@ -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),

View File

@ -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: