KDeclarative

quickviewsharedengine.h
1 /*
2  This file is part of the KDE libraries
3 
4  Copyright (C) 2015 Marco Martin <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 
21 */
22 
23 #ifndef QUICKVIEWSHAREDENGINE_H
24 #define QUICKVIEWSHAREDENGINE_H
25 
26 #include "quickaddons_export.h"
27 
28 #include <memory>
29 #include <QQuickWindow>
30 #include <QUrl>
31 #include <QQmlError>
32 #include <QQmlComponent>
33 
34 class QQuickItem;
35 class QQmlEngine;
36 
37 namespace KQuickAddons {
38 
39 class QuickViewSharedEnginePrivate;
40 
46 class QUICKADDONS_EXPORT QuickViewSharedEngine : public QQuickWindow
47 {
48  Q_OBJECT
49 
50  Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged)
51  Q_PROPERTY(QQmlComponent::Status status READ status NOTIFY statusChanged)
52  Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
53 
54 public:
55  enum ResizeMode {
56  SizeViewToRootObject,
57  SizeRootObjectToView
58  };
59  Q_ENUM(ResizeMode)
60 
61  explicit QuickViewSharedEngine(QWindow *parent = nullptr);
62  ~QuickViewSharedEngine() override;
63 
80  void setTranslationDomain(const QString &translationDomain);
81 
86  QString translationDomain() const;
87 
88  QQmlEngine *engine() const;
89  QList<QQmlError> errors() const;
90  QSize sizeHint() const;
91  QSize initialSize() const;
92  QQmlContext *rootContext() const;
93  QQuickItem *rootObject() const;
94  QUrl source() const;
95  QQmlComponent::Status status() const;
96  ResizeMode resizeMode() const;
97  void setResizeMode(ResizeMode);
98 
99 protected:
100  void resizeEvent(QResizeEvent *e) override;
101 
102 public Q_SLOTS:
103  void setSource(const QUrl &url);
104 
105 Q_SIGNALS:
106  void statusChanged(QQmlComponent::Status status);
107  void resizeModeChanged(QuickViewSharedEngine::ResizeMode resizeMode);
108  void sourceChanged(const QUrl &source);
109 
110 
111 private:
112  const std::unique_ptr<QuickViewSharedEnginePrivate> d;
113 
114  Q_PRIVATE_SLOT(d, void executionFinished())
115  Q_PRIVATE_SLOT(d, void syncWidth())
116  Q_PRIVATE_SLOT(d, void syncHeight())
117 };
118 
119 }
120 
121 
122 #endif //QuickViewSharedEngine_H
123 
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 5 2020 22:37:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.