新增数据插件接口
This commit is contained in:
parent
b8a4a009b1
commit
50791a5be1
|
@ -85,6 +85,7 @@ set(SOURCE_FILES
|
||||||
src/windows/menu-main-window.cpp src/windows/menu-main-window.h
|
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.cpp src/extension/menu-extension.h
|
||||||
src/extension/menu-extension-iface.h
|
src/extension/menu-extension-iface.h
|
||||||
|
src/appdata/data-provider-plugin-iface.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# qrc文件
|
# qrc文件
|
||||||
|
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UKUI_MENU_DATA_PROVIDER_PLUGIN_IFACE_H
|
||||||
|
#define UKUI_MENU_DATA_PROVIDER_PLUGIN_IFACE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
|
#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<DataEntity> data() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强制刷新数据,刷新完成后发送dataChange信号
|
||||||
|
*/
|
||||||
|
virtual void forceUpdate() = 0;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
/**
|
||||||
|
* 数据变化
|
||||||
|
*/
|
||||||
|
void dataChanged(QVector<DataEntity> newData);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // UkuiMenu
|
||||||
|
|
||||||
|
#endif //UKUI_MENU_DATA_PROVIDER_PLUGIN_IFACE_H
|
|
@ -37,18 +37,6 @@ public:
|
||||||
Q_ENUM(Type)
|
Q_ENUM(Type)
|
||||||
};
|
};
|
||||||
|
|
||||||
class SortType
|
|
||||||
{
|
|
||||||
Q_GADGET
|
|
||||||
public:
|
|
||||||
enum Type {
|
|
||||||
All,
|
|
||||||
Alphabetically,
|
|
||||||
Function
|
|
||||||
};
|
|
||||||
Q_ENUM(Type);
|
|
||||||
};
|
|
||||||
|
|
||||||
class DataType
|
class DataType
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
@ -72,6 +60,13 @@ class DataEntity
|
||||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||||
Q_PROPERTY(QString extraData READ extraData WRITE setExtraData)
|
Q_PROPERTY(QString extraData READ extraData WRITE setExtraData)
|
||||||
public:
|
public:
|
||||||
|
enum PropertyName {
|
||||||
|
Type = 0,
|
||||||
|
Icon,
|
||||||
|
Name,
|
||||||
|
Comment,
|
||||||
|
ExtraData
|
||||||
|
};
|
||||||
DataEntity() = default;
|
DataEntity() = default;
|
||||||
DataEntity(const DataEntity& obj);
|
DataEntity(const DataEntity& obj);
|
||||||
DataEntity(DataType::Type type, QString name, QString icon, QString comment, QString extraData);
|
DataEntity(DataType::Type type, QString name, QString icon, QString comment, QString extraData);
|
||||||
|
@ -103,12 +98,10 @@ class CommonsModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void defineModule(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::DataType::Type>("DataType::Type");
|
qRegisterMetaType<UkuiMenu::DataType::Type>("DataType::Type");
|
||||||
qRegisterMetaType<UkuiMenu::DataEntity>("DataEntity");
|
qRegisterMetaType<UkuiMenu::DataEntity>("DataEntity");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<Display>(uri, versionMajor, versionMinor, "Display", "Use enums only.");
|
qmlRegisterUncreatableType<Display>(uri, versionMajor, versionMinor, "Display", "Use enums only.");
|
||||||
qmlRegisterUncreatableType<UkuiMenu::SortType>(uri, versionMajor, versionMinor, "SortType", "Use enums only");
|
|
||||||
qmlRegisterUncreatableType<UkuiMenu::DataType>(uri, versionMajor, versionMinor, "DataType", "Use enums only");
|
qmlRegisterUncreatableType<UkuiMenu::DataType>(uri, versionMajor, versionMinor, "DataType", "Use enums only");
|
||||||
// qmlRegisterUncreatableType<UkuiMenu::DataEntity>(uri, versionMajor, versionMinor, "DataEntity", "unknown");
|
// qmlRegisterUncreatableType<UkuiMenu::DataEntity>(uri, versionMajor, versionMinor, "DataEntity", "unknown");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue