From 7bdddec934a454e625f0f95e06c7fc183080776a Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Wed, 5 Jul 2023 20:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BF=A1=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AicsKnowledgeBase/qml/component/FileList.qml | 3 ++- AicsKnowledgeBase/qml/global/SignalFileOperation.qml | 8 ++++++++ AicsKnowledgeBase/qml/page/ContentPage.qml | 9 +++++++++ AicsKnowledgeBase/src/main.cpp | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 AicsKnowledgeBase/qml/global/SignalFileOperation.qml diff --git a/AicsKnowledgeBase/qml/component/FileList.qml b/AicsKnowledgeBase/qml/component/FileList.qml index ab662a5..d1fdb2a 100644 --- a/AicsKnowledgeBase/qml/component/FileList.qml +++ b/AicsKnowledgeBase/qml/component/FileList.qml @@ -2,6 +2,7 @@ import QtQuick 2.15 import QtQuick.Layouts import FluentUI import "qrc:///AicsKnowledgeBase/qml/global" +import SignalFileOperation 1.0 Item { anchors.fill: parent @@ -163,7 +164,7 @@ Item { if (model.isDir) { listView.headerItem.add(model.title, model.uuid) } else { - emit: open(model.uuid) + emit: SignalFileOperation.open(model.uuid) } } } diff --git a/AicsKnowledgeBase/qml/global/SignalFileOperation.qml b/AicsKnowledgeBase/qml/global/SignalFileOperation.qml new file mode 100644 index 0000000..e60ce30 --- /dev/null +++ b/AicsKnowledgeBase/qml/global/SignalFileOperation.qml @@ -0,0 +1,8 @@ +pragma Singleton + +import QtQuick + +QtObject { + signal open(string file) + signal openNote(string note) +} diff --git a/AicsKnowledgeBase/qml/page/ContentPage.qml b/AicsKnowledgeBase/qml/page/ContentPage.qml index debb554..aec6663 100644 --- a/AicsKnowledgeBase/qml/page/ContentPage.qml +++ b/AicsKnowledgeBase/qml/page/ContentPage.qml @@ -6,12 +6,14 @@ import QtQuick.Controls.Basic import QtWebEngine 1.2 import FluentUI import AicsKB.FileTransferManager +import SignalFileOperation 1.0 import "qrc:///AicsKnowledgeBase/qml/page" FluArea { id: content_area paddings: 0 backgroundColor: "#f9f9f9" + visible: false property string type: "" property string knowledgeFileId signal download(string knowledgeFileId) @@ -23,6 +25,13 @@ FluArea { // bottom: 10 // left: 10 // } + Connections { + target: SignalFileOperation + function onOpen(file) { + content_area.visible = true + } + } + FluScrollablePage { id: content_page anchors.fill: parent diff --git a/AicsKnowledgeBase/src/main.cpp b/AicsKnowledgeBase/src/main.cpp index ef750eb..90a4c4f 100644 --- a/AicsKnowledgeBase/src/main.cpp +++ b/AicsKnowledgeBase/src/main.cpp @@ -54,6 +54,8 @@ int main(int argc, char *argv[]) qmlRegisterSingletonInstance("AicsKB.FileTransferManager", 1, 0, "FileTransferManager", fileTransferManager); + qmlRegisterSingletonType(QUrl("qrc:/AicsKnowledgeBase/qml/global/SignalFileOperation.qml"), "SignalFileOperation", 1, 0, + "SignalFileOperation"); const QUrl url(u"qrc:/AicsKnowledgeBase/qml/App.qml"_qs); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,