FluentUI/example/qml/component/CustomWindow.qml

65 lines
1.8 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
import org.wangwenx190.FramelessHelper 1.0
2023-05-19 07:57:23 +08:00
FluWindow {
id:window
property bool fixSize
property alias titleVisible: title_bar.titleVisible
property bool appBarVisible: true
default property alias content: container.data
FluAppBar {
id: title_bar
title: window.title
visible: window.appBarVisible
2023-08-21 11:51:03 +08:00
icon:"qrc:/example/res/image/favicon.ico"
2023-05-19 07:57:23 +08:00
anchors {
top: parent.top
left: parent.left
right: parent.right
}
darkText: lang.dark_mode
}
Item{
id:container
anchors{
top: title_bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
clip: true
}
FramelessHelper{
id:framless_helper
onReady: {
setTitleBarItem(title_bar)
2023-06-09 09:29:28 +08:00
moveWindowToDesktopCenter()
2023-05-19 07:57:23 +08:00
setHitTestVisible(title_bar.minimizeButton())
setHitTestVisible(title_bar.maximizeButton())
setHitTestVisible(title_bar.closeButton())
2023-06-09 09:29:28 +08:00
setWindowFixedSize(fixSize)
2023-05-19 07:57:23 +08:00
title_bar.maximizeButton.visible = !fixSize
if (blurBehindWindowEnabled)
2023-08-11 22:47:36 +08:00
window.background = undefined
2023-06-09 09:29:28 +08:00
window.show()
2023-05-19 07:57:23 +08:00
}
}
Connections{
target: FluTheme
function onDarkChanged(){
if (FluTheme.dark)
FramelessUtils.systemTheme = FramelessHelperConstants.Dark
else
FramelessUtils.systemTheme = FramelessHelperConstants.Light
}
}
2023-05-19 07:57:23 +08:00
function setHitTestVisible(com){
framless_helper.setHitTestVisible(com)
}
function setTitleBarItem(com){
framless_helper.setTitleBarItem(com)
}
}