TableView.qml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (C) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 1.4 as OldControls // TableView doesn't exist in the QtQuick Controls 2.x in 5.10, so use the old one
  5. import QtQuick.Controls 2.3
  6. import QtQuick.Controls.Styles 1.4
  7. import UM 1.2 as UM
  8. OldControls.TableView
  9. {
  10. itemDelegate: Item
  11. {
  12. height: tableCellLabel.implicitHeight
  13. Label
  14. {
  15. id: tableCellLabel
  16. color: UM.Theme.getColor("text")
  17. elide: Text.ElideRight
  18. text: styleData.value
  19. anchors.fill: parent
  20. anchors.leftMargin: 10 * screenScaleFactor
  21. verticalAlignment: Text.AlignVCenter
  22. }
  23. }
  24. rowDelegate: Rectangle
  25. {
  26. color: styleData.selected ? UM.Theme.getColor("secondary") : UM.Theme.getColor("main_background")
  27. height: UM.Theme.getSize("table_row").height
  28. }
  29. // Use the old styling technique since it's the only way to make the scrollbars themed in the TableView
  30. style: TableViewStyle
  31. {
  32. backgroundColor: UM.Theme.getColor("main_background")
  33. handle: Rectangle
  34. {
  35. // Both implicit width and height have to be set, since the handle is used by both the horizontal and the vertical scrollbars
  36. implicitWidth: UM.Theme.getSize("scrollbar").width
  37. implicitHeight: UM.Theme.getSize("scrollbar").width
  38. radius: width / 2
  39. color: UM.Theme.getColor(styleData.pressed ? "scrollbar_handle_down" : (styleData.hovered ? "scrollbar_handle_hover" : "scrollbar_handle"))
  40. }
  41. scrollBarBackground: Rectangle
  42. {
  43. // Both implicit width and height have to be set, since the handle is used by both the horizontal and the vertical scrollbars
  44. implicitWidth: UM.Theme.getSize("scrollbar").width
  45. implicitHeight: UM.Theme.getSize("scrollbar").width
  46. color: UM.Theme.getColor("main_background")
  47. }
  48. // The little rectangle between the vertical and horizontal scrollbars
  49. corner: Rectangle
  50. {
  51. color: UM.Theme.getColor("main_background")
  52. }
  53. // Override the control arrows
  54. incrementControl: Item { }
  55. decrementControl: Item { }
  56. }
  57. }