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

EAPI=8

inherit lomiri

if [[ ${PV} == 9999 ]]; then
    KEYWORDS=""
    EGIT_REPO_URI="https://gitlab.com/ubports/development/core/${PN}.git"
    inherit git-r3
else
    KEYWORDS="~amd64"
    SRC_URI="https://gitlab.com/ubports/development/core/${PN}/-/archive/${PV}/${P}.tar.gz"
fi

DESCRIPTION="Qt Components for Lomiri (Qt6)"
HOMEPAGE="https://gitlab.com/ubports/development/core/${PN}"
LICENSE="LGPL-3"
SLOT="6"
RESTRICT="test mirror"
IUSE="+bluetooth"

DEPEND="
    dev-libs/glib
    dev-libs/libevdev
    dev-qt/qt5compat:6
    dev-qt/qtbase:6
    dev-qt/qtdeclarative:6
    dev-qt/qtsvg:6
    dev-util/lttng-ust
    gui-libs/mir
    virtual/libudev
    x11-libs/libX11
    x11-libs/libXi
    x11-libs/libxcb
    bluetooth? ( net-wireless/bluez )
"
RDEPEND="${DEPEND}"

BDEPEND="
    dev-build/cmake
    dev-build/cmake-extras
    dev-build/samurai
    dev-qt/qtshadertools:6
    kde-frameworks/extra-cmake-modules
"

PATCHES=(
    "${FILESDIR}"/lomiri-ui-toolkit-optional-bluetooth.patch
)

src_configure() {
    local mycmakeargs=(
        -DWITH_LOMIRI_MIR="ON"
        -DWITH_BLUETOOTH=$(usex bluetooth ON OFF)
    )

    lomiri_src_configure
}