File indexing completed on 2024-12-08 03:40:48
0001 /* 0002 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 #include "kiowidgets_export.h" 0006 #include <QObject> 0007 0008 #ifndef KPROPERTIESDIALOGPLUGIN_H 0009 #define KPROPERTIESDIALOGPLUGIN_H 0010 0011 #include "kiowidgets_export.h" 0012 #include <QObject> 0013 #include <kpropertiesdialog.h> 0014 0015 class KPropertiesDialogPluginPrivate; 0016 /** 0017 * A Plugin in the Properties dialog 0018 * This is an abstract class. You must inherit from this class 0019 * to build a new kind of tabbed page for the KPropertiesDialog. 0020 * A plugin in itself is just a library containing code, not a dialog's page. 0021 * It's up to the plugin to insert pages into the parent dialog. 0022 * 0023 * To make a plugin available, ensure it has embedded json metadata using 0024 * K_PLUGIN_CLASS_WITH_JSON and install the plugin in the KDE_INSTALL_PLUGINDIR/kf6/propertiesdialog 0025 * folder from the KDEInstallDirs CMake module. 0026 * 0027 * The metadata can contain the MIME types for which the plugin should be created. 0028 * For instance: 0029 * @verbatim 0030 { 0031 "KPlugin": { 0032 "MimeTypes": ["text/html", "application/x-mymimetype"] 0033 }, 0034 "X-KDE-Protocols": ["file"] 0035 } 0036 @endverbatim 0037 * If the MIME types are empty or not specified, the plugin will be created for all MIME types. 0038 * 0039 * You can also include "X-KDE-Protocols" if you want that plugin for instance 0040 * to be loaded only for local files. 0041 */ 0042 class KIOWIDGETS_EXPORT KPropertiesDialogPlugin : public QObject 0043 { 0044 Q_OBJECT 0045 public: 0046 /** 0047 * Constructor whos parent will be cast to KPropertiesDialog 0048 * To insert tabs into the properties dialog, use the add methods provided by 0049 * KPageDialog (the properties dialog is a KPageDialog). 0050 */ 0051 KPropertiesDialogPlugin(QObject *parent); 0052 ~KPropertiesDialogPlugin() override; 0053 0054 /** 0055 * Applies all changes to the file. 0056 * This function is called when the user presses 'Ok'. The last plugin inserted 0057 * is called first. 0058 */ 0059 virtual void applyChanges(); 0060 0061 void setDirty(bool b = true); 0062 bool isDirty() const; 0063 0064 Q_SIGNALS: 0065 /** 0066 * Emit this signal when the user changed anything in the plugin's tabs. 0067 * The hosting PropertiesDialog will call applyChanges only if the 0068 * PropsPlugin has emitted this signal or if you have called setDirty() before. 0069 */ 0070 void changed(); 0071 0072 protected: 0073 /** 0074 * Pointer to the dialog 0075 */ 0076 KPropertiesDialog *const properties; 0077 0078 /** 0079 * Returns the font height. 0080 */ 0081 int fontHeight() const; 0082 0083 private: 0084 const std::unique_ptr<KPropertiesDialogPluginPrivate> d; 0085 }; 0086 #endif