70 lines
2.4 KiB
QML
70 lines
2.4 KiB
QML
|
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
|
||
|
property alias buttonMaximize: btn_maximize
|
||
|
|
||
|
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 {
|
||
|
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()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|