C
Qt Quick Ultralite loader Example
/****************************************************************************** ** ** Copyright (C) 2022 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 "ColorsQueue.h" #include <platform/platform.h> Color ColorsQueue::at(int i) const { return m_queue.at(i); } Color ColorsQueue::dequeue() { assert(!isEmpty()); Color c = m_queue.front(); m_queue.pop_front(); return c; } int ColorsQueue::size() const { return m_queue.size(); } bool ColorsQueue::isEmpty() const { return m_queue.empty(); } size_t getRandomColorId() { Qul::Platform::PlatformContext *platform = Qul::Platform::getPlatformInstance(); return static_cast<int>(platform->rand() * 10) % 4; } void ColorsQueue::generateColors(int count) { const uint32_t green = 0xff008000; const uint32_t blue = 0xff0000ff; const uint32_t red = 0xffff0000; const uint32_t yellow = 0xffffff00; uint32_t colors[4] = {green, blue, red, yellow}; reset(); while (count-- > 0) { m_queue.push_back(colors[getRandomColorId()]); } } void ColorsQueue::reset() { m_queue.clear(); }