QWKButton.qml 875 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Button {
  4. id: root
  5. width: height * 1.5
  6. leftPadding: 0
  7. topPadding: 0
  8. rightPadding: 0
  9. bottomPadding: 0
  10. leftInset: 0
  11. topInset: 0
  12. rightInset: 0
  13. bottomInset: 0
  14. property alias source: image.source
  15. contentItem: Item {
  16. Image {
  17. id: image
  18. anchors.centerIn: parent
  19. mipmap: true
  20. width: 12
  21. height: 12
  22. fillMode: Image.PreserveAspectFit
  23. }
  24. }
  25. background: Rectangle {
  26. color: {
  27. if (!root.enabled) {
  28. return "gray";
  29. }
  30. if (root.pressed) {
  31. return Qt.rgba(0, 0, 0, 0.15);
  32. }
  33. if (root.hovered) {
  34. return Qt.rgba(0, 0, 0, 0.15);
  35. }
  36. return "transparent";
  37. }
  38. }
  39. }