Merge pull request #577 from lucky9loogn/feat-fluexpander-custom-header

FluExpander 添加属性 headerHeight 和 headerDelegate
This commit is contained in:
zhuzichu 2024-12-24 21:50:57 +08:00 committed by GitHub
commit bb537f4328
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 232 additions and 16 deletions

View File

@ -1314,6 +1314,26 @@ Since that moment, I have been tormented day and night by the fear that I might
My only desire is to be permitted to drive out the traitors and restore the Han. If I should let you down, punish my offense and report it to the spirit of the late Emperor. If those three advisors should fail in their duties, then they should be punished for their negligence.Your Majesty, consider your course of action carefully. Seek out good advice, and never forget the late Emperor. I depart now on a long expedition, and I will be forever grateful if you heed my advice. Blinded by my own tears, I know not what I write.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="152"/>
<source>Check for Updates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="207"/>
<source>This is a ToggleButton in the header</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="215"/>
<source>This is a StandardButton in the content</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="217"/>
<source>Click StandardButton</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>T_FlipView</name>

View File

@ -1432,6 +1432,26 @@ Since that moment, I have been tormented day and night by the fear that I might
My only desire is to be permitted to drive out the traitors and restore the Han. If I should let you down, punish my offense and report it to the spirit of the late Emperor. If those three advisors should fail in their duties, then they should be punished for their negligence.Your Majesty, consider your course of action carefully. Seek out good advice, and never forget the late Emperor. I depart now on a long expedition, and I will be forever grateful if you heed my advice. Blinded by my own tears, I know not what I write.</oldsource>
<translation type="unfinished">使广使</translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="152"/>
<source>Check for Updates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="207"/>
<source>This is a ToggleButton in the header</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="215"/>
<source>This is a StandardButton in the content</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_Expander.qml" line="217"/>
<source>Click StandardButton</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>T_FlipView</name>

View File

@ -105,5 +105,147 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
}'
}
FluFrame {
Layout.fillWidth: true
padding: 10
Layout.topMargin: 20
Column {
spacing: 15
FluExpander {
headerHeight: 60
contentHeight: content_layout.implicitHeight
headerDelegate: Component {
Item {
RowLayout {
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 15
}
spacing: 15
FluImage {
width: 20
height: 20
sourceSize.width: 20
sourceSize.height: 20
source: "qrc:/example/res/image/favicon.ico"
}
ColumnLayout {
spacing: 0
FluText {
text: "FluentUI"
}
FluText {
text: "%1".arg(AppInfo.version)
textColor: FluTheme.fontSecondaryColor
font.pixelSize: 12
}
}
}
FluLoadingButton {
id: btn_checkupdate
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 15
}
text: qsTr("Check for Updates")
onClicked: {
loading = true;
FluEventBus.post("checkUpdate");
}
}
FluEvent {
name: "checkUpdateFinish"
onTriggered: {
btn_checkupdate.loading = false;
}
}
}
}
content: ColumnLayout {
id: content_layout
spacing: 0
RowLayout {
Layout.topMargin: 15
Layout.leftMargin: 15
spacing: 0
FluText {
text: "GitHub: "
}
FluTextButton {
text: "https://github.com/zhuzichu520/FluentUI"
onClicked: {
Qt.openUrlExternally(text);
}
}
}
RowLayout {
Layout.bottomMargin: 15
Layout.leftMargin: 15
spacing: 0
FluText {
text: "bilibili: "
}
FluTextButton {
text: "https://www.bilibili.com/video/BV1mg4y1M71w"
onClicked: {
Qt.openUrlExternally(text);
}
}
}
}
}
FluExpander {
contentHeight: 100
headerHeight: 45
headerDelegate: Component {
Item {
FluToggleButton {
anchors.centerIn: parent
text: qsTr("This is a ToggleButton in the header")
}
}
}
content: Item {
anchors.fill: parent
FluButton {
anchors.centerIn: parent
text: qsTr("This is a StandardButton in the content")
onClicked: {
showInfo(qsTr("Click StandardButton"))
}
}
}
}
}
}
CodeExpander {
Layout.fillWidth: true
Layout.topMargin: -6
code: 'FluExpander {
contentHeight: 100
headerHeight: 45
headerDelegate: Component {
Item {
FluToggleButton {
anchors.centerIn: parent
text: qsTr("This is a ToggleButton in the header")
}
}
}
content: Item {
anchors.fill: parent
FluButton {
anchors.centerIn: parent
text: qsTr("This is a StandardButton in the content")
onClicked: {
showInfo(qsTr("Click StandardButton"))
}
}
}
}'
}
}

View File

@ -5,6 +5,8 @@ import FluentUI 1.0
Item {
property string headerText: ""
property int headerHeight : 45
property Component headerDelegate: com_header
property bool expand: false
property int contentHeight : 300
default property alias content: container.data
@ -21,10 +23,23 @@ Item {
}
}
clip: true
Component {
id: com_header
Item {
FluText {
text: control.headerText
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 15
}
}
}
}
Rectangle{
id:layout_header
width: parent.width
height: 45
height: control.headerHeight
radius: 4
border.color: FluTheme.dividerColor
color: {
@ -41,15 +56,17 @@ Item {
d.toggle()
}
}
FluText{
text: headerText
anchors{
verticalCenter: parent.verticalCenter
FluLoader {
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
leftMargin: 15
right: btn_toggle.left
}
sourceComponent: control.headerDelegate
}
FluIconButton{
id: btn_toggle
anchors{
verticalCenter: parent.verticalCenter
right: parent.right

View File

@ -5,6 +5,8 @@ import FluentUI
Item {
property string headerText: ""
property int headerHeight : 45
property Component headerDelegate: com_header
property bool expand: false
property int contentHeight : 300
default property alias content: container.data
@ -21,10 +23,23 @@ Item {
}
}
clip: true
Component {
id: com_header
Item {
FluText {
text: control.headerText
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 15
}
}
}
}
Rectangle{
id:layout_header
width: parent.width
height: 45
height: control.headerHeight
radius: 4
border.color: FluTheme.dividerColor
color: {
@ -41,15 +56,17 @@ Item {
d.toggle()
}
}
FluText{
text: headerText
anchors{
verticalCenter: parent.verticalCenter
FluLoader {
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
leftMargin: 15
right: btn_toggle.left
}
sourceComponent: control.headerDelegate
}
FluIconButton{
id: btn_toggle
anchors{
verticalCenter: parent.verticalCenter
right: parent.right

View File

@ -355,8 +355,8 @@
<context>
<name>FluWindow</name>
<message>
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="354"/>
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="354"/>
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="375"/>
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="374"/>
<source>Loading...</source>
<translation type="unfinished"></translation>
</message>

View File

@ -355,8 +355,8 @@
<context>
<name>FluWindow</name>
<message>
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="354"/>
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="354"/>
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="375"/>
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="374"/>
<source>Loading...</source>
<translation type="unfinished">...</translation>
</message>