FluBreadcrumbBar.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import FluentUI
  5. Item {
  6. property int textSize: 15
  7. property string separator: "/"
  8. property var items: []
  9. property int spacing: 5
  10. signal clickItem(var model)
  11. id:control
  12. implicitWidth: 300
  13. height: 30
  14. onItemsChanged: {
  15. list_model.clear()
  16. list_model.append(items)
  17. }
  18. ListModel{
  19. id:list_model
  20. }
  21. ListView{
  22. id:list_view
  23. width: parent.width
  24. height: 30
  25. orientation: ListView.Horizontal
  26. model: list_model
  27. clip: true
  28. spacing : control.spacing
  29. boundsBehavior: ListView.StopAtBounds
  30. remove: Transition {
  31. NumberAnimation {
  32. properties: "opacity"
  33. from: 1
  34. to: 0
  35. duration: 83
  36. }
  37. }
  38. add: Transition {
  39. NumberAnimation {
  40. properties: "opacity"
  41. from: 0
  42. to: 1
  43. duration: 83
  44. }
  45. }
  46. delegate: Item{
  47. height: item_layout.height
  48. width: item_layout.width
  49. RowLayout{
  50. id:item_layout
  51. spacing: list_view.spacing
  52. height: list_view.height
  53. FluText{
  54. text:model.title
  55. Layout.alignment: Qt.AlignVCenter
  56. color: {
  57. if(item_mouse.pressed){
  58. return FluTheme.dark ? Qt.rgba(150/255,150/255,150/235,1) : Qt.rgba(134/255,134/255,134/235,1)
  59. }
  60. if(item_mouse.containsMouse){
  61. return FluTheme.dark ? Qt.rgba(204/255,204/255,204/235,1) : Qt.rgba(92/255,92/255,92/235,1)
  62. }
  63. return FluTheme.dark ? Qt.rgba(255/255,255/255,255/235,1) : Qt.rgba(26/255,26/255,26/235,1)
  64. }
  65. MouseArea{
  66. id:item_mouse
  67. anchors.fill: parent
  68. hoverEnabled: true
  69. onClicked: {
  70. control.clickItem(model)
  71. }
  72. }
  73. }
  74. FluText{
  75. text:control.separator
  76. font.pixelSize: control.textSize
  77. visible: list_view.count-1 !== index
  78. Layout.alignment: Qt.AlignVCenter
  79. }
  80. }
  81. }
  82. }
  83. function remove(index,count){
  84. list_model.remove(index,count)
  85. }
  86. function count(){
  87. return list_model.count
  88. }
  89. }