Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Mar 20, 2023
1 parent e29cb74 commit b83e70b
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 6 deletions.
101 changes: 101 additions & 0 deletions example/T_Badge.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
import FluentUI 1.0

FluScrollablePage{

title:"Badge"


FluArea{
width: parent.width
Layout.topMargin: 20
height: 106
paddings: 10

Column{
spacing: 15
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluText{
text:"一般出现在通知图标或头像的右上角,用于显示需要处理的消息条数"
}

Row{
spacing: 20
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:0
}
}

Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:5
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:50
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:100
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
isDot:true
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:99
color: Qt.rgba(250/255,173/255,20/255,1)
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:99
color: Qt.rgba(82/255,196/255,26/255,1)
}
}
}
}
}

}
2 changes: 0 additions & 2 deletions example/T_Rectangle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ FluScrollablePage{
height: 50
color:"#744da9"
radius:[15,15,15,15]
FluBadge{
}
}
FluRectangle{
width: 50
Expand Down
2 changes: 1 addition & 1 deletion example/T_Tooltip.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import FluentUI 1.0

FluScrollablePage{

title:"TextBox"
title:"Tooltip"

FluText{
Layout.topMargin: 20
Expand Down
8 changes: 8 additions & 0 deletions example/page/ChatPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ FluWindow {

title:"ChatGPT"

onInitArgument:
(argument)=>{
scrollview.focus = true
}

ChatController{
id:controller

Expand Down Expand Up @@ -167,6 +172,7 @@ FluWindow {


ScrollView{
id:scrollview
anchors{
bottom: parent.bottom
left: parent.left
Expand All @@ -178,6 +184,8 @@ FluWindow {
height: Math.min(textbox.implicitHeight,64)
FluMultiLineTextBox{
id:textbox
focus:true
placeholderText: "请输入消息"
}
}

Expand Down
8 changes: 7 additions & 1 deletion example/page/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@ FluWindow {
}
}

FluPaneItem{
title:"Badge"
onTap:{
nav_view.push("qrc:/T_Badge.qml")
}
}

FluPaneItem{
title:"Rectangle"
onTap:{
nav_view.push("qrc:/T_Rectangle.qml")
}
}


FluPaneItem{
title:"Carousel"
onTap:{
Expand Down
1 change: 1 addition & 0 deletions example/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
<file>res/image/logo_openai.png</file>
<file>page/ChatPage.qml</file>
<file>T_Tooltip.qml</file>
<file>T_Badge.qml</file>
</qresource>
</RCC>
70 changes: 68 additions & 2 deletions src/controls/FluBadge.qml
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
import QtQuick 2.15

Item {
Rectangle{

property bool isDot: false
property bool showZero: true
property int count: 0

Rectangle{

id:control
color:Qt.rgba(255/255,77/255,79/255,1)
width: {
if(isDot)
return 10
if(count<10){
return 20
}else if(count<100){
return 30
}
return 40
}
height: {
if(isDot)
return 10
return 20
}
radius: {
if(isDot)
return 5
return 10
}
border.width: 1
border.color: Qt.rgba(1,1,1,1)
visible: {
if(showZero)
return true
return count!==0
}
anchors{
right: {
if(parent)
return parent.right
return undefined
}
top: {
if(parent)
return parent.top
return undefined
}
rightMargin: {
if(isDot){
return -2.5
}
return -(control.width/2)
}
topMargin: {
if(isDot){
return -2.5
}
return -10
}
}

Text{
anchors.centerIn: parent
color: Qt.rgba(1,1,1,1)
visible: !isDot
text:{
if(count<100)
return count
return count+"+"
}
}



}

0 comments on commit b83e70b

Please sign in to comment.