# Maintainer: Jiachen YANG <farseerfc@archlinux.org>
# Contributor: xyzzy <628208@gmail.com>

pkgname=flameshot
pkgver=0.6.0
pkgrel=3
pkgdesc="Powerful yet simple to use screenshot software"
arch=('x86_64')
url="https://github.com/lupoDharkael/flameshot"
license=('GPL')
depends=('qt5-svg' 'hicolor-icon-theme')
makedepends=('make' 'qt5-tools')
source=("https://github.com/lupoDharkael/flameshot/archive/v${pkgver}.tar.gz"
	"fix311.patch::https://github.com/lupoDharkael/flameshot/commit/415b059fb248eec4b4ee3be85a1594ce99bfce67.patch"
	"pr470.patch::https://patch-diff.githubusercontent.com/raw/lupoDharkael/flameshot/pull/470.patch"
	)
sha256sums=('61b3a1969d6e17d80d5d90a3fce53ca5ae78fa21f9a45e5a19b0b32ea815a589'
            '94da922546ce1b41d702e13d4ec2141f6383b2410bd9b2ddd34ce75e1d8c9209'
            'd9cdf793db3b4637a8bd00475d9e936d4e7e94af3295feaf4c6c8e952de58a18')
install="${pkgname}.install"

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  ## fix https://github.com/lupoDharkael/flameshot/issues/311
  patch -Np1 -i ../fix311.patch
  ## fix https://github.com/lupoDharkael/flameshot/issues/459
  ## see https://github.com/lupoDharkael/flameshot/pull/470
  patch -Np1 -i ../pr470.patch

  ## add a version number from pkgver
  sed -i "s|TAG_VERSION = .*|TAG_VERSION = v${pkgver}|" flameshot.pro 
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  qmake CONFIG+=packaging BASEDIR="${pkgdir}"
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make INSTALL_ROOT="${pkgdir}" install
}
