# uncomment to enable bootstrap mode
%global bootstrap 1

%if !0%{?bootstrap}
%global tests 1
%endif

%global  base_name konsole

Name:          konsole5
Summary:       KDE Terminal emulator
Version:       23.08.4
Release:       2
License:       GPLv2 and GFDL-1.2-or-later
URL:           http://www.kde.org/applications/system/konsole/

%global majmin %majmin_ver_kf5
%global stable %stable_kf5
Source0:       http://download.kde.org/%{stable}/release-service/%{version}/src/%{base_name}-%{version}.tar.xz

Patch200:      konsole-history_location_default.patch
Source10:      konsolerc

Obsoletes:     konsole < 14.12
Provides:      konsole = %{version}-%{release}

%global maj_ver %(echo %{version} | cut -d. -f1)

BuildRequires: make
BuildRequires: desktop-file-utils
BuildRequires: gettext
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(zlib)

BuildRequires: extra-cmake-modules
BuildRequires: kf5-rpm-macros
BuildRequires: cmake(KF5Bookmarks)
BuildRequires: cmake(KF5Completion)
BuildRequires: cmake(KF5Config)
BuildRequires: cmake(KF5ConfigWidgets)
BuildRequires: cmake(KF5CoreAddons)
BuildRequires: cmake(KF5Crash)
BuildRequires: cmake(KF5DBusAddons)
BuildRequires: cmake(KF5DBusAddons)
BuildRequires: cmake(KF5DocTools)
BuildRequires: cmake(KF5GlobalAccel)
BuildRequires: cmake(KF5GuiAddons)
BuildRequires: cmake(KF5I18n)
BuildRequires: cmake(KF5IconThemes)
BuildRequires: cmake(KF5KIO)
BuildRequires: cmake(KF5NewStuff)
BuildRequires: cmake(KF5NewStuffCore)
BuildRequires: cmake(KF5Notifications)
BuildRequires: cmake(KF5NotifyConfig)
BuildRequires: cmake(KF5Parts)
BuildRequires: cmake(KF5Pty)
BuildRequires: cmake(KF5Service)
BuildRequires: cmake(KF5TextWidgets)
BuildRequires: cmake(KF5WidgetsAddons)
BuildRequires: cmake(KF5WindowSystem)
BuildRequires: cmake(KF5XmlGui)

BuildRequires: libappstream-glib
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qtmultimedia-devel
BuildRequires: libicu-devel

%if 0%{?tests}
BuildRequires: appstream
BuildRequires: xorg-x11-server-Xvfb dbus-x11
%endif
Conflicts:     kde-l10n < 17.03

Requires:      %{name}-part%{?_isa} = %{version}-%{release}
Requires:      keditbookmarks

%description
%{summary}.

%package part
Summary:       Konsole5 kpart plugin

%description part
%{summary}.


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


%build
%{cmake_kf5}
%{cmake_build}


%install
%{cmake_install}

install -m644 -p -b -D %{SOURCE10} %{buildroot}%{_kf5_sysconfdir}/xdg/konsolerc

%find_lang konsole --with-html

grep 'StartupWMClass=' %{buildroot}%{_kf5_datadir}/applications/org.kde.konsole.desktop >& /dev/null || \
desktop-file-edit --set-key=StartupWMClass --set-value=konsole %{buildroot}%{_kf5_datadir}/applications/org.kde.konsole.desktop


%check
%{ctest}


%files -f konsole.lang
%dir %{_kf5_datadir}/knsrcfiles/
%doc README*
%{_kf5_sysconfdir}/xdg/konsolerc~
%{_kf5_bindir}/konsole
%{_kf5_bindir}/konsoleprofile
%{_kf5_datadir}/applications/org.kde.konsole.desktop
%{_kf5_datadir}/kglobalaccel/org.kde.konsole.desktop
%{_kf5_datadir}/kconf_update/konsole.upd
%{_kf5_datadir}/kconf_update/konsole_add_hamburgermenu_to_toolbar.sh
%{_kf5_datadir}/kio/servicemenus/konsolerun.desktop
%{_kf5_datadir}/knotifications5/konsole.notifyrc
%{_kf5_datadir}/knsrcfiles/konsole.knsrc
%{_kf5_datadir}/kservicetypes5/terminalemulator.desktop
%{_kf5_datadir}/qlogging-categories5/konsole.*
%{_kf5_datadir}/zsh/site-functions/_konsole
%{_kf5_libdir}/kconf_update_bin/konsole_globalaccel
%{_kf5_libdir}/kconf_update_bin/konsole_show_menubar
%{_kf5_metainfodir}/org.kde.konsole.appdata.xml

%ldconfig_scriptlets part

%files part
%config(noreplace) %{_kf5_sysconfdir}/xdg/konsolerc
%{_kf5_datadir}/konsole/
%{_kf5_libdir}/libkonsoleapp.so.*
%{_kf5_libdir}/libkonsoleprivate.so.*
%{_kf5_qtplugindir}/konsolepart.so
%{_kf5_qtplugindir}/konsoleplugins/
%{_kf5_datadir}/kservices5/konsolepart.desktop


%changelog
* Fri Nov 15 2024 ChenYanpan <chenyanpan@xfusion.com> - 23.08.4-2
- adapt to the new CMake macros to fix build failure

* Mon Jan 08 2024 zhangxianting <zhangxianting@unintech.com> - 23.08.4-1
- Update package to version 23.08.4

* Mon Aug 07 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 23.04.3-1
- Update package to version 23.04.3

* Thu Jul 14 2022 misaka00251 <misaka00251@misakanet.cn> - 22.08.0-1
- Init package
