%define __cmake_in_source_build 1
%bcond_with clang

Name:           screengrab
Version:        2.7.0
Release:        1%{dist}
Summary:        Qt tool for creating screenshots
License:        GPL-2.0-only
Group:          LXQt
URL:            https://github.com/lxqt/screengrab
Source:         https://github.com/lxqt/screengrab/releases/download/%{version}/%{name}-%{version}.tar.xz
%if 0%{?rhel} <= 8
Patch0:         screengrab-downgrade-kde.patch
%endif

BuildRequires:  cmake
%if %{with clang}
BuildRequires: clang >= 5.0
%else
BuildRequires: gcc-c++
%endif
BuildRequires:  hicolor-icon-theme
BuildRequires:  pkgconfig
BuildRequires:  cmake(KF5WindowSystem) >= 5.36.0
BuildRequires:  cmake(Qt5LinguistTools)
BuildRequires:  pkgconfig(Qt5Core) >= 5.15.0
BuildRequires:  pkgconfig(Qt5DBus)
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(Qt5Xdg) >= 3.12.0
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(x11-xcb)
BuildRequires:  pkgconfig(xcb)
BuildRequires:  pkgconfig(xcb-shape)
BuildRequires:  pkgconfig(xcb-xfixes)

Recommends:     %{name}-lang

%description
Screenshot taker with the ability to publish them via hosting services.

%lang_package

%prep
%autosetup -p1

%{__mkdir} -p %{_target_platform}

%build

%if %{with clang}
export CC=clang
export CXX=clang++
%endif

pushd %{_target_platform}
%{cmake_lxqt} \
    -DCMAKE_SKIP_RPATH:BOOL=ON \
    -DSG_DBUS_NOTIFY=ON \
    -DSG_EXT_EDIT=ON \
    -DSG_EXT_UPLOADS=ON \
    -DSG_GLOBALSHORTCUTS=ON \
    -DUPDATE_TRANSLATIONS=OFF \
    -DPULL_TRANSLATIONS=NO \
    ..

%cmake_build
popd

%install
pushd %{_target_platform}
  %cmake_install
popd

rm -rf %{buildroot}%{_datadir}/doc

%find_lang %{name} --with-qt

%files
%license COPYING
%doc AUTHORS CHANGELOG README.md docs/html
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.??g
%{_datadir}/screengrab/screengrab.conf
%{_datadir}/metainfo/%{name}.metainfo.xml
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/translations

%changelog
* Mon Nov  6 2023 Raven <raven@sysadmins.ws> - 2.7.0-1
- update to 2.7.0
- clang support

* Thu May 18 2023 Raven <raven@sysadmins.ws> - 2.6.0-1
- update to 2.6.0

* Fri Nov 11 2022 Raven <raven@sysadmins.ws> - 2.5.0-1
- update to 2.5.0

* Mon Nov 08 2021 Raven <raven@sysadmins.ws> - 2.3.0-1
- update to 2.3.0
- drop RHEL7 support

* Wed Jan 27 2021 Raven <raven@sysadmins.ws> - 2.1.0-1
- version update

* Tue Jun 16 2020 Raven <raven@sysadmins.ws> - 2.0.1-1
- version update

* Tue Mar 24 2020 Max Lin <mlin@suse.com>
- Disable RPATH for building
* Thu Jan 23 2020 Michael Vetter <mvetter@suse.com>
- Update to 2.0.0:
  * Improved translations
  * Improved user experience (less noise with command line, better
    screen area instructions and better off-screen screenshots).
  * Code update and clean-up, including the removal of the
    deprecated class QDesktopWidget.
  * Bumped screengrab version to 2.0.0
  * Updated translations
  * Removed Qxt
  * Fixed typo in function name
  * Set min. Qt version to 5.10.0
  * Removed upload module (#183)
  * Removed QDesktopWidget
  * Removed (duplicated) string casts definitions
  * Deleted useless warning fixes #174
  * Make CMakeLists.txt a bit more strict
  * Updated QtXdg minimum required version
  * Use the new QtXdg XdgMimeApps class
  * Improved Screen Area instructions (#162)
  * Don't use automatic string conversions
  * Avoid char raw strings literals memory allocations
* Fri Mar  1 2019 mvetter@suse.com
- Update to 1.101:
  * Only translations was changed
* Thu Jan 31 2019 Michael Vetter <mvetter@suse.com>
- Update to 1.100:
  * Don’t crash with invalid config format
* Mon Jul 23 2018 mvetter@suse.com
- Update to 1.99:
  * Update translations
  * Add X11Extras and Network to link target
- Remove screengrab-1.98-build.patch: upstreamed
* Tue May 22 2018 mvetter@suse.com
- Require Qt >= 5.7.1
- Rename build.patch to screengrab-1.98-build.patch
- Add new default config file screengrab.conf
* Tue May 22 2018 adam.majer@suse.de
- cleanup cmake build
- build.patch: add missing requirements
* Tue May 22 2018 mvetter@suse.com
- Update to 1.98:
  * Update translations
  * A more specific condition for Ctrl+C
  * Filter out Ctrl+C in Delay box
  * No window screenshot with shaded windows
  * Always use contents rect Fixes https://github.com/lxqt/screengrab/issues/67
  * Never scale up beyond real size
  * Several fixes, especially for the tray icon
  * __DATE__ and __TIME__ macro are not very helpful for reproducible builds.
  * Added a minimum default configuration
  * Handle invalid window screenshots
  * Corrected a grammar mistake
  * Always use native (LXQt) file dialog
  * Just changed the location of a comment
  * Cleanup and fixes
  * Some ui polishing
  * Improve screengrab app behaviour
  * Drops Qt foreach
  * fix some uris
  * Update references in about dialog
* Sun May 20 2018 mvetter@suse.com
- Cleanup with spec-cleaner
- Adjust URL and tarball link
- Rename screengrab-keyring.gpg to screengrab.keyring
- Dont require gpg-offline, let OBS do checking
- Remove icon cache update statements
* Sat Feb 10 2018 and.november@opensuse.org
- run spec-cleaner
* Sat Feb 10 2018 and.november@opensuse.org
- build with Qt5
