# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake git-r3 readme.gentoo-r1 virtualx

DESCRIPTION="An apng image plugin for Qt to support animated PNGs"
HOMEPAGE="https://github.com/jurplel/QtApng"
EGIT_REPO_URI="https://github.com/jurplel/${PN}.git"

LICENSE="BSD"
SLOT="0/${PV}"
IUSE="test"
RESTRICT="test" # 4 tests fail

RDEPEND="dev-qt/qtbase:6[gui,widgets]
	media-libs/libpng:0=[apng]"
DEPEND="${RDEPEND}"
BDEPEND="virtual/pkgconfig"

DOC_CONTENTS="Since the png format is already used by Qt,
*.png files will not use the plugin. Rename the file to *.apng
to load a png as animated\\n"

src_configure() {
	local mycmakeargs=(
		-DAPNG_TESTS="$(usex test true false)"
	)
	cmake_src_configure
}

src_test() {
	virtx "${S}"_build/ApngTests
}

src_install() {
	exeinto /usr/"$(get_libdir)"/qt6/plugins/imageformats
	doexe "${S}"_build/plugins/imageformats/libqapng.so
	cmake_src_install
	readme.gentoo_create_doc
}

pkg_postinst() {
	readme.gentoo_print_elog
}