Make show() default to sane sizing behaviour based on the platform.
authorSamuel Rødal <samuel.rodal@nokia.com>
Wed, 11 Jan 2012 07:31:00 +0000 (08:31 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Jan 2012 09:19:49 +0000 (10:19 +0100)
Traditionally it's been hard to write a Qt app that behaves sanely
across embedded and desktop platforms, i.e. defaults to fullscreen on
embedded and non-fullscreen on desktop. For Qt 5 we can fix this by
making the behaviour of the default QWindow::show() be customizable by
the platform plugin.

If the application developer wants to override this behaviour he can
still use the explicit showFullScreen(), showNormal() etc functions.

Change-Id: I26a907b404058e345d841c818daefbb57a26d3fd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
src/gui/kernel/qplatformintegration_qpa.cpp
src/gui/kernel/qplatformintegration_qpa.h
src/gui/kernel/qstylehints.cpp
src/gui/kernel/qstylehints.h
src/gui/kernel/qwindow.cpp
src/gui/kernel/qwindow.h
src/plugins/platforms/eglfs/qeglfsintegration.cpp
src/plugins/platforms/eglfs/qeglfsintegration.h

index 35cb9a1..b35af1e 100644 (file)
@@ -235,6 +235,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
         return 10;
     case StartDragTime:
         return 500;
+    case ShowIsFullScreen:
+        return false;
     }
 
     return 0;
index f9a8a20..3975d82 100644 (file)
@@ -107,7 +107,8 @@ public:
         MouseDoubleClickInterval,
         StartDragDistance,
         StartDragTime,
-        KeyboardAutoRepeatRate
+        KeyboardAutoRepeatRate,
+        ShowIsFullScreen
     };
 
     virtual QVariant styleHint(StyleHint hint) const;
index 4218477..eb0f055 100644 (file)
@@ -86,4 +86,9 @@ int QStyleHints::cursorFlashTime() const
     return hint(QPlatformIntegration::CursorFlashTime).toInt();
 }
 
+bool QStyleHints::showIsFullScreen() const
+{
+    return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
+}
+
 QT_END_NAMESPACE
index d4e0415..6fa7211 100644 (file)
@@ -62,6 +62,7 @@ public:
     int keyboardInputInterval() const;
     int keyboardAutoRepeatRate() const;
     int cursorFlashTime() const;
+    bool showIsFullScreen() const;
 private:
     friend class QGuiApplication;
     QStyleHints();
index 2e724e1..0d08316 100644 (file)
@@ -54,6 +54,8 @@
 
 #include <QtCore/QDebug>
 
+#include <QStyleHints>
+
 QT_BEGIN_NAMESPACE
 
 /*!
@@ -741,30 +743,42 @@ QObject *QWindow::focusObject() const
     return const_cast<QWindow *>(this);
 }
 
+void QWindow::show()
+{
+    if (qApp->styleHints()->showIsFullScreen())
+        showFullScreen();
+    else
+        showNormal();
+}
+
+void QWindow::hide()
+{
+    setVisible(false);
+}
 
 void QWindow::showMinimized()
 {
     setWindowState(Qt::WindowMinimized);
-    show();
+    setVisible(true);
 }
 
 void QWindow::showMaximized()
 {
     setWindowState(Qt::WindowMaximized);
-    show();
+    setVisible(true);
 }
 
 void QWindow::showFullScreen()
 {
     setWindowState(Qt::WindowFullScreen);
-    show();
+    setVisible(true);
     requestActivateWindow();
 }
 
 void QWindow::showNormal()
 {
     setWindowState(Qt::WindowNoState);
-    show();
+    setVisible(true);
 }
 
 bool QWindow::close()
index 6f9e485..4d16165 100644 (file)
@@ -209,8 +209,8 @@ public:
 public Q_SLOTS:
     void setVisible(bool visible);
 
-    inline void show() { setVisible(true); }
-    inline void hide() { setVisible(false); }
+    void show();
+    void hide();
 
     void showMinimized();
     void showMaximized();
index 12d196f..47d5bd4 100644 (file)
@@ -110,4 +110,12 @@ QAbstractEventDispatcher *QEglFSIntegration::guiThreadEventDispatcher() const
     return createUnixEventDispatcher();
 }
 
+QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
+{
+    if (hint == QPlatformIntegration::ShowIsFullScreen)
+        return true;
+
+    return QPlatformIntegration::styleHint(hint);
+}
+
 QT_END_NAMESPACE
index 997ed3a..58af146 100644 (file)
@@ -66,6 +66,8 @@ public:
 
     QAbstractEventDispatcher *guiThreadEventDispatcher() const;
 
+    QVariant styleHint(QPlatformIntegration::StyleHint hint) const;
+
 private:
     QPlatformFontDatabase *mFontDb;
 };