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
4#ifndef QQMLPREVIEWHANDLER_H
5#define QQMLPREVIEWHANDLER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
19
20#include <QtCore/qobject.h>
21#include <QtCore/qvector.h>
22#include <QtCore/qrect.h>
23#include <QtCore/qpointer.h>
24#include <QtCore/qelapsedtimer.h>
25#include <QtQml/qqmlengine.h>
26
28
29class QQmlEngine;
30class QQuickItem;
31class QQmlPreviewUrlInterceptor;
32class QQuickWindow;
33
35{
37public:
38 explicit QQmlPreviewHandler(QObject *parent = nullptr);
40
41 QQuickItem *currentRootItem();
42
43 void addEngine(QQmlEngine *engine);
44 void removeEngine(QQmlEngine *engine);
45
46 void loadUrl(const QUrl &url);
47 void dropCU(const QUrl &url);
48 void rerun();
49 void zoom(qreal newFactor);
50
51 void clear();
52
64
66 void error(const QString &message);
67 void fps(const FpsInfo &info);
68
69protected:
70 bool eventFilter(QObject *obj, QEvent *event) override;
71private:
72 void doZoom();
73 void tryCreateObject();
74 void showObject(QObject *object);
75 void setCurrentWindow(QQuickWindow *window);
76
77 void beforeSynchronizing();
78 void afterSynchronizing();
79 void beforeRendering();
80 void frameSwapped();
81
82 void fpsTimerHit();
83
84 QScopedPointer<QQuickItem> m_dummyItem;
85 QList<QQmlEngine *> m_engines;
86 QPointer<QQuickItem> m_currentRootItem;
87 QVector<QPointer<QObject>> m_createdObjects;
88 QScopedPointer<QQmlComponent> m_component;
89 QPointer<QQuickWindow> m_currentWindow;
90 qreal m_zoomFactor = 1.0;
91 bool m_supportsMultipleWindows;
92 QQmlPreviewPosition m_lastPosition;
93
94 QTimer m_fpsTimer;
95
96 struct FrameTime {
97 void beginFrame();
98 void recordFrame();
99 void endFrame();
100 void reset();
101
102 QElapsedTimer timer;
103 qint64 elapsed = -1;
104 quint16 min = std::numeric_limits<quint16>::max();
105 quint16 max = 0;
106 quint16 total = 0;
107 quint16 number = 0;
108 };
109
110 FrameTime m_rendering;
111 FrameTime m_synchronizing;
112};
113
114QT_END_NAMESPACE
115
116Q_DECLARE_METATYPE(QQmlPreviewHandler::FpsInfo)
117
118#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 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 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
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QString translationIdString(const QQmlTranslation::QsTrData &data)