C
Qt Quick Ultralite Watch Demo
/****************************************************************************** ** ** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/#include "flickControl.h" #include <platforminterface/platforminterface.h> #include <qul/qul.h> static int flickCount = 0; static Qul::PlatformInterface::TouchPoint touchPoint; struct Functor { void operator()() { FlickControl::instance().continueFlick(); if (++flickCount >= 25) { flickCount = 0; FlickControl::instance().endFlick(); } } }; void FlickControl::startFlick(int x, int y, int dx, int dy) { touchPoint.positionX = x; touchPoint.positionY = y; _dx = dx; _dy = dy; touchPoint.state = Qul::PlatformInterface::TouchPoint::Pressed; Qul::PlatformInterface::handleTouchEvent(nullptr /* screen */, Qul::Platform::getPlatformInstance()->currentTimestamp(), &touchPoint, 1); timer.onTimeout(Functor()); timer.setSingleShot(false); timer.start(3); } void FlickControl::continueFlick() { touchPoint.positionX -= _dx; touchPoint.positionY -= _dy; touchPoint.state = Qul::PlatformInterface::TouchPoint::Moved; Qul::PlatformInterface::handleTouchEvent(nullptr /* screen */, Qul::Platform::getPlatformInstance()->currentTimestamp(), &touchPoint, 1); } void FlickControl::endFlick() { timer.stop(); touchPoint.state = Qul::PlatformInterface::TouchPoint::Released; Qul::PlatformInterface::handleTouchEvent(nullptr /* screen */, Qul::Platform::getPlatformInstance()->currentTimestamp(), &touchPoint, 1); } bool FlickControl::running() { return timer.isActive(); }