2023-03-02 18:21:43 +08:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Window 2.15
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
|
|
|
|
|
property int border: 4
|
|
|
|
|
property bool fixedSize: {
|
|
|
|
|
if(Window.window == null)
|
|
|
|
|
return true
|
|
|
|
|
if(Window.window.visibility === Window.Maximized || Window.window.visibility === Window.FullScreen){
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return (Window.window.minimumWidth === Window.window.maximumWidth && Window.window.minimumHeight === Window.window.maximumHeight)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
preventStealing: true
|
|
|
|
|
propagateComposedEvents: true
|
|
|
|
|
z: -65535
|
|
|
|
|
|
|
|
|
|
onPressed :
|
|
|
|
|
(mouse)=> {
|
|
|
|
|
if (fixedSize) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let e = 0;
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(0,0,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.TopEdge | Qt.LeftEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(border,0,window.width-border*2,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.TopEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(window.width-border,0,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.TopEdge | Qt.RightEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(window.width-border,border,border,window.height-border*2, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.RightEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(window.width-border,window.height-border,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.BottomEdge | Qt.RightEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(border,window.height-border,window.width-border*2,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.BottomEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(0,window.height-border,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.BottomEdge | Qt.LeftEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(0,border,border , window.height-border*2, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
e = Qt.LeftEdge;
|
|
|
|
|
window.startSystemResize(e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onPositionChanged:
|
|
|
|
|
(mouse)=> {
|
|
|
|
|
if (fixedSize) {
|
|
|
|
|
cursorShape = Qt.ArrowCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(0,0,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeFDiagCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(border,0,window.width-border*2,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeVerCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(window.width-border,0,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeBDiagCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(window.width-border,border,border,window.height-border*2, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeHorCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(window.width-border,window.height-border,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeFDiagCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(border,window.height-border,window.width-border*2,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeVerCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(0,window.height-border,border,border, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeBDiagCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if (ptInRect(0,border,border, window.height-border*2, mouse.x, mouse.y)) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
cursorShape = Qt.SizeHorCursor;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cursorShape = Qt.ArrowCursor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onExited: {
|
|
|
|
|
cursorShape = Qt.ArrowCursor;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 18:19:48 +08:00
|
|
|
|
function ptInRect(rcx,rcy,rcwidth,rcheight, x, y)
|
2023-03-02 18:21:43 +08:00
|
|
|
|
{
|
2023-03-03 18:19:48 +08:00
|
|
|
|
if ((rcx <= x && x <= (rcx + rcwidth)) &&
|
|
|
|
|
(rcy <= y && y <= (rcy + rcheight))) {
|
2023-03-02 18:21:43 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|