mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-03-13 23:49:40 +08:00
添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
This commit is contained in:
parent
24fdff7e35
commit
aecc3fe3b4
@ -5,6 +5,7 @@ import FluentUI
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
signal requestPage(int page, int count)
|
signal requestPage(int page, int count)
|
||||||
|
|
||||||
property string previousText: qsTr("<Previous")
|
property string previousText: qsTr("<Previous")
|
||||||
property string nextText: qsTr("Next>")
|
property string nextText: qsTr("Next>")
|
||||||
property int pageCurrent: 0
|
property int pageCurrent: 0
|
||||||
@ -13,6 +14,8 @@ Item {
|
|||||||
property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0
|
property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0
|
||||||
property int __itemPerPage: 10
|
property int __itemPerPage: 10
|
||||||
property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1
|
property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1
|
||||||
|
property Component header: null
|
||||||
|
property Component footer: null
|
||||||
id: control
|
id: control
|
||||||
implicitHeight: 40
|
implicitHeight: 40
|
||||||
implicitWidth: content.width
|
implicitWidth: content.width
|
||||||
@ -21,6 +24,9 @@ Item {
|
|||||||
height: control.height
|
height: control.height
|
||||||
spacing: 10
|
spacing: 10
|
||||||
padding: 10
|
padding: 10
|
||||||
|
Loader {
|
||||||
|
sourceComponent: header
|
||||||
|
}
|
||||||
FluToggleButton {
|
FluToggleButton {
|
||||||
visible: control.pageCount > 1
|
visible: control.pageCount > 1
|
||||||
disabled: control.pageCurrent <= 1
|
disabled: control.pageCurrent <= 1
|
||||||
@ -31,6 +37,7 @@ Item {
|
|||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
spacing: 5
|
spacing: 5
|
||||||
|
|
||||||
FluToggleButton {
|
FluToggleButton {
|
||||||
property int pageNumber: 1
|
property int pageNumber: 1
|
||||||
visible: control.pageCount > 0
|
visible: control.pageCount > 0
|
||||||
@ -86,9 +93,12 @@ Item {
|
|||||||
control.calcNewPage(control.pageCurrent + 1);
|
control.calcNewPage(control.pageCurrent + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loader {
|
||||||
|
sourceComponent: footer
|
||||||
}
|
}
|
||||||
function calcNewPage(page)
|
}
|
||||||
{
|
|
||||||
|
function calcNewPage(page) {
|
||||||
if (!page)
|
if (!page)
|
||||||
return
|
return
|
||||||
let page_num = Number(page)
|
let page_num = Number(page)
|
||||||
@ -97,4 +107,5 @@ Item {
|
|||||||
control.pageCurrent = page_num
|
control.pageCurrent = page_num
|
||||||
control.requestPage(page_num, control.__itemPerPage)
|
control.requestPage(page_num, control.__itemPerPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user