FluentUI/example/qml/window/MainWindow.qml

122 lines
3.1 KiB
QML
Raw Normal View History

2023-03-30 21:52:55 +08:00
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
2023-04-16 02:28:58 +08:00
import Qt.labs.platform
2023-03-30 21:52:55 +08:00
import FluentUI
2023-05-17 18:15:15 +08:00
import "../component"
2023-04-27 09:38:57 +08:00
import "qrc:///example/qml/global/"
2023-02-26 23:47:07 +08:00
2023-05-17 18:15:15 +08:00
CustomWindow {
2023-04-22 18:08:11 +08:00
2023-04-16 02:28:58 +08:00
id:window
2023-04-22 18:08:11 +08:00
title: "FluentUI"
2023-03-29 15:43:23 +08:00
width: 1000
2023-03-28 17:53:46 +08:00
height: 640
2023-04-16 02:28:58 +08:00
closeDestory:false
2023-03-24 18:25:13 +08:00
minimumWidth: 520
2023-03-29 22:42:08 +08:00
minimumHeight: 460
2023-05-17 18:15:15 +08:00
appBarVisible: false
2023-05-10 10:32:37 +08:00
launchMode: FluWindow.SingleTask
2023-02-27 18:46:39 +08:00
2023-04-20 20:13:31 +08:00
closeFunc:function(event){
close_app.open()
event.accepted = false
}
2023-04-22 00:29:47 +08:00
Connections{
target: appInfo
function onActiveWindow(){
window.show()
window.raise()
window.requestActivate()
}
}
2023-04-16 02:28:58 +08:00
SystemTrayIcon {
2023-04-20 19:15:38 +08:00
id:system_tray
2023-04-16 02:28:58 +08:00
visible: true
2023-04-27 09:38:57 +08:00
icon.source: "qrc:/example/res/image/favicon.ico"
2023-04-19 09:41:08 +08:00
tooltip: "FluentUI"
menu: Menu {
MenuItem {
text: "退出"
onTriggered: {
2023-05-11 18:24:58 +08:00
window.deleteWindow()
2023-04-19 09:41:08 +08:00
FluApp.closeApp()
}
}
2023-04-16 02:28:58 +08:00
}
2023-04-19 09:41:08 +08:00
onActivated:
(reason)=>{
if(reason === SystemTrayIcon.Trigger){
window.show()
window.raise()
window.requestActivate()
}
}
2023-04-16 02:28:58 +08:00
}
FluContentDialog{
id:close_app
title:"退出"
message:"确定要退出程序吗?"
negativeText:"最小化"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
onNegativeClicked:{
2023-04-20 19:15:38 +08:00
system_tray.showMessage("友情提示","FluentUI已隐藏至托盘,点击托盘可再次激活窗口");
window.hide()
}
positiveText:"退出"
neutralText:"取消"
onPositiveClicked:{
2023-05-11 18:24:58 +08:00
window.deleteWindow()
FluApp.closeApp()
}
2023-05-17 18:15:15 +08:00
}
2023-05-17 18:15:15 +08:00
FluAppBar {
id: title_bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
showDark: true
2023-05-17 19:52:33 +08:00
z:7
}
2023-04-10 22:05:20 +08:00
FluNavigationView{
2023-03-10 18:08:32 +08:00
id:nav_view
2023-05-17 18:15:15 +08:00
anchors{
2023-05-17 18:24:11 +08:00
top: parent.top
2023-05-17 18:15:15 +08:00
left: parent.left
right: parent.right
bottom: parent.bottom
}
2023-05-17 19:52:33 +08:00
z:999
2023-03-30 17:16:57 +08:00
items: ItemsOriginal
footerItems:ItemsFooter
2023-05-17 20:20:29 +08:00
topPadding:Qt.platform.os === "osx" ? 20 : 5
2023-04-10 18:17:22 +08:00
displayMode:MainEvent.displayMode
2023-04-27 09:38:57 +08:00
logo: "qrc:/example/res/image/favicon.ico"
2023-03-30 17:16:57 +08:00
title:"FluentUI"
autoSuggestBox:FluAutoSuggestBox{
width: 280
anchors.centerIn: parent
2023-04-10 22:05:20 +08:00
iconSource: FluentIcons.Search
2023-03-30 17:16:57 +08:00
items: ItemsOriginal.getSearchData()
2023-04-14 17:07:54 +08:00
placeholderText: lang.search
2023-03-30 17:16:57 +08:00
onItemClicked:
(data)=>{
ItemsOriginal.startPageByItem(data)
}
}
2023-03-10 18:08:32 +08:00
Component.onCompleted: {
2023-03-30 17:16:57 +08:00
ItemsOriginal.navigationView = nav_view
2023-04-10 18:17:22 +08:00
ItemsFooter.navigationView = nav_view
2023-03-29 15:43:23 +08:00
nav_view.setCurrentIndex(0)
2023-02-26 23:47:07 +08:00
}
}
}