DCheckBox.qml 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import QtQuick 2.15
  2. import QtQuick.Layouts 1.15
  3. import DMusic 1.0
  4. RowLayout {
  5. id: root
  6. spacing: 10
  7. property string text
  8. property bool checked: false
  9. property var style: Style.block
  10. property real fontSize: 11
  11. MouseArea {
  12. Layout.alignment: Qt.AlignVCenter
  13. width: 16
  14. height: 16
  15. cursorShape: Qt.PointingHandCursor
  16. onClicked: root.checked = !root.checked
  17. Rectangle {
  18. anchors.fill: parent
  19. visible: !root.checked
  20. radius: 3
  21. color: "transparent"
  22. border.color: style.checkBox.border.color
  23. border.width: style.checkBox.border.width
  24. }
  25. Icon {
  26. anchors.fill: parent
  27. visible: root.checked
  28. src: "qrc:/resources/checkbox.svg"
  29. color: style.accent
  30. }
  31. }
  32. DText {
  33. Layout.alignment: Qt.AlignVCenter
  34. visible: text != ""
  35. style: root.style.text
  36. font.pointSize: root.fontSize
  37. text: root.text
  38. MouseArea {
  39. anchors.fill: parent
  40. cursorShape: Qt.PointingHandCursor
  41. onClicked: root.checked = !root.checked
  42. }
  43. }
  44. }