This commit is contained in:
zhuzichu 2023-08-21 11:51:03 +08:00
parent 997101f349
commit bad1071bb4
3 changed files with 25 additions and 10 deletions

View File

@ -13,6 +13,7 @@ FluWindow {
id: title_bar id: title_bar
title: window.title title: window.title
visible: window.appBarVisible visible: window.appBarVisible
icon:"qrc:/example/res/image/favicon.ico"
anchors { anchors {
top: parent.top top: parent.top
left: parent.left left: parent.left

View File

@ -29,6 +29,7 @@ FluScrollablePage{
Layout.preferredWidth: 400 Layout.preferredWidth: 400
Layout.topMargin: 10 Layout.topMargin: 10
Layout.leftMargin: 4 Layout.leftMargin: 4
Layout.bottomMargin: 4
color: FluTheme.dark ? FluColors.Black : FluColors.White color: FluTheme.dark ? FluColors.Black : FluColors.White
FluShadow{ FluShadow{
radius: 0 radius: 0

View File

@ -23,6 +23,8 @@ Rectangle{
property bool showMinimize: true property bool showMinimize: true
property bool showMaximize: true property bool showMaximize: true
property bool titleVisible: true property bool titleVisible: true
property url icon
property int iconSize: 20
property bool isMac: FluTools.isMacos() property bool isMac: FluTools.isMacos()
property color borerlessColor : FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark property color borerlessColor : FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property var maxClickListener : function(){ property var maxClickListener : function(){
@ -44,7 +46,7 @@ Rectangle{
FluTheme.darkMode = FluThemeType.Dark FluTheme.darkMode = FluThemeType.Dark
} }
} }
id:root id:control
color: Qt.rgba(0,0,0,0) color: Qt.rgba(0,0,0,0)
height: visible ? 30 : 0 height: visible ? 30 : 0
opacity: visible opacity: visible
@ -64,20 +66,31 @@ Rectangle{
grabPermissions: TapHandler.CanTakeOverFromAnything grabPermissions: TapHandler.CanTakeOverFromAnything
onActiveChanged: if (active) { d.win.startSystemMove(); } onActiveChanged: if (active) { d.win.startSystemMove(); }
} }
FluText { Row{
text: title
anchors{ anchors{
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left: isMac ? undefined : parent.left left: isMac ? undefined : parent.left
leftMargin: isMac ? undefined : 10 leftMargin: isMac ? undefined : 10
horizontalCenter: isMac ? parent.horizontalCenter : undefined horizontalCenter: isMac ? parent.horizontalCenter : undefined
} }
visible: root.titleVisible spacing: 10
color:root.textColor Image{
width: control.iconSize
height: control.iconSize
visible: status === Image.Ready ? true : false
source: control.icon
anchors.verticalCenter: parent.verticalCenter
}
FluText {
text: title
visible: control.titleVisible
color:control.textColor
anchors.verticalCenter: parent.verticalCenter
}
} }
RowLayout{ RowLayout{
anchors.right: parent.right anchors.right: parent.right
height: root.height height: control.height
spacing: 0 spacing: 0
FluToggleSwitch{ FluToggleSwitch{
id:btn_dark id:btn_dark
@ -85,7 +98,7 @@ Rectangle{
Layout.rightMargin: 5 Layout.rightMargin: 5
visible: showDark visible: showDark
text:darkText text:darkText
textColor:root.textColor textColor:control.textColor
checked: FluTheme.dark checked: FluTheme.dark
textRight: false textRight: false
clickListener:()=> darkClickListener(btn_dark) clickListener:()=> darkClickListener(btn_dark)
@ -100,7 +113,7 @@ Rectangle{
text:minimizeText text:minimizeText
radius: 0 radius: 0
visible: !isMac && showMinimize visible: !isMac && showMinimize
iconColor: root.textColor iconColor: control.textColor
color: hovered ? minimizeHoverColor : minimizeNormalColor color: hovered ? minimizeHoverColor : minimizeNormalColor
onClicked: minClickListener() onClicked: minClickListener()
} }
@ -113,7 +126,7 @@ Rectangle{
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
visible: d.resizable && !isMac && showMaximize visible: d.resizable && !isMac && showMaximize
radius: 0 radius: 0
iconColor: root.textColor iconColor: control.textColor
text:d.isRestore?restoreText:maximizeText text:d.isRestore?restoreText:maximizeText
iconSize: 11 iconSize: 11
onClicked: maxClickListener() onClicked: maxClickListener()
@ -128,7 +141,7 @@ Rectangle{
visible: !isMac && showClose visible: !isMac && showClose
radius: 0 radius: 0
iconSize: 10 iconSize: 10
iconColor: hovered ? Qt.rgba(1,1,1,1) : root.textColor iconColor: hovered ? Qt.rgba(1,1,1,1) : control.textColor
color:hovered ? closeHoverColor : closeNormalColor color:hovered ? closeHoverColor : closeNormalColor
onClicked: closeClickListener() onClicked: closeClickListener()
} }