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 QQmlPreviewUrlInterceptor;
33class QQuickWindow;
34
36{
38public:
39 explicit QQmlPreviewHandler(QObject *parent = nullptr);
41
42 QQuickItem *currentRootItem();
43
44 void addEngine(QQmlEngine *engine);
45 void removeEngine(QQmlEngine *engine);
46
47 void loadUrl(const QUrl &url);
48 void dropCU(const QUrl &url);
49 void rerun();
50 void zoom(qreal newFactor);
51 void setAnimationSpeed(qreal newFactor);
52
53 void clear();
54
66
68 void error(const QString &message);
69 void fps(const FpsInfo &info);
70
71protected:
72 bool eventFilter(QObject *obj, QEvent *event) override;
73private:
74 void doZoom();
75 void tryCreateObject();
76 void showObject(QObject *object);
77 void setCurrentWindow(QQuickWindow *window);
78
79 void beforeSynchronizing();
80 void afterSynchronizing();
81 void beforeRendering();
82 void frameSwapped();
83
84 void fpsTimerHit();
85
86 QScopedPointer<QQuickItem> m_dummyItem;
87 QList<QQmlEngine *> m_engines;
88 QPointer<QQuickItem> m_currentRootItem;
89 QList<QPointer<QObject>> m_createdObjects;
90 QScopedPointer<QQmlComponent> m_component;
91 QPointer<QQuickWindow> m_currentWindow;
92 qreal m_zoomFactor = 1.0;
93 bool m_supportsMultipleWindows;
94 QQmlPreviewPosition m_lastPosition;
95
96 QTimer m_fpsTimer;
97
98 struct FrameTime {
99 void beginFrame();
100 void recordFrame();
101 void endFrame();
102 void reset();
103
104 QElapsedTimer timer;
105 qint64 elapsed = -1;
106 quint16 min = std::numeric_limits<quint16>::max();
107 quint16 max = 0;
108 quint16 total = 0;
109 quint16 number = 0;
110 };
111
112 FrameTime m_rendering;
113 FrameTime m_synchronizing;
114};
115
116QT_END_NAMESPACE
117
118Q_DECLARE_METATYPE(QQmlPreviewHandler::FpsInfo)
119
120#endif // QQMLPREVIEWHANDLER_H
void messageReceived(const QByteArray &message) override
void foundTranslationBinding(const TranslationBindingInformation &translationBindingInformation) override
void engineAboutToBeAdded(QJSEngine *engine) override
void state(const QString &stateName)
void engineAboutToBeRemoved(QJSEngine *engine) override
QMultiMap< QObject *, TranslationBindingInformation > objectTranslationBindingMultiMap
QList< QPointer< QQuickItem > > translatableTextOccurrences
void dropCU(const QUrl &url)
void zoom(qreal newFactor)
QQuickItem * currentRootItem()
bool eventFilter(QObject *obj, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void setAnimationSpeed(qreal newFactor)
void fps(const FpsInfo &info)
void removeEngine(QQmlEngine *engine)
void addEngine(QQmlEngine *engine)
void loadUrl(const QUrl &url)
void forwardRequest(const QString &file)
void drop(const QUrl &url)
void animationSpeed(qreal factor)
void engineAboutToBeRemoved(QJSEngine *engine) override
QQmlPreviewServiceImpl(QObject *parent=nullptr)
void file(const QString &file, const QByteArray &contents)
void directory(const QString &file, const QStringList &entries)
void engineAboutToBeAdded(QJSEngine *engine) override
void forwardFps(const QQmlPreviewHandler::FpsInfo &frames)
void zoom(qreal factor)
static const QString s_key
void load(const QUrl &url)
void stateChanged(State state) override
void forwardError(const QString &error)
void messageReceived(const QByteArray &message) override
Combined button and popup list for selecting options.
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QString translationIdString(const QQmlTranslation::QsTrData &data)