RibbonTitleBar and framelesshelper: restore titlebar, prepare to deprecate helper.

This commit is contained in:
Mentalflow 2024-01-31 19:22:53 +08:00
parent 04230551dd
commit 46148435f2
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
3 changed files with 55 additions and 62 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "3rdparty/framelesshelper"]
path = 3rdparty/framelesshelper
url = git@github.com:wangwenx190/framelesshelper.git
url = git@github.com:mentalfl0w/framelesshelper.git

@ -1 +1 @@
Subproject commit 43f632f2617bd8748fdca605e2fe0b4b67649324
Subproject commit 206cd7953eb37618bee14f7c3eae73f0bb863cad

View File

@ -11,12 +11,14 @@ Item {
property bool show_darkmode_btn: true
property bool dark_mode: RibbonTheme.dark_mode
property bool modern_style: RibbonTheme.modern_style
property bool show_buildin_title_btn: Qt.platform.os !== "osx" || RibbonUI.qt_version > 624
property string title_color: modern_style ? "transparent" : dark_mode ? "#282828" : "#2C59B7"
property string title_text_color: modern_style ? dark_mode ? "white" : "black" : "white"
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
@ -40,7 +42,7 @@ Item {
id: title_text
anchors.centerIn: parent
text: control.title
font.family: show_buildin_title_btn ? "PingFang SC" : "Microsoft YaHei UI"
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
color: title_text_color
Behavior on color {
ColorAnimation {
@ -57,13 +59,9 @@ Item {
top: parent.top
left: parent.left
bottom: parent.bottom
leftMargin: !show_buildin_title_btn ? 65 : 10
leftMargin: Qt.platform.os === "osx" ? 65 : 10
}
Layout.maximumWidth: (parent.width - title_text.contentWidth) / 2
Loader{
active: Qt.platform.os === "osx"
sourceComponent: title_btns
}
}
RowLayout{
@ -77,9 +75,54 @@ Item {
}
Layout.maximumWidth: (parent.width - title_text.contentWidth) / 2
layoutDirection: Qt.RightToLeft
Loader{
active: Qt.platform.os !== "osx"
sourceComponent: title_btns
RowLayout{
visible: Qt.platform.os !== "osx"
layoutDirection: Qt.RightToLeft
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
text_color: titleBar.title_text_color
hover_color: "#ED6B5E"
pressed_color: "#B55149"
text_color_reverse: false
tip_text: qsTr("Close")
onClicked: Window.window.close()
}
RibbonButton{
id: minimizeBtn
show_bg:false
icon_source: RibbonIcons.Subtract
icon_source_filled: RibbonIcons_Filled.Subtract
text_color: titleBar.title_text_color
hover_color: "#F4BE4F"
pressed_color: "#B78F3B"
text_color_reverse: false
tip_text: qsTr("Minimize")
font.bold: pressed || checked
onClicked: Window.window.visibility = Window.Minimized
}
RibbonButton{
id: maximizeBtn
show_bg:false
icon_source: Window.window.visibility === Window.Maximized ? RibbonIcons.ArrowMinimize : RibbonIcons.ArrowMaximize
text_color: titleBar.title_text_color
hover_color: "#61C554"
pressed_color: "#48953F"
text_color_reverse: false
tip_text: Window.window.visibility === Window.Maximized ? qsTr("Restore") : qsTr("Maximize")
onClicked: {
if (Window.window.visibility === Window.Maximized)
Window.window.visibility = Window.Windowed
else
Window.window.visibility = Window.Maximized
}
}
}
RibbonSwitchButton{
text: qsTr("Style")
@ -111,54 +154,4 @@ Item {
visible: show_darkmode_btn
}
}
Component{
id: title_btns
RowLayout{
visible: show_buildin_title_btn
layoutDirection: Qt.platform.os === "osx" ? Qt.LeftToRight : Qt.RightToLeft
spacing: 0
Layout.rightMargin: show_buildin_title_btn ? -5 : 0
RibbonButton{
show_bg:false
icon_source: RibbonIcons.Dismiss
icon_source_filled: RibbonIcons_Filled.Dismiss
text_color: titleBar.title_text_color
hover_color: "#ED6B5E"
pressed_color: "#B55149"
text_color_reverse: false
tip_text: qsTr("Close")
onClicked: Window.window.close()
}
RibbonButton{
show_bg:false
icon_source: RibbonIcons.Subtract
icon_source_filled: RibbonIcons_Filled.Subtract
text_color: titleBar.title_text_color
hover_color: "#F4BE4F"
pressed_color: "#B78F3B"
text_color_reverse: false
tip_text: qsTr("Minimize")
font.bold: pressed || checked
onClicked: Window.window.visibility = Window.Minimized
}
RibbonButton{
show_bg:false
icon_source: Window.window.visibility === Window.Maximized ? RibbonIcons.ArrowMinimize : RibbonIcons.ArrowMaximize
text_color: titleBar.title_text_color
hover_color: "#61C554"
pressed_color: "#48953F"
text_color_reverse: false
tip_text: Window.window.visibility === Window.Maximized ? qsTr("Restore") : qsTr("Maximize")
onClicked: {
if (Window.window.visibility === Window.Maximized)
Window.window.visibility = Window.Windowed
else
Window.window.visibility = Window.Maximized
}
}
}
}
}