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

EAPI=7

inherit cmake desktop xdg-utils

MY_PN="Dwarf-Therapist"
MY_PV="v${PV}"
MY_P="${MY_PN}-${PV}"

DESCRIPTION="For managing dwarves in  Dwarf Fortress"
HOMEPAGE="https://github.com/Dwarf-Therapist/Dwarf-Therapist"
SRC_URI="https://github.com/Dwarf-Therapist/${MY_PN}/archive/refs/tags/${MY_PV}.tar.gz -> ${MY_P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"

S="${WORKDIR}/${MY_P}"

# DEPEND=""
RDEPEND="
	dev-qt/qtconcurrent:5
	dev-qt/qtdeclarative:5
	dev-qt/qtwidgets:5
"
# BDEPEND=""

src_install() {
	# Install some sort of documentation
	dodoc README.rst

	# Add the desktop file
	domenu dist/xdg/applications/dwarftherapist.desktop

	# install icons
	insinto /usr/share/
	doins -r dist/xdg/icons

	# install memory layout files for dwarf-fortress versions
	insinto /usr/share/dwarftherapist/memory_layouts
	doins -r share/memory_layouts/linux

	# and of course, the binary
	newbin "${BUILD_DIR}/dwarftherapist" dwarf-therapist
}

pkg_postinst() {
	xdg_icon_cache_update
	xdg_desktop_database_update
}

pkg_postrm() {
	xdg_icon_cache_update
	xdg_desktop_database_update
}