SUMMARY="Powerful yet simple to use screenshot software"
DESCRIPTION="Features

* Customizable appearance.
* Easy to use.
* In-app screenshot edition.
* DBus interface.
* Upload to Imgur."
HOMEPAGE="https://github.com/lupoDharkael/flameshot/"
COPYRIGHT="2020 lupoDharkael"
LICENSE="GNU GPL v3"
REVISION="4"
SOURCE_URI="https://github.com/lupoDharkael/flameshot/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="f820c1f8cd464988cfcfc1af1fbcea2a3d0e5c4fb32accc3f54d93a8b5e1e890"
PATCHES="flameshot-$portVersion.patchset"
ADDITIONAL_FILES="
	flameshot.rdef.in
	flameshot.png
	"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	flameshot$secondaryArchSuffix = $portVersion
	app:Flameshot$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:dbus_launch
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix
	cmd:make
	"

PATCH()
{
	cp -f $sourceDir/../../additional-files/flameshot.png $sourceDir/data/img/app/flameshot.png
}

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$appsDir/Flameshot
	make $jobArgs
}

INSTALL()
{
	cd build
	make install/strip

	mv $appsDir/Flameshot/bin/flameshot \
		$appsDir/Flameshot/Flameshot

	mv $appsDir/Flameshot/share/flameshot/translations \
		$appsDir/Flameshot

	rm -rf $appsDir/Flameshot/bin
	rm -rf $appsDir/Flameshot/share

	local APP_SIGNATURE="application/x-vnd.flameshot"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/flameshot.rdef.in > flameshot.rdef

	addResourcesToBinaries flameshot.rdef $appsDir/Flameshot/Flameshot

	addAppDeskbarSymlink $appsDir/Flameshot/Flameshot
}
