RibbonTitleBar: Add support for snap layout in Windows 11+.

This commit is contained in:
Mentalflow 2024-01-13 03:24:49 +08:00
parent 57e01f465f
commit 1d25452a4b
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
2 changed files with 12 additions and 0 deletions

View File

@ -19,6 +19,12 @@ Window {
return FramelessUtils.defaultSystemLightColor;
}
FramelessHelper.onReady: {
if (Qt.platform.os === 'windows')
{
FramelessHelper.setSystemButton(titleBar.minimizeBtn, FramelessHelperConstants.Minimize);
FramelessHelper.setSystemButton(titleBar.maximizeBtn, FramelessHelperConstants.Maximize);
FramelessHelper.setSystemButton(titleBar.closeBtn, FramelessHelperConstants.Close);
}
FramelessHelper.titleBarItem = titleBar;
FramelessHelper.moveWindowToDesktopCenter();
window.visible = true;

View File

@ -16,6 +16,9 @@ Item {
default property alias content: left_container.data
property alias left_content: left_container.data
property alias right_content: right_container.data
property alias maximizeBtn: maximizeBtn
property alias minimizeBtn: minimizeBtn
property alias closeBtn: closeBtn
anchors {
top: parent.top
left: parent.left
@ -78,6 +81,7 @@ Item {
spacing: 0
Layout.rightMargin: Qt.platform.os === "osx" ? -5 : 0
RibbonButton{
id: closeBtn
show_bg:false
icon_source: RibbonIcons.Dismiss
icon_source_filled: RibbonIcons_Filled.Dismiss
@ -90,6 +94,7 @@ Item {
}
RibbonButton{
id: minimizeBtn
show_bg:false
icon_source: RibbonIcons.Subtract
icon_source_filled: RibbonIcons_Filled.Subtract
@ -103,6 +108,7 @@ Item {
}
RibbonButton{
id: maximizeBtn
show_bg:false
icon_source: Window.window.visibility === Window.Maximized ? RibbonIcons.ArrowMinimize : RibbonIcons.ArrowMaximize
text_color: titleBar.title_text_color