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

EAPI=8

ECM_QTHELP="false"
ECM_TEST="forceoptional"
QTMIN=6.10.1
inherit ecm frameworks.kde.org optfeature xdg

DESCRIPTION="Library for providing abstractions to get the developer's purposes fulfilled"

LICENSE="LGPL-2.1+"
KEYWORDS=""
IUSE="bluetooth webengine"

# requires running environment
RESTRICT="test"

DEPEND="
	>=dev-qt/qtbase-${QTMIN}:6[gui,network,widgets]
	>=dev-qt/qtdeclarative-${QTMIN}:6
	=kde-frameworks/kconfig-${KDE_CATV}*:6
	=kde-frameworks/kcoreaddons-${KDE_CATV}*:6
	=kde-frameworks/ki18n-${KDE_CATV}*:6
	=kde-frameworks/kio-${KDE_CATV}*:6
	=kde-frameworks/kirigami-${KDE_CATV}*:6
	=kde-frameworks/knotifications-${KDE_CATV}*:6
	=kde-frameworks/kservice-${KDE_CATV}*:6
	=kde-frameworks/prison-${KDE_CATV}*:6
	webengine? ( >=dev-qt/qtbase-${QTMIN}:6[dbus] )
"
RDEPEND="${DEPEND}
	=kde-frameworks/kcmutils-${KDE_CATV}*:6
	=kde-frameworks/kitemmodels-${KDE_CATV}*:6
	=kde-frameworks/prison-${KDE_CATV}*:6[qml]
	bluetooth? ( =kde-frameworks/bluez-qt-${KDE_CATV}*:6 )
	webengine? ( net-libs/konlineaccounts:6 )
"

src_prepare() {
	ecm_src_prepare

	use bluetooth ||
		cmake_comment_add_subdirectory -f src/plugins bluetooth
}

src_configure() {
	local mycmakeargs=(
		-DUSE_DBUS=$(usex webengine)
		-DCMAKE_DISABLE_FIND_PACKAGE_KAccounts6=ON
	)

	ecm_src_configure
}

pkg_postinst() {
	if [[ -z "${REPLACING_VERSIONS}" ]]; then
		optfeature "Send through KDE Connect" kde-misc/kdeconnect
	fi
	xdg_pkg_postinst
}