%global         commit 0154d81676b16866604e04201e7f3a1722efb87f
%global         shortcommit %(c=%{commit}; echo ${c:0:7})
%global         commitdate 20190713
%global         rname MellowPlayer

Name:           mellowplayer
Version:        3.5.5
Release:        2.%{commitdate}git%{shortcommit}%{?dist}
Summary:        Cloud music integration for your desktop
License:        GPLv2
Url:            https://colinduquesnoy.github.io/MellowPlayer/
Source0:        https://gitlab.com/ColinDuquesnoy/%{rname}/-/archive/%{commit}/%{name}-%{shortcommit}.tar.gz

ExclusiveArch:  %{qt5_qtwebengine_arches}

BuildRequires:  cmake
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5WebEngine)
BuildRequires:  pkgconfig(Qt5WebChannel) >= 5.9.3
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5DBus)
BuildRequires:  pkgconfig(Qt5Location)
BuildRequires:  pkgconfig(Qt5Qml)
BuildRequires:  pkgconfig(Qt5Quick)
BuildRequires:  pkgconfig(Qt5Sql)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(Qt5QuickControls2)
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  qt5-linguist
BuildRequires:  python3-devel
BuildRequires:  python3-sphinx
BuildRequires:  python3-sphinx_rtd_theme
#BuildRequires:  xorg-x11-server-Xvfb
Requires:       qt5-qtquickcontrols
Requires:       qt5-qtquickcontrols2
Requires:       hicolor-icon-theme

%description 
MellowPlayer is a free, open source and cross-platform desktop application that
integrates online music services with your desktop.

%package        doc
Summary:        Documentation files for %{name}
BuildArch:      noarch

%description    doc
The %{name}-doc package contains html documentation
that use %{name}.

%prep
%setup -q -n %{rname}-%{commit}

# remove uneeded stuff
rm -rf scripts/packaging/osx
# remove commend in first line
sed -i '1,1d' src/main/share/applications/%{name}.desktop

%build
%cmake .
%make_build

# Generate man page and html documentation (needs python3-sphinx)
sphinx-build-3 -N -bhtml docs/ docs/html
sphinx-build-3 -N -bman docs/ docs/man

%install
%make_install

# install man page
install -p -d -m755 %{buildroot}%{_mandir}/man1
install -p -m644 docs/man/%{name}.1 %{buildroot}%{_mandir}/man1/%{rname}.1

# install html docs
install -p -d -m755 %{buildroot}%{_docdir}/%{name}
mv docs/html %{buildroot}%{_docdir}/%{name}

# Fix W: file-not-utf8
iconv -f iso8859-1 -t utf-8 %{buildroot}%{_docdir}/%{name}/html/objects.inv > \
objects.inv.conv && mv -f objects.inv.conv %{buildroot}%{_docdir}/%{name}/html/objects.inv

# Fix W: hidden-file-or-dir
rm -rf %{buildroot}%{_docdir}/%{name}/html/{.buildinfo,.doctrees}

%check
# test suite fails
# to enable test suite, use "%%cmake -DBUILD_TESTS=ON ." 
# cd tests && xvfb-run -a ctest -V
desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/metainfo/%{name}.appdata.xml
 
%files
%doc AUTHORS.md CHANGELOG.md README.md
%license LICENSE
%dir %{_datadir}/%{name}
%{_bindir}/%{rname}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/metainfo/%{name}.appdata.xml
%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%{_datadir}/mellowplayer/plugins

%files doc
%{_datadir}/doc/%{name}/html
%{_mandir}/man1/%{rname}.1.*

%changelog
* Mon Nov 18 2019 Pavel Lisy <pali@fedoraproject.org> - 3.5.5-2.20190716git0154d81
- Rebuilt for EPEL Playground 8

* Tue Jul 16 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.5-1.20190716git0154d81
- Update to 3.5.5-1.20190716git0154d81

* Tue May 28 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.4-1.20190521git28ffca9
- Update to 3.5.4-1.20190521git28ffca9

* Tue Apr 30 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.3-2.20190310git4ac4b13
- Switch to python3

* Mon Mar 11 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.3-1.20190310git4ac4b13
- Update to 3.5.3-1.20190310git4ac4b13

* Sun Feb 10 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.2-1.20190206git54a1714
- Update to 3.5.2-1.20190206git54a1714

* Thu Feb 07 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.1-1.20190206git402e336
- Update to 3.5.1-1.20190206git402e336
- Add patch for F30 %%{name}-suppress-compiler-warnings.patch

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.0-2.20181227git40ef9dd
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Wed Jan 02 2019 Martin Gansser <martinkg@fedoraproject.org> - 3.5.0-1
- Update to 3.5.0-1
- QBS is deprecated: swich back to CMake
- Moving to gitlab

* Mon Nov 19 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.4.0-4
- Add Make_sure_that_debug_builds_behave_the_same_as_release_builds.patch

* Sun Nov 18 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.4.0-3
- Add flag config:release due restore window doesn't work from
  GNOME Shell launcher or from GNOME notification center

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jul 10 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.4.0-1
- Update to 3.4.0
- Adapt to qbs build system
- Add BR qbs
- Remove BR cmake

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 3.3.5-2
- Rebuilt for Python 3.7

* Sun Mar 04 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.3.5-1
- Update to 3.3.5

* Mon Feb 19 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.3.4-1
- Update to 3.3.4
- Dropped %%{name}-fix-sphinx-build.patch
- Dropped %%{name}-CMakeLists.patch

* Sun Feb 11 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.3.3-2
- Add %%{name}-fix-sphinx-build.patch

* Sun Feb 11 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.3.3-1
- Update to 3.3.3
- Add %%{name}-CMakeLists.patch

* Tue Feb 06 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.3.2-1
- Update to 3.3.2

* Wed Jan 03 2018 Martin Gansser <martinkg@fedoraproject.org> - 3.2.0-1
- Update to 3.2.0

* Sun Nov 05 2017 Martin Gansser <martinkg@fedoraproject.org> - 3.1.0-3
- Use %%{buildroot} macro for consistency
- Large documentation must go in a -doc subpackage

* Sun Nov 05 2017 Martin Gansser <martinkg@fedoraproject.org> - 3.1.0-2
- Don't add: %%dir %%{_datadir}/icons/hicolor/scalable and
             %%dir %%{_datadir}/icons/hicolor/scalable/apps
  These directories should be owned by the Requires to hicolor-icon-theme 
- Per the new guidelines, appdata files must now be installed in
  %%{_datadir}/metainfo/ instead of %%{_datadir}/appdata/
- Add Icon cache scriplet
- Add changelog and authors to %%doc
- Use simplified URL
- Use ExclusiveArch: %%{qt5_qtwebengine_arches} due Qt Web Engine is only
  available on some arches

* Wed Nov 01 2017 Martin Gansser <martinkg@fedoraproject.org> - 3.1.0-1
- Initial build