# Template file for 'QSyncthingTray'
pkgname=QSyncthingTray
version=0.5.8
revision=2
build_style=cmake
hostmakedepends="qt5-qmake qt5-host-tools"
makedepends="qt5-declarative-devel qt5-webchannel-devel
 qt5-location-devel qt5-quickcontrols2-devel qt5-devel"
short_desc="Tray App for Syncthing written in C++"
maintainer="Morgan Bazalgette <the@howl.moe>"
license="LGPL-3.0-or-later"
homepage="https://github.com/sieren/QSyncthingTray"
distfiles="https://github.com/sieren/QSyncthingTray/archive/${version}.tar.gz"
checksum=ff428ac5a09e5df7bde3d71044062de104a6cb17a2918ae317061f5ad1394480

# next release: make webkit an option and build nativebrowser with neither set
build_options="webengine"
desc_option_webengine="Use Qt5 WebEngine support"

if [ "$XBPS_TARGET_ENDIAN" = "le" ]; then
	if [ "$XBPS_TARGET_WORDSIZE" = "$XBPS_WORDSIZE" ]; then
		build_options_default="webengine"
	fi
fi

if [ "$build_option_webengine" ]; then
	makedepends+=" qt5-webengine-devel"
	configure_args+=" -DQST_BUILD_WEBKIT=0"
else
	makedepends+=" qt5-webkit-devel"
	configure_args+=" -DQST_BUILD_WEBKIT=1"
fi

do_install() {
	# Install main binary
	vbin ./build/QSyncthingTray

	# Desktop file
	vmkdir usr/share/applications
	vcopy ${FILESDIR}/qsyncthingtray.desktop usr/share/applications
	# Download icons
	mkdir -p ${wrksrc}/icons
	cd ${wrksrc}/icons
	for suffix in 'only.svg>logo-scalable.svg' {32,64,128,256,512}.png; do
		xbps-uhelper fetch \
			"https://raw.githubusercontent.com/syncthing/syncthing/"\
"7f0603effa8ff465ea0a96c6dd877c0fe6a1cb78/assets/logo-${suffix}"
	done
	sha256sum --check ${FILESDIR}/checksum-logos.txt || exit 1
	# Install icons
	vmkdir usr/share/icons/hicolor
	vinstall ./logo-scalable.svg 644 \
		usr/share/icons/hicolor/scalable/apps/ qsyncthingtray.svg
	for size in 32 64 128 256 512; do
		vinstall ./logo-${size}.png 644 \
			usr/share/icons/hicolor/${size}x${size}/apps/ qsyncthingtray.png
	done
}
