FluentUI/Gallery/res/qml/screen/MainPageScreen.qml
yxdy 8d68f26b15
Some checks failed
Gallery App Build / Windows (push) Has been cancelled
Gallery App Build / macOS (push) Has been cancelled
Gallery App Build / Ubuntu (push) Has been cancelled
feat: 添加功能
2025-02-15 18:06:24 +08:00

219 lines
7.7 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import FluentUI.Controls
import FluentUI.impl
import Gallery
import "../component"
Item {
id: control
anchors.fill: parent
property bool is_home: false
property bool show_right: false
property var right_type: "point"
ColumnLayout {
spacing: 20
width: parent.width
height: parent.height
TitleBar{
id: title_bar
Layout.preferredWidth: parent.width
onClickNav: (type, params) => {
if (type == "home") {
control.is_home = true
} else if (type == "other") {
control.is_home = false
map_container.run_js("QT_Refresh", params)
}
// nav_main.visitUrl("/")
}
}
ToolBar{
visible: !control.is_home
Layout.preferredWidth: parent.width
onClickButton: (fun) => {
control.show_right = false
com_info.reset_info()
map_container.run_js(fun)
}
}
RowLayout{
Layout.topMargin: 30
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle{
visible: control.is_home
Layout.fillHeight: true
Layout.preferredWidth: 250
color: "transparent"
// 主页的菜单。
LeftMainMenu{
anchors.fill: parent
}
// LeftNavMenu{
// id: nav_main
// height: parent.height
// onClickMenu: (item) => {
// if (item.key == "/") {
// control.is_home = true
// } else if (item.key == "/newproject") {
// } else {
// console.log(item.title + ", filter list...")
// control.is_home = false
// title_bar.addTab(item.title, item.key)
// }
// }
// }
}
Rectangle{
visible: control.is_home
Layout.fillHeight: true
Layout.fillWidth: true
color: "transparent"
RightMainContent {
anchors.fill: parent
onClickSee: function(data) {
title_bar.addTab(data.title, data.uuid)
control.is_home = false
}
}
}
// LeftProjectMenu{
// visible: !control.is_home
// Layout.preferredWidth: 200
// Layout.preferredHeight: parent.height
// }
LeftMainMenuTab{
id: left_tab
visible: !control.is_home
Layout.preferredWidth: 200
Layout.preferredHeight: parent.height
Layout.leftMargin: 10
onClickMenuItem: function(data) {
console.log(JSON.stringify(data))
if (data.type && data.type == "resource") {
map_container.run_js("QT_ZoomToResource", data.id)
} else {
map_container.run_js("QT_ZoomTo", [data.id])
// 更新右侧
com_info.update_only_data(data)
}
}
onClickResource: function(data) {
map_container.run_js("QT_LoadResource", [data.type, data.title])
// 需要更新元素tab数据
}
}
Rectangle{
visible: !control.is_home
Layout.fillHeight: true
Layout.fillWidth: true
color: "transparent"
MapContainer{
id: map_container
Layout.fillHeight: true
Layout.fillWidth: true
onAsyncMapInfo: function(data) {
com_info.reset_info()
console.log("接受===" + data.type)
if (data.type == "point") {
control.right_type = data.type
com_info.update_design(data.data)
left_tab.setMenuData(data.data)
control.show_right = true
} else if (data.type == "empty") {
control.show_right = false
com_info.reset_info()
} else if (data.type == "line") {
control.show_right = true
control.right_type = data.type
com_info.update_design(data.data)
left_tab.setMenuData(data.data)
} else if (data.type == "polygon") {
control.show_right = true
control.right_type = data.type
com_info.update_design(data.data)
left_tab.setMenuData(data.data)
} else if (data.type == "search-near") {
WindowRouter.go("/searchNear",{type:"WindowType.Standard"})
} else if (data.type == "resource") {
// 资源类的没有右侧面板
left_tab.setMenuData(data.data)
}
}
}
}
RightComponentInfo{
id: com_info
cur_type: control.right_type
visible: !control.is_home && control.show_right
Layout.preferredWidth: 200
Layout.preferredHeight: parent.height
Layout.rightMargin: 10
onIconChanged: function(data) {
map_container.run_js("QT_ChangeIcon", {img: data})
}
onTextChanged: function(data) {
map_container.run_js("QT_ChangeIcon", {text: data.title})
// 更新左侧标题
console.log("id====" + data.id)
if (data.title && data.id) {
left_tab.setMenuData(data)
}
}
onTextColorChanged: function(data) {
map_container.run_js("QT_ChangeIcon", {textColor: data})
}
onLineInfoChanged: function(data) {
map_container.run_js("QT_ChangeLine", data)
// 更新左侧标题
console.log("id====" + data.id)
if (data.title && data.id) {
left_tab.setMenuData(data)
}
}
onPolyInfoChanged: function(data) {
map_container.run_js("QT_ChangePoly", data)
// 更新左侧标题
if (data.title && data.id) {
left_tab.setMenuData(data)
}
}
}
}
}
Connections {
target: Global
onSendMessage: function(message) {
console.log("Window 2 received:", message)
map_container.run_js("QT_StartSim", "")
}
}
}