%bcond_without qt6
%bcond_with qt4

%undefine __cmake_in_source_build

Name:           kvantum
Version:        1.0.10
Release:        1%{dist}
Summary:        SVG-based theme engine for Qt5
License:        GPL-3.0-or-later
Group:          System/GUI/KDE
URL:            https://github.com/tsujan/Kvantum
Source0:        https://github.com/tsujan/Kvantum/releases/download/V%{version}/Kvantum-%{version}.tar.xz

BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(Qt5) > 5.15
BuildRequires:  pkgconfig(Qt5Designer)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  cmake(KF5WindowSystem)
BuildRequires:  desktop-file-utils
BuildRequires:  kde-filesystem
BuildRequires:  cmake(Qt5LinguistTools)
%if %{with qt4}
BuildRequires:  qt-devel
%endif
%if %{with qt6}
BuildRequires:  cmake(Qt6Core)
BuildRequires:  cmake(Qt6Svg)
%endif
Provides:       %{name}-qt5 = %{version}-%{release}
Obsoletes:      %{name}-openbox < %{version}-%{release}

%description
Kvantum is an SVG-based theme engine for Qt, tuned to Plasma and LXQt, with an emphasis on elegance, usability and practicality.
Its homepage is https://github.com/tsujan/Kvantum.

Kvantum also comes with extra themes that can be selected and activated by using Kvantum Manager.

%if %{with qt6}
%package qt6
Summary:	SVG-based theme engine for Qt6

%description qt6
Kvantum is an SVG-based theme engine for Qt, tuned to Plasma and LXQt, with an emphasis on elegance, usability and practicality.
Its homepage is https://github.com/tsujan/Kvantum.

Kvantum also comes with extra themes that can be selected and activated by using Kvantum Manager.

This package provides Kvantum theme engine for Qt6.
%endif

%if %{with qt4}
%package qt4
Summary:	SVG-based theme engine for Qt4
Requires:   qt-X11

%description qt4
Kvantum is an SVG-based theme engine for Qt, tuned to Plasma and LXQt, with an emphasis on elegance, usability and practicality.
Its homepage is https://github.com/tsujan/Kvantum.

Kvantum also comes with extra themes that can be selected and activated by using Kvantum Manager.

This package provides Kvantum theme engine for Qt4.
%endif


%package data
Summary:	Themes for Kvantum engine
Requires:	%{name}-qt5 = %{version}
BuildArch:	noarch

%description data

This package provides extra themes for Kvantum engine.


This package provides extra Openbox themes for Kvantum engine.

%prep
%setup -q -n Kvantum-%{version}

%build

pushd Kvantum
%global _vpath_builddir %{_target_platform}-qt5
%cmake
%cmake_build

%if %{with qt6}
%global _vpath_builddir %{_target_platform}-qt6
%cmake -DENABLE_QT5=OFF
%cmake_build
%endif

%if %{with qt4}
%global _vpath_builddir %{_target_platform}-qt4
%cmake -DENABLE_QT4=ON
%cmake_build
%endif

%install
pushd Kvantum

%if %{with qt6}
%global _vpath_builddir %{_target_platform}-qt6
%cmake_install
%endif

%if %{with qt4}
%global _vpath_builddir %{_target_platform}-qt4
%cmake_install
%endif

%global _vpath_builddir %{_target_platform}-qt5
%cmake_install

pushd %{_vpath_builddir}
%find_lang ../../%{name} --all-name --with-qt
popd


# desktop-file-validate doesn't recognize LXQt
sed -i "s|LXQt|X-LXQt|" %{buildroot}%{_datadir}/applications/kvantummanager.desktop
desktop-file-validate %{buildroot}%{_datadir}/applications/kvantummanager.desktop


%files -f %{name}.lang
%license Kvantum/COPYING
%doc Kvantum/ChangeLog Kvantum/NEWS Kvantum/README.md
%{_qt5_plugindir}/styles/libkvantum.so
%{_bindir}/kvantummanager
%{_bindir}/kvantumpreview

%if %{with qt6}
%files qt6
%dir %{_qt6_plugindir}/styles
%{_qt6_plugindir}/styles/libkvantum.so
%license Kvantum/COPYING
%doc Kvantum/README.md
%endif

%if %{with qt4}
%files qt4
%license Kvantum/COPYING
%doc Kvantum/README.md
%{_libdir}/qt4/plugins/styles/libkvantum.so
%{_datadir}/kde4/apps/color-schemes/Kvantum.colors
%endif

%files data
%{_datadir}/Kvantum/
%{_datadir}/applications/kvantummanager.desktop
%{_datadir}/color-schemes/Kv*.colors
%{_datadir}/icons/hicolor/scalable/apps/kvantum.svg
%dir %{_datadir}/kvantumpreview
%dir %{_datadir}/kvantumpreview/translations
%dir %{_datadir}/kvantummanager
%dir %{_datadir}/kvantummanager/translations


%changelog
* Wed Dec 20 2023 Raven <raven@sysadmins.ws> - 1.0.10-1
- update to 1.0.10
- remove openbox subpackage

* Mon Jan  9 2023 Raven <raven@sysadmins.ws> - 1.0.7-1
- initial build for el9
