2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-09-14 02:03:34 +00:00
|
|
|
|
2011-08-22 08:49:28 +00:00
|
|
|
#include <QWindow>
|
|
|
|
|
|
|
|
#include <QtGui/qopengl.h>
|
2020-01-17 13:40:36 +00:00
|
|
|
#include <QtOpenGL/qopenglshaderprogram.h>
|
2020-01-17 14:51:29 +00:00
|
|
|
#include <QtOpenGL/qopenglframebufferobject.h>
|
2011-08-22 08:49:28 +00:00
|
|
|
|
2011-11-23 08:36:51 +00:00
|
|
|
#include <QPropertyAnimation>
|
|
|
|
|
2011-08-22 08:49:28 +00:00
|
|
|
#include <QColor>
|
2011-11-23 08:36:51 +00:00
|
|
|
#include <QImage>
|
2011-08-22 08:49:28 +00:00
|
|
|
#include <QTime>
|
|
|
|
|
2011-09-28 07:49:05 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
2011-08-22 08:49:28 +00:00
|
|
|
class QOpenGLContext;
|
2011-09-28 07:49:05 +00:00
|
|
|
QT_END_NAMESPACE
|
2011-08-22 08:49:28 +00:00
|
|
|
|
|
|
|
class PaintedWindow : public QWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2011-11-23 08:36:51 +00:00
|
|
|
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
|
|
|
|
2011-08-22 08:49:28 +00:00
|
|
|
public:
|
|
|
|
PaintedWindow();
|
|
|
|
|
2011-11-23 08:36:51 +00:00
|
|
|
qreal rotation() const { return m_rotation; }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void rotationChanged(qreal rotation);
|
|
|
|
|
2011-08-22 08:49:28 +00:00
|
|
|
private slots:
|
|
|
|
void paint();
|
2011-11-23 08:36:51 +00:00
|
|
|
void setRotation(qreal r);
|
|
|
|
void orientationChanged(Qt::ScreenOrientation newOrientation);
|
|
|
|
void rotationDone();
|
2011-08-22 08:49:28 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-15 08:12:35 +00:00
|
|
|
void exposeEvent(QExposeEvent *) override;
|
|
|
|
void mousePressEvent(QMouseEvent *) override;
|
2011-08-22 08:49:28 +00:00
|
|
|
|
2011-11-23 08:36:51 +00:00
|
|
|
void paint(QPainter *painter, const QRect &rect);
|
|
|
|
|
2011-08-22 08:49:28 +00:00
|
|
|
QOpenGLContext *m_context;
|
2011-11-23 08:36:51 +00:00
|
|
|
qreal m_rotation;
|
|
|
|
|
|
|
|
QImage m_prevImage;
|
|
|
|
QImage m_nextImage;
|
|
|
|
qreal m_deltaRotation;
|
|
|
|
|
|
|
|
Qt::ScreenOrientation m_targetOrientation;
|
|
|
|
Qt::ScreenOrientation m_nextTargetOrientation;
|
|
|
|
|
|
|
|
QPropertyAnimation *m_animation;
|
|
|
|
QTimer *m_paintTimer;
|
2011-08-22 08:49:28 +00:00
|
|
|
};
|