Plasma-framework

quickviewsharedengine.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef QUICKVIEWSHAREDENGINE_H
9#define QUICKVIEWSHAREDENGINE_H
10
11#include "plasmaquick_export.h"
12
13#include <QQmlComponent>
14#include <QQmlError>
15#include <QQuickWindow>
16#include <QUrl>
17#include <memory>
18
19class QQuickItem;
20class QQmlEngine;
21
22namespace PlasmaQuick
23{
24class QuickViewSharedEnginePrivate;
25
26/**
27 * @class PlasmaQuick::QuickViewSharedEngine quickviewsharedengine.h KQuickAddons/QuickViewSharedEngine
28 */
29class PLASMAQUICK_EXPORT QuickViewSharedEngine : public QQuickWindow
30{
31 Q_OBJECT
32
33 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged)
34 Q_PROPERTY(QQmlComponent::Status status READ status NOTIFY statusChanged)
35 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
36
37public:
38 enum ResizeMode {
39 SizeViewToRootObject,
40 SizeRootObjectToView,
41 };
42 Q_ENUM(ResizeMode)
43
44 explicit QuickViewSharedEngine(QWindow *parent = nullptr);
45 ~QuickViewSharedEngine() override;
46
47 /**
48 * Installs a translation domain for all
49 * i18n global functions. If a translation domain is set all i18n calls delegate to the
50 * matching i18nd calls with the provided translation domain.
51 *
52 * The translationDomain affects all i18n calls including those from imports. Because of
53 * that modules intended to be used as imports should prefer the i18nd variants and set
54 * the translation domain explicitly in each call.
55 *
56 * This method is only required if your declarative usage is inside a library. If it's
57 * in an application there is no need to set the translation domain as the application's
58 * domain can be used.
59 *
60 * @param translationDomain The translation domain to be used for i18n calls.
61 */
62 void setTranslationDomain(const QString &translationDomain);
63
64 /**
65 * @return the translation domain for the i18n calls done in this QML engine
66 */
67 QString translationDomain() const;
68
69 std::shared_ptr<QQmlEngine> engine() const;
70 QList<QQmlError> errors() const;
71 QSize sizeHint() const;
72 QSize initialSize() const;
73 QQmlContext *rootContext() const;
74 QQuickItem *rootObject() const;
75 QUrl source() const;
77 ResizeMode resizeMode() const;
78 void setResizeMode(ResizeMode);
79
80protected:
81 void resizeEvent(QResizeEvent *e) override;
82
83public Q_SLOTS:
84 void setSource(const QUrl &url);
85
86Q_SIGNALS:
87 void statusChanged(QQmlComponent::Status status);
88 void resizeModeChanged(QuickViewSharedEngine::ResizeMode resizeMode);
89 void sourceChanged(const QUrl &source);
90
91private:
92 const std::unique_ptr<QuickViewSharedEnginePrivate> d;
93
94 Q_PRIVATE_SLOT(d, void executionFinished())
95 Q_PRIVATE_SLOT(d, void syncWidth())
96 Q_PRIVATE_SLOT(d, void syncHeight())
97};
98
99}
100
101#endif // QuickViewSharedEngine_H
Q_SCRIPTABLE CaptureState status()
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
Definition action.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.