summaryrefslogtreecommitdiffstats
path: root/tests/auto/integration/qwindowcapturebackend/widget.h
blob: e74c2902155aba630f9c0a215bcf0b9253186be9 (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
38
39
40
41
42
43
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef WINDOW_CAPTURE_WIDGET_H
#define WINDOW_CAPTURE_WIDGET_H

#include <qwidget.h>
#include <qscreen.h>
#include <qpainter.h>
#include <quuid.h>

/*!
    Window capable of drawing test patterns used for capture tests
 */
class TestWidget : public QWidget
{
    Q_OBJECT

public:
    enum Pattern { ColoredSquares, Grid };

    TestWidget(const QString &uuid = QUuid::createUuid().toString(), QScreen *screen = nullptr);

    void setDisplayPattern(Pattern p);
    void setSize(QSize size);
    QImage grabImage();

public slots:
    void togglePattern();

protected:
    void paintEvent(QPaintEvent * /*event*/) override;

private:
    void drawColoredSquares(QPainter &p);
    void drawGrid(QPainter &p) const;

    Pattern m_pattern = ColoredSquares;
};

bool showCaptureWindow(const QString &windowTitle);

#endif