diff --git a/include/dccfactory.h b/include/dccfactory.h index 61a796f381..b66aa4d97f 100644 --- a/include/dccfactory.h +++ b/include/dccfactory.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #ifndef DCCFACTORY_H @@ -8,6 +8,7 @@ namespace dccV25 { #define DccFactory_iid "org.deepin.dde.dcc-factory/v1.0" +#define QML_ENGINE_PROPERTY "QmlEngin" class DccObject; class DccFactory : public QObject @@ -16,28 +17,36 @@ class DccFactory : public QObject public: using QObject::QObject; - // 作为数据返回,会导出为dccData供main.qml使用 + // 作为数据返回,会导出为dccData供main.qml使用(在子线程执行) virtual QObject *create(QObject * = nullptr) { return nullptr; } - // 未提供qml的,可在此自己加载qml返回DccObject对象 - virtual DccObject *dccObject(QObject * = nullptr) { return nullptr; } + // 未提供qml的,可在此自己加载qml返回DccObject对象,qml相关操作,如注册qml类型(在主线程中执行) + virtual QObject *dccObject(QObject * = nullptr) { return nullptr; } }; } // namespace dccV25 Q_DECLARE_INTERFACE(dccV25::DccFactory, DccFactory_iid) -#define DCC_FACTORY_CLASS(classname) \ - namespace { \ - class Q_DECL_EXPORT classname##DccFactory : public dccV25::DccFactory \ - { \ - Q_OBJECT \ - Q_PLUGIN_METADATA(IID DccFactory_iid) \ - Q_INTERFACES(dccV25::DccFactory) \ - public: \ - using dccV25::DccFactory::DccFactory; \ - QObject *create(QObject *parent = nullptr) override \ - { \ - return new classname(parent); \ - } \ - }; \ +#define DCC_FACTORY_CLASS(classname, ...) \ + namespace { \ + class classname##DccFactory : public dccV25::DccFactory \ + { \ + Q_OBJECT \ + Q_PLUGIN_METADATA(IID DccFactory_iid) \ + Q_INTERFACES(dccV25::DccFactory) \ + public: \ + using dccV25::DccFactory::DccFactory; \ + QObject *create(QObject *parent = nullptr) override \ + { \ + return new classname(parent); \ + } \ + QObject *dccObject(QObject * = nullptr) override \ + { \ + auto executeQmlRegisters = []() { \ + __VA_ARGS__; \ + }; \ + executeQmlRegisters(); \ + return nullptr; \ + } \ + }; \ } #endif // DCCFACTORY_H diff --git a/src/dde-control-center/dccmanager.cpp b/src/dde-control-center/dccmanager.cpp index 8c23973c44..d7307a17ae 100644 --- a/src/dde-control-center/dccmanager.cpp +++ b/src/dde-control-center/dccmanager.cpp @@ -76,7 +76,7 @@ DccManager::DccManager(QObject *parent) QJSEngine::setObjectOwnership(m_noParentObjects, QQmlEngine::CppOwnership); initConfig(); - connect(m_plugins, &PluginManager::addObject, this, &DccManager::addObject, Qt::QueuedConnection); + connect(m_plugins, &PluginManager::addObject, this, &DccManager::addObject); connect(m_plugins, &PluginManager::loadAllFinished, this, &DccManager::tryShow, Qt::QueuedConnection); m_showTimer = new QTimer(this); connect(m_showTimer, &QTimer::timeout, this, &DccManager::tryShow); @@ -191,10 +191,12 @@ void DccManager::addObject(DccObject *obj) { if (!obj) return; + qWarning()<<__LINE__<<__FUNCTION__< objs; objs.append(obj); while (!objs.isEmpty()) { DccObject *o = objs.takeFirst(); + qWarning()<<__LINE__<<__FUNCTION__<<(void*)o; if (!o->name().isEmpty()) { m_objMap[o->name()].append(o); connect(o, &DccObject::destroyed, this, &DccManager::onDccObjectDestroyed, Qt::UniqueConnection); @@ -468,15 +470,15 @@ void DccManager::initConfig() connect(m_dconfig, &DConfig::valueChanged, this, &DccManager::updateModuleConfig); } -bool DccManager::contains(const QSet &urls, const DccObject *obj) +bool DccManager::containsByName(const QSet &urls, const QString &name) { for (auto &&url : urls) { if (url.contains("*")) { - if (isMatch(url, obj)) { + if (isMatchByName(url, name)) { return true; } } else { - if (isEqual(url, obj)) { + if (isEqualByName(url, name)) { return true; } } @@ -484,6 +486,11 @@ bool DccManager::contains(const QSet &urls, const DccObject *obj) return false; } +bool DccManager::contains(const QSet &urls, const DccObject *obj) +{ + return containsByName(urls, obj->parentName() + "/" + obj->name()); +} + QStringList DccManager::splitUrl(const QString &url, QString &targetName) { QStringList paths = url.split("/", Qt::SkipEmptyParts); @@ -777,7 +784,7 @@ void DccManager::clearShowParam() void DccManager::tryShow() { - if (m_showUrl.isEmpty() && !m_activeObject) { + if (m_showUrl.isEmpty() && m_showTimer) { clearShowParam(); showPage(m_root, QString()); return; @@ -801,6 +808,9 @@ void DccManager::tryShow() QDBusConnection::sessionBus().send(m_showMessage.createErrorReply(QDBusError::InvalidArgs, QString("not found url:") + m_showUrl)); } clearShowParam(); + if (!m_activeObject) { + showPage(m_root, QString()); + } } } diff --git a/src/dde-control-center/dccmanager.h b/src/dde-control-center/dccmanager.h index 66270f381f..cc28daeacd 100644 --- a/src/dde-control-center/dccmanager.h +++ b/src/dde-control-center/dccmanager.h @@ -59,6 +59,13 @@ class DccManager : public DccApp, protected QDBusContext inline const QSet &hideModule() const { return m_hideModule; } + static bool isMatchByName(const QString &url, const QString &name); + static bool isMatch(const QString &url, const DccObject *obj); + static bool isEqualByName(const QString &url, const QString &name); + static bool isEqual(const QString &url, const DccObject *obj); + static bool containsByName(const QSet &urls, const QString &name); + static bool contains(const QSet &urls, const DccObject *obj); + public Q_SLOTS: DccObject *object(const QString &name) override; void addObject(DccObject *obj) override; @@ -89,12 +96,7 @@ public Q_SLOTS: private: void initConfig(); - bool contains(const QSet &urls, const DccObject *obj); QStringList splitUrl(const QString &url, QString &targetName); - bool isMatchByName(const QString &url, const QString &name); - bool isMatch(const QString &url, const DccObject *obj); - bool isEqualByName(const QString &url, const QString &name); - bool isEqual(const QString &url, const DccObject *obj); DccObject *findObject(const QString &url); QVector findObjects(const QString &url, bool one = false); const DccObject *findParent(const DccObject *obj); diff --git a/src/dde-control-center/plugin/dccobject.cpp b/src/dde-control-center/plugin/dccobject.cpp index 7b0ce6ae1c..6c4ef0bf00 100644 --- a/src/dde-control-center/plugin/dccobject.cpp +++ b/src/dde-control-center/plugin/dccobject.cpp @@ -11,7 +11,7 @@ #include #include #include - +#include namespace dccV25 { static Q_LOGGING_CATEGORY(dccLog, "dde.dcc.object"); @@ -30,11 +30,16 @@ DccObject::Private::Private(DccObject *obj) , m_currentObject(nullptr) , m_page(nullptr) , m_parentItem(nullptr) + , m_pParent(nullptr) { } DccObject::Private::~Private() { + if(m_pParent){ + m_pParent->removeObject(q_ptr); + } + clearObject(); if (m_page && (!m_page->parent() || m_page->parent() == q_ptr)) { // Use deleteLater() to avoid dangling QObjectWrapper references in QML's // JS engine. Synchronous delete can cause crashes when GC runs during @@ -46,6 +51,7 @@ DccObject::Private::~Private() } if (m_parent) { m_parent->p_ptr->removeChild(q_ptr); + // m_parent->removeObject(q_ptr); } while (!m_children.isEmpty()) { DccObject *child = m_children.first(); @@ -55,6 +61,10 @@ DccObject::Private::~Private() // delete, then defer destruction so QML's GC can safely process any // remaining QObjectWrapper references to this child. child->setParent(nullptr); + // if(child->p_ptr->m_pParent){ + // child->p_ptr->m_pParent->removeObject(child); + // // child->p_ptr->m_pParent = nullptr; + // } child->deleteLater(); } } @@ -193,13 +203,16 @@ void DccObject::Private::addObject(DccObject *child) { if (child && !m_objects.contains(child)) { m_objects.append(child); + child->p_ptr->m_pParent=this; Q_EMIT q_ptr->addObject(child); } } void DccObject::Private::removeObject(DccObject *child) { - if (child && m_objects.removeOne(child)) { + if (child ) { + child->p_ptr->m_pParent=nullptr; + m_objects.removeOne(child); Q_EMIT q_ptr->removeObject(child); } } @@ -207,6 +220,7 @@ void DccObject::Private::removeObject(DccObject *child) void DccObject::Private::clearObject() { for (auto obj : m_objects) { + obj->p_ptr->m_pParent=nullptr; Q_EMIT q_ptr->removeObject(obj); } m_objects.clear(); @@ -249,10 +263,12 @@ DccObject::DccObject(QObject *parent) : QObject(parent) , p_ptr(new DccObject::Private(this)) { + qWarning()<<__LINE__<<__FUNCTION__<<"===== ===="< m_page; QPointer m_parentItem; // Item父项 + DccObject::Private *m_pParent; QString m_parentName; QString m_displayName; diff --git a/src/dde-control-center/plugin/dccrepeater.cpp b/src/dde-control-center/plugin/dccrepeater.cpp index 56ff8553e6..9db33f8532 100644 --- a/src/dde-control-center/plugin/dccrepeater.cpp +++ b/src/dde-control-center/plugin/dccrepeater.cpp @@ -34,7 +34,7 @@ class DccRepeaterPrivate for (int i = 0; i < itemCount; i++) { if (i >= deletables.size() || !deletables.at(i)) - model->object(i, QQmlIncubator::AsynchronousIfNested); + model->object(i, QQmlIncubator::Asynchronous); } } @@ -185,6 +185,8 @@ void DccRepeater::createdItem(int index, QObject *item) { DccObject *dccObj = qmlobject_cast(item); if (dccObj) { + Q_D(const DccRepeater); + d->model->object(index); dccObj->setParent(this); p_ptr->addObject(dccObj); Q_EMIT objAdded(index, item); diff --git a/src/dde-control-center/pluginmanager.cpp b/src/dde-control-center/pluginmanager.cpp index 6b7562edda..42027eca85 100644 --- a/src/dde-control-center/pluginmanager.cpp +++ b/src/dde-control-center/pluginmanager.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,7 @@ struct PluginData DccObject *mainObj; DccObject *soObj; QObject *data; + DccFactory *factory; QThread *thread; uint status; @@ -91,6 +93,7 @@ struct PluginData , mainObj(nullptr) , soObj(nullptr) , data(nullptr) + , factory(nullptr) , thread(nullptr) , status(PluginBegin) { @@ -112,6 +115,7 @@ class LoadPluginTask : public QRunnable protected: void run() override; void doLoadSo(); + void doCreate(); protected: PluginManager *m_pManager; @@ -121,10 +125,34 @@ class LoadPluginTask : public QRunnable void LoadPluginTask::run() { m_data->thread = QThread::currentThread(); - doLoadSo(); + doCreate(); m_data->thread = nullptr; } +void LoadPluginTask::doCreate() +{ + QElapsedTimer timer; + timer.start(); + Q_EMIT m_pManager->updatePluginStatus(m_data, DataBegin, "load plugin begin"); + QObject *dataObj = nullptr; + if (m_data->factory) { + dataObj = m_data->factory->create(); + if (dataObj && dataObj->parent()) { + dataObj->setParent(nullptr); + } + } + if (dataObj) { + m_data->data = dataObj; + } + if (m_data->data) { + m_data->data->moveToThread(m_pManager->thread()); + } + if (m_data->factory) { + m_data->factory->moveToThread(m_pManager->thread()); + } + Q_EMIT m_pManager->updatePluginStatus(m_data, DataEnd, ": create date finished. elapsed time :" + QString::number(timer.elapsed())); +} + void LoadPluginTask::doLoadSo() { Q_EMIT m_pManager->updatePluginStatus(m_data, DataBegin, "load plugin begin"); @@ -133,7 +161,6 @@ void LoadPluginTask::doLoadSo() QElapsedTimer timer; timer.start(); QObject *dataObj = nullptr; - DccObject *soObj = nullptr; if (QFile::exists(soPath)) { if (m_pManager->isDeleting()) { return; @@ -169,10 +196,7 @@ void LoadPluginTask::doLoadSo() if (dataObj && dataObj->parent()) { dataObj->setParent(nullptr); } - soObj = factory->dccObject(); - if (soObj && soObj->parent()) { - soObj->setParent(nullptr); - } + m_data->factory = factory; } while (false); } } else { @@ -181,20 +205,82 @@ void LoadPluginTask::doLoadSo() if (dataObj) { m_data->data = dataObj; } - if (soObj) { - m_data->soObj = soObj; - } if (m_data->data) { m_data->data->moveToThread(m_pManager->thread()); - m_data->data->setParent(m_pManager->parent()); } - if (m_data->soObj) { - m_data->soObj->moveToThread(m_pManager->thread()); - m_data->soObj->setParent(m_pManager->parent()); + if (m_data->factory) { + m_data->factory->moveToThread(m_pManager->thread()); } Q_EMIT m_pManager->updatePluginStatus(m_data, DataEnd, ": load plugin finished. elapsed time :" + QString::number(timer.elapsed())); } + +class DccIncubator : public QQmlIncubator +{ +public: + DccIncubator(PluginManager *pManager,PluginData *data,QQmlComponent *component,QQmlContext *context) + : QQmlIncubator(Asynchronous) + , m_pManager(pManager) + , m_data(data) + , m_component(component) + ,m_context(context) + { + } + +protected: + // 当对象孵化(创建)完成时调用 + void setInitialState(QObject *object) override + { + // 这里可以做一些初始化设置,但通常建议在 statusChanged 中处理 + QQmlIncubator::setInitialState(object); + } + + void statusChanged(Status status) override + { + switch(status){ + case Ready:{ + QObject *obj = object(); + m_component->deleteLater(); + if (!obj) { + m_context->deleteLater(); + Q_EMIT m_pManager->updatePluginStatus(m_data, MainObjErr | MainObjEnd, " component create main object is null:" + m_component->errorString()); + return; + } + m_context->setParent(m_context); + obj->setParent(m_data->module ? m_data->module : nullptr); + m_data->mainObj = qobject_cast(obj); + qWarning()<<__LINE__<<__FUNCTION__<<"=====MainEnd===="<mainObj<name<updatePluginStatus(m_data, MainObjEnd, ": create main finished"); + // Q_EMIT objectFinished(object()); + }break; + case Error:{ + Q_EMIT m_pManager->updatePluginStatus(m_data, MainObjErr | MainObjEnd, " component create main object error:" + m_component->errorString()); + m_component->deleteLater(); + // Q_EMIT objectFinished(nullptr); + }break; + default: + break; + } + + // if (status == Ready) { + // // 对象创建成功,object() 返回的是 QObject*,需要转换为具体类型 + // QObject *obj = object(); + // qDebug() << "对象异步创建成功:" << obj; + // // 发射信号通知外部 + // Q_EMIT objectFinished(obj); + // } else if (status == Error) { + // qWarning() << "异步创建出错:" << errors(); + // Q_EMIT objectFinished(nullptr); + // } + } +private: + PluginManager *m_pManager; + PluginData *m_data; + QQmlComponent *m_component; + QQmlContext *m_context; + +}; + PluginManager::PluginManager(DccManager *parent) : QObject(parent) , m_manager(parent) @@ -327,17 +413,84 @@ void PluginManager::loadPlugin(PluginData *plugin) addMainObject(plugin); Q_EMIT updatePluginStatus(plugin, PluginEnd, QString()); } else if ((plugin->status & (DataEnd | MainObjLoad)) == DataEnd) { + if (plugin->data) { + plugin->data->setParent(this); + QJSEngine::setObjectOwnership(plugin->data, QQmlEngine::CppOwnership); + } + if (plugin->factory) { + plugin->factory->setProperty(QML_ENGINE_PROPERTY, QVariant::fromValue(m_manager->engine())); + QObject *obj = plugin->factory->dccObject(); + DccObject *soObj = dynamic_cast(obj); + if (soObj) { + plugin->soObj = soObj; + } else if (obj) { + obj->deleteLater(); + } + } loadMain(plugin); } else if ((plugin->status & (ModuleEnd | DataBegin)) == ModuleEnd) { + auto loadfun = [&]() { + const QString soPath = plugin->path + "/" + plugin->name + ".so"; + QElapsedTimer timer; + timer.start(); + if (QFile::exists(soPath)) { + if (isDeleting()) { + return; + } + QPluginLoader loader(soPath); + Q_EMIT updatePluginStatus(plugin, DataLoad, QString()); + loader.load(); + if (isDeleting()) { + return; + } + if (!loader.isLoaded()) { + Q_EMIT updatePluginStatus(plugin, DataErr, "Load the plugin failed." + loader.errorString()); + } else { + const auto &meta = loader.metaData(); + do { + const auto iid = meta["IID"].toString(); + if (iid.isEmpty() || iid != QString(qobject_interface_iid())) { + Q_EMIT updatePluginStatus(plugin, DataErr, "Error iid:" + iid); + break; + } + + if (!loader.instance()) { + Q_EMIT updatePluginStatus(plugin, DataErr, "instance() failed." + loader.errorString()); + break; + } + DccFactory *factory = qobject_cast(loader.instance()); + if (!factory) { + Q_EMIT updatePluginStatus(plugin, DataErr, "The plugin isn't a DccFactory." + soPath); + loader.unload(); + break; + } + QObject *dataObj = factory->dccObject(); + // if (dataObj && dataObj->parent()) { + // dataObj->setParent(nullptr); + // } + // if (dataObj) { + // plugin->data = dataObj; + // } + // if (plugin->data) { + // plugin->data->moveToThread(thread()); + // } + plugin->factory = factory; + } while (false); + } + } + qWarning() << __LINE__ << __FUNCTION__ <name<< ": load plugin finished. elapsed time :" << QString::number(timer.elapsed()); + }; if (plugin->module) { disconnect(plugin->module, nullptr, this, nullptr); if (plugin->module->isVisibleToApp()) { + loadfun(); threadPool()->start(new LoadPluginTask(plugin, this)); } else { connect(plugin->module, &DccObject::visibleToAppChanged, this, &PluginManager::onVisibleToAppChanged); Q_EMIT updatePluginStatus(plugin, PluginEnd, QString()); } } else { + loadfun(); threadPool()->start(new LoadPluginTask(plugin, this)); } } else if ((plugin->status & (MetaDataEnd | ModuleLoad)) == MetaDataEnd) { @@ -371,7 +524,7 @@ void PluginManager::loadMetaData(PluginData *plugin) return; } updatePluginType(plugin); - if (m_manager->hideModule().contains(plugin->name)) { + if (DccManager::containsByName(m_manager->hideModule(), plugin->name)) { // 跳过隐藏的模块,需要动态加载回来 Q_EMIT updatePluginStatus(plugin, PluginEnd | MetaDataEnd, QString()); return; @@ -495,15 +648,20 @@ void PluginManager::createMain(QQmlComponent *component) case QQmlComponent::Ready: { QQmlContext *context = new QQmlContext(component->engine()); context->setContextProperties({ { "dccData", QVariant::fromValue(plugin->data) }, { "dccModule", QVariant::fromValue(plugin->module) } }); - QObject *object = component->create(context); - component->deleteLater(); - if (!object) { - Q_EMIT updatePluginStatus(plugin, MainObjErr | MainObjEnd, " component create main object is null:" + component->errorString()); - return; - } - object->setParent(plugin->module ? plugin->module : m_rootModule); - plugin->mainObj = qobject_cast(object); - Q_EMIT updatePluginStatus(plugin, MainObjEnd, ": create main finished"); + DccIncubator *incubator = new DccIncubator(this,plugin,component,context); + + component->create(*incubator,context,nullptr); + // QObject *object = component->create(context); + // component->deleteLater(); + // if (!object) { + // context->deleteLater(); + // Q_EMIT updatePluginStatus(plugin, MainObjErr | MainObjEnd, " component create main object is null:" + component->errorString()); + // return; + // } + // context->setParent(object); + // object->setParent(plugin->module ? plugin->module : m_rootModule); + // plugin->mainObj = qobject_cast(object); + // Q_EMIT updatePluginStatus(plugin, MainObjEnd, ": create main finished"); } break; case QQmlComponent::Error: { Q_EMIT updatePluginStatus(plugin, MainObjErr | MainObjEnd, " component create main object error:" + component->errorString()); @@ -545,13 +703,13 @@ void PluginManager::addMainObject(PluginData *plugin) } else { Q_EMIT updatePluginStatus(plugin, MainObjErr, "The plugin isn't main DccObject"); } - Q_EMIT updatePluginStatus(plugin, MainObjEnd | PluginEnd, "add main object finished"); if (plugin->mainObj) { Q_EMIT addObject(plugin->mainObj); } if (plugin->soObj) { Q_EMIT addObject(plugin->soObj); } + Q_EMIT updatePluginStatus(plugin, MainObjEnd | PluginEnd, "add main object finished"); } void PluginManager::moduleLoading() diff --git a/src/plugin-accounts/operation/accountscontroller.cpp b/src/plugin-accounts/operation/accountscontroller.cpp index 295ea21117..baa2f84be6 100644 --- a/src/plugin-accounts/operation/accountscontroller.cpp +++ b/src/plugin-accounts/operation/accountscontroller.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -30,7 +31,7 @@ DCORE_USE_NAMESPACE namespace dccV25 { -DCC_FACTORY_CLASS(AccountsController) +DCC_FACTORY_CLASS(AccountsController, qmlRegisterType("AccountsController", 1, 0, "CreationResult")) static bool isUserGroupName(int gid, const QString &name) { @@ -45,8 +46,6 @@ static bool isUserGroupName(int gid, const QString &name) AccountsController::AccountsController(QObject *parent) : QObject{ parent } { - qmlRegisterType("AccountsController", 1, 0, "CreationResult"); - m_model = new UserModel(this); m_worker = new AccountsWorker(m_model, this); diff --git a/src/plugin-accounts/operation/accountscontroller.h b/src/plugin-accounts/operation/accountscontroller.h index eb25600893..acf40faca2 100644 --- a/src/plugin-accounts/operation/accountscontroller.h +++ b/src/plugin-accounts/operation/accountscontroller.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -12,7 +12,6 @@ #include #include #include -#include namespace dccV25 { diff --git a/src/plugin-authentication/operation/biometricauthcontroller.cpp b/src/plugin-authentication/operation/biometricauthcontroller.cpp index 15d1d364d1..090a59054f 100644 --- a/src/plugin-authentication/operation/biometricauthcontroller.cpp +++ b/src/plugin-authentication/operation/biometricauthcontroller.cpp @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later @@ -8,19 +8,17 @@ namespace dccV25 { -DCC_FACTORY_CLASS(BiometricAuthController) +DCC_FACTORY_CLASS(BiometricAuthController, \ + qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "CharaMangerModel"); \ + qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "FaceAuthController"); \ + qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "FingerprintAuthController"); \ + qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "IrisAuthController")) BiometricAuthController::BiometricAuthController(QObject *parent) : QObject(parent) , m_charaModel(new CharaMangerModel(this)) , m_charaWorker(new CharaMangerWorker(m_charaModel, this)) { - // 注册QML类型 - qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "CharaMangerModel"); - qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "FaceAuthController"); - qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "FingerprintAuthController"); - qmlRegisterType("org.deepin.dcc.account.biometric", 1, 0, "IrisAuthController"); - // 创建子控制器 m_faceController = new FaceAuthController(m_charaModel, m_charaWorker, this); m_fingerprintController = new FingerprintAuthController(m_charaModel, m_charaWorker, this); diff --git a/src/plugin-bluetooth/operation/bluetoothinteraction.cpp b/src/plugin-bluetooth/operation/bluetoothinteraction.cpp index 5f73528147..1824d59943 100644 --- a/src/plugin-bluetooth/operation/bluetoothinteraction.cpp +++ b/src/plugin-bluetooth/operation/bluetoothinteraction.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -13,9 +13,6 @@ BluetoothInteraction::BluetoothInteraction(QObject *parent) , m_work(new BluetoothWorker(m_model, this)) { m_work->activate(); - - qmlRegisterType("dcc", 1, 0, "BluetoothWorker"); - qmlRegisterType("dcc", 1, 0, "BluetoothModel"); } BluetoothModel *BluetoothInteraction::model() const @@ -39,6 +36,8 @@ void BluetoothInteraction::setWork(BluetoothWorker *newWork) } -DCC_FACTORY_CLASS(BluetoothInteraction) +DCC_FACTORY_CLASS(BluetoothInteraction, \ + qmlRegisterType("dcc", 1, 0, "BluetoothWorker"); \ + qmlRegisterType("dcc", 1, 0, "BluetoothModel")) #include "bluetoothinteraction.moc" diff --git a/src/plugin-bluetooth/operation/bluetoothmodel.h b/src/plugin-bluetooth/operation/bluetoothmodel.h index 7a9b89de43..506c51f25c 100644 --- a/src/plugin-bluetooth/operation/bluetoothmodel.h +++ b/src/plugin-bluetooth/operation/bluetoothmodel.h @@ -1,11 +1,10 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #ifndef DCC_BLUETOOTH_BLUETOOTHMODEL_H #define DCC_BLUETOOTH_BLUETOOTHMODEL_H #include -#include #include "bluetoothadapter.h" #include "bluetoothadaptersmodel.h" @@ -18,8 +17,6 @@ class BluetoothModel : public QObject Q_PROPERTY(bool airplaneEnable READ airplaneEnable NOTIFY airplaneEnableChanged FINAL) Q_PROPERTY(bool showBluetooth READ showBluetooth NOTIFY showBluetoothChanged FINAL) - QML_NAMED_ELEMENT(BluetoothModel) - QML_SINGLETON public: explicit BluetoothModel(QObject *parent = nullptr); diff --git a/src/plugin-commoninfo/operation/commoninfointeraction.cpp b/src/plugin-commoninfo/operation/commoninfointeraction.cpp index 8228308121..c17b5d1c07 100644 --- a/src/plugin-commoninfo/operation/commoninfointeraction.cpp +++ b/src/plugin-commoninfo/operation/commoninfointeraction.cpp @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later @@ -12,9 +12,6 @@ CommonInfoInteraction::CommonInfoInteraction(QObject *parent) , m_work(NULL) , m_mode(NULL) { - qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "CommonInfoWork"); - qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "CommonInfoModel"); - m_mode = new CommonInfoModel(this); m_work = new CommonInfoWork(m_mode, this); @@ -41,7 +38,9 @@ void CommonInfoInteraction::setMode(CommonInfoModel *newMode) m_mode = newMode; } -DCC_FACTORY_CLASS(CommonInfoInteraction) +DCC_FACTORY_CLASS(CommonInfoInteraction,\ + qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "CommonInfoWork"),\ + qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "CommonInfoModel")) #include "commoninfointeraction.moc" diff --git a/src/plugin-commoninfo/operation/commoninfomodel.h b/src/plugin-commoninfo/operation/commoninfomodel.h index 90ff3dfe49..1afd6a8d90 100644 --- a/src/plugin-commoninfo/operation/commoninfomodel.h +++ b/src/plugin-commoninfo/operation/commoninfomodel.h @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #pragma once @@ -6,7 +6,6 @@ #include "grubanimationmodel.h" #include "grubmenulistmodel.h" -#include #include #include @@ -14,9 +13,6 @@ class CommonInfoModel : public QObject { Q_OBJECT - QML_NAMED_ELEMENT(CommonInfoModel) - QML_SINGLETON - Q_PROPERTY(bool bootDelay READ bootDelay NOTIFY bootDelayChanged FINAL) Q_PROPERTY(bool themeEnabled READ themeEnabled NOTIFY themeEnabledChanged FINAL) Q_PROPERTY(bool grubEditAuthEnabled READ grubEditAuthEnabled NOTIFY grubEditAuthEnabledChanged FINAL) diff --git a/src/plugin-datetime/operation/datetimemodel.cpp b/src/plugin-datetime/operation/datetimemodel.cpp index 3cad90f550..ff60b3e93f 100644 --- a/src/plugin-datetime/operation/datetimemodel.cpp +++ b/src/plugin-datetime/operation/datetimemodel.cpp @@ -236,8 +236,6 @@ DatetimeModel::DatetimeModel(QObject *parent) connect(this, &DatetimeModel::longTimeFormatChanged, this, [this]() { Q_EMIT currentFormatChanged(LongTime); }); - - qmlRegisterType("ZoneInfoModel", 1, 0, "ZoneInfoModel"); } DatetimeModel::~DatetimeModel() @@ -1630,6 +1628,6 @@ void DatetimeModel::updateCurrentTime() } } -DCC_FACTORY_CLASS(DatetimeModel) +DCC_FACTORY_CLASS(DatetimeModel, qmlRegisterType("ZoneInfoModel", 1, 0, "ZoneInfoModel")) #include "datetimemodel.moc" diff --git a/src/plugin-defaultapp/operation/defappmodel.cpp b/src/plugin-defaultapp/operation/defappmodel.cpp index 00e91f2cb3..f53ffcdea1 100644 --- a/src/plugin-defaultapp/operation/defappmodel.cpp +++ b/src/plugin-defaultapp/operation/defappmodel.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "defappmodel.h" @@ -13,7 +13,6 @@ DefAppModel::DefAppModel(QObject *parent) : QObject(parent) { - qmlRegisterType("org.deepin.dcc.defApp", 1, 0, "CategoryModel"); for (int i = 0; i < Count; i++) { m_categoryModel[i] = new CategoryModel(new Category(this)); } @@ -48,6 +47,6 @@ DefAppModel::~DefAppModel() } } -DCC_FACTORY_CLASS(DefAppModel) +DCC_FACTORY_CLASS(DefAppModel, qmlRegisterType("org.deepin.dcc.defApp", 1, 0, "CategoryModel")) #include "defappmodel.moc" diff --git a/src/plugin-display/operation/displaymodule.cpp b/src/plugin-display/operation/displaymodule.cpp index 2ac6c91f4c..0e1404376c 100644 --- a/src/plugin-display/operation/displaymodule.cpp +++ b/src/plugin-display/operation/displaymodule.cpp @@ -59,6 +59,8 @@ class Rect : public QRect DisplayModulePrivate::DisplayModulePrivate(DisplayModule *parent) : q_ptr(parent) + , m_model(nullptr) + , m_worker(nullptr) , m_primary(nullptr) , m_maxGlobalScale(1.0) { diff --git a/src/plugin-mouse/operation/mousemodel.h b/src/plugin-mouse/operation/mousemodel.h index 98ceb31da5..97f3f761be 100644 --- a/src/plugin-mouse/operation/mousemodel.h +++ b/src/plugin-mouse/operation/mousemodel.h @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #ifndef MOUSEMODEL_H @@ -10,7 +10,6 @@ #include #include #include -#include #include namespace DCC_NAMESPACE { diff --git a/src/plugin-personalization/operation/imagehelper.cpp b/src/plugin-personalization/operation/imagehelper.cpp index f4c533dd47..0af73b3854 100644 --- a/src/plugin-personalization/operation/imagehelper.cpp +++ b/src/plugin-personalization/operation/imagehelper.cpp @@ -1,9 +1,9 @@ -//SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #include -#include +// #include #include "imagehelper.h" diff --git a/src/plugin-personalization/operation/personalizationinterface.cpp b/src/plugin-personalization/operation/personalizationinterface.cpp index 53523589b0..bea9c7f397 100644 --- a/src/plugin-personalization/operation/personalizationinterface.cpp +++ b/src/plugin-personalization/operation/personalizationinterface.cpp @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later @@ -142,15 +142,12 @@ PersonalizationInterface::PersonalizationInterface(QObject *parent) , m_pickerId(QUuid::createUuid().toString()) , m_pickerAvailable(false) { - qmlRegisterType("org.deepin.dcc.personalization", 1, 0, "PersonalizationData"); if (Dtk::Gui::DGuiApplicationHelper::testAttribute(Dtk::Gui::DGuiApplicationHelper::IsWaylandPlatform)) { m_work = new TreeLandWorker(m_model, this); } else { m_work = new X11Worker(m_model, this); } - qmlRegisterType("org.deepin.dcc.personalization", 1, 0, "PersonalizationExport"); - m_globalThemeViewModel->setThemeModel(m_model->getGlobalThemeModel()); m_iconThemeViewModel->setThemeModel(m_model->getIconModel()); m_cursorThemeViewModel->setThemeModel(m_model->getMouseModel()); @@ -314,6 +311,8 @@ void PersonalizationInterface::onPickerColorPicked(const QString &uuid, const QS } } -DCC_FACTORY_CLASS(PersonalizationInterface) +DCC_FACTORY_CLASS(PersonalizationInterface,\ + qmlRegisterType("org.deepin.dcc.personalization", 1, 0, "PersonalizationData"),\ + qmlRegisterType("org.deepin.dcc.personalization", 1, 0, "PersonalizationExport")) #include "personalizationinterface.moc" diff --git a/src/plugin-power/operation/poweroperatormodel.h b/src/plugin-power/operation/poweroperatormodel.h index d72087f22f..1719385dc0 100644 --- a/src/plugin-power/operation/poweroperatormodel.h +++ b/src/plugin-power/operation/poweroperatormodel.h @@ -1,10 +1,9 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #ifndef POWEROPERATORMODEL_H #define POWEROPERATORMODEL_H -#include #include enum PowerOperatorType{ @@ -29,7 +28,6 @@ struct PowerOperator class PowerOperatorModel : public QAbstractListModel { Q_OBJECT - QML_NAMED_ELEMENT(PowerOperatorModel) public: enum PowerOperatorRole @@ -63,4 +61,4 @@ class PowerOperatorModel : public QAbstractListModel Q_DECLARE_METATYPE(PowerOperatorModel) -#endif // POWEROPERATORMODEL_H \ No newline at end of file +#endif // POWEROPERATORMODEL_H diff --git a/src/plugin-power/operation/utils.h b/src/plugin-power/operation/utils.h index b8b393a11a..3a3cf5c49e 100644 --- a/src/plugin-power/operation/utils.h +++ b/src/plugin-power/operation/utils.h @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #ifndef UTILS_H diff --git a/src/plugin-privacy/operation/privacysecurityexport.cpp b/src/plugin-privacy/operation/privacysecurityexport.cpp index 834731b9de..6166bf591d 100644 --- a/src/plugin-privacy/operation/privacysecurityexport.cpp +++ b/src/plugin-privacy/operation/privacysecurityexport.cpp @@ -1,10 +1,11 @@ -// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "privacysecurityexport.h" -#include "dccfactory.h" + #include "applicationitem.h" +#include "dccfactory.h" #include "privacysecuritymodel.h" #include "privacysecurityworker.h" @@ -19,10 +20,8 @@ PrivacySecurityExport::PrivacySecurityExport(QObject *parent) , m_woker(new PrivacySecurityWorker(m_privacyModel, this)) { m_appsModel = m_privacyModel->appModel(); - - qmlRegisterType("org.deepin.dcc.privacy", 1, 0, "ApplicationItem"); } -DCC_FACTORY_CLASS(PrivacySecurityExport) +DCC_FACTORY_CLASS(PrivacySecurityExport, qmlRegisterType("org.deepin.dcc.privacy", 1, 0, "ApplicationItem")) #include "privacysecurityexport.moc" diff --git a/src/plugin-privacy/operation/privacysecurityworker.cpp b/src/plugin-privacy/operation/privacysecurityworker.cpp index f30037f800..126b5326fe 100644 --- a/src/plugin-privacy/operation/privacysecurityworker.cpp +++ b/src/plugin-privacy/operation/privacysecurityworker.cpp @@ -536,7 +536,7 @@ ApplicationItem *PrivacySecurityWorker::addAppItem(int dataIndex) return nullptr; } - ApplicationItem *appItem = new ApplicationItem(); + ApplicationItem *appItem = new ApplicationItem(m_model); appItem->onIdChanged(id); appItem->onNameChanged(name); appItem->onIconChanged(iconName); diff --git a/src/plugin-sound/operation/soundInteraction.cpp b/src/plugin-sound/operation/soundInteraction.cpp index 52288baed8..3b6a21359b 100644 --- a/src/plugin-sound/operation/soundInteraction.cpp +++ b/src/plugin-sound/operation/soundInteraction.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "soundInteraction.h" @@ -6,6 +6,7 @@ #include "dccfactory.h" #include +#include using namespace dccV25; @@ -15,9 +16,6 @@ soundInteraction::soundInteraction(QObject *parent) , m_soundWork(new SoundWorker(m_soundModel,this)) { m_soundWork->activate(); - - qmlRegisterType("dcc", 1, 0, "SoundWorker"); - qmlRegisterType("dcc", 1, 0, "SoundModel"); } soundInteraction::~soundInteraction() @@ -50,6 +48,9 @@ void soundInteraction::setSinkVolume(double value) m_soundWork->setSinkVolume(value); } -DCC_FACTORY_CLASS(soundInteraction) +DCC_FACTORY_CLASS(soundInteraction,\ + qmlRegisterType("dcc", 1, 0, "SoundWorker"),\ + qmlRegisterType("dcc", 1, 0, "SoundModel"),\ + qmlRegisterType("SoundDeviceModel", 1, 0, "SoundDeviceModel")) #include "soundInteraction.moc" diff --git a/src/plugin-sound/operation/soundeffectsmodel.h b/src/plugin-sound/operation/soundeffectsmodel.h index b660764142..75445deea8 100644 --- a/src/plugin-sound/operation/soundeffectsmodel.h +++ b/src/plugin-sound/operation/soundeffectsmodel.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #ifndef SOUNDEFFECTSMODEL_H @@ -9,14 +9,11 @@ #include "soundEffectsData.h" -#include class SoundEffectsModel : public QAbstractListModel { Q_OBJECT - QML_NAMED_ELEMENT(SoundEffectsModel) - QML_SINGLETON public: enum soundEffectsRoles{ diff --git a/src/plugin-sound/operation/soundmodel.cpp b/src/plugin-sound/operation/soundmodel.cpp index 118afe0f0d..6e43f3b590 100644 --- a/src/plugin-sound/operation/soundmodel.cpp +++ b/src/plugin-sound/operation/soundmodel.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "soundmodel.h" @@ -13,8 +13,8 @@ Q_LOGGING_CATEGORY(DdcSoundModel, "dcc-sound-model") -const static Dtk::Core::DSysInfo::UosType UosType = Dtk::Core::DSysInfo::uosType(); -const static bool IsServerSystem = (Dtk::Core::DSysInfo::UosServer == UosType); //是否是服务器版 +// const static Dtk::Core::DSysInfo::UosType UosType = Dtk::Core::DSysInfo::uosType(); +// const static bool IsServerSystem = (Dtk::Core::DSysInfo::UosServer == UosType); //是否是服务器版 static const QMap SOUND_EFFECT_MAP{ { DDesktopServices::SystemSoundEffect::SSE_Notifications, "message" }, @@ -97,11 +97,10 @@ SoundModel::SoundModel(QObject *parent) { tr("Error"), DDesktopServices::SSE_Error }, }; - if (IsServerSystem) { + if (Dtk::Core::DSysInfo::UosServer == Dtk::Core::DSysInfo::uosType()) { m_soundEffectMapBattery.removeOne({ tr("Wake up"), DDesktopServices::SSE_WakeUp }); m_soundEffectMapPower.removeOne({ tr("Wake up"), DDesktopServices::SSE_WakeUp }); } - qmlRegisterType("SoundDeviceModel", 1, 0, "SoundDeviceModel"); } SoundModel::~SoundModel() diff --git a/src/plugin-sound/operation/soundmodel.h b/src/plugin-sound/operation/soundmodel.h index 1d8f2d2114..ec2a751a66 100644 --- a/src/plugin-sound/operation/soundmodel.h +++ b/src/plugin-sound/operation/soundmodel.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #ifndef DCC_SOUND_SOUNDMODEL_H @@ -9,7 +9,6 @@ #include #include #include -#include #include "soundeffectsmodel.h" #include "soundDeviceModel.h" @@ -59,8 +58,6 @@ class SoundModel : public QObject Q_PROPERTY(bool speakerOn READ speakerOn NOTIFY speakerOnChanged FINAL) Q_PROPERTY(bool microphoneOn READ microphoneOn NOTIFY microphoneOnChanged FINAL) - QML_NAMED_ELEMENT(SoundModel) - QML_SINGLETON public: explicit SoundModel(QObject *parent = 0); ~SoundModel(); diff --git a/src/plugin-sound/operation/soundworker.h b/src/plugin-sound/operation/soundworker.h index 338d1f9f4f..3529f25448 100644 --- a/src/plugin-sound/operation/soundworker.h +++ b/src/plugin-sound/operation/soundworker.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #ifndef SOUNDWORKER_H @@ -12,7 +12,6 @@ #include #include "qdbusconnectioninterface.h" -#include #include #include #include @@ -21,8 +20,6 @@ class SoundWorker : public QObject { Q_OBJECT - QML_NAMED_ELEMENT(SoundWorker) - QML_SINGLETON public: explicit SoundWorker(SoundModel *model, QObject * parent = 0); diff --git a/src/plugin-systeminfo/operation/systeminfointeraction.cpp b/src/plugin-systeminfo/operation/systeminfointeraction.cpp index ce536cb2a7..6de8e71333 100644 --- a/src/plugin-systeminfo/operation/systeminfointeraction.cpp +++ b/src/plugin-systeminfo/operation/systeminfointeraction.cpp @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #include "systeminfointeraction.h" @@ -14,9 +14,6 @@ SystemInfoInteraction::SystemInfoInteraction(QObject *parent) , m_systemInfoWork(nullptr) , m_systemInfoMode(nullptr) { - qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "SystemInfoWork"); - qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "SystemInfoModel"); - m_systemInfoMode = new SystemInfoModel(this); m_systemInfoWork = new SystemInfoWork(m_systemInfoMode, this); @@ -44,7 +41,8 @@ void SystemInfoInteraction::setSystemInfoMode(SystemInfoModel *newSystemInfoMode m_systemInfoMode = newSystemInfoMode; } -DCC_FACTORY_CLASS(SystemInfoInteraction) - +DCC_FACTORY_CLASS(SystemInfoInteraction,\ + qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "SystemInfoWork"),\ + qmlRegisterType("org.deepin.dcc.systemInfo", 1, 0, "SystemInfoModel")) #include "systeminfointeraction.moc" diff --git a/src/plugin-touchscreen/operation/touchscreenmodel.cpp b/src/plugin-touchscreen/operation/touchscreenmodel.cpp index 82e00b32a8..1d6a285608 100644 --- a/src/plugin-touchscreen/operation/touchscreenmodel.cpp +++ b/src/plugin-touchscreen/operation/touchscreenmodel.cpp @@ -1,4 +1,4 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd. // //SPDX-License-Identifier: GPL-3.0-or-later #include "touchscreenmodel.h" @@ -17,7 +17,6 @@ TouchScreenModel::TouchScreenModel(QObject *parent) , DCC_INIT_PRIVATE(TouchScreenModel) , m_touchScreenMatchModel(new TouchScreenMatchModel(this)) { - qmlRegisterType("org.deepin.dcc.touchscreen", 1, 0, "TouchScreenMatchModel"); } TouchScreenModel::~TouchScreenModel() @@ -92,5 +91,5 @@ void TouchScreenModelPrivate::assoiateTouchNotify() .call(); } -DCC_FACTORY_CLASS(TouchScreenModel) +DCC_FACTORY_CLASS(TouchScreenModel, qmlRegisterType("org.deepin.dcc.touchscreen", 1, 0, "TouchScreenMatchModel")) #include "touchscreenmodel.moc"