diff --git a/src/widgets/kpropertiesdialog.h b/src/widgets/kpropertiesdialog.h --- a/src/widgets/kpropertiesdialog.h +++ b/src/widgets/kpropertiesdialog.h @@ -234,6 +234,22 @@ */ void insertPlugin(KPropertiesDialogPlugin *plugin); + /** + * Adds a "3rd party" properties plugin to the dialog. Useful + * for extending the properties mechanism. + * + * To create a new plugin type, inherit from the base class KPropertiesDialogPlugin + * and implement all the methods. If you define a service .desktop file + * for your plugin, you do not need to call insertPlugin(). + * + * @param plugin plugin is a pointer to the KPropertiesDialogPlugin. The Properties + * dialog will do destruction for you. The KPropertiesDialogPlugin \b must + * have been created with the KPropertiesDialog as its parent. + * @param index specifies wanted position by number, starting from 0. + * @see KPropertiesDialogPlugin + */ + void KPropertiesDialog::insertPluginAt(KPropertiesDialogPlugin *plugin, int index); + #if KIOWIDGETS_ENABLE_DEPRECATED_SINCE(5, 0) /** * @deprecated since 5.0, use url() diff --git a/src/widgets/kpropertiesdialog.cpp b/src/widgets/kpropertiesdialog.cpp --- a/src/widgets/kpropertiesdialog.cpp +++ b/src/widgets/kpropertiesdialog.cpp @@ -469,6 +469,14 @@ d->m_pageList.append(plugin); } +void KPropertiesDialog::insertPluginAt(KPropertiesDialogPlugin *plugin, int index) +{ + connect(plugin, &KPropertiesDialogPlugin::changed, + plugin, QOverload<>::of(&KPropertiesDialogPlugin::setDirty)); + + d->m_pageList.insert(index, plugin); +} + QUrl KPropertiesDialog::url() const { return d->m_singleUrl; @@ -634,7 +642,11 @@ } plugin->setObjectName(ptr->name()); - q->insertPlugin(plugin); + if (ptr->serviceId() == QStringLiteral("baloofilepropertiesplugin")) { + q->insertPluginAt(plugin, 1); + } else { + q->insertPlugin(plugin); + } } }