This commit is contained in:
zhuzichu
2023-12-13 16:20:09 +08:00
parent 863c88411b
commit ec2378a07a
30 changed files with 215 additions and 264 deletions

View File

@ -74,14 +74,16 @@ Rectangle{
property bool isRestore: win && Window.Maximized === win.visibility
property bool resizable: win && !(win.height === win.maximumHeight && win.height === win.minimumHeight && win.width === win.maximumWidth && win.width === win.minimumWidth)
}
TapHandler {
onTapped: if (tapCount === 2 && d.resizable) btn_maximize.clicked()
gesturePolicy: TapHandler.DragThreshold
}
DragHandler {
target: null
grabPermissions: TapHandler.CanTakeOverFromAnything
onActiveChanged: if (active) { d.win.startSystemMove(); }
MouseArea{
anchors.fill: parent
onPositionChanged: {
d.win.startSystemMove()
}
onDoubleClicked: {
if(d.resizable){
btn_maximize.clicked()
}
}
}
Row{
anchors{
@ -105,6 +107,49 @@ Rectangle{
anchors.verticalCenter: parent.verticalCenter
}
}
Component{
id:com_mac_buttons
RowLayout{
FluImageButton{
Layout.preferredHeight: 12
Layout.preferredWidth: 12
normalImage: "../Image/btn_close_normal.png"
hoveredImage: "../Image/btn_close_hovered.png"
pushedImage: "../Image/btn_close_pushed.png"
visible: showClose
onClicked: closeClickListener()
}
FluImageButton{
Layout.preferredHeight: 12
Layout.preferredWidth: 12
normalImage: "../Image/btn_min_normal.png"
hoveredImage: "../Image/btn_min_hovered.png"
pushedImage: "../Image/btn_min_pushed.png"
onClicked: minClickListener()
visible: showMinimize
}
FluImageButton{
Layout.preferredHeight: 12
Layout.preferredWidth: 12
normalImage: "../Image/btn_max_normal.png"
hoveredImage: "../Image/btn_max_hovered.png"
pushedImage: "../Image/btn_max_pushed.png"
onClicked: maxClickListener()
visible: d.resizable && showMaximize
}
}
}
FluLoader{
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 10
}
sourceComponent: isMac ? com_mac_buttons : undefined
}
RowLayout{
anchors.right: parent.right
height: control.height

View File

@ -0,0 +1,18 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
Button{
id:control
property string normalImage: ""
property string hoveredImage: ""
property string pushedImage: ""
background: Item{
implicitHeight: 12
implicitWidth: 12
BorderImage {
anchors.fill: parent
source: control.hovered ? (control.pressed ? control.pushedImage : control.hoveredImage ) : control.normalImage
}
}
}

View File

@ -37,8 +37,9 @@ Window {
property bool showMinimize: true
property bool showMaximize: true
property bool showStayTop: true
flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint
property bool autoMaximize: false
property color resizeBorderColor: FluTheme.dark ? Qt.rgba(80/255,80/255,80/255,1) : Qt.rgba(210/255,210/255,210/255,1)
property int resizeBorderWidth: 1
property var closeListener: function(event){
if(closeDestory){
destoryOnClose()
@ -126,18 +127,18 @@ Window {
left: parent.left
right: parent.right
}
height: {
if(FluApp.useSystemAppBar){
return 0
}
return window.fitsAppBarWindows ? 0 : window.appBar.height
}
sourceComponent: FluApp.useSystemAppBar ? undefined : com_app_bar
}
Component{
id:com_app_bar
Item{
data: window.appBar
height: {
if(FluApp.useSystemAppBar){
return 0
}
return window.fitsAppBarWindows ? 0 : childrenRect.height
}
}
}
Item{
@ -225,27 +226,19 @@ Window {
WindowLifecycle{
id:lifecycle
}
FluLoader{
id:loader_window_border
Rectangle{
anchors.fill: parent
z:999
sourceComponent: FluApp.useSystemAppBar ? undefined : com_window_border
}
Component{
id:com_window_border
Item{
Rectangle{
anchors.fill: parent
color: Qt.rgba(0,0,0,0)
border.width: 1
visible: FluTools.isLinux()
border.color: {
if(window.active){
return Qt.rgba(51/255,51/255,51/255,1)
}
return Qt.rgba(153/255,153/255,153/255,1)
}
color:"transparent"
border.width: window.resizeBorderWidth
border.color: window.resizeBorderColor
visible: {
if(FluApp.useSystemAppBar){
return false
}
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){
return false
}
return true
}
}
function destoryOnClose(){

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -97,5 +97,15 @@
<file>FluentUI/Controls/FluClip.qml</file>
<file>FluentUI/Controls/FluLoader.qml</file>
<file>FluentUI/Controls/FluShortcutPicker.qml</file>
<file>FluentUI/Image/btn_close_hovered.png</file>
<file>FluentUI/Image/btn_close_normal.png</file>
<file>FluentUI/Image/btn_close_pushed.png</file>
<file>FluentUI/Image/btn_max_hovered.png</file>
<file>FluentUI/Image/btn_max_normal.png</file>
<file>FluentUI/Image/btn_max_pushed.png</file>
<file>FluentUI/Image/btn_min_hovered.png</file>
<file>FluentUI/Image/btn_min_normal.png</file>
<file>FluentUI/Image/btn_min_pushed.png</file>
<file>FluentUI/Controls/FluImageButton.qml</file>
</qresource>
</RCC>