## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global translation_domain kcm_fcitx5
	
# as of 2024-01, required dependencies 
# for building QT6 are not available 
# in Fedora 39 
#  - cmake(Plasma)
#  - cmake(KF6Svg)
#  - cmake(KF6KCMUtils)
%if 0%{?fedora} >= 40
%global use_qt6 1
%else
%global use_qt6 0
%endif

%if %{use_qt6}
%define qt_major_ver 6
%else
%define qt_major_ver 5
%endif

Name:           fcitx5-configtool
Version:        5.1.6
Release:        %autorelease
Summary:        Configuration tools used by fcitx5
License:        GPLv2+
URL:            https://github.com/fcitx/fcitx5-configtool
Source:         https://download.fcitx-im.org/fcitx5/%{name}/%{name}-%{version}.tar.zst
Source1:        https://download.fcitx-im.org/fcitx5/%{name}/%{name}-%{version}.tar.zst.sig
Source2:        https://pgp.key-server.io/download/0x8E8B898CBF2412F9

BuildRequires:  gnupg2
BuildRequires:  cmake
BuildRequires:  desktop-file-utils
BuildRequires:  extra-cmake-modules
BuildRequires:  gcc-c++
BuildRequires:  ninja-build
BuildRequires:  fcitx5-qt-devel
BuildRequires:  gettext-devel
BuildRequires:  kf%{qt_major_ver}-kwidgetsaddons-devel
BuildRequires:  kf%{qt_major_ver}-kirigami2-devel
BuildRequires:  kf%{qt_major_ver}-kdeclarative-devel
BuildRequires:  kf%{qt_major_ver}-kpackage-devel
BuildRequires:  kf%{qt_major_ver}-ki18n-devel
BuildRequires:  kf%{qt_major_ver}-kcoreaddons-devel
BuildRequires:  kf%{qt_major_ver}-kitemviews-devel
BuildRequires:  pkgconfig
BuildRequires:  cmake(Fcitx5Core)
BuildRequires:  cmake(Fcitx5Utils)
BuildRequires:  cmake(KF%{qt_major_ver}IconThemes)
BuildRequires:  cmake(Qt%{qt_major_ver}QuickControls2)
BuildRequires:  cmake(Qt%{qt_major_ver}Svg)
BuildRequires:  pkgconfig(iso-codes)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(x11-xcb)
BuildRequires:  pkgconfig(xkeyboard-config)
BuildRequires:  pkgconfig(xkbcommon-x11)
BuildRequires:  pkgconfig(xkbfile)
BuildRequires:  /usr/bin/appstream-util
%if %{use_qt6}
BuildRequires:  cmake(Plasma)
BuildRequires:  cmake(KF6Svg)
BuildRequires:  cmake(KF6KCMUtils)
%else
BuildRequires:  cmake(Qt5X11Extras)
BuildRequires:  cmake(KF5Plasma)
%endif

# to display scalable icons
Requires:       qt%{qt_major_ver}-qtsvg
# explicit requires on fcitx5-qt{5,6}-gui-wrapper
Requires:       fcitx5-qt-qt%{qt_major_ver}gui

%description
Configuration tools used by fcitx5.

%package -n kcm-fcitx5
Summary:        Config tools to be used on KDE based environment.
Requires:       kf%{qt_major_ver}-filesystem
Requires:       kf%{qt_major_ver}-kcmutils
Requires:       kf%{qt_major_ver}-plasma
Suggests:       %{name}%{?_isa} = %{version}-%{release}

%description -n kcm-fcitx5
Config tools to be used on KDE based environment. Can be installed seperately.

%package -n fcitx5-migrator
Summary:        Migration tools for fcitx5
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n fcitx5-migrator
Migration tools for fcitx5, containing fcitx5-migrator

%package -n fcitx5-migrator-devel
Summary:        Devel files for fcitx5-migrator
Requires:       fcitx5-migrator%{?_isa} = %{version}-%{release}

%description -n fcitx5-migrator-devel
Development files for fcitx5-migrator

%prep
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%autosetup -p1

#fix typos
sed -i 's/Catogories/Categories/g' src/configtool/org.fcitx.fcitx5-config-qt.desktop.in
sed -i 's/Catogories/Categories/g' src/migrator/app/org.fcitx.fcitx5-migrator.desktop.in

%build
%if %{use_qt6}
  %cmake_kf6 -GNinja -DUSE_QT6=On
%else
  %cmake_kf5 -GNinja -DUSE_QT6=Off
%endif
%cmake_build 

%install
%cmake_install
# kservices5/*.desktop desktop file dont't need to use desktop-file-install
# only for applications/*.desktop
for desktop_file_name in kbd-layout-viewer5 org.fcitx.fcitx5-config-qt org.fcitx.fcitx5-migrator
do
desktop-file-install --delete-original \
  --dir %{buildroot}%{_datadir}/applications \
  %{buildroot}%{_datadir}/applications/${desktop_file_name}.desktop
done
%find_lang %{name}
%find_lang %{translation_domain}


%files -f %{name}.lang 
%license LICENSES/GPL-2.0-or-later.txt
%doc README
%{_bindir}/fcitx5-config-qt
%{_datadir}/applications/org.fcitx.fcitx5-config-qt.desktop
%{_bindir}/kbd-layout-viewer5
%{_datadir}/applications/kbd-layout-viewer5.desktop

%files -n kcm-fcitx5 -f %{translation_domain}.lang 
%license LICENSES/GPL-2.0-or-later.txt
%if %{use_qt6}
%{_kf6_qtplugindir}/plasma/kcms/systemsettings/kcm_fcitx5.so
%else
%{_datadir}/kpackage/kcms/%{translation_domain}
%{_kf5_qtplugindir}/plasma/kcms/systemsettings/kcm_fcitx5.so
%endif
%{_datadir}/applications/kcm_fcitx5.desktop
%{_bindir}/fcitx5-plasma-theme-generator

%files -n fcitx5-migrator
%{_bindir}/fcitx5-migrator
%{_libdir}/libFcitx5Migrator.so.5*
%{_libdir}/libFcitx5Migrator.so.1
%{_datadir}/applications/org.fcitx.fcitx5-migrator.desktop

%files -n fcitx5-migrator-devel
%{_libdir}/libFcitx5Migrator.so

%changelog
## START: Generated by rpmautospec
* Sat Jun 01 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.6-1
- update to upstream release 5.1.6

* Tue Apr 23 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.5-1
- update to upstream release 5.1.5

* Fri Mar 01 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.4-1
- update to upstream release 5.1.4

* Sun Feb 04 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.3-7
- require explicitly package instead of path

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

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 5.1.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 05 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.3-4
- fix qt5/6-qtsvg dep

* Fri Jan 05 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.3-3
- add missing dependency for f39/38

* Fri Jan 05 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.3-2
- enable pure QT6 build when available

* Fri Jan 05 2024 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.3-1
- update to upstream release 5.1.3

* Thu Nov 02 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.2-1
- update to upstream release 5.1.2

* Mon Oct 02 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.1-1
- update to upstream release 5.1.1

* Fri Aug 18 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.1.0-1
- update to upstream release 5.1.0

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sun Mar 12 2023 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.17-1
- update to upstream release 5.0.17

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

* Mon Nov 21 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.16-1
- update to upstream release 5.0.16

* Tue Aug 30 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.15-1
- update to upstream release 5.0.15

* Wed Aug 03 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-4
- move fcitx5-plasma-theme-generator to kcm-fcitx5

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

* Mon Jul 04 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-2
- add fcitx5-plasma-theme-generator tool

* Mon Jul 04 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.14-1
- update to upstream release 5.0.14

* Mon May 23 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.13-1
- update to upstream release 5.0.13

* Thu Mar 10 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.12-2
- explicit requires on fcitx5-qt

* Thu Mar 10 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.12-1
- update to upstream release 5.0.12

* Wed Feb 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.11-1
- update to upstream release 5.0.11

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

* Sun Jan 02 2022 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.10-1
- update to 5.0.10

* Sat Dec 25 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.9-2
- make kbd-layout-viewer5 exit gracefully on wayland

* Sun Dec 05 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.9-1
- update to 5.0.9

* Sat Nov 06 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.8-1
- update to 5.0.8

* Sun Sep 26 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.6-1
- update to 5.0.6

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Wed May 05 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.5-1
- Update to 5.0.5 upstream release

* Fri Apr 02 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.4-2
- fix icon display

* Mon Mar 22 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.4-1
- Update to 5.0.4 upstream release

* Sat Feb 20 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.3-1
- update to 5.0.3 upstream release

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

* Wed Jan 13 11:18:46 CST 2021 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.2-1
- update to 5.0.2 upstream release

* Sat Dec  5 16:54:30 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.1-1
- Update to 5.0.1 upstream release
- sobump libFcitx5Migrator.so.0 -> libFcitx5Migrator.so.5

* Tue Nov  3 19:34:44 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 5.0.0-1
- update to 5.0.0 upstream release

* Fri Oct 16 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.6
- update to 8b2aec745af6da7a82b76a32a4b9196bb03db067 upstream commit

* Wed Sep 16 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.5
- Upstream commit e8c08930045bc00d49aebb9465445d9ab8d2a120
- new subpackage fcitx5-migrator containing migration tools

* Sat Sep 12 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.4
- Rebuild for fcitx5
- Upstream commit 8f113a78e334ecc962d5aa92022887ca077df588

* Tue Sep  1 10:17:42 CST 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.3
- Add subpackage kcm-fcitx5
- Improve macros

* Sun Aug 16 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.2.20200811gitecd16e5
- rebuilt

* Wed Aug 12 2020 Qiyu Yan <yanqiyu@fedoraproject.org> - 0-0.1.20200811gitecd16e5
- initial package

## END: Generated by rpmautospec