FluentUI/example/page/MainPage.qml

102 lines
2.5 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-04-16 02:28:58 +08:00
import "qrc:///global/"
2023-02-26 23:47:07 +08:00
2023-02-27 18:46:39 +08:00
FluWindow {
2023-04-16 02:28:58 +08:00
id:window
2023-03-29 15:43:23 +08:00
width: 1000
2023-03-28 17:53:46 +08:00
height: 640
2023-02-27 23:04:52 +08:00
title: "FluentUI"
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-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-02-27 18:46:39 +08:00
FluAppBar{
id:appbar
2023-04-10 18:17:22 +08:00
z:9
2023-03-29 15:43:23 +08:00
showDark: true
2023-03-30 21:52:55 +08:00
width:parent.width
2023-04-14 17:07:54 +08:00
darkText: lang.dark_mode
2023-02-27 18:46:39 +08:00
}
2023-02-26 23:47:07 +08:00
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
icon.source: "qrc:/res/image/favicon.ico"
2023-04-19 09:41:08 +08:00
tooltip: "FluentUI"
menu: Menu {
MenuItem {
text: "退出"
onTriggered: {
window.destoryWindow()
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:{
window.destoryWindow()
FluApp.closeApp()
}
}
2023-04-10 22:05:20 +08:00
FluNavigationView{
2023-03-10 18:08:32 +08:00
id:nav_view
2023-03-28 17:53:46 +08:00
anchors.fill: parent
2023-03-30 17:16:57 +08:00
items: ItemsOriginal
footerItems:ItemsFooter
2023-04-10 18:17:22 +08:00
z:11
displayMode:MainEvent.displayMode
2023-03-28 17:53:46 +08:00
logo: "qrc:/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
}
}
}