diff --git a/CMakeLists.txt b/CMakeLists.txt index 7769c4e..48a0f14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,10 +61,13 @@ message(STATUS "QML_IMPORT_PATH: ${QML_IMPORT_PATH}") # 基础设置 set(UKUI_MENU_DATA_DIR "/usr/share/ukui-menu") set(UKUI_MENU_TRANSLATION_DIR "${UKUI_MENU_DATA_DIR}/translations") +set(UKUI_MENU_EXTENSION_DIR "${UKUI_MENU_DATA_DIR}/extensions") +#set(UKUI_MENU_EXTENSION_IFACE_QML_DIR "/usr/lib/x86_64-linux-gnu/qt5/qml/org/ukui/menu/extension") # 宏定义 add_compile_definitions(UKUI_MENU_TRANSLATION_DIR="${UKUI_MENU_TRANSLATION_DIR}" UKUI_MENU_DATA_DIR="${UKUI_MENU_DATA_DIR}" + UKUI_MENU_EXTENSION_DIR="${UKUI_MENU_EXTENSION_DIR}" ) # ukui-menu的源码 @@ -80,6 +83,8 @@ set(SOURCE_FILES src/model/model-manager.cpp src/model/model-manager.h src/appdata/app-icon-provider.cpp src/appdata/app-icon-provider.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-iface.h ) # qrc文件 @@ -89,6 +94,8 @@ set(DESKTOP_FILE data/ukui-menu.desktop) set(GSETTING_FILE data/org.ukui.menu.settings.gschema.xml) # data files #set(DATA_FILES data/xxx) +# extension +#file(GLOB EXTENSION_IFACE_QML_FILES "qml/org/ukui/menu/extension/*") # 翻译文件 file(GLOB TS_FILES "${PROJECT_SOURCE_DIR}/translations/*.ts") @@ -126,3 +133,4 @@ install(FILES ${QM_FILES} DESTINATION "${UKUI_MENU_TRANSLATION_DIR}") # 安装desktop文件 install(FILES ${DESKTOP_FILE} DESTINATION "/etc/xdg/autostart") install(FILES ${GSETTING_FILE} DESTINATION "/usr/share/glib-2.0/schemas") +#install(FILES ${EXTENSION_IFACE_QML_FILES} DESTINATION "${UKUI_MENU_EXTENSION_IFACE_QML_DIR}") diff --git a/qml/AppUI/NormalUI.qml b/qml/AppUI/NormalUI.qml index 36a93f8..5db239f 100644 --- a/qml/AppUI/NormalUI.qml +++ b/qml/AppUI/NormalUI.qml @@ -1,5 +1,6 @@ import QtQuick 2.12 import QtQuick.Controls 2.0 as QQC2 +import org.ukui.menu.extension 1.0 Item { Row { @@ -11,7 +12,7 @@ Item { } Sidebar { - width: parent.width - 300; + width: parent.width - 400; height: parent.height; MouseArea { @@ -21,5 +22,10 @@ Item { } } } + + UkuiMenuExtension { + width: 100; + height: parent.height; + } } } diff --git a/qml/org/ukui/menu/extension/UkuiMenuExtension.qml b/qml/org/ukui/menu/extension/UkuiMenuExtension.qml new file mode 100644 index 0000000..4c59cc3 --- /dev/null +++ b/qml/org/ukui/menu/extension/UkuiMenuExtension.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + id: extensionView; + property var data; + signal send(var data); +} diff --git a/qml/org/ukui/menu/extension/qmldir b/qml/org/ukui/menu/extension/qmldir new file mode 100644 index 0000000..e66de49 --- /dev/null +++ b/qml/org/ukui/menu/extension/qmldir @@ -0,0 +1,2 @@ +module org.ukui.menu.extension +UkuiMenuExtension 1.0 UkuiMenuExtension.qml diff --git a/qml/qml.qrc b/qml/qml.qrc index ebf0fc2..374d78e 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -1,6 +1,8 @@ main.qml + org/ukui/menu/extension/qmldir + org/ukui/menu/extension/UkuiMenuExtension.qml AppUI/qmldir AppUI/NormalUI.qml AppUI/FullScreenUI.qml diff --git a/src/extension/menu-extension-iface.h b/src/extension/menu-extension-iface.h new file mode 100644 index 0000000..ff854cc --- /dev/null +++ b/src/extension/menu-extension-iface.h @@ -0,0 +1,45 @@ +/* + * 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_MENU_EXTENSION_I_FACE_H +#define UKUI_MENU_MENU_EXTENSION_I_FACE_H + + +#include +#include +#include + +namespace UkuiMenu { + +class MenuExtensionIFace : public QObject +{ + Q_OBJECT +public: + virtual int index() = 0; + virtual QString name() = 0; + virtual QString url() = 0; + virtual QVariantMap data() = 0; + virtual void receive(QVariantMap data) = 0; + +Q_SIGNALS: + void dataUpdated(); +}; + +} + +#endif //UKUI_MENU_MENU_EXTENSION_I_FACE_H diff --git a/src/extension/menu-extension.cpp b/src/extension/menu-extension.cpp new file mode 100644 index 0000000..bd80a56 --- /dev/null +++ b/src/extension/menu-extension.cpp @@ -0,0 +1,24 @@ +/* + * 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 . + * + */ + +#include "menu-extension.h" + +namespace UkuiMenu { + + +} // UkuiMenu diff --git a/src/extension/menu-extension.h b/src/extension/menu-extension.h new file mode 100644 index 0000000..5918a4c --- /dev/null +++ b/src/extension/menu-extension.h @@ -0,0 +1,36 @@ +/* + * 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_MENU_EXTENSION_H +#define UKUI_MENU_MENU_EXTENSION_H + +#include + +namespace UkuiMenu { + +class MenuExtension : public QObject +{ + Q_OBJECT +public: + + +}; + +} // UkuiMenu + +#endif //UKUI_MENU_MENU_EXTENSION_H