# Copyright 2017 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require github [ tag="v${PV}" ]
require qmake [ slot=5 ]
require gtk-icon-cache freedesktop-desktop

SUMMARY="Notepad++-like editor for Linux"
HOMEPAGE="http://notepadqq.altervista.org/ ${HOMEPAGE}"

LICENCES="GPL-3"
SLOT="0"
PLATFORMS="~amd64 ~x86"
MYOPTIONS=""

# qtwebkit deprecation:
# https://github.com/notepadqq/notepadqq/issues/359
DEPENDENCIES="
    build:
        x11-libs/qttools:5
    build+run:
        x11-libs/qtbase:5
        x11-libs/qtsvg:5
        x11-libs/qtwebkit:5
"

BUGS_TO="hasufell@posteo.de"

EQMAKE_PARAMS=(
    PREFIX=/usr
    LRELEASE="/usr/$(exhost --target)/bin/lrelease-qt5"
)

src_install() {
    emake INSTALL_ROOT="${IMAGE}" install
    edo find "${IMAGE}" -type d -empty -delete

    # relocate some misplaced files
    # this might improve with the new cmake build system anyway,
    # so don't care to patch
    # https://github.com/notepadqq/notepadqq/pull/357
    dodir /usr/$(exhost --target)/bin
    edo mv "${IMAGE}"/usr/lib/notepadqq/notepadqq-bin \
        "${IMAGE}"/usr/$(exhost --target)/bin/notepadqq
    edo rm -r "${IMAGE}"/usr/{lib,bin}
}

pkg_postinst() {
    gtk-icon-cache_pkg_postinst
    freedesktop-desktop_pkg_postinst
}

pkg_postrm() {
    gtk-icon-cache_pkg_postrm
    freedesktop-desktop_pkg_postrm
}