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

inherit udev cmake xdg-utils

MY_PN="OpenHantek6022"

DESCRIPTION="${MY_PN} is a free software for Hantek DSO6022 USB digital signal oscilloscopes"
HOMEPAGE="https://github.com/OpenHantek/${MY_PN}"
SRC_URI="https://github.com/OpenHantek/${MY_PN}/archive/refs/tags/${PV/_/-}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64"

RDEPEND="
    dev-qt/qtbase:6[gui,opengl,widgets]
    dev-qt/qt5compat:6
    sci-libs/fftw:3.0
    dev-libs/libusb:1
"
DEPEND="${RDEPEND}"
BDEPEND="
    dev-qt/qttools:6[linguist]
    dev-build/cmake
"
S="${WORKDIR}/${MY_PN}-${PV/_/-}"

src_prepare() {
    sed -i 's:project(OpenHantek CXX)::g' openhantek/CMakeLists.txt || die "couldn't patch CMakeLists.txt"
    cmake_src_prepare
}

src_configure() {
    cmake_src_configure
}

src_install() {
    cmake_src_install
}

pkg_postinst() {
    xdg_icon_cache_update
    udev_reload
}

pkg_postrm() {
    xdg_icon_cache_update
    udev_reload
}