Removed requestOrientation() API from QWindow.
There are no proper implementations of this API, and as it stands it only acts to confuse anyone who stumbles across it. It will be better to revisit the full cross platform orientation API story for 5.1. Change-Id: Iff7054a32c6e5e4ad0cc0493a5e4ecc35a6ec4f3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
parent
675676aba1
commit
7da7bbcd87
@ -70,12 +70,10 @@ PaintedWindow::PaintedWindow()
|
|||||||
m_animation->setEndValue(qreal(1));
|
m_animation->setEndValue(qreal(1));
|
||||||
m_animation->setDuration(500);
|
m_animation->setDuration(500);
|
||||||
|
|
||||||
requestOrientation(Qt::PortraitOrientation);
|
|
||||||
|
|
||||||
QRect screenGeometry = screen()->availableGeometry();
|
QRect screenGeometry = screen()->availableGeometry();
|
||||||
|
|
||||||
QPoint center = screenGeometry.center();
|
QPoint center = screenGeometry.center();
|
||||||
QRect windowRect = screen()->isLandscape(orientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640);
|
QRect windowRect = screen()->isLandscape(screen()->orientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640);
|
||||||
setGeometry(QRect(center - windowRect.center(), windowRect.size()));
|
setGeometry(QRect(center - windowRect.center(), windowRect.size()));
|
||||||
|
|
||||||
m_rotation = 0;
|
m_rotation = 0;
|
||||||
@ -142,13 +140,13 @@ void PaintedWindow::orientationChanged(Qt::ScreenOrientation newOrientation)
|
|||||||
|
|
||||||
QPainter p;
|
QPainter p;
|
||||||
p.begin(&m_prevImage);
|
p.begin(&m_prevImage);
|
||||||
p.setTransform(screen()->transformBetween(contentOrientation(), orientation(), rect));
|
p.setTransform(screen()->transformBetween(contentOrientation(), screen()->orientation(), rect));
|
||||||
paint(&p, screen()->mapBetween(contentOrientation(), orientation(), rect));
|
paint(&p, screen()->mapBetween(contentOrientation(), screen()->orientation(), rect));
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
p.begin(&m_nextImage);
|
p.begin(&m_nextImage);
|
||||||
p.setTransform(screen()->transformBetween(newOrientation, orientation(), rect));
|
p.setTransform(screen()->transformBetween(newOrientation, screen()->orientation(), rect));
|
||||||
paint(&p, screen()->mapBetween(newOrientation, orientation(), rect));
|
paint(&p, screen()->mapBetween(newOrientation, screen()->orientation(), rect));
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
m_deltaRotation = screen()->angleBetween(newOrientation, contentOrientation());
|
m_deltaRotation = screen()->angleBetween(newOrientation, contentOrientation());
|
||||||
@ -207,9 +205,9 @@ void PaintedWindow::paint()
|
|||||||
painter.setOpacity(m_rotation);
|
painter.setOpacity(m_rotation);
|
||||||
painter.drawImage(0, 0, m_nextImage);
|
painter.drawImage(0, 0, m_nextImage);
|
||||||
} else {
|
} else {
|
||||||
QRect mapped = screen()->mapBetween(contentOrientation(), orientation(), rect);
|
QRect mapped = screen()->mapBetween(contentOrientation(), screen()->orientation(), rect);
|
||||||
|
|
||||||
painter.setTransform(screen()->transformBetween(contentOrientation(), orientation(), rect));
|
painter.setTransform(screen()->transformBetween(contentOrientation(), screen()->orientation(), rect));
|
||||||
paint(&painter, mapped);
|
paint(&painter, mapped);
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
@ -330,31 +330,6 @@ void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orien
|
|||||||
Q_UNUSED(orientation);
|
Q_UNUSED(orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Request a different orientation of the platform window.
|
|
||||||
|
|
||||||
This tells the window manager how the window wants to be rotated in order
|
|
||||||
to be displayed, and how input events should be translated.
|
|
||||||
|
|
||||||
As an example, a portrait compositor might rotate the window by 90 degrees,
|
|
||||||
if the window is in landscape. It will also rotate input coordinates from
|
|
||||||
portrait to landscape such that top right in portrait gets mapped to top
|
|
||||||
left in landscape.
|
|
||||||
|
|
||||||
If the implementation doesn't support the requested orientation it should
|
|
||||||
signal this by returning an actual supported orientation.
|
|
||||||
|
|
||||||
If the implementation doesn't support rotating the window at all it should
|
|
||||||
return Qt::PrimaryOrientation, this is also the default value.
|
|
||||||
|
|
||||||
\sa QWindow::requestWindowOrientation()
|
|
||||||
*/
|
|
||||||
Qt::ScreenOrientation QPlatformWindow::requestWindowOrientation(Qt::ScreenOrientation orientation)
|
|
||||||
{
|
|
||||||
Q_UNUSED(orientation);
|
|
||||||
return Qt::PrimaryOrientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Reimplement this function in subclass to return the device pixel ratio
|
Reimplement this function in subclass to return the device pixel ratio
|
||||||
for the window. This is the ratio between physical pixels
|
for the window. This is the ratio between physical pixels
|
||||||
|
@ -115,7 +115,6 @@ public:
|
|||||||
virtual void requestActivateWindow();
|
virtual void requestActivateWindow();
|
||||||
|
|
||||||
virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation);
|
virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation);
|
||||||
virtual Qt::ScreenOrientation requestWindowOrientation(Qt::ScreenOrientation orientation);
|
|
||||||
|
|
||||||
virtual qreal devicePixelRatio() const;
|
virtual qreal devicePixelRatio() const;
|
||||||
|
|
||||||
|
@ -89,23 +89,16 @@ QT_BEGIN_NAMESPACE
|
|||||||
buffers to support double and triple buffering, as well as depth and stencil
|
buffers to support double and triple buffering, as well as depth and stencil
|
||||||
buffers. To release a window's memory resources, call the destroy() function.
|
buffers. To release a window's memory resources, call the destroy() function.
|
||||||
|
|
||||||
\section1 Window and content orientation
|
\section1 Content orientation
|
||||||
|
|
||||||
QWindow has reportContentOrientationChange() and
|
QWindow has reportContentOrientationChange() that can be used to specify
|
||||||
requestWindowOrientation() that can be used to specify the
|
the layout of the window contents in relation to the screen. The content
|
||||||
layout of the window contents in relation to the screen. The
|
orientation is simply a hint to the windowing system about which
|
||||||
window orientation determines the actual buffer layout of the
|
orientation the window contents are in. It's useful when you wish to keep
|
||||||
window, and the windowing system uses this value to rotate the
|
the same window size, but rotate the contents instead, especially when
|
||||||
window before it ends up on the display, and to ensure that input
|
doing rotation animations between different orientations. The windowing
|
||||||
coordinates are in the correct coordinate space relative to the
|
system might use this value to determine the layout of system popups or
|
||||||
application.
|
dialogs.
|
||||||
|
|
||||||
On the other hand, the content orientation is simply a hint to the
|
|
||||||
windowing system about which orientation the window contents are in.
|
|
||||||
It's useful when you wish to keep the same buffer layout, but rotate
|
|
||||||
the contents instead, especially when doing rotation animations
|
|
||||||
between different orientations. The windowing system might use this
|
|
||||||
value to determine the layout of system popups or dialogs.
|
|
||||||
|
|
||||||
\section1 Visibility and Windowing system exposure.
|
\section1 Visibility and Windowing system exposure.
|
||||||
|
|
||||||
@ -743,8 +736,6 @@ bool QWindow::isActive() const
|
|||||||
to compute the necessary transform.
|
to compute the necessary transform.
|
||||||
|
|
||||||
The default value is Qt::PrimaryOrientation
|
The default value is Qt::PrimaryOrientation
|
||||||
|
|
||||||
\sa requestOrientation(), QScreen::orientation()
|
|
||||||
*/
|
*/
|
||||||
void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)
|
void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)
|
||||||
{
|
{
|
||||||
@ -765,46 +756,6 @@ Qt::ScreenOrientation QWindow::contentOrientation() const
|
|||||||
return d->contentOrientation;
|
return d->contentOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Requests the given window \a orientation.
|
|
||||||
|
|
||||||
The window \a orientation specifies how the window should be rotated
|
|
||||||
by the window manager in order to be displayed. Input events will
|
|
||||||
be correctly mapped to the given \a orientation.
|
|
||||||
|
|
||||||
The return value is false if the system doesn't support the given
|
|
||||||
\a orientation (for example when requesting a portrait orientation
|
|
||||||
on a device that only handles landscape buffers, typically a desktop
|
|
||||||
system).
|
|
||||||
|
|
||||||
If the return value is false, call \l orientation() to get the actual
|
|
||||||
supported orientation.
|
|
||||||
|
|
||||||
\sa orientation(), reportContentOrientationChange(), QScreen::orientation()
|
|
||||||
*/
|
|
||||||
bool QWindow::requestOrientation(Qt::ScreenOrientation orientation)
|
|
||||||
{
|
|
||||||
Q_D(QWindow);
|
|
||||||
if (!d->platformWindow)
|
|
||||||
create();
|
|
||||||
Q_ASSERT(d->platformWindow);
|
|
||||||
d->windowOrientation = d->platformWindow->requestWindowOrientation(orientation);
|
|
||||||
return d->windowOrientation == orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns the actual window orientation.
|
|
||||||
|
|
||||||
The default value is Qt::PrimaryOrientation.
|
|
||||||
|
|
||||||
\sa requestOrientation()
|
|
||||||
*/
|
|
||||||
Qt::ScreenOrientation QWindow::orientation() const
|
|
||||||
{
|
|
||||||
Q_D(const QWindow);
|
|
||||||
return d->windowOrientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the ratio between physical pixels and device-independent pixels
|
Returns the ratio between physical pixels and device-independent pixels
|
||||||
for the window. This value is dependent on the screen the window is on,
|
for the window. This value is dependent on the screen the window is on,
|
||||||
|
@ -157,9 +157,6 @@ public:
|
|||||||
|
|
||||||
qreal devicePixelRatio() const;
|
qreal devicePixelRatio() const;
|
||||||
|
|
||||||
bool requestOrientation(Qt::ScreenOrientation orientation);
|
|
||||||
Qt::ScreenOrientation orientation() const;
|
|
||||||
|
|
||||||
Qt::WindowState windowState() const;
|
Qt::WindowState windowState() const;
|
||||||
void setWindowState(Qt::WindowState state);
|
void setWindowState(Qt::WindowState state);
|
||||||
|
|
||||||
|
@ -89,7 +89,6 @@ public:
|
|||||||
, receivedExpose(false)
|
, receivedExpose(false)
|
||||||
, positionPolicy(WindowFrameExclusive)
|
, positionPolicy(WindowFrameExclusive)
|
||||||
, contentOrientation(Qt::PrimaryOrientation)
|
, contentOrientation(Qt::PrimaryOrientation)
|
||||||
, windowOrientation(Qt::PrimaryOrientation)
|
|
||||||
, minimumSize(0, 0)
|
, minimumSize(0, 0)
|
||||||
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
|
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
|
||||||
, modality(Qt::NonModal)
|
, modality(Qt::NonModal)
|
||||||
@ -136,7 +135,6 @@ public:
|
|||||||
bool receivedExpose;
|
bool receivedExpose;
|
||||||
PositionPolicy positionPolicy;
|
PositionPolicy positionPolicy;
|
||||||
Qt::ScreenOrientation contentOrientation;
|
Qt::ScreenOrientation contentOrientation;
|
||||||
Qt::ScreenOrientation windowOrientation;
|
|
||||||
|
|
||||||
QSize minimumSize;
|
QSize minimumSize;
|
||||||
QSize maximumSize;
|
QSize maximumSize;
|
||||||
|
@ -731,10 +731,6 @@ void tst_QWindow::orientation()
|
|||||||
window.reportContentOrientationChange(Qt::PrimaryOrientation);
|
window.reportContentOrientationChange(Qt::PrimaryOrientation);
|
||||||
QCOMPARE(window.contentOrientation(), Qt::PrimaryOrientation);
|
QCOMPARE(window.contentOrientation(), Qt::PrimaryOrientation);
|
||||||
|
|
||||||
QVERIFY(!window.requestOrientation(Qt::LandscapeOrientation) || window.orientation() == Qt::LandscapeOrientation);
|
|
||||||
QVERIFY(!window.requestOrientation(Qt::PortraitOrientation) || window.orientation() == Qt::PortraitOrientation);
|
|
||||||
QVERIFY(!window.requestOrientation(Qt::PrimaryOrientation) || window.orientation() == Qt::PrimaryOrientation);
|
|
||||||
|
|
||||||
QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)));
|
QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)));
|
||||||
window.reportContentOrientationChange(Qt::LandscapeOrientation);
|
window.reportContentOrientationChange(Qt::LandscapeOrientation);
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user