kdecore: replace component with class headers inclusion

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-19 07:02:09 +03:00
parent 687fcc041c
commit 059c365fee

View file

@ -24,78 +24,69 @@
#include "kdedmodule.h" #include "kdedmodule.h"
#include "kdebug.h" #include "kdebug.h"
#include <QtCore/QTimer> #include <QTimer>
#include <QtDBus/QtDBus> #include <QDBusObjectPath>
#include <QDBusConnection>
class KDEDModulePrivate class KDEDModulePrivate
{ {
public: public:
QString moduleName; QString moduleName;
}; };
KDEDModule::KDEDModule(QObject* parent) KDEDModule::KDEDModule(QObject* parent)
: QObject(parent), d(new KDEDModulePrivate) : QObject(parent),
d(new KDEDModulePrivate())
{ {
} }
KDEDModule::~KDEDModule() KDEDModule::~KDEDModule()
{ {
emit moduleDeleted(this); emit moduleDeleted(this);
delete d; delete d;
} }
void KDEDModule::setModuleName( const QString& name ) void KDEDModule::setModuleName(const QString &name)
{ {
d->moduleName = name; d->moduleName = name;
QDBusObjectPath realPath( QString::fromLatin1("/modules/") + d->moduleName); QDBusObjectPath realPath( QString::fromLatin1("/modules/") + d->moduleName);
if (realPath.path().isEmpty()) if (realPath.path().isEmpty()) {
{ kError() << "The kded module name '" << name << "' is invalid!";
kError() << "The kded module name '" << name << "' is invalid!"; return;
return; }
}
QDBusConnection::RegisterOptions regOptions;
QDBusConnection::RegisterOptions regOptions; if (this->metaObject()->indexOfClassInfo("D-Bus Interface") != -1) {
// 1. There are kded modules that don't have a D-Bus interface.
if (this->metaObject()->indexOfClassInfo("D-Bus Interface")!=-1) // 2. qt 4.4.3 crashes when trying to emit signals on class without
{ // Q_CLASSINFO("D-Bus Interface", "<your interface>") but
// 1. There are kded modules that don't have a D-Bus interface. // ExportSignal set.
// 2. qt 4.4.3 crashes when trying to emit signals on class without // We try to solve that for now with just registering Properties and
// Q_CLASSINFO("D-Bus Interface", "<your interface>") but // Adaptors. But we should investigate where the sense is in registering
// ExportSignal set. // the module at all. Just for autoload? Is there a better solution?
// We try to solve that for now with just registering Properties and regOptions = QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors;
// Adaptors. But we should investigate where the sense is in registering } else {
// the module at all. Just for autoload? Is there a better solution? // Full functional module. Register everything.
regOptions = QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors; regOptions = QDBusConnection::ExportScriptableSlots
}
else
{
// Full functional module. Register everything.
regOptions = QDBusConnection::ExportScriptableSlots
| QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportScriptableProperties
| QDBusConnection::ExportAdaptors; | QDBusConnection::ExportAdaptors;
kDebug() << "Registration of kded module " << d->moduleName << "without D-Bus interface."; kDebug() << "Registration of kded module " << d->moduleName << "without D-Bus interface.";
} }
if (!QDBusConnection::sessionBus().registerObject(realPath.path(), this, regOptions))
{
// Happens for khotkeys but the module works. Need some time to investigate.
kDebug() << "registerObject() returned false for " << d->moduleName;
}
else
{
kDebug() << "registerObject() successful for " << d->moduleName;
emit moduleRegistered(realPath);
}
if (!QDBusConnection::sessionBus().registerObject(realPath.path(), this, regOptions)) {
// Happens for khotkeys but the module works. Need some time to investigate.
kDebug() << "registerObject() returned false for " << d->moduleName;
} else {
kDebug() << "registerObject() successful for " << d->moduleName;
emit moduleRegistered(realPath);
}
} }
QString KDEDModule::moduleName() const QString KDEDModule::moduleName() const
{ {
return d->moduleName; return d->moduleName;
} }
#include "moc_kdedmodule.cpp" #include "moc_kdedmodule.cpp"