2024-08-21 23:26:43 +08:00
|
|
|
import QtQuick as Quick
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import Fluent
|
|
|
|
|
|
|
|
Quick.Rectangle {
|
|
|
|
id: root
|
|
|
|
property bool showMinimize: true
|
|
|
|
property bool showMaximize: true
|
|
|
|
property bool showClose: true
|
|
|
|
property bool showStayTop: true
|
|
|
|
property bool showDark: false
|
|
|
|
property string title: ""
|
|
|
|
property url icon
|
|
|
|
property string maximizeText : qsTr("Maximize")
|
|
|
|
property Quick.color textColor: Theme.fontPrimaryColor
|
|
|
|
property Quick.color maximizeNormalColor: Theme.itemNormalColor
|
2024-08-23 00:04:16 +08:00
|
|
|
property Quick.color maximizeHoverColor: Theme.itemHoverColor
|
|
|
|
property bool isMac: Utilities.isMacos()
|
2024-08-21 23:26:43 +08:00
|
|
|
property alias buttonMaximize: btn_maximize
|
2024-08-23 00:04:16 +08:00
|
|
|
property alias layoutMacosButtons: layout_macos_buttons
|
|
|
|
property alias layoutStandardbuttons: layout_standard_buttons
|
2024-08-21 23:26:43 +08:00
|
|
|
|
|
|
|
Quick.Item{
|
|
|
|
id:d
|
|
|
|
property var hitTestList: []
|
|
|
|
property bool hoverMaxBtn: false
|
|
|
|
property var win: Window.window
|
|
|
|
property bool stayTop: {
|
|
|
|
if(d.win instanceof Window){
|
|
|
|
return d.win.stayTop
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
property bool isRestore: win && (Window.Maximized === win.visibility || Window.FullScreen === win.visibility)
|
|
|
|
property bool resizable: win && !(win.height === win.maximumHeight && win.height === win.minimumHeight && win.width === win.maximumWidth && win.width === win.minimumWidth)
|
|
|
|
function containsPointToItem(point,item){
|
|
|
|
var pos = item.mapToGlobal(0,0)
|
|
|
|
var rect = Qt.rect(pos.x,pos.y,item.width,item.height)
|
|
|
|
if(point.x>rect.x && point.x<(rect.x+rect.width) && point.y>rect.y && point.y<(rect.y+rect.height)){
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
2024-08-23 00:04:16 +08:00
|
|
|
id:layout_standard_buttons
|
|
|
|
height: parent.height
|
|
|
|
anchors.right: parent.right
|
|
|
|
spacing: 0
|
|
|
|
|
2024-08-21 23:26:43 +08:00
|
|
|
IconButton{
|
|
|
|
id:btn_maximize
|
|
|
|
property bool hover: btn_maximize.hovered
|
|
|
|
Layout.preferredWidth: 40
|
|
|
|
Layout.preferredHeight: 30
|
|
|
|
padding: 0
|
|
|
|
verticalPadding: 0
|
|
|
|
horizontalPadding: 0
|
|
|
|
iconSource : d.isRestore ? Icons.ChromeRestore : Icons.ChromeMaximize
|
|
|
|
color: {
|
|
|
|
if(down){
|
|
|
|
return maximizePressColor
|
|
|
|
}
|
|
|
|
return btn_maximize.hover ? maximizeHoverColor : maximizeNormalColor
|
|
|
|
}
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
visible: d.resizable && !isMac && showMaximize
|
|
|
|
radius: 0
|
|
|
|
iconColor: root.textColor
|
|
|
|
text:d.isRestore?restoreText:maximizeText
|
|
|
|
iconSize: 11
|
|
|
|
onClicked: maxClickListener()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-23 00:04:16 +08:00
|
|
|
Quick.Loader{
|
|
|
|
id:layout_macos_buttons
|
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: 10
|
|
|
|
}
|
|
|
|
sourceComponent: isMac ? com_macos_buttons : undefined
|
|
|
|
Quick.Component.onDestruction: sourceComponent = undefined
|
|
|
|
}
|
2024-08-21 23:26:43 +08:00
|
|
|
}
|