SUMMARY="A GUI for FFMPEG"
DESCRIPTION="FFmpeg can read audio and video files in various formats and \
convert them into other formats. QwinFF features an intuitive graphical \
interface and a rich set of presets to help you convert media files within a \
few clicks. Advanced users can also adjust conversion parameters in detail."
HOMEPAGE="https://qwinff.github.io/"
COPYRIGHT="2011 Timothy Lin"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="https://downloads.sf.net/qwinff/qwinff_$portVersion.tar.gz"
CHECKSUM_SHA256="b9f230b22e56c5ebd50a2b51dc9369df5006b1e3bf7cfcee819b7745c0d9fc18"
PATCHES="qwinff-$portVersion.patchset"
ADDITIONAL_FILES="
	qwinff.rdef.in
	haikuicons.zip
	"

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

PROVIDES="
	QwinFF$secondaryArchSuffix = $portVersion
	app:QwinFF$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:ffmpeg
	cmd:ffplay
	cmd:ffprobe
	cmd:sox$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5DBus$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5OpenGL$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/haikuicons.zip -d $sourceDir/src/icons
}

BUILD()
{
	make $jobArgs PREFIX=$appsDir/QwinFF
}

INSTALL()
{
	make PREFIX=$appsDir/QwinFF install

	mv $appsDir/QwinFF/bin/* $appsDir/QwinFF
	mv $appsDir/QwinFF/qwinff $appsDir/QwinFF/QwinFF
	rm -rf $appsDir/QwinFF/bin/

	local APP_SIGNATURE="application/x-vnd.qwinff"
	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/qwinff.rdef.in > qwinff.rdef

	addResourcesToBinaries qwinff.rdef $appsDir/QwinFF/QwinFF
	addAppDeskbarSymlink $appsDir/QwinFF/QwinFF QwinFF
}
