8#include "quickviewsharedengine.h"
9#include "sharedqmlengine.h"
15#include <KLocalizedString>
19class QuickViewSharedEnginePrivate
22 QuickViewSharedEnginePrivate(QuickViewSharedEngine *module)
24 , resizeMode(QuickViewSharedEngine::ResizeMode::SizeRootObjectToView)
27 qmlObject =
new SharedQmlEngine(q);
28 QObject::connect(qmlObject, &SharedQmlEngine::statusChanged, q, &QuickViewSharedEngine::statusChanged);
34 void executionFinished();
35 void syncResizeMode();
39 QuickViewSharedEngine *q;
40 SharedQmlEngine *qmlObject;
41 QuickViewSharedEngine::ResizeMode resizeMode;
45void QuickViewSharedEnginePrivate::executionFinished()
47 if (!qmlObject->rootObject()) {
51 QQuickItem *item = qobject_cast<QQuickItem *>(qmlObject->rootObject());
68void QuickViewSharedEnginePrivate::syncResizeMode()
70 QQuickItem *item = qobject_cast<QQuickItem *>(qmlObject->rootObject());
76 if (resizeMode == QuickViewSharedEngine::SizeRootObjectToView) {
95void QuickViewSharedEnginePrivate::syncWidth()
97 QQuickItem *item = qobject_cast<QQuickItem *>(qmlObject->rootObject());
106void QuickViewSharedEnginePrivate::syncHeight()
108 QQuickItem *item = qobject_cast<QQuickItem *>(qmlObject->rootObject());
117QuickViewSharedEngine::QuickViewSharedEngine(
QWindow *parent)
119 , d(new QuickViewSharedEnginePrivate(this))
123QuickViewSharedEngine::~QuickViewSharedEngine()
128void QuickViewSharedEngine::setTranslationDomain(
const QString &translationDomain)
130 d->qmlObject->setTranslationDomain(translationDomain);
133QString QuickViewSharedEngine::translationDomain()
const
135 return d->qmlObject->translationDomain();
138std::shared_ptr<QQmlEngine> QuickViewSharedEngine::engine()
const
140 return d->qmlObject->engine();
147 if (d->qmlObject->mainComponent()) {
148 errs = d->qmlObject->mainComponent()->errors();
154QSize QuickViewSharedEngine::sizeHint()
const
156 QQuickItem *item = qobject_cast<QQuickItem *>(d->qmlObject->rootObject());
163 if (!implicitSize.isEmpty()) {
164 return implicitSize.toSize();
170QSize QuickViewSharedEngine::initialSize()
const
172 return d->initialSize;
175QuickViewSharedEngine::ResizeMode QuickViewSharedEngine::resizeMode()
const
177 return d->resizeMode;
180QQmlContext *QuickViewSharedEngine::rootContext()
const
182 return d->qmlObject->rootContext();
185QQuickItem *QuickViewSharedEngine::rootObject()
const
187 return qobject_cast<QQuickItem *>(d->qmlObject->rootObject());
190void QuickViewSharedEngine::setResizeMode(ResizeMode mode)
192 if (d->resizeMode == mode) {
196 d->resizeMode = mode;
198 Q_EMIT resizeModeChanged(mode);
200 QQuickItem *item = qobject_cast<QQuickItem *>(d->qmlObject->rootObject());
208void QuickViewSharedEngine::setSource(
const QUrl &url)
210 if (d->qmlObject->source() == url) {
214 d->qmlObject->setSource(url);
215 Q_EMIT sourceChanged(url);
218QUrl QuickViewSharedEngine::source()
const
220 return d->qmlObject->source();
225 if (!d->qmlObject->mainComponent()) {
234 QQuickItem *item = qobject_cast<QQuickItem *>(d->qmlObject->rootObject());
235 if (item && d->resizeMode == SizeRootObjectToView) {
244#include "moc_quickviewsharedengine.cpp"
void finished()
Emitted when the parsing and execution of the QML file is terminated.
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
void setParentItem(QQuickItem *parent)
void setSize(const QSizeF &size)
virtual void resizeEvent(QResizeEvent *ev) override
const QSize & size() const const
bool isEmpty() const const
void resize(const QSize &newSize)
virtual QSize size() const const override