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

EAPI=8

inherit cmake

DESCRIPTION="QT6 Theme Provider for Hyprland"
HOMEPAGE="https://github.com/hyprwm/hyprqt6engine"
if [[ "${PV}" = *9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/hyprwm/${PN^}.git"
else
	SRC_URI="https://github.com/hyprwm/${PN^}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~amd64"
fi

LICENSE="BSD"
SLOT="0"

IUSE="kde"

DEPEND="
	>=dev-qt/qtbase-6.9:6=[gui,widgets]
	dev-qt/qtdeclarative:6
	dev-libs/hyprlang
	gui-libs/hyprutils
	kde? (
		kde-frameworks/kcolorscheme:6
		kde-frameworks/kconfig:6
		kde-frameworks/kiconthemes:6
	)
"
RDEPEND="${DEPEND}"

BDEPEND="
	virtual/pkgconfig
"

PATCHES=(
	"${FILESDIR}/hyprqt6engine-0.1.0-fix-GuiPrivate-not-found.patch"
	"${FILESDIR}/hyprqt6engine-0.1.0-KDE-option.patch"
)

src_configure() {
	local mycmakeargs=(
		-DWITH_KDE=$(usex kde)
	)
	cmake_src_configure
}

pkg_postinst() {
	elog "QT_QPA_PLATFORMTHEME=${PN} has to be set to enable ${PN}."
	elog "You can set it in the Hyprland Lua config like"
	elog "  hl.env(\"QT_QPA_PLATFORMTHEME\", \"${PN}\")"
	elog "If you use uwsm with Hyprland, then set it in ~/.config/uwsm/env with"
	elog "  export QT_QPA_PLATFORMTHEME=${PN}"
	elog "instead."
}