# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgbase=ktextaddons
pkgname=(ktextaddons
         ktextaddons5)
pkgver=1.5.4
pkgrel=1
pkgdesc='Various text handling addons'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=(GPL)
url='https://invent.kde.org/libraries/ktextaddons'
depends=(gcc-libs
         glibc)
makedepends=(doxygen
             extra-cmake-modules
             karchive
             kconfig
             kconfigwidgets
             ki18n
             kio
             ktextaddons
             kwidgetsaddons
             kxmlgui
             qt6-base
             qt6-doc
             qt6-speech
             qt6-tools
             qtkeychain-qt6
             sonnet
             syntax-highlighting
             karchive5
             kconfig5
             kconfigwidgets5
             ki18n5
             kio5
             kwidgetsaddons5
             qt5-base
             qt5-doc
             qt5-speech
             qt5-tools
             qtkeychain-qt5
             sonnet5
             syntax-highlighting5)
optdepends=('languagetool: Grammar checking'
            'grammalecte: French grammar checking'
            'libreoffice: Use autocorrection data from LibreOffice')
source=(https://download.kde.org/stable/$pkgname/$pkgbase-$pkgver.tar.xz)
sha256sums=('64b80602e84b25e9164620af3f6341fa865b85e826ab8f5e02061ae24a277b20')

build() {
  cmake -B build -S $pkgbase-$pkgver \
    -DBUILD_TESTING=OFF \
    -DBUILD_DESIGNERPLUGIN=ON \
    -DBUILD_QCH=ON \
    -DQT_MAJOR_VERSION=6
  cmake --build build

  cmake -B build5 -S $pkgbase-$pkgver \
    -DBUILD_TESTING=OFF \
    -DBUILD_DESIGNERPLUGIN=ON \
    -DBUILD_QCH=ON
  cmake --build build5
}

package_ktextaddons() {
  depends+=(karchive
            kcolorscheme
            kconfig
            kconfigwidgets
            ki18n
            kio  
            kwidgetsaddons
            qt6-base
            qt6-speech
            qtkeychain-qt6
            sonnet
            syntax-highlighting)

  DESTDIR="$pkgdir" cmake --install build
}

package_ktextaddons5() {
  depends+=(karchive5
            kconfig5
            kconfigwidgets5
            ki18n5
            kio5
            kwidgetsaddons5
            qt5-base
            qt5-speech
            qtkeychain-qt5
            sonnet5
            syntax-highlighting5)
  conflicts=('ktextaddons<1.5.2-3')
  replaces=('ktextaddons<1.5.2-3')

  DESTDIR="$pkgdir" cmake --install build5
  rm -r "$pkgdir"/usr/share/locale # Conflicts with Qt5 version
}
