summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/macnativeevents/nativeeventlist.h
blob: 20e91a689a87e63ea453eb72b093ce1206629ae0 (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
44
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef Q_NATIVE_PLAYBACK
#define Q_NATIVE_PLAYBACK

#include <QtCore>
#include "qnativeevents.h"

class NativeEventList : public QObject
{
    Q_OBJECT;

    public:
    enum Playback {ReturnImmediately, WaitUntilFinished};

    NativeEventList(int defaultWaitMs = 20);
    ~NativeEventList();

    void append(QNativeEvent *event);
    void append(int waitMs, QNativeEvent *event = nullptr);

    void play(Playback playback = WaitUntilFinished);
    void stop();
    void setTimeMultiplier(float multiplier);

signals:
    void done();

private slots:
    void sendNextEvent();

private:
    void waitNextEvent();

    QList<QPair<int, QNativeEvent *> > eventList;
    float playbackMultiplier;
    int currIndex;
    bool wait;
    int defaultWaitMs;
    int debug;
};

#endif