PoolToRefresh.qml 868 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Item {
  4. id: root
  5. signal update()
  6. property string text: qsTr("Release to update")
  7. property real sensivity: 50.0
  8. property alias enabled: connections.enabled
  9. property bool triggered: false
  10. property bool trigger: parent.contentY < -1 * sensivity
  11. property bool atStart: parent.contentY === 0
  12. Label {
  13. id: label
  14. anchors.horizontalCenter: root.horizontalCenter
  15. visible: root.trigger
  16. text: root.text
  17. }
  18. Connections {
  19. id: connections
  20. target: root.parent
  21. function onContentYChanged() {
  22. if (root.trigger) {
  23. root.triggered = true
  24. }
  25. if (root.atStart && root.triggered) {
  26. root.update()
  27. root.triggered = false
  28. }
  29. }
  30. }
  31. }