FluentUI/src/controls/FluWindow.qml

116 lines
2.8 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
2023-03-02 18:21:43 +08:00
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
id:root
2023-03-02 18:21:43 +08:00
property var window : {
2023-02-27 18:46:39 +08:00
if(Window.window == null)
2023-03-02 18:21:43 +08:00
return null
return Window.window
2023-02-27 18:46:39 +08:00
}
2023-03-01 22:06:48 +08:00
2023-03-06 14:22:13 +08:00
property color color: FluTheme.isDark ? "#202020" : "#F3F3F3"
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-06 18:08:01 +08:00
2023-03-02 18:21:43 +08:00
property int borderless:{
2023-03-06 18:08:01 +08:00
if(window === null)
2023-03-02 18:21:43 +08:00
return 4
if(Window.window.visibility === Window.Maximized){
return 0
}
return 4
}
2023-03-06 18:08:01 +08:00
default property alias content: container.data
2023-02-27 18:46:39 +08:00
2023-03-06 18:08:01 +08:00
FluWindowResize{
border:borderless
}
2023-03-03 18:19:48 +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
}
}
2023-03-06 12:09:06 +08:00
Rectangle{
2023-03-06 18:08:01 +08:00
property color borerlessColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
color: {
if(window === null)
return borerlessColor
2023-03-07 00:05:27 +08:00
return window.active ? borerlessColor : Qt.lighter(borerlessColor,1.1)
2023-03-06 18:08:01 +08:00
}
2023-03-06 12:09:06 +08:00
border.width: 1
anchors.fill: parent
radius: 4
2023-03-06 18:08:01 +08:00
border.color:FluTheme.isDark ? Qt.darker(FluTheme.primaryColor.lighter,1.3) : Qt.lighter(FluTheme.primaryColor.dark,1.2)
2023-03-03 18:19:48 +08:00
}
2023-03-02 18:21:43 +08:00
Rectangle{
id:container
color:root.color
anchors.fill: parent
anchors.margins: borderless
2023-02-27 18:46:39 +08:00
}
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-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-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
}