注册设置模块的元对象

This commit is contained in:
hewenfei 2022-12-13 09:08:51 +08:00
parent f3053a7076
commit f25ad51865
4 changed files with 17 additions and 2 deletions

View File

@ -85,7 +85,7 @@ private:
class CommonsModule class CommonsModule
{ {
public: public:
static void defineCommonsMod(const char *uri, int versionMajor, int versionMinor) { static void defineModule(const char *uri, int versionMajor, int versionMinor) {
qRegisterMetaType<UkuiMenu::SortType::Type>("SortType::Type"); qRegisterMetaType<UkuiMenu::SortType::Type>("SortType::Type");
qRegisterMetaType<UkuiMenu::DataType::Type>("DataType::Type"); qRegisterMetaType<UkuiMenu::DataType::Type>("DataType::Type");
qRegisterMetaType<UkuiMenu::DataEntity>("DataEntity"); qRegisterMetaType<UkuiMenu::DataEntity>("DataEntity");

View File

@ -20,6 +20,7 @@
#include <QVariant> #include <QVariant>
#include <QDebug> #include <QDebug>
#include <QtQml>
#define UKUI_MENU_SCHEMA "org.ukui.menu.settings" #define UKUI_MENU_SCHEMA "org.ukui.menu.settings"
#define CONTROL_CENTER_SETTING "org.ukui.control-center.personalise" #define CONTROL_CENTER_SETTING "org.ukui.control-center.personalise"
@ -31,6 +32,12 @@
namespace UkuiMenu { namespace UkuiMenu {
void SettingModule::defineModule(const char *uri, int versionMajor, int versionMinor)
{
qRegisterMetaType<GlobalSetting::Key>("GlobalSetting::Key");
qmlRegisterUncreatableType<GlobalSetting>(uri, versionMajor, versionMinor, "GlobalSetting", "Use enums only.");
}
GlobalSetting *GlobalSetting::instance() GlobalSetting *GlobalSetting::instance()
{ {
static GlobalSetting setting(nullptr); static GlobalSetting setting(nullptr);

View File

@ -34,6 +34,12 @@
namespace UkuiMenu { namespace UkuiMenu {
class SettingModule
{
public:
static void defineModule(const char *uri, int versionMajor, int versionMinor);
};
class GlobalSetting : public QObject class GlobalSetting : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -45,7 +45,9 @@ void UkuiMenuApplication::registerQmlTypes()
{ {
const char *uri = "org.ukui.menu.core"; const char *uri = "org.ukui.menu.core";
int versionMajor = 1, versionMinor = 0; int versionMajor = 1, versionMinor = 0;
CommonsModule::defineCommonsMod(uri, versionMajor, versionMinor); CommonsModule::defineModule(uri, versionMajor, versionMinor);
SettingModule::defineModule(uri, versionMajor, versionMinor);
ModelManager::registerMetaTypes(); ModelManager::registerMetaTypes();
} }