# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=qownnotes
pkgver=23.6.6
pkgrel=0
pkgdesc="Plain-text file markdown note taking with Nextcloud/ownCloud integration"
url="https://www.qownnotes.org/"
arch="all !ppc64le !s390x !armhf" # armhf blocked by qt5-qtdeclarative
license="GPL-2.0-only"
makedepends="
	botan-dev
	cmake
	md4c-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qt5-qtwebsockets-dev
	qt5-qtx11extras-dev
	qt5-qtxmlpatterns-dev
	samurai
	"
subpackages="$pkgname-lang"
source="https://download.tuxfamily.org/qownnotes/src/qownnotes-$pkgver.tar.xz
	botan.patch
	exclude.patch
	md4c.patch
	no-werror.patch
	"
options="!check" # no tests

prepare() {
	default_prepare
	echo "#define RELEASE \"Alpine Linux\"" > release.h
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_WITH_SYSTEM_BOTAN=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -D -m755 build/QOwnNotes "$pkgdir/usr/bin/QOwnNotes"
	install -D -m644 PBE.QOwnNotes.desktop "$pkgdir/usr/share/applications/PBE.QOwnNotes.desktop"
	install -D -m644 "images/icons/128x128/apps/QOwnNotes.png" "$pkgdir/usr/share/pixmaps/QOwnNotes.png"
	for format in 16x16 24x24 32x32 48x48 64x64 96x96 128x128 256x256 512x512 ; do
		install -D -m644 "images/icons/$format/apps/QOwnNotes.png" "$pkgdir/usr/share/icons/hicolor/$format/apps/QOwnNotes.png"
	done
}

lang() {
	pkgdesc="Translations for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel lang"

	amove usr/share/qt5/translations
}

sha512sums="
c64460a92dd4d250d69dacecc7d6f74c248c51909cfec19603e56ee12fea77de86ad38155cee5d3e48bf52422f3f7e3efe1aaa03c8260f35d901350d2094ac8e  qownnotes-23.6.6.tar.xz
81b3171f826a310be0e78e56f9f9780a226b4aea5a81ddd7d3cdc90e3a6d460c242a20766e4db72df1b0a6a99edced04f85f2fa3d939e5f7969a624044365e33  botan.patch
4fe0cb83bc32b3fdbd31ed97a1c228a558579daabb0a5aee7c2b6a357256e04fc90cdbf7dde8897670130737bda5db2de0db664f1c1407875b2012f22ec038be  exclude.patch
f8a279b4485aad1649cb1941761cec385be035affd8acc71b071f368461593dfe787c8fc7080d9e0b18b5dceac2a897a0b4f8e8345d6f6301a244ed4c14386ff  md4c.patch
4129d840d17046015947c55c382db26938bfa4605a8737d69161eff6e44adaa06cd8c908e411f754595fe204e46a801ec1e8dc79121eab62dfd631ff6998fce9  no-werror.patch
"
