From 50791a5be1f81ca56c99e94618e56587eef4751c Mon Sep 17 00:00:00 2001 From: hewenfei Date: Wed, 28 Dec 2022 15:38:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + src/appdata/data-provider-plugin-iface.h | 73 ++++++++++++++++++++++++ src/commons.h | 21 +++---- 3 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 src/appdata/data-provider-plugin-iface.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 48a0f14..8a0479f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ set(SOURCE_FILES src/windows/menu-main-window.cpp src/windows/menu-main-window.h src/extension/menu-extension.cpp src/extension/menu-extension.h src/extension/menu-extension-iface.h + src/appdata/data-provider-plugin-iface.h ) # qrc文件 diff --git a/src/appdata/data-provider-plugin-iface.h b/src/appdata/data-provider-plugin-iface.h new file mode 100644 index 0000000..1bd54bd --- /dev/null +++ b/src/appdata/data-provider-plugin-iface.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef UKUI_MENU_DATA_PROVIDER_PLUGIN_IFACE_H +#define UKUI_MENU_DATA_PROVIDER_PLUGIN_IFACE_H + +#include +#include +#include +#include +#include + +#include "commons.h" + +namespace UkuiMenu { + +class PluginGroup +{ + Q_GADGET +public: + enum Group { + Button, + SortMenuItem + }; + Q_ENUM(Group) +}; + +class DataProviderPluginIFace : public QObject +{ + Q_OBJECT +public: + virtual int index() = 0; + virtual QString name() = 0; + virtual QString icon() = 0; + virtual QString title() = 0; + virtual PluginGroup::Group group() = 0; + + /** + * 获取插件存放的数据 + * @return 数据容器 + */ + virtual QVector data() = 0; + + /** + * 强制刷新数据,刷新完成后发送dataChange信号 + */ + virtual void forceUpdate() = 0; + +Q_SIGNALS: + /** + * 数据变化 + */ + void dataChanged(QVector newData); +}; + +} // UkuiMenu + +#endif //UKUI_MENU_DATA_PROVIDER_PLUGIN_IFACE_H diff --git a/src/commons.h b/src/commons.h index 2811782..1b31b51 100644 --- a/src/commons.h +++ b/src/commons.h @@ -37,18 +37,6 @@ public: Q_ENUM(Type) }; -class SortType -{ - Q_GADGET -public: - enum Type { - All, - Alphabetically, - Function - }; - Q_ENUM(Type); -}; - class DataType { Q_GADGET @@ -72,6 +60,13 @@ class DataEntity Q_PROPERTY(QString comment READ comment WRITE setComment) Q_PROPERTY(QString extraData READ extraData WRITE setExtraData) public: + enum PropertyName { + Type = 0, + Icon, + Name, + Comment, + ExtraData + }; DataEntity() = default; DataEntity(const DataEntity& obj); DataEntity(DataType::Type type, QString name, QString icon, QString comment, QString extraData); @@ -103,12 +98,10 @@ class CommonsModule { public: static void defineModule(const char *uri, int versionMajor, int versionMinor) { - qRegisterMetaType("SortType::Type"); qRegisterMetaType("DataType::Type"); qRegisterMetaType("DataEntity"); qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "Display", "Use enums only."); - qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "SortType", "Use enums only"); qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "DataType", "Use enums only"); // qmlRegisterUncreatableType(uri, versionMajor, versionMinor, "DataEntity", "unknown"); }