%bcond_with gcc

%global appname kColorPicker
%global libname lib%{appname}

Name: kcolorpicker
Version: 0.3.1
Release: 1%{?dist}

License: LGPL-3.0-or-later
Summary: QToolButton control with color popup menu
URL: https://github.com/ksnip/%{appname}
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz

Patch0: kcolorpicker-revert-f58d6ad.patch

BuildRequires: cmake(Qt5Core)
BuildRequires: cmake(Qt5Gui)

BuildRequires: cmake(Qt6Core)
BuildRequires: cmake(Qt6Gui)

BuildRequires: cmake
%if %{with gcc}
BuildRequires: gcc-toolset-14-gcc-c++
%else
BuildRequires: clang
%endif
BuildRequires: ninja-build

Provides:  %{name}-qt6 = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: %{name}-qt6 < %{version}

%description
QToolButton with color popup menu which lets you select a color.

The popup features a color dialog button which can be used to add
custom colors to the popup menu.

%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: %{name}-qt6-devel = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: %{name}-qt6-devel < %{version}

%description devel
%{summary}.

%package qt5
Summary: QToolButton control with color popup menu (Qt5)
Obsoletes: %{name} < %{version}

%description qt5
%{summary}.

%package qt5-devel
Summary: Qt5 Development files for %{name}
Requires: %{name}-qt5%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes: %{name}-devel < %{version}

%description qt5-devel
%{summary}.

%prep
%autosetup -n %{appname}-%{version} -p1

%build
%if %{with gcc}
%enable_devtoolset14
export CC=gcc
export CXX=c++
%endif

mkdir qt5
pushd qt5
%cmake -G Ninja \
     -S'..' \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTS:BOOL=OFF \
    -DBUILD_EXAMPLE:BOOL=OFF
%cmake_build
popd
mkdir qt6
pushd qt6
%cmake -G Ninja \
     -S'..' \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTS:BOOL=OFF \
    -DBUILD_EXAMPLE:BOOL=OFF \
    -DBUILD_WITH_QT6:BOOL=ON
%cmake_build
popd

%install
pushd qt5
%cmake_install
popd
pushd qt6
%cmake_install
popd

%files
%doc README.md
%license LICENSE
%{_libdir}/%{libname}-Qt6.so.0*

%files devel
%{_includedir}/%{appname}-Qt6/
%{_libdir}/cmake/%{appname}-Qt6/
%{_libdir}/%{libname}-Qt6.so

%files qt5
%doc README.md
%license LICENSE
%{_libdir}/%{libname}-Qt5.so.0*

%files qt5-devel
%{_includedir}/%{appname}-Qt5/
%{_libdir}/cmake/%{appname}-Qt5/
%{_libdir}/%{libname}-Qt5.so

%changelog
* Thu Aug  8 2024 Raven <raven@sysadmins.ws> - 0.3.1-1
- update to 0.3.1
- add patch to use different names for Qt5 and Qt6 files
- swap -qt6 and -qt5 packages

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sat Jan 20 2024 Marie Loise Nolden <loise@kde.org> - 0.3.0-1
- update to 0.3.0

* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon May 23 2022 Vitaly Zaitsev <vitaly@easycoding.org> - 0.2.0-1
- Updated to version 0.2.0.

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue May 25 2021 Vitaly Zaitsev <vitaly@easycoding.org> - 0.1.6-1
- Updated to version 0.1.6.

* Mon Feb 15 2021 Vitaly Zaitsev <vitaly@easycoding.org> - 0.1.5-1
- Updated to version 0.1.5.

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Fri Jul 31 2020 Vitaly Zaitsev <vitaly@easycoding.org> - 0.1.4-1
- Initial SPEC release.
