KDeclarative

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

KDE's Doxygen guidelines are available online.