Kylin/Examples/FluentWindow/qml/Main.qml
2024-09-05 22:05:05 +08:00

89 lines
2.7 KiB
QML

import QtQuick
import Fluent as Fluent
Fluent.ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("FluentWindow")
appBar {
height: 30
showDark: true
darkClickListener:(button)=>handleDarkChanged(button)
closeClickListener: ()=>{dialog_close.open()}
z:7
}
Fluent.Button {
text: "成功"
property int dd: 0
onClicked: {
showSuccess("This is a success message %1".arg(dd++),2000)
}
}
Fluent.Rectangle {
x:100
y:100
width: 100
height: 100
color:"red"
radius:[10,0,10,0]
}
Fluent.ContentDialog{
id: dialog_close
title: qsTr("Quit")
message: qsTr("Are you sure you want to exit the program?")
negativeText: qsTr("Minimize")
buttonFlags: Fluent.ContentDialogType.NegativeButton | Fluent.ContentDialogType.NeutralButton | Fluent.ContentDialogType.PositiveButton
onNegativeClicked: {
system_tray.showMessage(qsTr("Friendly Reminder"),qsTr("FluentUI is hidden from the tray, click on the tray to activate the window again"));
timer_window_hide_delay.restart()
}
positiveText: qsTr("Quit")
neutralText: qsTr("Cancel")
onPositiveClicked:{
Fluent.Router.exit(0)
}
}
function changeDark(){
if(Fluent.Theme.dark){
Fluent.Theme.darkMode = Fluent.ThemeType.Light
}else{
Fluent.Theme.darkMode = Fluent.ThemeType.Dark
}
}
function handleDarkChanged(button){
if(Fluent.Utilities.isMacos() || !Fluent.Theme.animationEnabled || !fitsAppBarWindows){
changeDark()
}else{
loader_reveal.sourceComponent = com_reveal
var target = window.containerItem()
var pos = button.mapToItem(target,0,0)
var mouseX = pos.x + button.width / 2
var mouseY = pos.y + button.height / 2
var radius = Math.max(distance(mouseX,mouseY,0,0),distance(mouseX,mouseY,target.width,0),distance(mouseX,mouseY,0,target.height),distance(mouseX,mouseY,target.width,target.height))
var reveal = loader_reveal.item
reveal.start(reveal.width*Screen.devicePixelRatio,reveal.height*Screen.devicePixelRatio,Qt.point(mouseX,mouseY),radius)
}
}
Fluent.FpsItem {
id:fps_item
}
Fluent.Text{
text: "fps %1".arg(fps_item.fps)
opacity: 0.3
anchors{
bottom: parent.bottom
right: parent.right
bottomMargin: 5
rightMargin: 5
}
}
}