summaryrefslogtreecommitdiffstats
path: root/tests/manual/subsurface/shmwindow.cpp
blob: 33798f9b87b2a80c4d3d118ec5f01d7a8f8dadff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "shmwindow.h"

#include <QPainter>
#include <QDebug>

ShmWindow::ShmWindow(QWindow *parent)
   : QRasterWindow(parent)
   , m_rotation(0)
{
    m_timer = startTimer(100);
}

void ShmWindow::timerEvent(QTimerEvent *event)
{
    if (event->timerId() == m_timer) {
        m_rotation++;
        update();
    }
}

void ShmWindow::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter(this);

    painter.fillRect(0, 0, width(), height(), Qt::white);

    qreal xc = width() * 0.5;
    qreal yc = height() * 0.5;
    painter.translate(xc, yc);
    painter.rotate(m_rotation);
    painter.drawText(QRectF(-xc, -yc, width(), height()), Qt::AlignCenter, QStringLiteral("SHM"));
}