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() { auto platform = Qul::Platform::getPlatformInstance(); return static_cast<int>(platform->rand() * 10) % 4; } void ColorsQueue::generateColors(int count) { constexpr auto green = 0xff008000; constexpr auto blue = 0xff0000ff; constexpr auto red = 0xffff0000; constexpr auto yellow = 0xffffff00; constexpr uint colors[4] = {green, blue, red, yellow}; reset(); while (count-- > 0) { m_queue.emplace_back(colors[getRandomColorId()]); } } void ColorsQueue::reset() { m_queue.clear(); }