新增FluRatingControl组件

main
zhuzihcu 2023-04-14 15:18:08 +08:00
parent 727a0220b4
commit 70585c007e
9 changed files with 116 additions and 2 deletions

View File

@ -0,0 +1,43 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Controls
import FluentUI
import "./component"
FluScrollablePage{
title:"RatingControl"
leftPadding:10
rightPadding:10
bottomPadding:20
spacing: 0
FluArea{
Layout.fillWidth: true
height: 100
paddings: 10
Layout.topMargin: 20
Column{
spacing: 10
anchors.verticalCenter: parent.verticalCenter
FluRatingControl{
}
FluRatingControl{
number:10
}
}
}
CodeExpander{
Layout.fillWidth: true
code:'FluRatingControl{
}'
}
}

View File

@ -118,7 +118,8 @@ FluExpander{
"FluTableView", "FluTableView",
"FluColors", "FluColors",
"FluTheme", "FluTheme",
"FluStatusView" "FluStatusView",
"FluRatingControl"
]; ];
code = code.replace(/\n/g, "<br>"); code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;"); code = code.replace(/ /g, "&nbsp;");

View File

@ -113,6 +113,12 @@ FluObject{
navigationView.push("qrc:/T_Progress.qml") navigationView.push("qrc:/T_Progress.qml")
} }
} }
FluPaneItem{
title:"RatingControl"
onTap:{
navigationView.push("qrc:/T_RatingControl.qml")
}
}
FluPaneItem{ FluPaneItem{
title:"Badge" title:"Badge"
onTap:{ onTap:{

View File

@ -165,5 +165,6 @@
<file>page/StandardWindow.qml</file> <file>page/StandardWindow.qml</file>
<file>page/SingleTaskWindow.qml</file> <file>page/SingleTaskWindow.qml</file>
<file>page/SingleInstanceWindow.qml</file> <file>page/SingleInstanceWindow.qml</file>
<file>T_RatingControl.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -34,6 +34,7 @@ void Fluent::registerTypes(const char *uri){
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper"); qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet"); qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluRatingControl.qml"),uri,major,minor,"FluRatingControl");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluStatusView.qml"),uri,major,minor,"FluStatusView"); qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluStatusView.qml"),uri,major,minor,"FluStatusView");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPagination.qml"),uri,major,minor,"FluPagination"); 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/FluToggleButton.qml"),uri,major,minor,"FluToggleButton");

View File

@ -0,0 +1,60 @@
import QtQuick
import QtQuick.Controls
import FluentUI
Item {
property int number: 5
property int spacing: 4
property int size: 18
property int value:0
id:control
implicitWidth: container.width
implicitHeight: container.height
QtObject{
id:d
property int mouseValue: 0
property int itemSize: control.size+spacing*2
}
Row{
id:container
spacing: 0
Repeater{
model:control.number
Item{
width: d.itemSize
height: d.itemSize
FluIcon{
property bool isSelected : {
if(d.mouseValue!==0){
return index<d.mouseValue
}
return index<control.value
}
iconSize: control.size
iconSource: isSelected ? FluentIcons.FavoriteStarFill : FluentIcons.FavoriteStar
iconColor: isSelected ? FluTheme.primaryColor.dark : (FluTheme.dark ? "#FFFFFF" : "#000000")
anchors.centerIn: parent
}
}
}
}
MouseArea{
anchors.fill: container
hoverEnabled: true
onPositionChanged: (mouse)=>{
d.mouseValue = Number(mouse.x / d.itemSize)+1
}
onExited: {
d.mouseValue = 0
}
onClicked: (mouse)=>{
control.value = Number(mouse.x / d.itemSize)+1
}
}
}

View File

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Controls
import QtQuick.Controls.impl import QtQuick.Controls.impl
import QtQuick.Templates as T import QtQuick.Templates as T

View File

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Controls
import QtQuick.Controls.impl import QtQuick.Controls.impl
import QtQuick.Templates as T import QtQuick.Templates as T
@ -26,7 +27,6 @@ T.TextField {
y: control.topPadding y: control.topPadding
width: control.width - (control.leftPadding + control.rightPadding) width: control.width - (control.leftPadding + control.rightPadding)
height: control.height - (control.topPadding + control.bottomPadding) height: control.height - (control.topPadding + control.bottomPadding)
text: control.placeholderText text: control.placeholderText
font: control.font font: control.font
color: control.placeholderTextColor color: control.placeholderTextColor

View File

@ -72,5 +72,6 @@
<file>controls/FluToggleButton.qml</file> <file>controls/FluToggleButton.qml</file>
<file>controls/FluStatusView.qml</file> <file>controls/FluStatusView.qml</file>
<file>controls/FluPaneItemEmpty.qml</file> <file>controls/FluPaneItemEmpty.qml</file>
<file>controls/FluRatingControl.qml</file>
</qresource> </qresource>
</RCC> </RCC>