C

Qt Quick Ultralite image_cache Example

cmake_minimum_required (VERSION 3.15)

project(image_cache VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::QuickUltralite)
    find_package(Qul)
endif()

# 552960 is decompressed photo size in bytes (QImage) for QUL_COLOR_DEPTH=32
# All photos have the same width, height and format. We display 4 photo slideshow.
# For user convenience we need UL-3093 and also need to clarify UL-3097.
math(EXPR cache_size_in_bytes "552960 * 4")
set(QUL_TEXTURE_CACHE ${cache_size_in_bytes})
set(QUL_DEFAULT_COPY_TO_RAM "OnDemand")

# Set FreeRTOS heap size (needed for cache entries)
if (OS STREQUAL "FreeRTOS")
    math(EXPR heap_size "1024 * 1024 + ${cache_size_in_bytes}")
    add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()

qul_add_target(image_cache ImageModel.cpp)
qul_target_qml_sources(image_cache image_cache.qml)

qul_target_generate_interfaces(image_cache ImageModel.h)

app_target_setup_os(image_cache)
app_target_default_entrypoint(image_cache image_cache)

qul_add_resource(image_cache
    FILES
        images/basse-terre-guadeloupe.jpg
        images/grand-canyon-arizona.jpg
        images/grand-canyon-national-park.jpg
        images/Jokulsarlon-glacier-lagoon-iceland.jpg
        images/reine-lofoten-islands.jpg
        images/sequoia-national-park.jpg
        images/sogn-og-fjordane.jpg
        images/yosemite-national-park.jpg
)