FluentUI/src/controls/FluWindow.qml

92 lines
2.0 KiB
QML
Raw Normal View History

2023-02-27 18:46:39 +08:00
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
Rectangle {
id:root
property bool isMax: {
if(Window.window == null)
return false
return Window.Maximized === Window.window.visibility
}
property string title: "FluentUI"
2023-03-01 22:06:48 +08:00
property string winId
2023-03-01 11:58:30 +08:00
property var minimumSize
property var maximumSize
2023-02-27 18:46:39 +08:00
2023-02-27 23:04:52 +08:00
Behavior on opacity{
NumberAnimation{
2023-02-28 18:29:00 +08:00
duration: 100
2023-02-27 23:04:52 +08:00
}
}
property var window : {
if(Window.window == null)
return null
return Window.window
}
2023-02-27 18:46:39 +08:00
onIsMaxChanged: {
if(isMax){
2023-02-28 18:29:00 +08:00
root.anchors.margins = 8*(1/Screen.devicePixelRatio)
2023-02-27 18:46:39 +08:00
root.anchors.fill = parent
}else{
root.anchors.margins = 0
root.anchors.fill = null
}
}
color : FluApp.isDark ? "#202020" : "#F3F3F3"
Component.onCompleted: {
2023-03-02 00:35:58 +08:00
2023-02-27 23:04:52 +08:00
}
2023-02-27 18:46:39 +08:00
2023-02-27 23:04:52 +08:00
Connections{
target: FluApp
function onWindowReady(view){
if(FluApp.equalsWindow(view,window)){
helper.initWindow(view);
helper.setTitle(title);
2023-03-01 11:58:30 +08:00
if(minimumSize){
helper.setMinimumSize(minimumSize)
}
if(maximumSize){
helper.setMaximumSize(maximumSize)
}
2023-03-02 00:35:58 +08:00
helper.refreshWindow()
2023-02-27 23:04:52 +08:00
}
}
2023-02-27 18:46:39 +08:00
}
WindowHelper{
id:helper
}
2023-02-28 18:29:00 +08:00
FluInfoBar{
id:infoBar
root: root
}
function showSuccess(text,duration,moremsg){
infoBar.showSuccess(text,duration,moremsg);
}
function showInfo(text,duration,moremsg){
infoBar.showInfo(text,duration,moremsg);
}
function showWarning(text,duration,moremsg){
infoBar.showWarning(text,duration,moremsg);
}
function showError(text,duration,moremsg){
infoBar.showError(text,duration,moremsg);
}
2023-03-01 22:06:48 +08:00
function close(){
window.close()
}
2023-02-28 18:29:00 +08:00
2023-02-27 18:46:39 +08:00
}