Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlpreviewhandler.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
5#ifndef QQMLPREVIEWHANDLER_H
6#define QQMLPREVIEWHANDLER_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
20
21#include <QtCore/qobject.h>
22#include <QtCore/qvector.h>
23#include <QtCore/qrect.h>
24#include <QtCore/qpointer.h>
25#include <QtCore/qelapsedtimer.h>
26#include <QtQml/qqmlengine.h>
27
29
30class QQmlEngine;
31class QQuickItem;
32class QQuickWindow;
34
36{
38public:
50
51 explicit QQmlPreviewHandler(QObject *parent = nullptr);
53
54 QQuickItem *currentRootItem() const;
55 void setCurrentRootItem(QQuickItem *item);
56
57 QQuickWindow *currentWindow() const;
58 void setCurrentWindow(QQuickWindow *window);
59
60 virtual void connectToService(QQmlPreviewServiceImpl *service);
61 virtual void addEngine(QQmlEngine *engine);
62 virtual void removeEngine(QQmlEngine *engine);
63
64 virtual void load(const QUrl &url) = 0;
65 void setAnimationSpeed(qreal newFactor);
66
67 QList<QQmlEngine *> engines() const { return m_engines; }
68
70 void error(const QString &message);
71 void fps(const QQmlPreviewHandler::FpsInfo &info);
72
73protected:
74 struct FrameTime {
75 void beginFrame();
76 void recordFrame();
77 void endFrame();
78 void reset();
79
86 };
87
88 void connectWindow(QQuickWindow *window);
89 void disconnectWindow(QQuickWindow *window);
90 void zoomWindow(QQuickWindow *window, qreal zoomFactor, QQmlPreviewPosition *position);
91
92private:
93 void beforeSynchronizing();
94 void afterSynchronizing();
95 void beforeRendering();
96 void frameSwapped();
97
98 void fpsTimerHit();
99
100 QList<QQmlEngine *> m_engines;
101
102 QPointer<QQuickItem> m_currentRootItem;
103 QPointer<QQuickWindow> m_currentWindow;
104
105 QTimer m_fpsTimer;
106 FrameTime m_rendering;
107 FrameTime m_synchronizing;
108};
109
110QT_END_NAMESPACE
111
112Q_DECLARE_METATYPE(QQmlPreviewHandler::FpsInfo)
113
114#endif // QQMLPREVIEWHANDLER_H
void load(const QUrl &url) final
void removeEngine(QQmlEngine *engine) final
void connectToService(QQmlPreviewServiceImpl *service) final
bool eventFilter(QObject *obj, QEvent *event) final
Filters events if this object has been installed as an event filter for the watched object.
void disconnectWindow(QQuickWindow *window)
void fps(const QQmlPreviewHandler::FpsInfo &info)
void setCurrentRootItem(QQuickItem *item)
QList< QQmlEngine * > engines() const
void zoomWindow(QQuickWindow *window, qreal zoomFactor, QQmlPreviewPosition *position)
QQuickItem * currentRootItem() const
void setCurrentWindow(QQuickWindow *window)
void connectWindow(QQuickWindow *window)
void setAnimationSpeed(qreal newFactor)
virtual void removeEngine(QQmlEngine *engine)
virtual void load(const QUrl &url)=0
QQmlPreviewHandler(QObject *parent=nullptr)
virtual void addEngine(QQmlEngine *engine)
QQuickWindow * currentWindow() const
virtual void connectToService(QQmlPreviewServiceImpl *service)
Combined button and popup list for selecting options.
static Qt::WindowFlags fixFlags(Qt::WindowFlags flags)
static void closeAllWindows()