1// Copyright (C) 2020 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
4#ifndef QUILOADER_H
5#define QUILOADER_H
6
7#include <QtUiTools/qtuitoolsglobal.h>
8#include <QtCore/qobject.h>
9#include <QtCore/qscopedpointer.h>
10
11QT_BEGIN_NAMESPACE
12
13class QWidget;
14class QLayout;
15class QAction;
16class QActionGroup;
17class QString;
18class QIODevice;
19class QDir;
20
21class QUiLoaderPrivate;
22class Q_UITOOLS_EXPORT QUiLoader : public QObject
23{
24 Q_OBJECT
25public:
26 explicit QUiLoader(QObject *parent = nullptr);
27 ~QUiLoader() override;
28
29 QStringList pluginPaths() const;
30 void clearPluginPaths();
31 void addPluginPath(const QString &path);
32
33 QWidget *load(QIODevice *device, QWidget *parentWidget = nullptr);
34 QStringList availableWidgets() const;
35 QStringList availableLayouts() const;
36
37 virtual QWidget *createWidget(const QString &className, QWidget *parent = nullptr, const QString &name = QString());
38 virtual QLayout *createLayout(const QString &className, QObject *parent = nullptr, const QString &name = QString());
39 virtual QActionGroup *createActionGroup(QObject *parent = nullptr, const QString &name = QString());
40 virtual QAction *createAction(QObject *parent = nullptr, const QString &name = QString());
41
42 void setWorkingDirectory(const QDir &dir);
43 QDir workingDirectory() const;
44
45 void setLanguageChangeEnabled(bool enabled);
46 bool isLanguageChangeEnabled() const;
47
48 void setTranslationEnabled(bool enabled);
49 bool isTranslationEnabled() const;
50
51 QString errorString() const;
52
53private:
54 QScopedPointer<QUiLoaderPrivate> d_ptr;
55 Q_DECLARE_PRIVATE(QUiLoader)
56 Q_DISABLE_COPY_MOVE(QUiLoader)
57};
58
59QT_END_NAMESPACE
60
61#endif // QUILOADER_H
62

source code of qttools/src/uitools/quiloader.h