1 | /* |
2 | SPDX-FileCopyrightText: 2020-2023 Alexander Lohnau <alexander.lohnau@gmx.de> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-or-later |
5 | */ |
6 | |
7 | #ifndef KNEWSTUFF_QTQUICKDIALOGWRAPPER_H |
8 | #define KNEWSTUFF_QTQUICKDIALOGWRAPPER_H |
9 | |
10 | #include <KNSCore/Entry> |
11 | #include <KNSCore/ErrorCode> |
12 | #include <QDialog> |
13 | |
14 | #include "knewstuffwidgets_export.h" |
15 | |
16 | namespace KNSCore |
17 | { |
18 | class EngineBase; |
19 | }; |
20 | |
21 | namespace KNSWidgets |
22 | { |
23 | class DialogPrivate; |
24 | /*! |
25 | * \class KNSWidgets::Dialog |
26 | * \inmodule KNewStuffWidgets |
27 | * |
28 | * \brief This class is a wrapper around the QtQuick QML dialog. This dialog content is loaded QQuickWidget. |
29 | * |
30 | * It is recommended to reuse an instance of this class if it is expected that the user reopens the dialog. |
31 | * For most usecases, you should use KNSWidgets::Button or KNSWidgets::Action directly. |
32 | * |
33 | * \since 6.0 |
34 | */ |
35 | class KNEWSTUFFWIDGETS_EXPORT Dialog : public QDialog |
36 | { |
37 | Q_OBJECT |
38 | |
39 | public: |
40 | /*! |
41 | * Constructs a new Dialog for the given config file and parent widget |
42 | */ |
43 | explicit Dialog(const QString &configFile, QWidget *parent = nullptr); |
44 | ~Dialog() override; |
45 | |
46 | /*! |
47 | * Engine that is used by the dialog, might be null if the engine failed to initialize. |
48 | * Returns KNSCore::EngineBase used by the dialog |
49 | */ |
50 | KNSCore::EngineBase *engine(); |
51 | |
52 | /*! |
53 | * Entries that were changed while the user interacted with the dialog |
54 | * \since 5.94 |
55 | */ |
56 | QList<KNSCore::Entry> changedEntries() const; |
57 | |
58 | void open() override; |
59 | |
60 | private: |
61 | Q_PRIVATE_SLOT(d, void onEntryEvent(const KNSCore::Entry &entry, KNSCore::Entry::EntryEvent event)) |
62 | const std::unique_ptr<DialogPrivate> d; |
63 | |
64 | Q_DISABLE_COPY(Dialog) |
65 | }; |
66 | } |
67 | |
68 | #endif // KNEWSTUFF_QTQUICKDIALOGWRAPPER_H |
69 | |