File indexing completed on 2024-04-28 03:56:30

0001 /*
0002     SPDX-FileCopyrightText: 2020-2023 Alexander Lohnau <alexander.lohnau@gmx.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef KNEWSTUFF_QTQUICKDIALOGWRAPPER_H
0008 #define KNEWSTUFF_QTQUICKDIALOGWRAPPER_H
0009 
0010 #include <KNSCore/Entry>
0011 #include <KNSCore/ErrorCode>
0012 #include <QDialog>
0013 
0014 #include "knewstuffwidgets_export.h"
0015 
0016 namespace KNSCore
0017 {
0018 class EngineBase;
0019 };
0020 
0021 namespace KNSWidgets
0022 {
0023 class DialogPrivate;
0024 /**
0025  * @class Dialog dialog.h <KNSWidgets/Dialog>
0026  *
0027  * This class is a wrapper around the QtQuick QML dialog. This dialog content is loaded QQuickWidget.
0028  * It is recommended to reuse an instance of this class if it is expected that the user reopens the dialog.
0029  * For most usecases, you should use KNSWidgets::Button or KNSWidgets::Action directly.
0030  *
0031  * @since 6.0
0032  */
0033 class KNEWSTUFFWIDGETS_EXPORT Dialog : public QDialog
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     /**
0039      * Constructs a new Dialog for the given config file and parent widget
0040      */
0041     explicit Dialog(const QString &configFile, QWidget *parent = nullptr);
0042     ~Dialog() override;
0043 
0044     /**
0045      * Engine that is used by the dialog, might be null if the engine failed to initialize.
0046      * @return KNSCore::EngineBase used by the dialog
0047      */
0048     KNSCore::EngineBase *engine();
0049 
0050     /**
0051      * Entries that were changed while the user interacted with the dialog
0052      * @since 5.94
0053      */
0054     QList<KNSCore::Entry> changedEntries() const;
0055 
0056     void open() override;
0057 
0058 private:
0059     Q_PRIVATE_SLOT(d, void onEntryEvent(const KNSCore::Entry &entry, KNSCore::Entry::EntryEvent event))
0060     const std::unique_ptr<DialogPrivate> d;
0061 
0062     Q_DISABLE_COPY(Dialog)
0063 };
0064 }
0065 
0066 #endif // KNEWSTUFF_QTQUICKDIALOGWRAPPER_H