diff --git a/example/example.qrc b/example/example.qrc index 9ff80f86..daa59ed7 100644 --- a/example/example.qrc +++ b/example/example.qrc @@ -123,7 +123,6 @@ res/image/qrcode_zfb.jpg qml/App.qml qml/component/CodeExpander.qml - qml/component/CustomWindow.qml qml/global/ItemsFooter.qml qml/global/ItemsOriginal.qml qml/global/qmldir diff --git a/example/qml/component/CustomWindow.qml b/example/qml/component/CustomWindow.qml deleted file mode 100644 index 626d1a39..00000000 --- a/example/qml/component/CustomWindow.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Layouts 1.15 -import FluentUI 1.0 -import org.wangwenx190.FramelessHelper 1.0 - -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 - icon:"qrc:/example/res/image/favicon.ico" - 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) - moveWindowToDesktopCenter() - setHitTestVisible(title_bar.minimizeButton()) - setHitTestVisible(title_bar.maximizeButton()) - setHitTestVisible(title_bar.closeButton()) - setWindowFixedSize(fixSize) - title_bar.maximizeButton.visible = !fixSize - if (blurBehindWindowEnabled) - window.background = undefined - window.show() - } - } - Connections{ - target: FluTheme - function onDarkChanged(){ - if (FluTheme.dark) - FramelessUtils.systemTheme = FramelessHelperConstants.Dark - else - FramelessUtils.systemTheme = FramelessHelperConstants.Light - } - } - function setHitTestVisible(com){ - framless_helper.setHitTestVisible(com) - } - function setTitleBarItem(com){ - framless_helper.setTitleBarItem(com) - } -} diff --git a/example/qml/window/AboutWindow.qml b/example/qml/window/AboutWindow.qml index ccef8216..ef929418 100644 --- a/example/qml/window/AboutWindow.qml +++ b/example/qml/window/AboutWindow.qml @@ -5,7 +5,7 @@ import FluentUI 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window title:"关于" diff --git a/example/qml/window/HotloadWindow.qml b/example/qml/window/HotloadWindow.qml index 8c89810c..8ab2356e 100644 --- a/example/qml/window/HotloadWindow.qml +++ b/example/qml/window/HotloadWindow.qml @@ -6,7 +6,7 @@ import example 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window title:"热加载" diff --git a/example/qml/window/LoginWindow.qml b/example/qml/window/LoginWindow.qml index 81f4b39a..c8269bb7 100644 --- a/example/qml/window/LoginWindow.qml +++ b/example/qml/window/LoginWindow.qml @@ -5,7 +5,7 @@ import FluentUI 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window title:"登录" diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index c2f336fe..a6b2f407 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -12,7 +12,7 @@ import "../component" import "../viewmodel" import "../global" -CustomWindow { +FluWindow { id:window title: "FluentUI" @@ -21,8 +21,8 @@ CustomWindow { closeDestory:false minimumWidth: 520 minimumHeight: 200 - appBarVisible: false launchMode: FluWindowType.SingleTask + appBar: undefined SettingsViewModel{ id:viewmodel_settings diff --git a/example/qml/window/PageWindow.qml b/example/qml/window/PageWindow.qml index 174ebeb6..4ac73699 100644 --- a/example/qml/window/PageWindow.qml +++ b/example/qml/window/PageWindow.qml @@ -6,7 +6,7 @@ import example 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window width: 800 diff --git a/example/qml/window/SingleInstanceWindow.qml b/example/qml/window/SingleInstanceWindow.qml index 5e75b6b4..82d81cad 100644 --- a/example/qml/window/SingleInstanceWindow.qml +++ b/example/qml/window/SingleInstanceWindow.qml @@ -5,7 +5,7 @@ import FluentUI 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window title:"SingleInstance" diff --git a/example/qml/window/SingleTaskWindow.qml b/example/qml/window/SingleTaskWindow.qml index dabb1084..25d53a08 100644 --- a/example/qml/window/SingleTaskWindow.qml +++ b/example/qml/window/SingleTaskWindow.qml @@ -5,7 +5,7 @@ import FluentUI 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window title:"SingleTask" diff --git a/example/qml/window/StandardWindow.qml b/example/qml/window/StandardWindow.qml index 44780e63..28513a53 100644 --- a/example/qml/window/StandardWindow.qml +++ b/example/qml/window/StandardWindow.qml @@ -5,7 +5,7 @@ import FluentUI 1.0 import "qrc:///example/qml/component" import "../component" -CustomWindow { +FluWindow { id:window title:"Standard" diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 00c262d9..3ca47e8d 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -3,6 +3,7 @@ import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import FluentUI 1.0 +import org.wangwenx190.FramelessHelper 1.0 Window { default property alias content: container.data @@ -10,7 +11,9 @@ Window { property int launchMode: FluWindowType.Standard property var argument:({}) property var background : com_background + property bool fixSize: false property Component loadingItem: com_loading + property var appBar: com_app_bar property color backgroundColor: { if(active){ return FluTheme.dark ? Qt.rgba(26/255,34/255,40/255,1) : Qt.rgba(243/255,243/255,243/255,1) @@ -28,6 +31,7 @@ Window { } } signal initArgument(var argument) + property bool showSystemAppBar: true id:window color:"transparent" Component.onCompleted: { @@ -50,13 +54,33 @@ Window { color: window.backgroundColor } } + Component{ + id:com_app_bar + FluAppBar { + title: window.title + } + } Loader{ anchors.fill: parent sourceComponent: background } + Loader{ + id: loader_title_bar + anchors { + top: parent.top + left: parent.left + right: parent.right + } + sourceComponent: window.appBar + } Item{ id:container - anchors.fill: parent + anchors{ + top: loader_title_bar.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } clip: true } Loader{ @@ -65,10 +89,6 @@ Window { id:loader_loading anchors.fill: container } - FluInfoBar{ - id:infoBar - root: window - } Component{ id:com_loading Popup{ @@ -132,6 +152,37 @@ Window { } } } + FluInfoBar{ + id:infoBar + root: window + } + Connections{ + target: FluTheme + function onDarkChanged(){ + if (FluTheme.dark) + FramelessUtils.systemTheme = FramelessHelperConstants.Dark + else + FramelessUtils.systemTheme = FramelessHelperConstants.Light + } + } + FramelessHelper{ + id:framless_helper + onReady: { + if(appBar && !showSystemAppBar){ + var title_bar = loader_title_bar.item + setTitleBarItem(title_bar) + moveWindowToDesktopCenter() + setHitTestVisible(title_bar.minimizeButton()) + setHitTestVisible(title_bar.maximizeButton()) + setHitTestVisible(title_bar.closeButton()) + setWindowFixedSize(fixSize) + title_bar.maximizeButton.visible = !fixSize + if (blurBehindWindowEnabled) + window.background = undefined + } + window.show() + } + } WindowLifecycle{ id:lifecycle }