This commit is contained in:
zhuzichu 2024-01-22 15:32:45 +08:00
parent 53d28448e0
commit d6325b4f5b
3 changed files with 21 additions and 20 deletions

View File

@ -194,7 +194,6 @@ bool FluFramelessHelper::eventFilter(QObject *obj, QEvent *ev){
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
_edges = 0; _edges = 0;
_updateCursor(_edges);
break; break;
case QEvent::MouseMove: { case QEvent::MouseMove: {
if(_maximized() || _fullScreen()){ if(_maximized() || _fullScreen()){

View File

@ -4,12 +4,12 @@ import QtQuick.Window 2.15
import FluentUI 1.0 import FluentUI 1.0
Item { Item {
property string headerText: "Titlte" property string headerText: ""
property bool expand: false property bool expand: false
property int contentHeight : 300 property int contentHeight : 300
default property alias content: container.data default property alias content: container.data
id:control id:control
implicitHeight: Math.max((layout_header.height + container.height),layout_header.height) implicitHeight: Math.max((layout_header.height + layout_container.height),layout_header.height)
implicitWidth: 400 implicitWidth: 400
Rectangle{ Rectangle{
id:layout_header id:layout_header
@ -64,31 +64,32 @@ Item {
} }
} }
Item{ Item{
id:layout_container
anchors{ anchors{
top: layout_header.bottom top: layout_header.bottom
topMargin: -1 topMargin: -1
left: layout_header.left left: layout_header.left
} }
width: parent.width width: parent.width
clip: true
visible: contentHeight+container.y !== 0 visible: contentHeight+container.y !== 0
height: contentHeight+container.y height: contentHeight+container.y
clip: true
Rectangle{ Rectangle{
id:container id:container
width: parent.width anchors.fill: parent
height: parent.height
radius: 4 radius: 4
clip: true clip: true
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1) border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
y: -contentHeight anchors.topMargin: -contentHeight
// y: -contentHeight
states: [ states: [
State{ State{
name:"expand" name:"expand"
when: control.expand when: control.expand
PropertyChanges { PropertyChanges {
target: container target: container
y:0 anchors.topMargin:0
} }
}, },
State{ State{
@ -96,7 +97,7 @@ Item {
when: !control.expand when: !control.expand
PropertyChanges { PropertyChanges {
target: container target: container
y:-contentHeight anchors.topMargin:-contentHeight
} }
} }
] ]
@ -104,7 +105,7 @@ Item {
Transition { Transition {
to:"expand" to:"expand"
NumberAnimation { NumberAnimation {
properties: "y" properties: "anchors.topMargin"
duration: FluTheme.enableAnimation ? 167 : 0 duration: FluTheme.enableAnimation ? 167 : 0
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }
@ -112,7 +113,7 @@ Item {
Transition { Transition {
to:"collapsed" to:"collapsed"
NumberAnimation { NumberAnimation {
properties: "y" properties: "anchors.topMargin"
duration: FluTheme.enableAnimation ? 167 : 0 duration: FluTheme.enableAnimation ? 167 : 0
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }

View File

@ -4,12 +4,12 @@ import QtQuick.Window
import FluentUI import FluentUI
Item { Item {
property string headerText: "Titlte" property string headerText: ""
property bool expand: false property bool expand: false
property int contentHeight : 300 property int contentHeight : 300
default property alias content: container.data default property alias content: container.data
id:control id:control
implicitHeight: Math.max((layout_header.height + container.height),layout_header.height) implicitHeight: Math.max((layout_header.height + layout_container.height),layout_header.height)
implicitWidth: 400 implicitWidth: 400
Rectangle{ Rectangle{
id:layout_header id:layout_header
@ -64,6 +64,7 @@ Item {
} }
} }
Item{ Item{
id:layout_container
anchors{ anchors{
top: layout_header.bottom top: layout_header.bottom
topMargin: -1 topMargin: -1
@ -75,20 +76,20 @@ Item {
height: contentHeight+container.y height: contentHeight+container.y
Rectangle{ Rectangle{
id:container id:container
width: parent.width anchors.fill: parent
height: parent.height
radius: 4 radius: 4
clip: true clip: true
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1) color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1) border.color: FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
y: -contentHeight anchors.topMargin: -contentHeight
// y: -contentHeight
states: [ states: [
State{ State{
name:"expand" name:"expand"
when: control.expand when: control.expand
PropertyChanges { PropertyChanges {
target: container target: container
y:0 anchors.topMargin:0
} }
}, },
State{ State{
@ -96,7 +97,7 @@ Item {
when: !control.expand when: !control.expand
PropertyChanges { PropertyChanges {
target: container target: container
y:-contentHeight anchors.topMargin:-contentHeight
} }
} }
] ]
@ -104,7 +105,7 @@ Item {
Transition { Transition {
to:"expand" to:"expand"
NumberAnimation { NumberAnimation {
properties: "y" properties: "anchors.topMargin"
duration: FluTheme.enableAnimation ? 167 : 0 duration: FluTheme.enableAnimation ? 167 : 0
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }
@ -112,7 +113,7 @@ Item {
Transition { Transition {
to:"collapsed" to:"collapsed"
NumberAnimation { NumberAnimation {
properties: "y" properties: "anchors.topMargin"
duration: FluTheme.enableAnimation ? 167 : 0 duration: FluTheme.enableAnimation ? 167 : 0
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }