1 | /* |
2 | SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> |
3 | SPDX-License-Identifier: LGPL-2.0-or-later |
4 | */ |
5 | #include "kiowidgets_export.h" |
6 | #include <QObject> |
7 | |
8 | #ifndef KPROPERTIESDIALOGPLUGIN_H |
9 | #define KPROPERTIESDIALOGPLUGIN_H |
10 | |
11 | #include "kiowidgets_export.h" |
12 | #include <QObject> |
13 | #include <kpropertiesdialog.h> |
14 | |
15 | class KPropertiesDialogPluginPrivate; |
16 | /*! |
17 | * \class KPropertiesDialogPlugin |
18 | * \inmodule KIOWidgets |
19 | * |
20 | * \brief A Plugin in the Properties dialog. |
21 | * |
22 | * This is an abstract class. You must inherit from this class |
23 | * to build a new kind of tabbed page for the KPropertiesDialog. |
24 | * A plugin in itself is just a library containing code, not a dialog's page. |
25 | * It's up to the plugin to insert pages into the parent dialog. |
26 | * |
27 | * To make a plugin available, ensure it has embedded json metadata using |
28 | * K_PLUGIN_CLASS_WITH_JSON and install the plugin in the KDE_INSTALL_PLUGINDIR/kf6/propertiesdialog |
29 | * folder from the KDEInstallDirs CMake module. |
30 | * |
31 | * The metadata can contain the MIME types for which the plugin should be created. |
32 | * For instance: |
33 | * \badcode |
34 | * { |
35 | * "KPlugin": { |
36 | * "MimeTypes": ["text/html", "application/x-mymimetype"] |
37 | * }, |
38 | * "X-KDE-Protocols": ["file"] |
39 | * } |
40 | * \endcode |
41 | * If the MIME types are empty or not specified, the plugin will be created for all MIME types. |
42 | * |
43 | * You can also include "X-KDE-Protocols" if you want that plugin for instance |
44 | * to be loaded only for local files. |
45 | */ |
46 | class KIOWIDGETS_EXPORT KPropertiesDialogPlugin : public QObject |
47 | { |
48 | Q_OBJECT |
49 | public: |
50 | /*! |
51 | * Constructor whos parent will be cast to KPropertiesDialog |
52 | * To insert tabs into the properties dialog, use the add methods provided by |
53 | * KPageDialog (the properties dialog is a KPageDialog). |
54 | */ |
55 | KPropertiesDialogPlugin(QObject *parent); |
56 | ~KPropertiesDialogPlugin() override; |
57 | |
58 | /*! |
59 | * Applies all changes to the file. |
60 | * This function is called when the user presses 'Ok'. The last plugin inserted |
61 | * is called first. |
62 | */ |
63 | virtual void applyChanges(); |
64 | |
65 | /*! |
66 | * |
67 | */ |
68 | void setDirty(bool b = true); |
69 | |
70 | /*! |
71 | * |
72 | */ |
73 | bool isDirty() const; |
74 | |
75 | Q_SIGNALS: |
76 | /*! |
77 | * Emit this signal when the user changed anything in the plugin's tabs. |
78 | * The hosting PropertiesDialog will call applyChanges only if the |
79 | * PropsPlugin has emitted this signal or if you have called setDirty() before. |
80 | */ |
81 | void changed(); |
82 | |
83 | protected: |
84 | /*! |
85 | * Pointer to the dialog |
86 | */ |
87 | KPropertiesDialog *const properties; |
88 | |
89 | /*! |
90 | * Returns the font height. |
91 | */ |
92 | int fontHeight() const; |
93 | |
94 | private: |
95 | const std::unique_ptr<KPropertiesDialogPluginPrivate> d; |
96 | }; |
97 | #endif |
98 | |