T_TabView.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import QtQuick.Window
  5. import FluentUI
  6. import "../component"
  7. FluScrollablePage{
  8. title:"TabView"
  9. leftPadding:10
  10. rightPadding:10
  11. bottomPadding:20
  12. spacing: 0
  13. property var colors : [FluColors.Yellow,FluColors.Orange,FluColors.Red,FluColors.Magenta,FluColors.Purple,FluColors.Blue,FluColors.Teal,FluColors.Green]
  14. Component{
  15. id:com_page
  16. Rectangle{
  17. anchors.fill: parent
  18. color: argument
  19. }
  20. }
  21. function newTab(){
  22. tab_view.appendTab("qrc:/example/res/image/favicon.ico","Document "+tab_view.count(),com_page,colors[Math.floor(Math.random() * 8)].dark)
  23. }
  24. Component.onCompleted: {
  25. newTab()
  26. newTab()
  27. newTab()
  28. }
  29. FluArea{
  30. Layout.fillWidth: true
  31. Layout.topMargin: 20
  32. height: 50
  33. paddings: 10
  34. RowLayout{
  35. spacing: 14
  36. FluDropDownButton{
  37. id:btn_tab_width_behavior
  38. Layout.preferredWidth: 140
  39. text:"Equal"
  40. items:[
  41. FluMenuItem{
  42. text:"Equal"
  43. onClicked: {
  44. btn_tab_width_behavior.text = text
  45. tab_view.tabWidthBehavior = FluTabView.Equal
  46. }
  47. },
  48. FluMenuItem{
  49. text:"SizeToContent"
  50. onClicked: {
  51. btn_tab_width_behavior.text = text
  52. tab_view.tabWidthBehavior = FluTabView.SizeToContent
  53. }
  54. },
  55. FluMenuItem{
  56. text:"Compact"
  57. onClicked: {
  58. btn_tab_width_behavior.text = text
  59. tab_view.tabWidthBehavior = FluTabView.Compact
  60. }
  61. }
  62. ]
  63. }
  64. FluDropDownButton{
  65. id:btn_close_button_visibility
  66. text:"Always"
  67. Layout.preferredWidth: 120
  68. items:[
  69. FluMenuItem{
  70. text:"Nerver"
  71. onClicked: {
  72. btn_close_button_visibility.text = text
  73. tab_view.closeButtonVisibility = FluTabView.Nerver
  74. }
  75. },
  76. FluMenuItem{
  77. text:"Always"
  78. onClicked: {
  79. btn_close_button_visibility.text = text
  80. tab_view.closeButtonVisibility = FluTabView.Always
  81. }
  82. },
  83. FluMenuItem{
  84. text:"OnHover"
  85. onClicked: {
  86. btn_close_button_visibility.text = text
  87. tab_view.closeButtonVisibility = FluTabView.OnHover
  88. }
  89. }
  90. ]
  91. }
  92. }
  93. }
  94. FluArea{
  95. Layout.fillWidth: true
  96. Layout.topMargin: 15
  97. height: 400
  98. paddings: 10
  99. FluTabView{
  100. id:tab_view
  101. onNewPressed:{
  102. newTab()
  103. }
  104. }
  105. }
  106. CodeExpander{
  107. Layout.fillWidth: true
  108. Layout.topMargin: -1
  109. code:'FluTabView{
  110. anchors.fill: parent
  111. Component.onCompleted: {
  112. newTab()
  113. newTab()
  114. newTab()
  115. }
  116. Component{
  117. id:com_page
  118. Rectangle{
  119. anchors.fill: parent
  120. color: argument
  121. }
  122. }
  123. function newTab(){
  124. tab_view.appendTab("qrc:/example/res/image/favicon.ico","Document 1",com_page,argument)
  125. }
  126. }
  127. '
  128. }
  129. }