From b349c22434ae7761a7effc5d170b38ea05739aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Sat, 8 Apr 2023 20:08:26 +0800 Subject: [PATCH] update --- example/T_TableView.qml | 51 ++++++++++++++++++++++++++++++ example/component/CodeExpander.qml | 4 ++- src/Fluent.cpp | 1 + src/controls/FluPagination.qml | 10 +++--- src/controls/FluTextButton.qml | 6 +++- 5 files changed, 66 insertions(+), 6 deletions(-) diff --git a/example/T_TableView.qml b/example/T_TableView.qml index 92ab6247..cd73fcb7 100644 --- a/example/T_TableView.qml +++ b/example/T_TableView.qml @@ -90,6 +90,57 @@ FluScrollablePage{ } } } + CodeExpander{ + Layout.fillWidth: true + Layout.topMargin: 10 + code:'FluTableView{ + id:table_view + Layout.fillWidth: true + Layout.topMargin: 20 + width:parent.width + pageCurrent:1 + pageCount:10 + itemCount: 1000 + onRequestPage: + (page,count)=> { + loadData(page,count) + } + Component.onCompleted: { + const columns = [ + { + title: "姓名", + dataIndex: "name", + width:100 + }, + { + title: "年龄", + dataIndex: "age", + width:100 + }, + { + title: "住址", + dataIndex: "address", + width:200 + }, + { + title: "别名", + dataIndex: "nickname", + width:100 + } + ]; + table_view.columns = columns + const dataSource = [ + { + name: "孙悟空”, + age: 500, + address:"钟灵毓秀的花果山,如神仙仙境的水帘洞", + nickname:"齐天大圣" + } + ]; + table_view.dataSource = columns + } +}' + } function loadData(page,count){ const dataSource = [] diff --git a/example/component/CodeExpander.qml b/example/component/CodeExpander.qml index f3a6bc93..1650e991 100644 --- a/example/component/CodeExpander.qml +++ b/example/component/CodeExpander.qml @@ -113,7 +113,9 @@ FluExpander{ "FluTooltip", "FluTreeView", "FluWindow", - "FluWindowResize" + "FluWindowResize", + "FluToggleButton", + "FluTableView" ]; code = code.replace(/\n/g, "
"); code = code.replace(/ /g, " "); diff --git a/src/Fluent.cpp b/src/Fluent.cpp index 8fced893..99d85777 100644 --- a/src/Fluent.cpp +++ b/src/Fluent.cpp @@ -33,6 +33,7 @@ void Fluent::registerTypes(const char *uri){ qmlRegisterType(uri,major,minor,"WindowHelper"); qmlRegisterType(uri,major,minor,"FluColorSet"); + qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPagination.qml"),uri,major,minor,"FluPagination"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluToggleButton.qml"),uri,major,minor,"FluToggleButton"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTableView.qml"),uri,major,minor,"FluTableView"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPivotItem.qml"),uri,major,minor,"FluPivotItem"); diff --git a/src/controls/FluPagination.qml b/src/controls/FluPagination.qml index 9cca90e9..952e9891 100644 --- a/src/controls/FluPagination.qml +++ b/src/controls/FluPagination.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Controls import FluentUI import QtQuick.Layouts @@ -7,6 +8,8 @@ Item { signal requestPage(int page,int count) + property string previousText: "<上一页" + property string nextText: "下一页>" property int pageCurrent: 0 property int itemCount: 0 property int pageCount: itemCount>0?Math.ceil(itemCount/__itemPerPage):0 @@ -28,7 +31,7 @@ Item { FluToggleButton{ visible: control.pageCount>1 disabled: control.pageCurrent<=1 - text:"<上一页" + text:control.previousText onClicked: { control.calcNewPage(control.pageCurrent-1); } @@ -76,8 +79,7 @@ Item { } FluToggleButton{ property int pageNumber:control.pageCount - visible: control.pageCount>0 - enabled: control.pageCurrent>1 + visible: control.pageCount>1 selected: pageNumber === control.pageCurrent text:String(pageNumber) onClicked: { @@ -88,7 +90,7 @@ Item { FluToggleButton{ visible: control.pageCount>1 disabled: control.pageCurrent>=control.pageCount - text:"下一页>" + text:control.nextText onClicked: { control.calcNewPage(control.pageCurrent+1); } diff --git a/src/controls/FluTextButton.qml b/src/controls/FluTextButton.qml index 77429f86..9d041413 100644 --- a/src/controls/FluTextButton.qml +++ b/src/controls/FluTextButton.qml @@ -6,7 +6,8 @@ FluControl { property bool disabled: false property color normalColor: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark - property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.3) : Qt.lighter(normalColor,1.3) + property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.15) : Qt.lighter(normalColor,1.15) + property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.3) : Qt.lighter(normalColor,1.3) property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) property bool textBold: true @@ -36,6 +37,9 @@ FluControl { if(disabled){ return disableColor } + if(pressed){ + return pressedColor + } return hovered ? hoverColor :normalColor } }