2023-03-24 20:44:38 +08:00
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Window
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import FluentUI
|
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-09 23:53:36 +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)
|
|
|
|
|
}
|
|
|
|
|
|
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-06 18:08:01 +08:00
|
|
|
|
|
2023-03-13 21:18:51 +08:00
|
|
|
|
property var pageRegister
|
|
|
|
|
|
2023-03-02 18:21:43 +08:00
|
|
|
|
property int borderless:{
|
2023-03-09 11:50:40 +08:00
|
|
|
|
if(!FluTheme.isFrameless){
|
2023-03-09 01:18:46 +08:00
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-03-09 23:53:36 +08:00
|
|
|
|
return (window && (window.visibility === Window.Maximized)) ? 0 : 4
|
2023-03-02 18:21:43 +08:00
|
|
|
|
}
|
2023-03-09 11:50:40 +08:00
|
|
|
|
|
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
|
2023-03-09 23:53:36 +08:00
|
|
|
|
color: (window && window.active) ? borerlessColor : Qt.lighter(borerlessColor,1.1)
|
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-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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2023-03-24 14:15:06 +08:00
|
|
|
|
updateWindowSize()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections{
|
|
|
|
|
target: FluTheme
|
|
|
|
|
function onIsFramelessChanged(){
|
|
|
|
|
updateWindowSize()
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-02 00:35:58 +08:00
|
|
|
|
|
2023-03-24 14:15:06 +08:00
|
|
|
|
function updateWindowSize(){
|
|
|
|
|
if(FluTheme.isFrameless){
|
|
|
|
|
height = height + 34
|
|
|
|
|
}else{
|
|
|
|
|
height = height - 34
|
|
|
|
|
}
|
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)){
|
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-24 20:44:38 +08:00
|
|
|
|
function showSuccess(text,duration=1000,moremsg){
|
2023-02-28 18:29:00 +08:00
|
|
|
|
infoBar.showSuccess(text,duration,moremsg);
|
|
|
|
|
}
|
2023-03-13 21:18:51 +08:00
|
|
|
|
|
2023-03-24 20:44:38 +08:00
|
|
|
|
function showInfo(text,duration=1000,moremsg){
|
2023-02-28 18:29:00 +08:00
|
|
|
|
infoBar.showInfo(text,duration,moremsg);
|
|
|
|
|
}
|
2023-03-13 21:18:51 +08:00
|
|
|
|
|
2023-03-24 20:44:38 +08:00
|
|
|
|
function showWarning(text,duration=1000,moremsg){
|
2023-02-28 18:29:00 +08:00
|
|
|
|
infoBar.showWarning(text,duration,moremsg);
|
|
|
|
|
}
|
2023-03-13 21:18:51 +08:00
|
|
|
|
|
2023-03-24 20:44:38 +08:00
|
|
|
|
function showError(text,duration=1000,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
|
|
|
|
}
|