新增FluRatingControl组件
parent
727a0220b4
commit
70585c007e
|
@ -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{
|
||||
|
||||
}'
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -118,7 +118,8 @@ FluExpander{
|
|||
"FluTableView",
|
||||
"FluColors",
|
||||
"FluTheme",
|
||||
"FluStatusView"
|
||||
"FluStatusView",
|
||||
"FluRatingControl"
|
||||
];
|
||||
code = code.replace(/\n/g, "<br>");
|
||||
code = code.replace(/ /g, " ");
|
||||
|
|
|
@ -113,6 +113,12 @@ FluObject{
|
|||
navigationView.push("qrc:/T_Progress.qml")
|
||||
}
|
||||
}
|
||||
FluPaneItem{
|
||||
title:"RatingControl"
|
||||
onTap:{
|
||||
navigationView.push("qrc:/T_RatingControl.qml")
|
||||
}
|
||||
}
|
||||
FluPaneItem{
|
||||
title:"Badge"
|
||||
onTap:{
|
||||
|
|
|
@ -165,5 +165,6 @@
|
|||
<file>page/StandardWindow.qml</file>
|
||||
<file>page/SingleTaskWindow.qml</file>
|
||||
<file>page/SingleInstanceWindow.qml</file>
|
||||
<file>T_RatingControl.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue