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
52 void clear();
53
65
67 void error(const QString &message);
68 void fps(const FpsInfo &info);
69
70protected:
71 bool eventFilter(QObject *obj, QEvent *event) override;
72private:
73 void doZoom();
74 void tryCreateObject();
75 void showObject(QObject *object);
76 void setCurrentWindow(QQuickWindow *window);
77
78 void beforeSynchronizing();
79 void afterSynchronizing();
80 void beforeRendering();
81 void frameSwapped();
82
83 void fpsTimerHit();
84
85 QScopedPointer<QQuickItem> m_dummyItem;
86 QList<QQmlEngine *> m_engines;
87 QPointer<QQuickItem> m_currentRootItem;
88 QVector<QPointer<QObject>> m_createdObjects;
89 QScopedPointer<QQmlComponent> m_component;
90 QPointer<QQuickWindow> m_currentWindow;
91 qreal m_zoomFactor = 1.0;
92 bool m_supportsMultipleWindows;
93 QQmlPreviewPosition m_lastPosition;
94
95 QTimer m_fpsTimer;
96
97 struct FrameTime {
98 void beginFrame();
99 void recordFrame();
100 void endFrame();
101 void reset();
102
103 QElapsedTimer timer;
104 qint64 elapsed = -1;
105 quint16 min = std::numeric_limits<quint16>::max();
106 quint16 max = 0;
107 quint16 total = 0;
108 quint16 number = 0;
109 };
110
111 FrameTime m_rendering;
112 FrameTime m_synchronizing;
113};
114
115QT_END_NAMESPACE
116
117Q_DECLARE_METATYPE(QQmlPreviewHandler::FpsInfo)
118
119#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
Combined button and popup list for selecting options.
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QString translationIdString(const QQmlTranslation::QsTrData &data)