FluentUI/src/controls/FluWindow.qml

126 lines
3.1 KiB
QML
Raw Normal View History

2023-03-25 13:35:21 +08:00
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
import QtGraphicalEffects 1.15
2023-02-27 18:46:39 +08:00
2023-03-02 18:21:43 +08:00
Item {
2023-02-27 18:46:39 +08:00
2023-03-02 18:21:43 +08:00
property string title: "FluentUI"
property int minimumWidth
property int maximumWidth
property int minimumHeight
property int maximumHeight
2023-03-13 18:23:46 +08:00
property int modality:0
signal initArgument(var argument)
2023-03-13 21:18:51 +08:00
property var pageRegister
2023-03-27 18:24:35 +08:00
default property alias content: container.data
property var window : {
if(Window.window == null)
return null
return Window.window
}
2023-03-28 11:53:25 +08:00
2023-03-27 18:24:35 +08:00
property color color: {
if(window && window.active){
return FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(238/255,244/255,249/255,1)
}
return FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
}
id:root
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
}
}
2023-03-02 18:21:43 +08:00
Rectangle{
id:container
color:root.color
anchors.fill: parent
2023-03-28 11:53:25 +08:00
anchors.margins: (window && (window.visibility === Window.Maximized)) ? 8/Screen.devicePixelRatio : 0
2023-03-10 18:08:32 +08:00
clip: true
2023-03-09 23:53:36 +08:00
Behavior on color{
ColorAnimation {
duration: 300
}
}
2023-02-27 18:46:39 +08:00
}
2023-03-28 11:53:25 +08:00
Rectangle{
border.width: 1
anchors.fill: parent
color: Qt.rgba(0,0,0,0,)
border.color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1)
2023-03-24 14:15:06 +08:00
}
2023-03-02 00:35:58 +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)){
2023-03-13 21:18:51 +08:00
helper.initWindow(view)
initArgument(helper.getArgument())
pageRegister = helper.getPageRegister()
2023-03-13 18:23:46 +08:00
helper.setTitle(title)
2023-03-02 18:21:43 +08:00
if(minimumWidth){
helper.setMinimumWidth(minimumWidth)
}
if(maximumWidth){
helper.setMaximumWidth(maximumWidth)
}
if(minimumHeight){
helper.setMinimumHeight(minimumHeight)
2023-03-01 11:58:30 +08:00
}
2023-03-02 18:21:43 +08:00
if(maximumHeight){
helper.setMaximumHeight(maximumHeight)
2023-03-01 11:58:30 +08:00
}
2023-03-13 18:23:46 +08:00
helper.setModality(root.modality);
helper.updateWindow()
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
}
2023-03-25 13:35:21 +08:00
function showSuccess(text,duration,moremsg){
2023-02-28 18:29:00 +08:00
infoBar.showSuccess(text,duration,moremsg);
}
2023-03-13 21:18:51 +08:00
2023-03-25 13:35:21 +08:00
function showInfo(text,duration,moremsg){
2023-02-28 18:29:00 +08:00
infoBar.showInfo(text,duration,moremsg);
}
2023-03-13 21:18:51 +08:00
2023-03-25 13:35:21 +08:00
function showWarning(text,duration,moremsg){
2023-02-28 18:29:00 +08:00
infoBar.showWarning(text,duration,moremsg);
}
2023-03-13 21:18:51 +08:00
2023-03-25 13:35:21 +08:00
function showError(text,duration,moremsg){
2023-02-28 18:29:00 +08:00
infoBar.showError(text,duration,moremsg);
}
2023-03-13 21:18:51 +08:00
2023-03-01 22:06:48 +08:00
function close(){
window.close()
}
2023-02-28 18:29:00 +08:00
2023-03-13 21:18:51 +08:00
function registerForPageResult(path){
return helper.createRegister(path)
}
2023-03-13 18:23:46 +08:00
2023-03-13 21:18:51 +08:00
function onResult(data){
if(pageRegister){
pageRegister.onResult(data)
}
2023-03-13 18:23:46 +08:00
}
2023-02-27 18:46:39 +08:00
}