# Template file for 'syncthingtray'
pkgname=syncthingtray
version=1.3.0
revision=1
build_style=cmake
configure_args="-DJS_PROVIDER=qml -DBUILTIN_TRANSLATIONS=ON -DSYSTEMD_SUPPORT=OFF
 -DBUILD_SHARED_LIBS=ON -DWEBVIEW_PROVIDER=$(vopt_if webengine webengine none)
 -Wno-dev"
hostmakedepends="pkg-config qt5-host-tools qt5-qmake extra-cmake-modules plasma-framework"
makedepends="cpp-utilities-devel qtutilities-devel qtforkawesome-devel
 qt5-devel qt5-core qt5-network qt5-gui qt5-widgets qt5-svg qt5-declarative
 qt5-quickcontrols qt5-location-devel boost-devel kio-devel plasma-framework-devel
 $(vopt_if webengine 'qt5-webengine-devel qt5-webchannel-devel')"
depends="syncthing"
checkdepends="syncthing iproute2"
short_desc="Tray application for Syncthing"
maintainer="classabbyamp <void@placeviolette.net>"
license="GPL-2.0-or-later"
homepage="https://github.com/Martchus/syncthingtray"
distfiles="https://github.com/Martchus/syncthingtray/archive/refs/tags/v${version}.tar.gz"
checksum=aece0be140187a3c0c989a50007c3d5541d9e1abd51ec45b8c1e45ab783a9e52

# requires weird port-binding shenanigans that may not work on ipv6
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=syncthingtray#n50
make_check=no

build_options="webengine"
desc_option_webengine="Build with Qt5 WebEngine support"

# if not enabled, it will fall back to web browser
if [ "$XBPS_TARGET_ENDIAN" = "le" ]; then
	if [ "$XBPS_WORDSIZE" = "$XBPS_TARGET_WORDSIZE" ]; then
		build_options_default+=" webengine"
	fi
fi

syncthingtray-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		for d in connector fileitemaction model plasmoid widgets; do
			vmove "usr/share/syncthing${d}/cmake"
		done
	}
}

syncthingtray-plasma_package() {
	depends="${sourcepkg}>=${version}_${revision} plasma-workspace"
	short_desc+=" - KDE plasmoid"
	pkg_install() {
		vmove usr/lib/qt5/plugins/plasma
		vmove usr/share/plasma
		vmove usr/share/kservices5/plasma-applet-martchus.syncthingplasmoid.desktop
	}
}

syncthingtray-dolphin_package() {
	depends="${sourcepkg}>=${version}_${revision} kio"
	short_desc+=" - KDE dolphin integration"
	pkg_install() {
		vmove usr/share/kservices5/syncthingfileitemaction.desktop
		vmove "usr/lib/qt5/plugins/*.so"
	}
}