summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-01-11 08:31:00 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-12 10:19:49 +0100
commit8ff37ff535318331f0179cdf0d2f6319cd7ae1c2 (patch)
tree640cd1a229f497624a4fc49bc24843ef2341fd35 /src/gui/kernel
parentbffbcfd0ccc863884701e79a260b1b05f9dc8bb0 (diff)
Make show() default to sane sizing behaviour based on the platform.
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>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h3
-rw-r--r--src/gui/kernel/qstylehints.cpp5
-rw-r--r--src/gui/kernel/qstylehints.h1
-rw-r--r--src/gui/kernel/qwindow.cpp22
-rw-r--r--src/gui/kernel/qwindow.h4
6 files changed, 30 insertions, 7 deletions
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index 35cb9a160d..b35af1e8b7 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -235,6 +235,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return 10;
case StartDragTime:
return 500;
+ case ShowIsFullScreen:
+ return false;
}
return 0;
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index f9a8a206a8..3975d82288 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -107,7 +107,8 @@ public:
MouseDoubleClickInterval,
StartDragDistance,
StartDragTime,
- KeyboardAutoRepeatRate
+ KeyboardAutoRepeatRate,
+ ShowIsFullScreen
};
virtual QVariant styleHint(StyleHint hint) const;
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index 4218477aac..eb0f055270 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -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
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index d4e0415ba4..6fa72110fb 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -62,6 +62,7 @@ public:
int keyboardInputInterval() const;
int keyboardAutoRepeatRate() const;
int cursorFlashTime() const;
+ bool showIsFullScreen() const;
private:
friend class QGuiApplication;
QStyleHints();
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 2e724e1b3c..0d08316945 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -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()
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 6f9e4855b1..4d161658c6 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -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();