FloatingRoundButton.qml 603 B

123456789101112131415161718192021222324252627
  1. import QtQuick 2.0
  2. Rectangle {
  3. id: root
  4. signal clicked()
  5. property alias icon: iconItem.source
  6. property color primaryColor: "#2196F3"
  7. property color secondaryColor: "#03A9F4"
  8. width: 70
  9. height: width
  10. radius: width/2
  11. opacity: enabled ? 1.0 : 0.3
  12. color: control.pressed ? root.secondaryColor : root.primaryColor
  13. Behavior on opacity {
  14. NumberAnimation { duration: 300 }
  15. }
  16. Image {
  17. anchors.centerIn: parent
  18. id: iconItem
  19. }
  20. MouseArea {
  21. id: control
  22. anchors.fill: parent
  23. onClicked: root.clicked()
  24. }
  25. }