mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-02 08:05:29 +08:00
新增FluRatingControl组件
This commit is contained in:
@ -34,6 +34,7 @@ void Fluent::registerTypes(const char *uri){
|
||||
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
|
||||
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/FluPagination.qml"),uri,major,minor,"FluPagination");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluToggleButton.qml"),uri,major,minor,"FluToggleButton");
|
||||
|
60
src/controls/FluRatingControl.qml
Normal file
60
src/controls/FluRatingControl.qml
Normal 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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.impl
|
||||
import QtQuick.Templates as T
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.impl
|
||||
import QtQuick.Templates as T
|
||||
|
||||
@ -26,7 +27,6 @@ T.TextField {
|
||||
y: control.topPadding
|
||||
width: control.width - (control.leftPadding + control.rightPadding)
|
||||
height: control.height - (control.topPadding + control.bottomPadding)
|
||||
|
||||
text: control.placeholderText
|
||||
font: control.font
|
||||
color: control.placeholderTextColor
|
||||
|
@ -72,5 +72,6 @@
|
||||
<file>controls/FluToggleButton.qml</file>
|
||||
<file>controls/FluStatusView.qml</file>
|
||||
<file>controls/FluPaneItemEmpty.qml</file>
|
||||
<file>controls/FluRatingControl.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Reference in New Issue
Block a user