From 15f4f2531f545931a37673b0076f389db8a87cd8 Mon Sep 17 00:00:00 2001 From: "Denis V. Dedkov" Date: Sat, 18 May 2024 09:24:51 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=20PullToRefresh=20=D0=B4=D0=BB=D1=8F=20ListView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + CMakeLists.txt | 5 ++++- PoolToRefresh.qml | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 PoolToRefresh.qml diff --git a/.gitignore b/.gitignore index 4a0b530..d0b2fe7 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ CMakeLists.txt.user* *.dll *.exe +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c0481b..f3be782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,10 @@ qt_add_library(components STATIC) qt_add_qml_module(components URI ru.ded.components VERSION 1.0 - QML_FILES MainMenu.qml MenuBackButton.qml SubtitledItemDelegate.qml + QML_FILES MainMenu.qml + MenuBackButton.qml + SubtitledItemDelegate.qml + PoolToRefresh.qml ) set_target_properties(components PROPERTIES diff --git a/PoolToRefresh.qml b/PoolToRefresh.qml new file mode 100644 index 0000000..a7a3169 --- /dev/null +++ b/PoolToRefresh.qml @@ -0,0 +1,42 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +Item { + id: root + + signal update() + + property string text: qsTr("Release to update") + property real sensivity: 50.0 + property alias enabled: connections.enabled + + property bool triggered: false + property bool trigger: parent.contentY < -1 * sensivity + property bool atStart: parent.contentY === 0 + + Label { + id: label + + anchors.horizontalCenter: root.horizontalCenter + + visible: root.trigger + text: root.text + } + + Connections { + id: connections + + target: root.parent + + function onContentYChanged() { + if (root.trigger) { + root.triggered = true + } + + if (root.atStart && root.triggered) { + root.update() + root.triggered = false + } + } + } +}