Prepare libqtxdg 3.0.0

ubuntu/cosmic
Alf Gaida 7 years ago
parent 6548865b94
commit 4c58fcb9c3

@ -4,7 +4,7 @@ Upstream Authors:
Copyright: Copyright:
Copyright (c) 2010-2012 Razor team Copyright (c) 2010-2012 Razor team
Copyright (c) 2012-2016 LXQt team Copyright (c) 2012-2017 LXQt team
License: LGPL-2.1+ and LGPL-2.1-or-3-with-Digia-1.1-exception License: LGPL-2.1+ and LGPL-2.1-or-3-with-Digia-1.1-exception
The full text of the LGPL-2.1+ license can be found in the 'COPYING' file. The full text of the LGPL-2.1+ license can be found in the 'COPYING' file.

@ -25,11 +25,13 @@ else()
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
endif() endif()
set(QTXDG_MAJOR_VERSION 2) set(QTXDG_MAJOR_VERSION 3)
set(QTXDG_MINOR_VERSION 0) set(QTXDG_MINOR_VERSION 0)
set(QTXDG_PATCH_VERSION 0) set(QTXDG_PATCH_VERSION 0)
set(QTXDG_VERSION_STRING ${QTXDG_MAJOR_VERSION}.${QTXDG_MINOR_VERSION}.${QTXDG_PATCH_VERSION}) set(QTXDG_VERSION_STRING ${QTXDG_MAJOR_VERSION}.${QTXDG_MINOR_VERSION}.${QTXDG_PATCH_VERSION})
set(QT_MINIMUM_VERSION "5.6.1")
include(GNUInstallDirs) # Standard directories for installation include(GNUInstallDirs) # Standard directories for installation
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(GenerateExportHeader) include(GenerateExportHeader)
@ -37,13 +39,12 @@ include(create_portable_headers)
include(create_pkgconfig_file) include(create_pkgconfig_file)
include(compiler_settings NO_POLICY_SCOPE) include(compiler_settings NO_POLICY_SCOPE)
find_package(Qt5Widgets REQUIRED QUIET) set(CMAKE_AUTOMOC ON)
find_package(Qt5Svg REQUIRED QUIET)
find_package(Qt5Xml REQUIRED QUIET) find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Svg Xml DBus)
find_package(Qt5DBus REQUIRED QUIET)
if (BUILD_TESTS) if (BUILD_TESTS)
find_package(Qt5Test REQUIRED QUIET) find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Test)
endif() endif()
@ -52,12 +53,13 @@ set(QTXDGX_FILE_NAME "qt5xdg")
set(QTXDGX_ICONLOADER_LIBRARY_NAME "Qt5XdgIconLoader") set(QTXDGX_ICONLOADER_LIBRARY_NAME "Qt5XdgIconLoader")
set(QTXDGX_ICONLOADER_FILE_NAME "qt5xdgiconloader") set(QTXDGX_ICONLOADER_FILE_NAME "qt5xdgiconloader")
set(QTXDGX_ICONENGINEPLUGIN_LIBRARY_NAME "Qt5XdgIconPlugin")
set(QTXDGX_PKG_CONFIG_DESCRIPTION "Qt5Xdg, a Qt5 implementation of XDG standards") set(QTXDGX_PKG_CONFIG_DESCRIPTION "Qt5Xdg, a Qt5 implementation of XDG standards")
set(QTXDGX_PKG_CONFIG_REQUIRES "Qt5Core, Qt5Xml, Qt5Widgets, Qt5DBus, Qt5XdgIconLoader") set(QTXDGX_PKG_CONFIG_REQUIRES "Qt5Core >= ${QT_MINIMUM_VERSION}, Qt5Xml >= ${QT_MINIMUM_VERSION}, Qt5Widgets >= ${QT_MINIMUM_VERSION}, Qt5DBus >= ${QT_MINIMUM_VERSION}, Qt5XdgIconLoader = ${QTXDG_VERSION_STRING}")
set(QTXDGX_ICONLOADER_PKG_CONFIG_DESCRIPTION "Qt5XdgIconLader, a Qt5 XDG Icon Loader") set(QTXDGX_ICONLOADER_PKG_CONFIG_DESCRIPTION "Qt5XdgIconLader, a Qt5 XDG Icon Loader")
set(QTXDGX_ICONLOADER_PKG_CONFIG_REQUIRES "Qt5Gui, Qt5Svg") set(QTXDGX_ICONLOADER_PKG_CONFIG_REQUIRES "Qt5Gui >= ${QT_MINIMUM_VERSION}, Qt5Svg >= ${QT_MINIMUM_VERSION}")
set(QTXDGX_INTREE_INCLUDEDIR "${CMAKE_CURRENT_BINARY_DIR}/InTreeBuild/include") set(QTXDGX_INTREE_INCLUDEDIR "${CMAKE_CURRENT_BINARY_DIR}/InTreeBuild/include")
@ -65,7 +67,7 @@ if (NOT CMAKE_BUILD_TYPE)
set ( CMAKE_BUILD_TYPE Release ) set ( CMAKE_BUILD_TYPE Release )
endif (NOT CMAKE_BUILD_TYPE) endif (NOT CMAKE_BUILD_TYPE)
message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}") message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt5Core_VERSION}")
add_subdirectory(xdgiconloader) add_subdirectory(xdgiconloader)
add_subdirectory(qtxdg) add_subdirectory(qtxdg)
@ -167,16 +169,5 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY) IMMEDIATE @ONLY)
add_custom_target(uninstall #add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") # COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# building tarball with CPack -------------------------------------------------
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_VERSION_MAJOR ${QTXDG_MAJOR_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${QTXDG_MINOR_VERSION})
set (CPACK_PACKAGE_VERSION_PATCH ${QTXDG_PATCH_VERSION})
set (CPACK_GENERATOR TBZ2)
set (CPACK_SOURCE_GENERATOR TBZ2)
set (CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
include (CPack)

@ -1,5 +1,6 @@
#============================================================================= #=============================================================================
# Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com> # Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com>
# Copyright 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@ -65,6 +66,14 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
endif() endif()
#-----------------------------------------------------------------------------
# Global definitions
#-----------------------------------------------------------------------------
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DQT_STRICT_ITERATORS)
endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Set visibility to hidden to hide symbols, unless they're exported manually # Set visibility to hidden to hide symbols, unless they're exported manually
# in the code # in the code
@ -80,18 +89,25 @@ if (CMAKE_COMPILER_IS_GNUCXX OR QTXDG_COMPILER_IS_CLANGCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
endif() endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Common warning flags # Common warning flags
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
set(QTXDG_COMMON_WARNING_FLAGS "-Wall") set(QTXDG_COMMON_WARNING_FLAGS "-Wall -Wextra -Wchar-subscripts -Wno-long-long -Wpointer-arith -Wundef -Wformat-security")
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Warning flags # Warning flags
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCXX OR QTXDG_COMPILER_IS_CLANGCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__QTXDG_COMMON_WARNING_FLAGS} -Wnon-virtual-dtor -Woverloaded-virtual -Wpedantic")
endif()
if (QTXDG_COMPILER_IS_CLANGCXX)
# qCDebug(), qCWarning, etc trigger a very verbose warning, about.... nothing. Disable it.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
endif()
list(APPEND QTXDG_WARNING_FLAGS ${QTXDG_COMMON_WARNING_FLAGS}) list(APPEND QTXDG_WARNING_FLAGS ${QTXDG_COMMON_WARNING_FLAGS})
add_definitions(${QTXDG_WARNING_FLAGS})
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# String conversion flags # String conversion flags
@ -103,3 +119,53 @@ add_definitions(
-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_FROM_BYTEARRAY
) )
#-----------------------------------------------------------------------------
# Linker flags
# Do not allow undefined symbols
#-----------------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCXX OR QTXDG_COMPILER_IS_CLANGCXX)
# -Bsymbolic-functions: replace dynamic symbols used internally in
# shared libs with direct addresses.
set(SYMBOLIC_FLAGS
"-Wl,-Bsymbolic-functions -Wl,-Bsymbolic"
)
set(CMAKE_SHARED_LINKER_FLAGS
"-Wl,--no-undefined ${SYMBOLIC_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}"
)
set(CMAKE_MODULE_LINKER_FLAGS
"-Wl,--no-undefined ${SYMBOLIC_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}"
)
set(CMAKE_EXE_LINKER_FLAGS
"${SYMBOLIC_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}"
)
endif()
#-----------------------------------------------------------------------------
# Turn on more aggrassive optimizations not supported by CMake
# References: https://wiki.qt.io/Performance_Tip_Startup_Time
#-----------------------------------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCXX OR QTXDG_COMPILER_IS_CLANGCXX)
# -flto: use link-time optimizations to generate more efficient code
if (CMAKE_COMPILER_IS_GNUCXX)
set(LTO_FLAGS "-flto -fuse-linker-plugin")
# When building static libraries with LTO in gcc >= 4.9,
# "gcc-ar" and "gcc-ranlib" should be used instead of "ar" and "ranlib".
# references:
# https://gcc.gnu.org/gcc-4.9/changes.html
# http://hubicka.blogspot.tw/2014/04/linktime-optimization-in-gcc-2-firefox.html
# https://github.com/monero-project/monero/pull/1065/commits/1855213c8fb8f8727f4107716aab8e7ba826462b
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0") # gcc >= 4.9
set(CMAKE_AR "gcc-ar")
set(CMAKE_RANLIB "gcc-ranlib")
endif()
elseif (QTXDG_COMPILER_IS_CLANGCXX)
# The link-time optimization of clang++/llvm seems to be too aggrassive.
# After testing, it breaks the signal/slots of QObject sometimes.
# So disable it for now until there is a solution.
# set(LTO_FLAGS "-flto")
endif()
# apply these options to "Release" build type only
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LTO_FLAGS}")
endif()

@ -1,13 +1,15 @@
@PACKAGE_INIT@ @PACKAGE_INIT@
include(CMakeFindDependencyMacro) if (NOT TARGET @QTXDGX_LIBRARY_NAME@)
include(CMakeFindDependencyMacro)
find_dependency(Qt5Widgets) find_dependency(Qt5Widgets @QT_MINIMUM_VERSION@)
find_dependency(Qt5Xml) find_dependency(Qt5Xml @QT_MINIMUM_VERSION@)
find_dependency(Qt5DBus) find_dependency(Qt5DBus @QT_MINIMUM_VERSION@)
find_dependency(Qt5XdgIconLoader) find_dependency(Qt5XdgIconLoader @QTXDG_VERSION_STRING@ EXACT)
if (CMAKE_VERSION VERSION_GREATER 2.8.12) if (CMAKE_VERSION VERSION_GREATER 2.8.12)
cmake_policy(SET CMP0024 OLD) cmake_policy(SET CMP0024 NEW)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/qt5xdg-targets.cmake")
endif() endif()
include("${CMAKE_CURRENT_LIST_DIR}/qt5xdg-targets.cmake")

@ -1,11 +1,13 @@
@PACKAGE_INIT@ @PACKAGE_INIT@
include(CMakeFindDependencyMacro) if (NOT TARGET @QTXDGX_ICONLOADER_LIBRARY_NAME@)
include(CMakeFindDependencyMacro)
find_dependency(Qt5Gui) find_dependency(Qt5Gui @QT_MINIMUM_REQUIRED@)
find_dependency(Qt5Svg) find_dependency(Qt5Svg @QT_MINIMUM_REQUIRED@)
if (CMAKE_VERSION VERSION_GREATER 2.8.12) if (CMAKE_VERSION VERSION_GREATER 2.8.12)
cmake_policy(SET CMP0024 OLD) cmake_policy(SET CMP0024 NEW)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/qt5xdgiconloader-targets.cmake")
endif() endif()
include("${CMAKE_CURRENT_LIST_DIR}/qt5xdgiconloader-targets.cmake")

1
debian/.gitignore vendored

@ -9,4 +9,5 @@
/libqt5xdg-dev/ /libqt5xdg-dev/
/libqt5xdgiconloader-dev/ /libqt5xdgiconloader-dev/
/libqt5xdgiconloader2/ /libqt5xdgiconloader2/
/qtxdg-dev-tools/
/tmp /tmp

91
debian/changelog vendored

@ -1,71 +1,70 @@
libqtxdg (2.0.0-3) experimental; urgency=medium libqtxdg (2.96.0-1) experimental; urgency=medium
* Fixed typo Recommmends -> Recommends * New snapshot: 2.0.0-58-gbc64037
* Switched to experimental
* Renamed packages to reflect the new soname
* Bumped standards to 4.0.0, no changes needed
-- Alf Gaida <agaida@siduction.org> Tue, 04 Oct 2016 21:20:53 +0200 -- Alf Gaida <agaida@siduction.org> Tue, 25 Jul 2017 00:42:08 +0200
libqtxdg (2.0.0-2) experimental; urgency=medium libqtxdg (2.0.0-7) unstable; urgency=medium
* XdgIconLoader: Recommend gtk-update-icon-cache instead depend on it. * Added qttranslations5-l10n to Recommends - without this packagage there are
Thanks Rohan Garg <rohan@kde.org> no working shortcuts in localized LXQt desktops. So we want to make sure
that the package is at least recommended for qtxdg based packages.
-- Alf Gaida <agaida@siduction.org> Mon, 24 Jul 2017 21:54:16 +0200
libqtxdg (2.0.0-6) unstable; urgency=medium
* Bump Standards to 4.0.0 - no changes needed
* Added Dependeny share-mime-info (Closes: #866744)
* Bumped year in copyrights
* Removed --parallel from rules, default in compat-leveld 10
-- Alf Gaida <agaida@siduction.org> Fri, 30 Sep 2016 19:10:36 +0200 -- Alf Gaida <agaida@siduction.org> Sat, 01 Jul 2017 14:15:07 +0200
libqtxdg (2.0.0-1) experimental; urgency=medium libqtxdg (2.0.0-5) unstable; urgency=medium
* Rebuild with Qt 5.7.1~
-- Alf Gaida <agaida@siduction.org> Fri, 04 Nov 2016 17:59:49 +0100
libqtxdg (2.0.0-4) unstable; urgency=medium
* Cherry-picked new upstream release 2.0.0. * Cherry-picked new upstream release 2.0.0.
* Added current signing key * Added current signing key
* Bumped compat to 10 * Bumped compat to 10
* Bumped debhelper to (>=10) * Bumped debhelper to (>= 10)
* Added build dependency libqt5svg5-dev * Added build dependency libqt5svg5-dev
* Renamed package libqt5xdg1 -> libqt5xdg2 (soname bump) * Renamed package libqt5xdg1 -> libqt5xdg2 (soname bump)
* Renamed package libqt5xdgiconloader1 -> libqt5xdgiconloader2 (soname bump) * Added packages libqt5xdgiconloader2 and libqt5xdgiconloader-dev
* Added dependency gtk-update-icon-cache to libqt5xdgiconloader2 * XdgIconLoader: Recommend gtk-update-icon-cache
Thanks Rohan Garg <rohan@kde.org>
* Renamed install and symbols files * Renamed install and symbols files
* Fixed symbols * Fixed symbols
* Fixed .gitignore * Fixed .gitignore
* Reworked descriptions in debian/control to prevent lintian whining
* Fixed copyright for xdgiconloader
* Added README.md to debian/docs
* Set CMAKE_BUILD_TYPE=RelWithDebInfo
-- Alf Gaida <agaida@siduction.org> Sun, 18 Sep 2016 02:28:47 +0200 -- Alf Gaida <agaida@siduction.org> Sat, 09 Jul 2016 20:16:32 +0200
libqtxdg (1.3.1~50-g4fde773-4) experimental; urgency=medium libqtxdg (1.3.0-4) unstable; urgency=medium
* Added libfile-mimeinfo-perl as dependency, we really need this, a * Added libfile-mimeinfo-perl as dependency, we really need this, a
recommendation is not enough. Thanks tsujan. recommendation is not enough. Thanks tsujan.
-- Alf Gaida <agaida@siduction.org> Wed, 10 Aug 2016 22:48:40 +0200
libqtxdg (1.3.1~50-g4fde773-3) experimental; urgency=medium
* Fixed typo in changelog
-- Alf Gaida <agaida@siduction.org> Sat, 23 Jul 2016 13:05:14 +0200
libqtxdg (1.3.1~50-g4fde773-2) experimental; urgency=medium
* Added build dependencies gcc (>= 4:6), g++ (>= 4:6)
* Exported LC_ALL=C.UTF-8 - define language settings for
reproducible builds
-- Alf Gaida <agaida@siduction.org> Sat, 16 Jul 2016 20:26:26 +0200
libqtxdg (1.3.1~50-g4fde773-1) experimental; urgency=medium
* New pre-release 1.3.1~50-g4fde773
* Fixed libqt5xdgiconloader-dev.install
* Reworked descriptions in debian/control to prevent lintian whining
* Fixed symbols version
* Fixed copyright for xdgiconloader
* Fixed package descrioptions
* Introduced the new package libqt5xdgiconloader1
* Bumped standards to 3.9.8, no changes needed * Bumped standards to 3.9.8, no changes needed
* Symbols sorted and unified
* Added missed Symbol
* Bump years in copyright * Bump years in copyright
* Added README to debian/docs
* Added hardening=+all * Added hardening=+all
* Added README.md to debian/docs * Exported LC_ALL=C.UTF-8 - define language settings for
* set CMAKE_BUILD_TYPE=RelWithDebInfo reproducible builds
* Fixed VCS-fields, use https and plain /git/
-- Alf Gaida <agaida@siduction.org> Sat, 09 Jul 2016 20:16:32 +0200 * Fixed copyrights Format field to https
-- Alf Gaida <agaida@siduction.org> Wed, 10 Aug 2016 23:06:12 +0200
libqtxdg (1.3.0-3) unstable; urgency=medium libqtxdg (1.3.0-3) unstable; urgency=medium

26
debian/control vendored

@ -13,17 +13,19 @@ Build-Depends: debhelper (>= 10),
qtbase5-private-dev, qtbase5-private-dev,
qttools5-dev, qttools5-dev,
qttools5-dev-tools qttools5-dev-tools
Standards-Version: 3.9.8 Standards-Version: 4.1.0
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-lxqt/libqtxdg.git/?h=debian/experimental Vcs-Browser: https://anonscm.debian.org/cgit/pkg-lxqt/libqtxdg.git/?h=debian/experimental
Vcs-Git: https://anonscm.debian.org/git/pkg-lxqt/libqtxdg.git -b debian/experimental Vcs-Git: https://anonscm.debian.org/git/pkg-lxqt/libqtxdg.git -b debian/experimental
Homepage: https://github.com/lxde/libqtxdg Homepage: https://github.com/lxde/libqtxdg
Package: libqt5xdg2 Package: libqt5xdg3
Architecture: any Architecture: any
Multi-Arch: same Multi-Arch: same
Depends: ${shlibs:Depends}, Depends: ${shlibs:Depends},
${misc:Depends}, ${misc:Depends},
libfile-mimeinfo-perl libfile-mimeinfo-perl,
shared-mime-info
Recommends: qttranslations5-l10n
Pre-Depends: ${misc:Pre-Depends} Pre-Depends: ${misc:Pre-Depends}
Provides: libqt5xdg Provides: libqt5xdg
Description: Implementation of the XDG Specifications for Qt (shared lib) Description: Implementation of the XDG Specifications for Qt (shared lib)
@ -32,7 +34,7 @@ Description: Implementation of the XDG Specifications for Qt (shared lib)
. .
This package provides the shared library. This package provides the shared library.
Package: libqt5xdgiconloader2 Package: libqt5xdgiconloader3
Architecture: any Architecture: any
Multi-Arch: same Multi-Arch: same
Depends: ${shlibs:Depends}, Depends: ${shlibs:Depends},
@ -50,7 +52,7 @@ Package: libqt5xdg-dev
Architecture: any Architecture: any
Section: libdevel Section: libdevel
Depends: ${misc:Depends}, Depends: ${misc:Depends},
libqt5xdg2 (= ${binary:Version}), libqt5xdg3 (= ${binary:Version}),
libqt5xdgiconloader-dev (= ${binary:Version}) libqt5xdgiconloader-dev (= ${binary:Version})
Description: Development files for libqtxdg Description: Development files for libqtxdg
This library implements functions of the XDG Specifications in Qt. It is part This library implements functions of the XDG Specifications in Qt. It is part
@ -61,10 +63,20 @@ Description: Development files for libqtxdg
Package: libqt5xdgiconloader-dev Package: libqt5xdgiconloader-dev
Architecture: any Architecture: any
Section: libdevel Section: libdevel
Depends: ${misc:Depends}, Depends: ${shlibs:Depends},
libqt5xdgiconloader2 (= ${binary:Version}) libqt5xdgiconloader3 (= ${binary:Version})
Description: Development files for libqtxdgiconloader Description: Development files for libqtxdgiconloader
This library implements the backend to load icons which are handled according This library implements the backend to load icons which are handled according
to the XDG Icon Theme Specification in Qt. It is part of LXQt. to the XDG Icon Theme Specification in Qt. It is part of LXQt.
. .
This package provides development files. This package provides development files.
Package: qtxdg-dev-tools
Architecture: any
Section: devel
Depends: ${shlibs:Depends},
${misc:Depends},
libqt5xdgiconloader3 (= ${binary:Version})
Description: Development tools for libqtxdgiconloader
This package provide some development tools for qtxdg.

2
debian/copyright vendored

@ -15,7 +15,7 @@ License: LGPL-2.1-or-3-with-Digia-1.1-exception
Files: debian/* Files: debian/*
Copyright: 2014-2016 ChangZhuo Chen (陳昌倬) <czchen@debian.org> Copyright: 2014-2016 ChangZhuo Chen (陳昌倬) <czchen@debian.org>
2013-2016 Alf Gaida <agaida@siduction.org> 2013-2017 Alf Gaida <agaida@siduction.org>
2015 Andrew Lee (李健秋) <ajqlee@debian.org> 2015 Andrew Lee (李健秋) <ajqlee@debian.org>
License: LGPL-2.1+ License: LGPL-2.1+

2
debian/gbp.conf vendored

@ -1,5 +1,5 @@
[DEFAULT] [DEFAULT]
debian-branch = debian/sid debian-branch = debian/experimental
upstream-branch = upstream/latest upstream-branch = upstream/latest
pristine-tar = True pristine-tar = True

@ -1,9 +1,21 @@
libQt5Xdg.so.2 libqt5xdg2 #MINVER# libQt5Xdg.so.3 libqt5xdg3 #MINVER#
(c++)"XdgAction::XdgAction(QObject*)@Base" 1.0.0 (c++)"non-virtual thunk to XdgMenuWidget::~XdgMenuWidget()@Base" 1.0.0
(c++)"XdgAction::XdgAction(QString const&, QObject*)@Base" 1.0.0 (c++)"typeinfo for XdgAction@Base" 1.0.0
(c++)"XdgAction::XdgAction(XdgAction const&, QObject*)@Base" 1.0.0 (c++)"typeinfo for XdgDesktopFile@Base" 1.0.0
(c++)"XdgAction::XdgAction(XdgDesktopFile const&, QObject*)@Base" 1.0.0 (c++)"typeinfo for XdgIcon@Base" 1.0.0
(c++)"XdgAction::XdgAction(XdgDesktopFile const*, QObject*)@Base" 1.0.0 (c++)"typeinfo for XdgMenu@Base" 1.0.0
(c++)"typeinfo for XdgMenuWidget@Base" 1.0.0
(c++)"typeinfo name for XdgAction@Base" 1.0.0
(c++)"typeinfo name for XdgDesktopFile@Base" 1.0.0
(c++)"typeinfo name for XdgIcon@Base" 1.0.0
(c++)"typeinfo name for XdgMenu@Base" 1.0.0
(c++)"typeinfo name for XdgMenuWidget@Base" 1.0.0
(c++)"vtable for XdgAction@Base" 1.0.0
(c++)"vtable for XdgDesktopFile@Base" 1.0.0
(c++)"vtable for XdgIcon@Base" 1.0.0
(c++)"vtable for XdgMenu@Base" 1.0.0
(c++)"vtable for XdgMenuWidget@Base" 1.0.0
(c++)"XdgAction::isValid() const@Base" 1.0.0 (c++)"XdgAction::isValid() const@Base" 1.0.0
(c++)"XdgAction::load(XdgDesktopFile const&)@Base" 1.0.0 (c++)"XdgAction::load(XdgDesktopFile const&)@Base" 1.0.0
(c++)"XdgAction::metaObject() const@Base" 1.0.0 (c++)"XdgAction::metaObject() const@Base" 1.0.0
@ -14,18 +26,35 @@ libQt5Xdg.so.2 libqt5xdg2 #MINVER#
(c++)"XdgAction::staticMetaObject@Base" 1.0.0 (c++)"XdgAction::staticMetaObject@Base" 1.0.0
(c++)"XdgAction::updateIcon()@Base" 1.0.0 (c++)"XdgAction::updateIcon()@Base" 1.0.0
(c++)"XdgAction::~XdgAction()@Base" 1.0.0 (c++)"XdgAction::~XdgAction()@Base" 1.0.0
(c++)"XdgAutoStart::desktopFileList(QStringList, bool)@Base" 1.0.0 (c++)"XdgAction::XdgAction(QObject*)@Base" 1.0.0
(c++)"XdgAction::XdgAction(QString const&, QObject*)@Base" 1.0.0
(c++)"XdgAction::XdgAction(XdgAction const&, QObject*)@Base" 1.0.0
(c++)"XdgAction::XdgAction(XdgDesktopFile const*, QObject*)@Base" 1.0.0
(c++)"XdgAction::XdgAction(XdgDesktopFile const&, QObject*)@Base" 1.0.0
(c++)"XdgAutoStart::desktopFileList(bool)@Base" 1.0.0 (c++)"XdgAutoStart::desktopFileList(bool)@Base" 1.0.0
(c++)"XdgAutoStart::desktopFileList(QStringList, bool)@Base" 1.0.0
(c++)"XdgAutoStart::localPath(XdgDesktopFile const&)@Base" 1.0.0 (c++)"XdgAutoStart::localPath(XdgDesktopFile const&)@Base" 1.0.0
(c++)"XdgDesktopFile::XdgDesktopFile()@Base" 1.0.0
(c++)"XdgDesktopFile::XdgDesktopFile(XdgDesktopFile const&)@Base" 1.0.0 (c++)"XdgDesktopFileCache::desktopFileSettingsFormat()@Base" 1.0.0
(c++)"XdgDesktopFile::XdgDesktopFile(XdgDesktopFile::Type, QString const&, QString const&)@Base" 1.0.0 (c++)"XdgDesktopFileCache::getAllFiles()@Base" 1.0.0
(c++)"XdgDesktopFileCache::getAppsOfCategory(QString const&)@Base" 1.2.0
(c++)"XdgDesktopFileCache::getApps(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::getDefaultApp(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::getFile(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::initialize()@Base" 1.0.0
(c++)"XdgDesktopFileCache::initialize(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::instance()@Base" 1.0.0
(c++)"XdgDesktopFileCache::load(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::~XdgDesktopFileCache()@Base" 1.0.0
(c++)"XdgDesktopFileCache::XdgDesktopFileCache()@Base" 1.0.0
(c++)"XdgDesktopFile::categories() const@Base" 1.2.0 (c++)"XdgDesktopFile::categories() const@Base" 1.2.0
(c++)"XdgDesktopFile::contains(QString const&) const@Base" 1.0.0 (c++)"XdgDesktopFile::contains(QString const&) const@Base" 1.0.0
(c++)"XdgDesktopFile::expandExecString(QStringList const&) const@Base" 1.0.0 (c++)"XdgDesktopFile::expandExecString(QStringList const&) const@Base" 1.0.0
(c++)"XdgDesktopFile::fileName() const@Base" 1.0.0 (c++)"XdgDesktopFile::fileName() const@Base" 1.0.0
(c++)"XdgDesktopFile::icon(QIcon const&) const@Base" 1.0.0
(c++)"XdgDesktopFile::iconName() const@Base" 1.0.0 (c++)"XdgDesktopFile::iconName() const@Base" 1.0.0
(c++)"XdgDesktopFile::icon(QIcon const&) const@Base" 1.0.0
(c++)"XdgDesktopFile::id(QString const&, bool)@Base" 2.0.0 (c++)"XdgDesktopFile::id(QString const&, bool)@Base" 2.0.0
(c++)"XdgDesktopFile::isShown(QString const&) const@Base" 1.0.0 (c++)"XdgDesktopFile::isShown(QString const&) const@Base" 1.0.0
(c++)"XdgDesktopFile::isSuitable(bool, QString const&) const@Base" 1.0.0 (c++)"XdgDesktopFile::isSuitable(bool, QString const&) const@Base" 1.0.0
@ -47,18 +76,10 @@ libQt5Xdg.so.2 libqt5xdg2 #MINVER#
(c++)"XdgDesktopFile::url() const@Base" 1.0.0 (c++)"XdgDesktopFile::url() const@Base" 1.0.0
(c++)"XdgDesktopFile::value(QString const&, QVariant const&) const@Base" 1.0.0 (c++)"XdgDesktopFile::value(QString const&, QVariant const&) const@Base" 1.0.0
(c++)"XdgDesktopFile::~XdgDesktopFile()@Base" 1.0.0 (c++)"XdgDesktopFile::~XdgDesktopFile()@Base" 1.0.0
(c++)"XdgDesktopFileCache::XdgDesktopFileCache()@Base" 1.0.0 (c++)"XdgDesktopFile::XdgDesktopFile()@Base" 1.0.0
(c++)"XdgDesktopFileCache::desktopFileSettingsFormat()@Base" 1.0.0 (c++)"XdgDesktopFile::XdgDesktopFile(XdgDesktopFile const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::getAllFiles()@Base" 1.0.0 (c++)"XdgDesktopFile::XdgDesktopFile(XdgDesktopFile::Type, QString const&, QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::getApps(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::getAppsOfCategory(QString const&)@Base" 1.2.0
(c++)"XdgDesktopFileCache::getDefaultApp(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::getFile(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::initialize()@Base" 1.0.0
(c++)"XdgDesktopFileCache::initialize(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::instance()@Base" 1.0.0
(c++)"XdgDesktopFileCache::load(QString const&)@Base" 1.0.0
(c++)"XdgDesktopFileCache::~XdgDesktopFileCache()@Base" 1.0.0
(c++)"XdgDirs::autostartDirs(QString const&)@Base" 1.0.0 (c++)"XdgDirs::autostartDirs(QString const&)@Base" 1.0.0
(c++)"XdgDirs::autostartHome(bool)@Base" 1.0.0 (c++)"XdgDirs::autostartHome(bool)@Base" 1.0.0
(c++)"XdgDirs::cacheHome(bool)@Base" 1.0.0 (c++)"XdgDirs::cacheHome(bool)@Base" 1.0.0
@ -68,18 +89,19 @@ libQt5Xdg.so.2 libqt5xdg2 #MINVER#
(c++)"XdgDirs::dataHome(bool)@Base" 1.0.0 (c++)"XdgDirs::dataHome(bool)@Base" 1.0.0
(c++)"XdgDirs::runtimeDir()@Base" 1.0.0 (c++)"XdgDirs::runtimeDir()@Base" 1.0.0
(c++)"XdgDirs::setUserDir(XdgDirs::UserDirectory, QString const&, bool)@Base" 1.0.0 (c++)"XdgDirs::setUserDir(XdgDirs::UserDirectory, QString const&, bool)@Base" 1.0.0
(c++)"XdgDirs::userDir(XdgDirs::UserDirectory)@Base" 1.0.0
(c++)"XdgDirs::userDirDefault(XdgDirs::UserDirectory)@Base" 1.3.0 (c++)"XdgDirs::userDirDefault(XdgDirs::UserDirectory)@Base" 1.3.0
(c++)"XdgIcon::XdgIcon()@Base" 1.0.0 (c++)"XdgDirs::userDir(XdgDirs::UserDirectory)@Base" 1.0.0
(c++)"XdgIcon::defaultApplicationIcon()@Base" 1.0.0 (c++)"XdgIcon::defaultApplicationIcon()@Base" 1.0.0
(c++)"XdgIcon::defaultApplicationIconName()@Base" 1.0.0 (c++)"XdgIcon::defaultApplicationIconName()@Base" 1.0.0
(c++)"XdgIcon::followColorScheme()@Base" 2.0.1~
(c++)"XdgIcon::fromTheme(QString const&, QIcon const&)@Base" 1.0.0 (c++)"XdgIcon::fromTheme(QString const&, QIcon const&)@Base" 1.0.0
(c++)"XdgIcon::fromTheme(QString const&, QString const&, QString const&, QString const&, QString const&)@Base" 1.0.0 (c++)"XdgIcon::fromTheme(QString const&, QString const&, QString const&, QString const&, QString const&)@Base" 1.0.0
(c++)"XdgIcon::fromTheme(QStringList const&, QIcon const&)@Base" 1.0.0 (c++)"XdgIcon::fromTheme(QStringList const&, QIcon const&)@Base" 1.0.0
(c++)"XdgIcon::setThemeName(QString const&)@Base" 1.0.0 (c++)"XdgIcon::setFollowColorScheme(bool)@Base" 2.0.1~
(c++)"XdgIcon::themeName()@Base" 1.0.0
(c++)"XdgIcon::~XdgIcon()@Base" 1.0.0 (c++)"XdgIcon::~XdgIcon()@Base" 1.0.0
(c++)"XdgMenu::XdgMenu(QObject*)@Base" 1.0.0 (c++)"XdgIcon::XdgIcon()@Base" 1.0.0
(c++)"XdgMenu::addWatchPath(QString const&)@Base" 1.0.0 (c++)"XdgMenu::addWatchPath(QString const&)@Base" 1.0.0
(c++)"XdgMenu::changed()@Base" 1.0.0 (c++)"XdgMenu::changed()@Base" 1.0.0
(c++)"XdgMenu::environments()@Base" 1.0.0 (c++)"XdgMenu::environments()@Base" 1.0.0
@ -98,11 +120,7 @@ libQt5Xdg.so.2 libqt5xdg2 #MINVER#
(c++)"XdgMenu::setEnvironments(QStringList const&)@Base" 1.0.0 (c++)"XdgMenu::setEnvironments(QStringList const&)@Base" 1.0.0
(c++)"XdgMenu::setLogDir(QString const&)@Base" 1.0.0 (c++)"XdgMenu::setLogDir(QString const&)@Base" 1.0.0
(c++)"XdgMenu::staticMetaObject@Base" 1.0.0 (c++)"XdgMenu::staticMetaObject@Base" 1.0.0
(c++)"XdgMenu::xml() const@Base" 1.0.0
(c++)"XdgMenu::~XdgMenu()@Base" 1.0.0
(c++)"XdgMenuWidget::XdgMenuWidget(QDomElement const&, QWidget*)@Base" 1.0.0
(c++)"XdgMenuWidget::XdgMenuWidget(XdgMenu const&, QString const&, QWidget*)@Base" 1.0.0
(c++)"XdgMenuWidget::XdgMenuWidget(XdgMenuWidget const&, QWidget*)@Base" 1.0.0
(c++)"XdgMenuWidget::event(QEvent*)@Base" 1.0.0 (c++)"XdgMenuWidget::event(QEvent*)@Base" 1.0.0
(c++)"XdgMenuWidget::metaObject() const@Base" 1.0.0 (c++)"XdgMenuWidget::metaObject() const@Base" 1.0.0
(c++)"XdgMenuWidget::operator=(XdgMenuWidget const&)@Base" 1.0.0 (c++)"XdgMenuWidget::operator=(XdgMenuWidget const&)@Base" 1.0.0
@ -110,26 +128,18 @@ libQt5Xdg.so.2 libqt5xdg2 #MINVER#
(c++)"XdgMenuWidget::qt_metacast(char const*)@Base" 1.0.0 (c++)"XdgMenuWidget::qt_metacast(char const*)@Base" 1.0.0
(c++)"XdgMenuWidget::staticMetaObject@Base" 1.0.0 (c++)"XdgMenuWidget::staticMetaObject@Base" 1.0.0
(c++)"XdgMenuWidget::~XdgMenuWidget()@Base" 1.0.0 (c++)"XdgMenuWidget::~XdgMenuWidget()@Base" 1.0.0
(c++)"XdgMimeType::XdgMimeType()@Base" 1.0.0 (c++)"XdgMenuWidget::XdgMenuWidget(QDomElement const&, QWidget*)@Base" 1.0.0
(c++)"XdgMimeType::XdgMimeType(QMimeType const&)@Base" 1.0.0 (c++)"XdgMenuWidget::XdgMenuWidget(XdgMenu const&, QString const&, QWidget*)@Base" 1.0.0
(c++)"XdgMimeType::XdgMimeType(XdgMimeType const&)@Base" 1.0.0 (c++)"XdgMenuWidget::XdgMenuWidget(XdgMenuWidget const&, QWidget*)@Base" 1.0.0
(c++)"XdgMenu::~XdgMenu()@Base" 1.0.0
(c++)"XdgMenu::XdgMenu(QObject*)@Base" 1.0.0
(c++)"XdgMenu::xml() const@Base" 1.0.0
(c++)"XdgMimeType::icon() const@Base" 1.0.0 (c++)"XdgMimeType::icon() const@Base" 1.0.0
(c++)"XdgMimeType::iconName() const@Base" 1.0.0 (c++)"XdgMimeType::iconName() const@Base" 1.0.0
(c++)"XdgMimeType::operator=(XdgMimeType const&)@Base" 1.0.0 (c++)"XdgMimeType::operator=(XdgMimeType const&)@Base" 1.0.0
(c++)"XdgMimeType::~XdgMimeType()@Base" 1.0.0 (c++)"XdgMimeType::~XdgMimeType()@Base" 1.0.0
(c++)"non-virtual thunk to XdgMenuWidget::~XdgMenuWidget()@Base" 1.0.0 (c++)"XdgMimeType::XdgMimeType()@Base" 1.0.0
(c++)"typeinfo for XdgAction@Base" 1.0.0 (c++)"XdgMimeType::XdgMimeType(QMimeType const&)@Base" 1.0.0
(c++)"typeinfo for XdgDesktopFile@Base" 1.0.0 (c++)"XdgMimeType::XdgMimeType(XdgMimeType const&)@Base" 1.0.0
(c++)"typeinfo for XdgIcon@Base" 1.0.0
(c++)"typeinfo for XdgMenu@Base" 1.0.0
(c++)"typeinfo for XdgMenuWidget@Base" 1.0.0
(c++)"typeinfo name for XdgAction@Base" 1.0.0
(c++)"typeinfo name for XdgDesktopFile@Base" 1.0.0
(c++)"typeinfo name for XdgIcon@Base" 1.0.0
(c++)"typeinfo name for XdgMenu@Base" 1.0.0
(c++)"typeinfo name for XdgMenuWidget@Base" 1.0.0
(c++)"vtable for XdgAction@Base" 1.0.0
(c++)"vtable for XdgDesktopFile@Base" 1.0.0
(c++)"vtable for XdgIcon@Base" 1.0.0
(c++)"vtable for XdgMenu@Base" 1.0.0
(c++)"vtable for XdgMenuWidget@Base" 1.0.0

@ -3,6 +3,8 @@ usr/include/qt5xdgiconloader
usr/lib/*/libQt5XdgIconLoader.so usr/lib/*/libQt5XdgIconLoader.so
usr/lib/*/pkgconfig/Qt5XdgIconLoader.pc usr/lib/*/pkgconfig/Qt5XdgIconLoader.pc
usr/lib/*/qt5/plugins/iconengines/libQt5XdgIconPlugin.so
usr/share/cmake/qt5xdgiconloader/qt5xdgiconloader-config-version.cmake usr/share/cmake/qt5xdgiconloader/qt5xdgiconloader-config-version.cmake
usr/share/cmake/qt5xdgiconloader/qt5xdgiconloader-config.cmake usr/share/cmake/qt5xdgiconloader/qt5xdgiconloader-config.cmake
usr/share/cmake/qt5xdgiconloader/qt5xdgiconloader-targets.cmake usr/share/cmake/qt5xdgiconloader/qt5xdgiconloader-targets.cmake

@ -1,15 +1,8 @@
libQt5XdgIconLoader.so.2 libqt5xdgiconloader2 #MINVER# libQt5XdgIconLoader.so.3 libqt5xdgiconloader3 #MINVER#
(c++)"XdgIconLoader::XdgIconLoader()@Base" 2.0.0 (c++)"typeinfo for XdgIconLoaderEngine@Base" 2.0.0
(c++)"XdgIconLoader::ensureInitialized()@Base" 2.0.0 (c++)"typeinfo name for XdgIconLoaderEngine@Base" 2.0.0
(c++)"XdgIconLoader::findIconHelper(QString const&, QString const&, QStringList&) const@Base" 2.0.0 (c++)"vtable for XdgIconLoaderEngine@Base" 2.0.0
(c++)"XdgIconLoader::instance()@Base" 2.0.0
(c++)"XdgIconLoader::loadIcon(QString const&) const@Base" 2.0.0
(c++)"XdgIconLoader::setThemeName(QString const&)@Base" 2.0.0
(c++)"XdgIconLoader::setThemeSearchPath(QStringList const&)@Base" 2.0.0
(c++)"XdgIconLoader::themeSearchPaths() const@Base" 2.0.0
(c++)"XdgIconLoader::updateSystemTheme()@Base" 2.0.0
(c++)"XdgIconLoaderEngine::XdgIconLoaderEngine(QString const&)@Base" 2.0.0
(c++)"XdgIconLoaderEngine::XdgIconLoaderEngine(XdgIconLoaderEngine const&)@Base" 2.0.0
(c++)"XdgIconLoaderEngine::actualSize(QSize const&, QIcon::Mode, QIcon::State)@Base" 2.0.0 (c++)"XdgIconLoaderEngine::actualSize(QSize const&, QIcon::Mode, QIcon::State)@Base" 2.0.0
(c++)"XdgIconLoaderEngine::clone() const@Base" 2.0.0 (c++)"XdgIconLoaderEngine::clone() const@Base" 2.0.0
(c++)"XdgIconLoaderEngine::ensureLoaded()@Base" 2.0.0 (c++)"XdgIconLoaderEngine::ensureLoaded()@Base" 2.0.0
@ -22,6 +15,11 @@ libQt5XdgIconLoader.so.2 libqt5xdgiconloader2 #MINVER#
(c++)"XdgIconLoaderEngine::virtual_hook(int, void*)@Base" 2.0.0 (c++)"XdgIconLoaderEngine::virtual_hook(int, void*)@Base" 2.0.0
(c++)"XdgIconLoaderEngine::write(QDataStream&) const@Base" 2.0.0 (c++)"XdgIconLoaderEngine::write(QDataStream&) const@Base" 2.0.0
(c++)"XdgIconLoaderEngine::~XdgIconLoaderEngine()@Base" 2.0.0 (c++)"XdgIconLoaderEngine::~XdgIconLoaderEngine()@Base" 2.0.0
(c++)"typeinfo for XdgIconLoaderEngine@Base" 2.0.0 (c++)"XdgIconLoaderEngine::XdgIconLoaderEngine(QString const&)@Base" 2.0.0
(c++)"typeinfo name for XdgIconLoaderEngine@Base" 2.0.0 (c++)"XdgIconLoaderEngine::XdgIconLoaderEngine(XdgIconLoaderEngine const&)@Base" 2.0.0
(c++)"vtable for XdgIconLoaderEngine@Base" 2.0.0
(c++)"XdgIconLoader::findIconHelper(QString const&, QString const&, QStringList&, bool) const@Base" 2.0.1~
(c++)"XdgIconLoader::instance()@Base" 2.0.0
(c++)"XdgIconLoader::loadIcon(QString const&) const@Base" 2.0.0
(c++)"XdgIconLoader::setFollowColorScheme(bool)@Base" 2.0.1~
(c++)"XdgIconLoader::unthemedFallback(QString const&, QStringList const&) const@Base" 2.0.1~

@ -0,0 +1,4 @@
usr/bin/qtxdg-iconfinder
usr/bin/qtxdg-desktop-file-start

8
debian/rules vendored

@ -6,11 +6,13 @@ export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%: %:
dh ${@} --buildsystem cmake \ dh ${@} --buildsystem cmake
--parallel \
--fail-missing override_dh_missing:
dh_missing --fail-missing
override_dh_auto_configure: override_dh_auto_configure:
dh_auto_configure -- \ dh_auto_configure -- \
-DBUILD_DEV_UTILS=YES \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_BUILD_TYPE=RelWithDebInfo

@ -1,8 +1,5 @@
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus) set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
include_directories(
"${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
)
set(libqtxdg_PUBLIC_H_FILES set(libqtxdg_PUBLIC_H_FILES
xdgaction.h xdgaction.h
xdgdesktopfile.h xdgdesktopfile.h
@ -63,14 +60,11 @@ set(libqtxdg_MOCS
xdgmenuwidget.h xdgmenuwidget.h
) )
QT5_WRAP_CPP(libqtxdg_CXX_FILES ${libqtxdg_MOCS})
add_library(${QTXDGX_LIBRARY_NAME} SHARED add_library(${QTXDGX_LIBRARY_NAME} SHARED
${libqtxdg_PUBLIC_H_FILES} ${libqtxdg_PUBLIC_H_FILES}
${libqtxdg_PRIVATE_H_FILES} ${libqtxdg_PRIVATE_H_FILES}
${libqtxdg_PRIVATE_H_FILES}
${libqtxdg_CPP_FILES} ${libqtxdg_CPP_FILES}
${libqtxdg_CXX_FILES} ${libqtxdg_MOCS}
) )
target_link_libraries(${QTXDGX_LIBRARY_NAME} target_link_libraries(${QTXDGX_LIBRARY_NAME}
@ -85,24 +79,22 @@ set_target_properties(${QTXDGX_LIBRARY_NAME} PROPERTIES
) )
target_compile_definitions(${QTXDGX_LIBRARY_NAME} target_compile_definitions(${QTXDGX_LIBRARY_NAME}
PRIVATE "QTXDG_COMPILATION=\"1\"" PRIVATE
PRIVATE "QTXDG_VERSION=\"${QTXDG_VERSION_STRING}\"" "QTXDG_COMPILATION=\"1\""
"QTXDG_VERSION=\"${QTXDG_VERSION_STRING}\""
"QT_NO_KEYWORDS"
) )
target_include_directories(${QTXDGX_LIBRARY_NAME} target_include_directories(${QTXDGX_LIBRARY_NAME}
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}>" INTERFACE
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
"$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}>"
"$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}>"
PRIVATE
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
) )
# include directories and targets for the in tree build
target_include_directories(${QTXDGX_LIBRARY_NAME}
INTERFACE "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}>"
INTERFACE "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}>"
)
export(TARGETS ${QTXDGX_LIBRARY_NAME} APPEND FILE "${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-targets.cmake")
# end of in tree build stuff
# create the portble headers # create the portble headers
create_portable_headers(libqtxdg_PORTABLE_HEADERS create_portable_headers(libqtxdg_PORTABLE_HEADERS
HEADER_NAMES ${libqtxdg_PUBLIC_CLASSES} HEADER_NAMES ${libqtxdg_PUBLIC_CLASSES}

@ -71,7 +71,7 @@ public:
const XdgDesktopFile& desktopFile() const { return mDesktopFile; } const XdgDesktopFile& desktopFile() const { return mDesktopFile; }
private slots: private Q_SLOTS:
void runConmmand() const; void runConmmand() const;
void updateIcon(); void updateIcon();

@ -57,14 +57,14 @@ XdgDesktopFileList XdgAutoStart::desktopFileList(QStringList dirs, bool excludeH
QSet<QString> processed; QSet<QString> processed;
XdgDesktopFileList ret; XdgDesktopFileList ret;
foreach (const QString &dirName, dirs) Q_FOREACH (const QString &dirName, dirs)
{ {
QDir dir(dirName); QDir dir(dirName);
if (!dir.exists()) if (!dir.exists())
continue; continue;
const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files | QDir::Readable); const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files | QDir::Readable);
foreach (const QFileInfo &fi, files) Q_FOREACH (const QFileInfo &fi, files)
{ {
if (processed.contains(fi.fileName())) if (processed.contains(fi.fileName()))
continue; continue;

@ -409,9 +409,9 @@ bool XdgDesktopFileData::startApplicationDetached(const XdgDesktopFile *q, const
} }
bool nonDetach = false; bool nonDetach = false;
foreach(const QString &s, nonDetachExecs) Q_FOREACH(const QString &s, nonDetachExecs)
{ {
foreach(const QString &a, args) Q_FOREACH(const QString &a, args)
{ {
if (a.contains(s)) if (a.contains(s))
{ {
@ -953,7 +953,7 @@ QString expandEnvVariables(const QString str)
QStringList expandEnvVariables(const QStringList strs) QStringList expandEnvVariables(const QStringList strs)
{ {
QStringList res; QStringList res;
foreach(const QString &s, strs) Q_FOREACH(const QString &s, strs)
res << expandEnvVariables(s); res << expandEnvVariables(s);
return res; return res;
@ -971,7 +971,7 @@ QStringList XdgDesktopFile::expandExecString(const QStringList& urls) const
unEscapeExec(execStr); unEscapeExec(execStr);
QStringList tokens = parseCombinedArgString(execStr); QStringList tokens = parseCombinedArgString(execStr);
foreach (QString token, tokens) Q_FOREACH (QString token, tokens)
{ {
// The parseCombinedArgString() splits the string by the space symbols, // The parseCombinedArgString() splits the string by the space symbols,
// we temporarily replaced them on the special characters. // we temporarily replaced them on the special characters.
@ -1016,7 +1016,7 @@ QStringList XdgDesktopFile::expandExecString(const QStringList& urls) const
// program. Local files may either be passed as file: URLs or as file path. // program. Local files may either be passed as file: URLs or as file path.
if (token == QLatin1String("%U")) if (token == QLatin1String("%U"))
{ {
foreach (const QString &s, urls) Q_FOREACH (const QString &s, urls)
{ {
QUrl url(expandEnvVariables(s)); QUrl url(expandEnvVariables(s));
result << ((!url.toLocalFile().isEmpty()) ? url.toLocalFile() : QString::fromUtf8(url.toEncoded())); result << ((!url.toLocalFile().isEmpty()) ? url.toLocalFile() : QString::fromUtf8(url.toEncoded()));
@ -1081,7 +1081,7 @@ bool checkTryExec(const QString& progName)
QStringList dirs = QFile::decodeName(qgetenv("PATH")).split(QLatin1Char(':')); QStringList dirs = QFile::decodeName(qgetenv("PATH")).split(QLatin1Char(':'));
foreach (const QString &dir, dirs) Q_FOREACH (const QString &dir, dirs)
{ {
if (QFileInfo(QDir(dir), progName).isExecutable()) if (QFileInfo(QDir(dir), progName).isExecutable())
return true; return true;
@ -1103,7 +1103,7 @@ QString XdgDesktopFile::id(const QString &fileName, bool checkFileExists)
QString id = f.absoluteFilePath(); QString id = f.absoluteFilePath();
const QStringList dataDirs = XdgDirs::dataDirs(); const QStringList dataDirs = XdgDirs::dataDirs();
foreach(const QString &d, dataDirs) { Q_FOREACH(const QString &d, dataDirs) {
if (id.startsWith(d)) { if (id.startsWith(d)) {
// remove only the first occurence // remove only the first occurence
id.replace(id.indexOf(d), d.size(), QString()); id.replace(id.indexOf(d), d.size(), QString());
@ -1211,7 +1211,7 @@ bool XdgDesktopFile::isSuitable(bool excludeHidden, const QString &environment)
QString expandDynamicUrl(QString url) QString expandDynamicUrl(QString url)
{ {
foreach(const QString &line, QProcess::systemEnvironment()) Q_FOREACH(const QString &line, QProcess::systemEnvironment())
{ {
QString name = line.section(QLatin1Char('='), 0, 0); QString name = line.section(QLatin1Char('='), 0, 0);
QString val = line.section(QLatin1Char('='), 1); QString val = line.section(QLatin1Char('='), 1);
@ -1253,7 +1253,7 @@ QString findDesktopFile(const QString& dirName, const QString& desktopName)
// Working recursively ............ // Working recursively ............
QFileInfoList dirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList dirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QFileInfo &d, dirs) Q_FOREACH (const QFileInfo &d, dirs)
{ {
QString cn = d.canonicalFilePath(); QString cn = d.canonicalFilePath();
if (dirName != cn) if (dirName != cn)
@ -1273,7 +1273,7 @@ QString findDesktopFile(const QString& desktopName)
QStringList dataDirs = XdgDirs::dataDirs(); QStringList dataDirs = XdgDirs::dataDirs();
dataDirs.prepend(XdgDirs::dataHome(false)); dataDirs.prepend(XdgDirs::dataHome(false));
foreach (const QString &dirName, dataDirs) Q_FOREACH (const QString &dirName, dataDirs)
{ {
QString f = findDesktopFile(dirName + QLatin1String("/applications"), desktopName); QString f = findDesktopFile(dirName + QLatin1String("/applications"), desktopName);
if (!f.isEmpty()) if (!f.isEmpty())
@ -1415,14 +1415,14 @@ bool writeDesktopFile(QIODevice & device, const QSettings::SettingsMap & map)
QTextStream stream(&device); QTextStream stream(&device);
QString section; QString section;
foreach (const QString &key, map.keys()) for (auto it = map.constBegin(); it != map.constEnd(); ++it)
{ {
if (! map.value(key).canConvert<QString>()) if (! it.value().canConvert<QString>())
{ {
return false; return false;
} }
QString thisSection = key.section(QLatin1Char('/'), 0, 0); QString thisSection = it.key().section(QLatin1Char('/'), 0, 0);
if (thisSection.isEmpty()) if (thisSection.isEmpty())
{ {
qWarning() << "No section defined"; qWarning() << "No section defined";
@ -1435,7 +1435,7 @@ bool writeDesktopFile(QIODevice & device, const QSettings::SettingsMap & map)
section = thisSection; section = thisSection;
} }
QString remainingKey = key.section(QLatin1Char('/'), 1, -1); QString remainingKey = it.key().section(QLatin1Char('/'), 1, -1);
if (remainingKey.isEmpty()) if (remainingKey.isEmpty())
{ {
@ -1443,7 +1443,7 @@ bool writeDesktopFile(QIODevice & device, const QSettings::SettingsMap & map)
return false; return false;
} }
stream << remainingKey << QLatin1Char('=') << map.value(key).toString() << QLatin1Char('\n'); stream << remainingKey << QLatin1Char('=') << it.value().toString() << QLatin1Char('\n');
} }
@ -1462,7 +1462,7 @@ void XdgDesktopFileCache::initialize(const QString& dirName)
// Working recursively ............ // Working recursively ............
QFileInfoList files = dir.entryInfoList(QStringList(), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList files = dir.entryInfoList(QStringList(), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QFileInfo &f, files) Q_FOREACH (const QFileInfo &f, files)
{ {
if (f.isDir()) if (f.isDir())
{ {
@ -1482,7 +1482,7 @@ void XdgDesktopFileCache::initialize(const QString& dirName)
QStringList mimes = df->value(mimeTypeKey).toString().split(QLatin1Char(';'), QString::SkipEmptyParts); QStringList mimes = df->value(mimeTypeKey).toString().split(QLatin1Char(';'), QString::SkipEmptyParts);
foreach (const QString &mime, mimes) Q_FOREACH (const QString &mime, mimes)
{ {
int pref = df->value(initialPreferenceKey, 0).toInt(); int pref = df->value(initialPreferenceKey, 0).toInt();
// We move the desktopFile forward in the list for this mime, so that // We move the desktopFile forward in the list for this mime, so that
@ -1522,8 +1522,8 @@ void loadMimeCacheDir(const QString& dirName, QHash<QString, QList<XdgDesktopFil
// Working recursively ............ // Working recursively ............
QFileInfoList files = dir.entryInfoList(QStringList(), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); const QFileInfoList files = dir.entryInfoList(QStringList(), QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QFileInfo &f, files) Q_FOREACH (const QFileInfo &f, files)
{ {
if (f.isDir()) if (f.isDir())
{ {
@ -1536,9 +1536,9 @@ void loadMimeCacheDir(const QString& dirName, QHash<QString, QList<XdgDesktopFil
if (!df) if (!df)
continue; continue;
QStringList mimes = df->value(mimeTypeKey).toString().split(QLatin1Char(';'), QString::SkipEmptyParts); const QStringList mimes = df->value(mimeTypeKey).toString().split(QLatin1Char(';'), QString::SkipEmptyParts);
foreach (const QString &mime, mimes) Q_FOREACH (const QString &mime, mimes)
{ {
int pref = df->value(initialPreferenceKey, 0).toInt(); int pref = df->value(initialPreferenceKey, 0).toInt();
// We move the desktopFile forward in the list for this mime, so that // We move the desktopFile forward in the list for this mime, so that
@ -1582,7 +1582,7 @@ void XdgDesktopFileCache::initialize()
QStringList dataDirs = XdgDirs::dataDirs(); QStringList dataDirs = XdgDirs::dataDirs();
dataDirs.prepend(XdgDirs::dataHome(false)); dataDirs.prepend(XdgDirs::dataHome(false));
foreach (const QString &dirname, dataDirs) Q_FOREACH (const QString &dirname, dataDirs)
{ {
initialize(dirname + QLatin1String("/applications")); initialize(dirname + QLatin1String("/applications"));
// loadMimeCacheDir(dirname + "/applications", m_defaultAppsCache); // loadMimeCacheDir(dirname + "/applications", m_defaultAppsCache);
@ -1593,7 +1593,7 @@ QList<XdgDesktopFile*> XdgDesktopFileCache::getAppsOfCategory(const QString& cat
{ {
QList<XdgDesktopFile*> list; QList<XdgDesktopFile*> list;
const QString _category = category.toUpper(); const QString _category = category.toUpper();
foreach (XdgDesktopFile *desktopFile, instance().m_fileCache.values()) Q_FOREACH (XdgDesktopFile *desktopFile, instance().m_fileCache)
{ {
QStringList categories = desktopFile->value(categoriesKey).toString().toUpper().split(QLatin1Char(';')); QStringList categories = desktopFile->value(categoriesKey).toString().toUpper().split(QLatin1Char(';'));
if (!categories.isEmpty() && (categories.contains(_category) || categories.contains(QLatin1String("X-") + _category))) if (!categories.isEmpty() && (categories.contains(_category) || categories.contains(QLatin1String("X-") + _category)))
@ -1614,10 +1614,10 @@ XdgDesktopFile* XdgDesktopFileCache::getDefaultApp(const QString& mimetype)
// /usr/share/applications/mimeapps.list (in that order) for a default. // /usr/share/applications/mimeapps.list (in that order) for a default.
QStringList dataDirs = XdgDirs::dataDirs(); QStringList dataDirs = XdgDirs::dataDirs();
dataDirs.prepend(XdgDirs::dataHome(false)); dataDirs.prepend(XdgDirs::dataHome(false));
foreach(const QString &dataDir, dataDirs) Q_FOREACH(const QString &dataDir, dataDirs)
{ {
QString defaultsListPath = dataDir + QLatin1String("/applications/mimeapps.list"); QString defaultsListPath = dataDir + QLatin1String("/applications/mimeapps.list");
if (QFileInfo(defaultsListPath).exists()) if (QFileInfo::exists(defaultsListPath))
{ {
QSettings defaults(defaultsListPath, desktopFileSettingsFormat()); QSettings defaults(defaultsListPath, desktopFileSettingsFormat());
@ -1628,7 +1628,7 @@ XdgDesktopFile* XdgDesktopFileCache::getDefaultApp(const QString& mimetype)
QVariant value = defaults.value(mimetype); QVariant value = defaults.value(mimetype);
if (value.canConvert<QStringList>()) // A single string can also convert to a stringlist if (value.canConvert<QStringList>()) // A single string can also convert to a stringlist
{ {
foreach (const QString &desktopFileName, value.toStringList()) Q_FOREACH (const QString &desktopFileName, value.toStringList())
{ {
XdgDesktopFile* desktopFile = XdgDesktopFileCache::getFile(desktopFileName); XdgDesktopFile* desktopFile = XdgDesktopFileCache::getFile(desktopFileName);
if (desktopFile) if (desktopFile)

@ -108,7 +108,7 @@ QString userDirFallback(XdgDirs::UserDirectory dir)
if (home.isEmpty()) if (home.isEmpty())
return QString::fromLatin1("/tmp"); return QString::fromLatin1("/tmp");
else if (dir == XdgDirs::Desktop) else if (dir == XdgDirs::Desktop)
fallback = QString::fromLatin1("%1/%2").arg(home).arg(QLatin1String("Desktop")); fallback = QString::fromLatin1("%1/%2").arg(home, QLatin1String("Desktop"));
else else
fallback = home; fallback = home;
@ -178,10 +178,12 @@ bool XdgDirs::setUserDir(XdgDirs::UserDirectory dir, const QString& value, bool
if (dir < XdgDirs::Desktop || dir > XdgDirs::Videos) if (dir < XdgDirs::Desktop || dir > XdgDirs::Videos)
return false; return false;
const QString home = QFile::decodeName(qgetenv("HOME"));
if (!(value.startsWith(QLatin1String("$HOME")) if (!(value.startsWith(QLatin1String("$HOME"))
|| value.startsWith(QLatin1String("~/")) || value.startsWith(QLatin1String("~/"))
|| value.startsWith(QFile::decodeName(qgetenv("HOME"))))) || value.startsWith(home)
return false; || value.startsWith(QDir(home).canonicalPath())))
return false;
QString folderName = userDirectoryString[dir]; QString folderName = userDirectoryString[dir];
@ -215,7 +217,7 @@ bool XdgDirs::setUserDir(XdgDirs::UserDirectory dir, const QString& value, bool
stream.reset(); stream.reset();
configFile.resize(0); configFile.resize(0);
if (!foundVar) if (!foundVar)
stream << QString::fromLatin1("XDG_%1_DIR=\"%2\"\n").arg(folderName.toUpper()).arg(value); stream << QString::fromLatin1("XDG_%1_DIR=\"%2\"\n").arg(folderName.toUpper(),(value));
for (QVector<QString>::iterator i = lines.begin(); i != lines.end(); ++i) for (QVector<QString>::iterator i = lines.begin(); i != lines.end(); ++i)
stream << *i << QLatin1Char('\n'); stream << *i << QLatin1Char('\n');
@ -334,7 +336,7 @@ QStringList XdgDirs::autostartDirs(const QString &postfix)
{ {
QStringList dirs; QStringList dirs;
const QStringList s = configDirs(); const QStringList s = configDirs();
foreach(const QString &dir, s) Q_FOREACH(const QString &dir, s)
dirs << QString::fromLatin1("%1/autostart").arg(dir) + postfix; dirs << QString::fromLatin1("%1/autostart").arg(dir) + postfix;
return dirs; return dirs;

@ -50,7 +50,7 @@ struct QtIconCache: public IconCache
} }
}; };
} }
Q_GLOBAL_STATIC(IconCache, qtIconCache); Q_GLOBAL_STATIC(IconCache, qtIconCache)
static void qt_cleanup_icon_cache() static void qt_cleanup_icon_cache()
{ {
@ -68,25 +68,6 @@ XdgIcon::~XdgIcon()
} }
/************************************************
Returns the name of the current icon theme.
************************************************/
QString XdgIcon::themeName()
{
return QIcon::themeName();
}
/************************************************
Sets the current icon theme to name.
************************************************/
void XdgIcon::setThemeName(const QString& themeName)
{
QIcon::setThemeName(themeName);
XdgIconLoader::instance()->updateSystemTheme();
}
/************************************************ /************************************************
Returns the QIcon corresponding to name in the current icon theme. If no such icon Returns the QIcon corresponding to name in the current icon theme. If no such icon
is found in the current theme fallback is return instead. is found in the current theme fallback is return instead.
@ -137,7 +118,7 @@ QIcon XdgIcon::fromTheme(const QString& iconName, const QIcon& fallback)
************************************************/ ************************************************/
QIcon XdgIcon::fromTheme(const QStringList& iconNames, const QIcon& fallback) QIcon XdgIcon::fromTheme(const QStringList& iconNames, const QIcon& fallback)
{ {
foreach (const QString &iconName, iconNames) Q_FOREACH (const QString &iconName, iconNames)
{ {
QIcon icon = fromTheme(iconName); QIcon icon = fromTheme(iconName);
if (!icon.isNull()) if (!icon.isNull())
@ -164,6 +145,17 @@ QIcon XdgIcon::fromTheme(const QString &iconName,
return fromTheme(icons); return fromTheme(icons);
} }
bool XdgIcon::followColorScheme()
{
return XdgIconLoader::instance()->followColorScheme();
}
void XdgIcon::setFollowColorScheme(bool enable)
{
XdgIconLoader::instance()->setFollowColorScheme(enable);
}
QIcon XdgIcon::defaultApplicationIcon() QIcon XdgIcon::defaultApplicationIcon()
{ {

@ -44,8 +44,19 @@ public:
const QString &fallbackIcon4 = QString()); const QString &fallbackIcon4 = QString());
static QIcon fromTheme(const QStringList& iconNames, const QIcon& fallback = QIcon()); static QIcon fromTheme(const QStringList& iconNames, const QIcon& fallback = QIcon());
static QString themeName(); /*!
static void setThemeName(const QString& themeName); * Flag if the "FollowsColorScheme" hint (the KDE extension to XDG
* themes) should be honored. If enabled and the icon theme supports
* this, the icon engine "colorizes" icons based on the application's
* palette.
*
* Default is true (use this extension).
*/
static bool followColorScheme();
static void setFollowColorScheme(bool enable);
/* TODO: deprecate & remove all QIcon wrappers */
static QString themeName() { return QIcon::themeName(); }
static void setThemeName(const QString& themeName) { QIcon::setThemeName(themeName); }
static QIcon defaultApplicationIcon(); static QIcon defaultApplicationIcon();
static QString defaultApplicationIconName(); static QString defaultApplicationIconName();

@ -205,8 +205,7 @@ void XdgMenu::save(const QString& fileName)
if (!file.open(QFile::WriteOnly | QFile::Text)) if (!file.open(QFile::WriteOnly | QFile::Text))
{ {
qWarning() << QString::fromLatin1("Cannot write file %1:\n%2.") qWarning() << QString::fromLatin1("Cannot write file %1:\n%2.")
.arg(fileName) .arg(fileName, file.errorString());
.arg(file.errorString());
return; return;
} }
@ -225,7 +224,7 @@ void XdgMenuPrivate::load(const QString& fileName)
QFile file(fileName); QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) if (!file.open(QFile::ReadOnly | QFile::Text))
{ {
qWarning() << QString::fromLatin1("%1 not loading: %2").arg(fileName).arg(file.errorString()); qWarning() << QString::fromLatin1("%1 not loading: %2").arg(fileName, file.errorString());
return; return;
} }
mXml.setContent(&file, true); mXml.setContent(&file, true);
@ -413,7 +412,7 @@ QDomElement XdgMenu::findMenu(QDomElement& baseElement, const QString& path, boo
const QStringList names = path.split(QLatin1Char('/'), QString::SkipEmptyParts); const QStringList names = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
QDomElement el = baseElement; QDomElement el = baseElement;
foreach (const QString &name, names) Q_FOREACH (const QString &name, names)
{ {
QDomElement p = el; QDomElement p = el;
el = d->mXml.createElement(QLatin1String("Menu")); el = d->mXml.createElement(QLatin1String("Menu"));
@ -538,12 +537,12 @@ void XdgMenuPrivate::processDirectoryEntries(QDomElement& element, const QString
dirs << parentDirs; dirs << parentDirs;
bool found = false; bool found = false;
foreach(const QString &file, files){ Q_FOREACH(const QString &file, files){
if (file.startsWith(QLatin1Char('/'))) if (file.startsWith(QLatin1Char('/')))
found = loadDirectoryFile(file, element); found = loadDirectoryFile(file, element);
else else
{ {
foreach (const QString &dir, dirs) Q_FOREACH (const QString &dir, dirs)
{ {
found = loadDirectoryFile(dir + QLatin1Char('/') + file, element); found = loadDirectoryFile(dir + QLatin1Char('/') + file, element);
if (found) break; if (found) break;
@ -652,7 +651,7 @@ QString XdgMenu::getMenuFileName(const QString& baseName)
const QStringList configDirs = XdgDirs::configDirs(); const QStringList configDirs = XdgDirs::configDirs();
QString menuPrefix = QString::fromLocal8Bit(qgetenv("XDG_MENU_PREFIX")); QString menuPrefix = QString::fromLocal8Bit(qgetenv("XDG_MENU_PREFIX"));
foreach(const QString &configDir, configDirs) Q_FOREACH(const QString &configDir, configDirs)
{ {
QFileInfo file(QString::fromLatin1("%1/menus/%2%3").arg(configDir, menuPrefix, baseName)); QFileInfo file(QString::fromLatin1("%1/menus/%2%3").arg(configDir, menuPrefix, baseName));
if (file.exists()) if (file.exists())
@ -670,9 +669,9 @@ QString XdgMenu::getMenuFileName(const QString& baseName)
wellKnownFiles << QLatin1String("gnome-applications.menu"); wellKnownFiles << QLatin1String("gnome-applications.menu");
wellKnownFiles << QLatin1String("lxde-applications.menu"); wellKnownFiles << QLatin1String("lxde-applications.menu");
foreach(const QString &configDir, configDirs) Q_FOREACH(const QString &configDir, configDirs)
{ {
foreach (const QString &f, wellKnownFiles) Q_FOREACH (const QString &f, wellKnownFiles)
{ {
QFileInfo file(QString::fromLatin1("%1/menus/%2").arg(configDir, f)); QFileInfo file(QString::fromLatin1("%1/menus/%2").arg(configDir, f));
if (file.exists()) if (file.exists())
@ -715,7 +714,7 @@ void XdgMenuPrivate::rebuild()
if (prevHash != mHash) if (prevHash != mHash)
{ {
mOutDated = true; mOutDated = true;
emit changed(); Q_EMIT changed();
} }
} }

@ -112,7 +112,7 @@ public:
bool isOutDated() const; bool isOutDated() const;
signals: Q_SIGNALS:
void changed(); void changed();
protected: protected:

@ -73,10 +73,10 @@ public:
QFileSystemWatcher mWatcher; QFileSystemWatcher mWatcher;
bool mOutDated; bool mOutDated;
public slots: public Q_SLOTS:
void rebuild(); void rebuild();
signals: Q_SIGNALS:
void changed(); void changed();

@ -90,7 +90,7 @@ void XdgMenuApplinkProcessor::step1()
} }
// Process childs menus ............................... // Process childs menus ...............................
foreach (XdgMenuApplinkProcessor* child, mChilds) Q_FOREACH (XdgMenuApplinkProcessor* child, mChilds)
child->step1(); child->step1();
} }
@ -100,7 +100,7 @@ void XdgMenuApplinkProcessor::step2()
// Create AppLinks elements ........................... // Create AppLinks elements ...........................
QDomDocument doc = mElement.ownerDocument(); QDomDocument doc = mElement.ownerDocument();
foreach (XdgMenuAppFileInfo* fileInfo, mSelected) Q_FOREACH (XdgMenuAppFileInfo* fileInfo, mSelected)
{ {
if (mOnlyUnallocated && fileInfo->allocated()) if (mOnlyUnallocated && fileInfo->allocated())
continue; continue;
@ -141,7 +141,7 @@ void XdgMenuApplinkProcessor::step2()
// Process childs menus ............................... // Process childs menus ...............................
foreach (XdgMenuApplinkProcessor* child, mChilds) Q_FOREACH (XdgMenuApplinkProcessor* child, mChilds)
child->step2(); child->step2();
} }
@ -189,7 +189,7 @@ void XdgMenuApplinkProcessor::findDesktopFiles(const QString& dirName, const QSt
mMenu->addWatchPath(dir.absolutePath()); mMenu->addWatchPath(dir.absolutePath());
const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files); const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files);
foreach (const QFileInfo &file, files) Q_FOREACH (const QFileInfo &file, files)
{ {
XdgDesktopFile* f = XdgDesktopFileCache::getFile(file.canonicalFilePath()); XdgDesktopFile* f = XdgDesktopFileCache::getFile(file.canonicalFilePath());
if (f) if (f)
@ -199,7 +199,7 @@ void XdgMenuApplinkProcessor::findDesktopFiles(const QString& dirName, const QSt
// Working recursively ............ // Working recursively ............
const QFileInfoList dirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot); const QFileInfoList dirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QFileInfo &d, dirs) Q_FOREACH (const QFileInfo &d, dirs)
{ {
QString dn = d.canonicalFilePath(); QString dn = d.canonicalFilePath();
if (dn != dirName) if (dn != dirName)
@ -242,7 +242,7 @@ bool XdgMenuApplinkProcessor::checkTryExec(const QString& progName)
const QStringList dirs = QFile::decodeName(qgetenv("PATH")).split(QLatin1Char(':')); const QStringList dirs = QFile::decodeName(qgetenv("PATH")).split(QLatin1Char(':'));
foreach (const QString &dir, dirs) Q_FOREACH (const QString &dir, dirs)
{ {
if (QFileInfo(QDir(dir), progName).isExecutable()) if (QFileInfo(QDir(dir), progName).isExecutable())
return true; return true;

@ -76,7 +76,7 @@ bool XdgMenuReader::load(const QString& fileName, const QString& baseDir)
QFile file(mFileName); QFile file(mFileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) if (!file.open(QFile::ReadOnly | QFile::Text))
{ {
mErrorStr = QString::fromLatin1("%1 not loading: %2").arg(fileName).arg(file.errorString()); mErrorStr = QString::fromLatin1("%1 not loading: %2").arg(fileName, file.errorString());
return false; return false;
} }
//qDebug() << "Load file:" << mFileName; //qDebug() << "Load file:" << mFileName;
@ -215,7 +215,7 @@ void XdgMenuReader::processMergeFileTag(QDomElement& element, QStringList* merge
QString relativeName; QString relativeName;
QStringList configDirs = XdgDirs::configDirs(); QStringList configDirs = XdgDirs::configDirs();
foreach (const QString &configDir, configDirs) Q_FOREACH (const QString &configDir, configDirs)
{ {
if (mFileName.startsWith(configDir)) if (mFileName.startsWith(configDir))
{ {
@ -236,9 +236,9 @@ void XdgMenuReader::processMergeFileTag(QDomElement& element, QStringList* merge
if (relativeName.isEmpty()) if (relativeName.isEmpty())
return; return;
foreach (const QString &configDir, configDirs) Q_FOREACH (const QString &configDir, configDirs)
{ {
if (QFileInfo(configDir + relativeName).exists()) if (QFileInfo::exists(configDir + relativeName))
{ {
mergeFile(configDir + relativeName, element, mergedFiles); mergeFile(configDir + relativeName, element, mergedFiles);
return; return;
@ -295,9 +295,9 @@ void XdgMenuReader::processDefaultMergeDirsTag(QDomElement& element, QStringList
QStringList dirs = XdgDirs::configDirs(); QStringList dirs = XdgDirs::configDirs();
dirs << XdgDirs::configHome(); dirs << XdgDirs::configHome();
foreach (const QString &dir, dirs) Q_FOREACH (const QString &dir, dirs)
{ {
mergeDir(QString::fromLatin1("%1/menus/%2-merged").arg(dir).arg(menuBaseName), element, mergedFiles); mergeDir(QString::fromLatin1("%1/menus/%2-merged").arg(dir, menuBaseName), element, mergedFiles);
} }
if (menuBaseName == QLatin1String("applications")) if (menuBaseName == QLatin1String("applications"))
@ -329,7 +329,7 @@ void XdgMenuReader::processDefaultAppDirsTag(QDomElement& element)
QStringList dirs = XdgDirs::dataDirs(); QStringList dirs = XdgDirs::dataDirs();
dirs.prepend(XdgDirs::dataHome(false)); dirs.prepend(XdgDirs::dataHome(false));
foreach (const QString &dir, dirs) Q_FOREACH (const QString &dir, dirs)
{ {
//qDebug() << "Add AppDir: " << dir + "/applications/"; //qDebug() << "Add AppDir: " << dir + "/applications/";
addDirTag(element, QLatin1String("AppDir"), dir + QLatin1String("/applications/")); addDirTag(element, QLatin1String("AppDir"), dir + QLatin1String("/applications/"));
@ -360,7 +360,7 @@ void XdgMenuReader::processDefaultDirectoryDirsTag(QDomElement& element)
QStringList dirs = XdgDirs::dataDirs(); QStringList dirs = XdgDirs::dataDirs();
dirs.prepend(XdgDirs::dataHome(false)); dirs.prepend(XdgDirs::dataHome(false));
foreach (const QString &dir, dirs) Q_FOREACH (const QString &dir, dirs)
addDirTag(element, QLatin1String("DirectoryDir"), dir + QLatin1String("/desktop-directories/")); addDirTag(element, QLatin1String("DirectoryDir"), dir + QLatin1String("/desktop-directories/"));
} }
@ -431,7 +431,7 @@ void XdgMenuReader::mergeDir(const QString& dirName, QDomElement& element, QStri
QDir dir = QDir(dirInfo.canonicalFilePath()); QDir dir = QDir(dirInfo.canonicalFilePath());
const QFileInfoList files = dir.entryInfoList(QStringList() << QLatin1String("*.menu"), QDir::Files | QDir::Readable); const QFileInfoList files = dir.entryInfoList(QStringList() << QLatin1String("*.menu"), QDir::Files | QDir::Readable);
foreach (const QFileInfo &file, files) Q_FOREACH (const QFileInfo &file, files)
mergeFile(file.canonicalFilePath(), element, mergedFiles); mergeFile(file.canonicalFilePath(), element, mergedFiles);
} }
} }

@ -47,9 +47,9 @@ public:
QString errorString() const { return mErrorStr; } QString errorString() const { return mErrorStr; }
QDomDocument& xml() { return mXml; } QDomDocument& xml() { return mXml; }
signals: Q_SIGNALS:
public slots: public Q_SLOTS:
protected: protected:
void processMergeTags(QDomElement& element); void processMergeTags(QDomElement& element);

@ -44,7 +44,7 @@ class XdgMenuWidgetPrivate
{ {
private: private:
XdgMenuWidget* const q_ptr; XdgMenuWidget* const q_ptr;
Q_DECLARE_PUBLIC(XdgMenuWidget); Q_DECLARE_PUBLIC(XdgMenuWidget)
public: public:
explicit XdgMenuWidgetPrivate(XdgMenuWidget* parent): explicit XdgMenuWidgetPrivate(XdgMenuWidget* parent):
@ -186,7 +186,7 @@ void XdgMenuWidgetPrivate::buildMenu()
QAction* first = 0; QAction* first = 0;
if (!q->actions().isEmpty()) if (!q->actions().isEmpty())
first = q->actions().last(); first = q->actions().constLast();
DomElementIterator it(mXml, QString()); DomElementIterator it(mXml, QString());

@ -96,7 +96,7 @@ QString XdgMimeType::iconName() const
names.append(QMimeType::iconName()); names.append(QMimeType::iconName());
names.append(QMimeType::genericIconName()); names.append(QMimeType::genericIconName());
foreach (const QString &s, names) { Q_FOREACH (const QString &s, names) {
if (!XdgIcon::fromTheme(s).isNull()) { if (!XdgIcon::fromTheme(s).isNull()) {
dx->iconName = s; dx->iconName = s;
break; break;

@ -41,6 +41,6 @@ QDebug operator<<(QDebug dbg, const QDomElement &el)
for (int i=0; i<map.count(); ++i) for (int i=0; i<map.count(); ++i)
args += QLatin1Char(' ') + map.item(i).nodeName() + QLatin1Char('=') + map.item(i).nodeValue() + QLatin1Char('\''); args += QLatin1Char(' ') + map.item(i).nodeName() + QLatin1Char('=') + map.item(i).nodeValue() + QLatin1Char('\'');
dbg.nospace() << QString::fromLatin1("<%1%2>%3</%1>").arg(el.tagName()).arg(args).arg(el.text()); dbg.nospace() << QString::fromLatin1("<%1%2>%3</%1>").arg(el.tagName(), args, el.text());
return dbg.space(); return dbg.space();
} }

@ -1,28 +0,0 @@
#!/bin/bash
PROJECT="libqtxdg"
version="$1"
prefix=$PROJECT-$version
shift
if [[ -z $version ]]; then
>&2 echo "USAGE: $0 <tag>"
exit 1
fi
mkdir -p "dist/$version"
echo "Creating $prefix.tar.gz"
git archive -9 --format tar.gz $version --prefix="$prefix/" > "dist/$version/$prefix.tar.gz"
gpg --armor --detach-sign "dist/$version/$prefix.tar.gz"
echo "Creating $prefix.tar.xz"
git archive -9 --format tar.xz $version --prefix="$prefix/" > "dist/$version/$prefix.tar.xz"
gpg --armor --detach-sign "dist/$version/$prefix.tar.xz"
cd "dist/$version"
sha1sum --tag *.tar.gz *.tar.xz >> CHECKSUMS
sha256sum --tag *.tar.gz *.tar.xz >> CHECKSUMS
cd ..
echo "Uploading to lxqt.org..."
scp -r "$version" "downloads.lxqt.org:/srv/downloads.lxqt.org/$PROJECT/"

@ -1,25 +1,25 @@
set(PROJECT_NAME "qtxdg_test")
remove_definitions( remove_definitions(
-DQT_USE_QSTRINGBUILDER -DQT_USE_QSTRINGBUILDER
-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_ASCII
) )
set(CMAKE_AUTOMOC TRUE) add_definitions(
-DQT_NO_KEYWORDS
)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
macro(qtxdg_add_test) macro(qtxdg_add_test)
foreach(_testname ${ARGN}) foreach(_testname ${ARGN})
add_executable(${_testname} ${_testname}.cpp) add_executable(${_testname} ${_testname}.cpp)
target_link_libraries(${_testname} Qt5::Test ${QTXDGX_LIBRARY_NAME}) target_link_libraries(${_testname} Qt5::Test ${QTXDGX_LIBRARY_NAME})
target_include_directories(${_testname}
PRIVATE "${PROJECT_SOURCE_DIR}/qtxdg"
)
add_test(NAME ${_testname} COMMAND ${_testname}) add_test(NAME ${_testname} COMMAND ${_testname})
endforeach() endforeach()
endmacro() endmacro()
include_directories (
"${CMAKE_SOURCE_DIR}/qtxdg"
${CMAKE_CURRENT_BINARY_DIR}
)
set_property(DIRECTORY APPEND set_property(DIRECTORY APPEND
PROPERTY COMPILE_DEFINITIONS "QTXDG_BUILDING_TESTS=\"1\"" PROPERTY COMPILE_DEFINITIONS "QTXDG_BUILDING_TESTS=\"1\""
) )

@ -47,15 +47,15 @@ void QtXdgTest::testDefaultApp()
{ {
QStringList mimedirs = XdgDirs::dataDirs(); QStringList mimedirs = XdgDirs::dataDirs();
mimedirs.prepend(XdgDirs::dataHome(false)); mimedirs.prepend(XdgDirs::dataHome(false));
foreach (QString mimedir, mimedirs) Q_FOREACH (QString mimedir, mimedirs)
{ {
QDir dir(mimedir + "/mime"); QDir dir(mimedir + "/mime");
qDebug() << dir.path(); qDebug() << dir.path();
QStringList filters = (QStringList() << "*.xml"); QStringList filters = (QStringList() << "*.xml");
foreach(QFileInfo mediaDir, dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) Q_FOREACH(QFileInfo mediaDir, dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
{ {
qDebug() << " " << mediaDir.fileName(); qDebug() << " " << mediaDir.fileName();
foreach (QString mimeXmlFileName, QDir(mediaDir.absoluteFilePath()).entryList(filters, QDir::Files)) Q_FOREACH (QString mimeXmlFileName, QDir(mediaDir.absoluteFilePath()).entryList(filters, QDir::Files))
{ {
QString mimetype = mediaDir.fileName() + "/" + mimeXmlFileName.left(mimeXmlFileName.length() - 4); QString mimetype = mediaDir.fileName() + "/" + mimeXmlFileName.left(mimeXmlFileName.length() - 4);
QString xdg_utils_default = xdgUtilDefaultApp(mimetype); QString xdg_utils_default = xdgUtilDefaultApp(mimetype);

@ -39,7 +39,7 @@ class QtXdgTest : public QObject
{ {
Q_OBJECT Q_OBJECT
private slots: private Q_SLOTS:
void testCustomFormat(); void testCustomFormat();
private: private:

@ -27,20 +27,20 @@ class Language
{ {
public: public:
Language (const QString& lang) Language (const QString& lang)
: mPreviousLang(QString::fromLocal8Bit(qgetenv("LANG"))) : mPreviousLang(QString::fromLocal8Bit(qgetenv("LC_MESSAGES")))
{ {
qputenv("LANG", lang.toLocal8Bit()); qputenv("LC_MESSAGES", lang.toLocal8Bit());
} }
~Language() ~Language()
{ {
qputenv("LANG", mPreviousLang.toLocal8Bit()); qputenv("LC_MESSAGES", mPreviousLang.toLocal8Bit());
} }
private: private:
QString mPreviousLang; QString mPreviousLang;
}; };
QTEST_MAIN(tst_xdgdesktopfile); QTEST_MAIN(tst_xdgdesktopfile)
void tst_xdgdesktopfile::testRead() void tst_xdgdesktopfile::testRead()
{ {

@ -25,7 +25,7 @@
class tst_xdgdesktopfile : public QObject { class tst_xdgdesktopfile : public QObject {
Q_OBJECT Q_OBJECT
private slots: private Q_SLOTS:
void testRead(); void testRead();
void testReadLocalized(); void testReadLocalized();

@ -36,7 +36,7 @@ class tst_xdgdirs : public QObject
{ {
Q_OBJECT Q_OBJECT
private slots: private Q_SLOTS:
void initTestCase(); void initTestCase();
void cleanupTestCase(); void cleanupTestCase();

@ -1,26 +1,52 @@
include_directories ( set(CMAKE_INCLUDE_CURRENT_DIR ON)
"${CMAKE_PROJECT_DIR}/qtxdg"
${CMAKE_CURRENT_BINARY_DIR}
)
set(QTXDG_DESKTOP_FILE_START_SRCS set(QTXDG_DESKTOP_FILE_START_SRCS
qtxdg-desktop-file-start.cpp qtxdg-desktop-file-start.cpp
) )
set(QTXDG_ICONFINDER_SRCS
qtxdg-iconfinder.cpp
)
add_executable(qtxdg-desktop-file-start add_executable(qtxdg-desktop-file-start
${QTXDG_DESKTOP_FILE_START_SRCS} ${QTXDG_DESKTOP_FILE_START_SRCS}
) )
add_executable(qtxdg-iconfinder
${QTXDG_ICONFINDER_SRCS}
)
target_include_directories(qtxdg-desktop-file-start
PRIVATE "${PROJECT_SOURCE_DIR}/qtxdg"
)
target_include_directories(qtxdg-iconfinder
PRIVATE "${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
)
target_compile_definitions(qtxdg-desktop-file-start target_compile_definitions(qtxdg-desktop-file-start
PRIVATE "-DQTXDG_VERSION=\"${QTXDG_VERSION_STRING}\"" PRIVATE
"-DQTXDG_VERSION=\"${QTXDG_VERSION_STRING}\""
"QT_NO_KEYWORDS"
)
target_compile_definitions(qtxdg-iconfinder
PRIVATE
"-DQTXDG_VERSION=\"${QTXDG_VERSION_STRING}\""
"QT_NO_KEYWORDS"
) )
target_link_libraries(qtxdg-desktop-file-start target_link_libraries(qtxdg-desktop-file-start
${QTXDGX_LIBRARY_NAME} ${QTXDGX_LIBRARY_NAME}
) )
target_link_libraries(qtxdg-iconfinder
${QTXDGX_ICONLOADER_LIBRARY_NAME}
)
install(TARGETS install(TARGETS
qtxdg-desktop-file-start qtxdg-desktop-file-start
qtxdg-iconfinder
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT Runtime COMPONENT Runtime
) )

@ -0,0 +1,74 @@
/*
* libqtxdg - An Qt implementation of freedesktop.org xdg specs
* Copyright (C) 2017 Luís Pereira <luis.artur.pereira@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include <QGuiApplication> // XdgIconLoader needs a QGuiApplication
#include <QCommandLineParser>
#include <QElapsedTimer>
#include <private/xdgiconloader/xdgiconloader_p.h>
#include <iostream>
#include <QDebug>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
app.setApplicationName(QStringLiteral("qtxdg-iconfinder"));
app.setApplicationVersion(QStringLiteral(QTXDG_VERSION));
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("QtXdg icon finder"));
parser.addPositionalArgument(QStringLiteral("iconnames"),
QStringLiteral("The icon names to search for"),
QStringLiteral("[iconnames...]"));
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);
if (parser.positionalArguments().isEmpty())
parser.showHelp(EXIT_FAILURE);
qint64 totalElapsed = 0;
const auto icons = parser.positionalArguments();
for (const QString& iconName : icons) {
QElapsedTimer t;
t.start();
const auto info = XdgIconLoader::instance()->loadIcon(iconName);
qint64 elapsed = t.elapsed();
const auto icon = info.iconName;
const auto entries = info.entries;
std::cout << qPrintable(iconName) <<
qPrintable(QString::fromLatin1(":")) << qPrintable(icon) <<
qPrintable(QString::fromLatin1(":")) <<
qPrintable(QString::number(elapsed)) << "\n";
for (const auto &i : entries) {
std::cout << "\t" << qPrintable(i->filename) << "\n";
}
totalElapsed += elapsed;
}
std::cout << qPrintable(QString::fromLatin1("Total loadIcon() time: ")) <<
qPrintable(QString::number(totalElapsed)) <<
qPrintable(QString::fromLatin1(" ms")) << "\n";
return EXIT_SUCCESS;
}

@ -1,7 +1,3 @@
include_directories(
"${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
)
set(xdgiconloader_PUBLIC_H_FILES set(xdgiconloader_PUBLIC_H_FILES
) )
@ -38,17 +34,22 @@ configure_file(
COPYONLY COPYONLY
) )
target_include_directories(${QTXDGX_ICONLOADER_LIBRARY_NAME} target_compile_definitions(${QTXDGX_ICONLOADER_LIBRARY_NAME}
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}>" PRIVATE
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "QT_NO_KEYWORDS"
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}>"
) )
# include directories and targets for the in tree build
target_include_directories(${QTXDGX_ICONLOADER_LIBRARY_NAME} target_include_directories(${QTXDGX_ICONLOADER_LIBRARY_NAME}
PUBLIC "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}>" INTERFACE
PUBLIC "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}>"
PUBLIC "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}>"
PUBLIC
"$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}>"
"$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}>"
"$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}>"
PRIVATE
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
) )
target_link_libraries(${QTXDGX_ICONLOADER_LIBRARY_NAME} target_link_libraries(${QTXDGX_ICONLOADER_LIBRARY_NAME}
@ -63,7 +64,7 @@ set_target_properties(${QTXDGX_ICONLOADER_LIBRARY_NAME}
SOVERSION ${QTXDG_MAJOR_VERSION} SOVERSION ${QTXDG_MAJOR_VERSION}
) )
export(TARGETS ${QTXDGX_ICONLOADER_LIBRARY_NAME} FILE "${CMAKE_BINARY_DIR}/${QTXDGX_ICONLOADER_FILE_NAME}-targets.cmake") add_subdirectory(plugin)
install(TARGETS install(TARGETS
${QTXDGX_ICONLOADER_LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}" ${QTXDGX_ICONLOADER_LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}"
@ -77,6 +78,11 @@ install(FILES
COMPONENT Devel COMPONENT Devel
) )
file(COPY
${xdgiconloader_PRIVATE_INSTALLABLE_H_FILES}
DESTINATION "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}/private/xdgiconloader"
)
install(FILES install(FILES
"${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${XDGICONLOADER_EXPORT_FILE}" "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${XDGICONLOADER_EXPORT_FILE}"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}"

@ -0,0 +1,49 @@
set(xdgiconengineplugin_CPP_FILES
xdgiconengineplugin.cpp
)
add_library(${QTXDGX_ICONENGINEPLUGIN_LIBRARY_NAME} MODULE
${xdgiconengineplugin_CPP_FILES}
)
target_compile_definitions(${QTXDGX_ICONENGINEPLUGIN_LIBRARY_NAME}
PRIVATE
"QT_NO_KEYWORDS"
)
target_link_libraries(${QTXDGX_ICONENGINEPLUGIN_LIBRARY_NAME}
PUBLIC
Qt5::Gui
"${QTXDGX_ICONLOADER_LIBRARY_NAME}"
)
target_include_directories("${QTXDGX_ICONENGINEPLUGIN_LIBRARY_NAME}"
PRIVATE
"${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
)
mark_as_advanced(QTXDGX_ICONENGINEPLUGIN_INSTALL_PATH)
if (NOT DEFINED QTXDGX_ICONENGINEPLUGIN_INSTALL_PATH)
get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "qmake is not found.")
endif()
# execute the command "qmake -query QT_INSTALL_PLUGINS" to get the path of plugins dir.
execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query QT_INSTALL_PLUGINS
OUTPUT_VARIABLE QT_PLUGINS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT QT_PLUGINS_DIR)
message(FATAL_ERROR "Qt5 plugin directory cannot be detected.")
endif()
set(QTXDGX_ICONENGINEPLUGIN_INSTALL_PATH "${QT_PLUGINS_DIR}/iconengines")
endif()
message(STATUS "XdgIconEnginePlugin will be installed into: ${QTXDGX_ICONENGINEPLUGIN_INSTALL_PATH}")
install(TARGETS
"${QTXDGX_ICONENGINEPLUGIN_LIBRARY_NAME}" DESTINATION "${QTXDGX_ICONENGINEPLUGIN_INSTALL_PATH}"
COMPONENT Runtime
)

@ -0,0 +1,35 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight Qt based desktop
* http://lxqt.org
*
* Copyright: 2017 LXQt team
* Authors:
* Palo Kisa <palo.kisa@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "xdgiconengineplugin.h"
#include "../xdgiconloader_p.h"
QIconEngine * XdgIconEnginePlugin::create(const QString & filename/* = QString{}*/)
{
return new XdgIconLoaderEngine{filename};
}

@ -0,0 +1,38 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight Qt based desktop
* http://lxqt.org
*
* Copyright: 2017 LXQt team
* Authors:
* Palo Kisa <palo.kisa@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include <QIconEnginePlugin>
class XdgIconEnginePlugin : public QIconEnginePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QIconEngineFactoryInterface" FILE "xdgiconengineplugin.json")
public:
using QIconEnginePlugin::QIconEnginePlugin;
virtual QIconEngine * create(const QString & filename = QString{}) override;
};

@ -0,0 +1 @@
{"Keys": ["XdgIconLoaderEngine"]}

@ -45,6 +45,8 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QPainter> #include <QtGui/QPainter>
#include <QImageReader>
#include <QXmlStreamReader>
#ifdef Q_DEAD_CODE_FROM_QT4_MAC #ifdef Q_DEAD_CODE_FROM_QT4_MAC
#include <private/qt_cocoa_helpers_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h>
@ -62,104 +64,36 @@ static QString fallbackTheme()
{ {
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const QVariant themeHint = theme->themeHint(QPlatformTheme::SystemIconFallbackThemeName); const QVariant themeHint = theme->themeHint(QPlatformTheme::SystemIconFallbackThemeName);
if (themeHint.isValid()) if (themeHint.isValid()) {
return themeHint.toString(); const QString theme = themeHint.toString();
} if (theme != QLatin1String("hicolor"))
return QLatin1String("hicolor"); return theme;
} }
XdgIconLoader::XdgIconLoader() :
m_themeKey(1), m_supportsSvg(false), m_initialized(false)
{
}
static inline QString systemThemeName()
{
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const QVariant themeHint = theme->themeHint(QPlatformTheme::SystemIconThemeName);
if (themeHint.isValid())
return themeHint.toString();
}
return QIcon::themeName();
}
static inline QStringList systemIconSearchPaths()
{
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const QVariant themeHint = theme->themeHint(QPlatformTheme::IconThemeSearchPaths);
if (themeHint.isValid())
return themeHint.toStringList();
} }
return QIcon::themeSearchPaths(); return QString();
} }
#ifndef QT_NO_LIBRARY #ifdef QT_NO_LIBRARY
//extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp static bool gSupportsSvg = false;
#endif #else
static bool gSupportsSvg = true;
#endif //QT_NO_LIBRARY
void XdgIconLoader::ensureInitialized() void XdgIconLoader::setFollowColorScheme(bool enable)
{ {
if (!m_initialized) { if (m_followColorScheme != enable)
m_initialized = true; {
QIconLoader::instance()->invalidateKey();
Q_ASSERT(qApp); m_followColorScheme = enable;
m_systemTheme = systemThemeName();
if (m_systemTheme.isEmpty())
m_systemTheme = fallbackTheme();
#ifndef QT_NO_LIBRARY
// if (qt_iconEngineFactoryLoader()->keyMap().key(QLatin1String("svg"), -1) != -1)
m_supportsSvg = true;
#endif //QT_NO_LIBRARY
} }
} }
XdgIconLoader *XdgIconLoader::instance() XdgIconLoader *XdgIconLoader::instance()
{ {
iconLoaderInstance()->ensureInitialized(); QIconLoader::instance()->ensureInitialized();
return iconLoaderInstance(); return iconLoaderInstance();
} }
// Queries the system theme and invalidates existing
// icons if the theme has changed.
void XdgIconLoader::updateSystemTheme()
{
// Only change if this is not explicitly set by the user
if (m_userTheme.isEmpty()) {
QString theme = systemThemeName();
if (theme.isEmpty())
theme = fallbackTheme();
if (theme != m_systemTheme) {
m_systemTheme = theme;
invalidateKey();
}
}
}
void XdgIconLoader::setThemeName(const QString &themeName)
{
m_userTheme = themeName;
invalidateKey();
}
void XdgIconLoader::setThemeSearchPath(const QStringList &searchPaths)
{
m_iconDirs = searchPaths;
themeList.clear();
invalidateKey();
}
QStringList XdgIconLoader::themeSearchPaths() const
{
if (m_iconDirs.isEmpty()) {
m_iconDirs = systemIconSearchPaths();
// Always add resource directory as search path
m_iconDirs.append(QLatin1String(":/icons"));
}
return m_iconDirs;
}
/*! /*!
\class QIconCacheGtkReader \class QIconCacheGtkReader
\internal \internal
@ -172,7 +106,7 @@ class QIconCacheGtkReader
{ {
public: public:
explicit QIconCacheGtkReader(const QString &themeDir); explicit QIconCacheGtkReader(const QString &themeDir);
QVector<const char *> lookup(const QString &); QVector<const char *> lookup(const QStringRef &);
bool isValid() const { return m_isValid; } bool isValid() const { return m_isValid; }
private: private:
QFile m_file; QFile m_file;
@ -203,7 +137,7 @@ private:
QIconCacheGtkReader::QIconCacheGtkReader(const QString &dirName) QIconCacheGtkReader::QIconCacheGtkReader(const QString &dirName)
: m_isValid(false) : m_isValid(false)
{ {
QFileInfo info(dirName + QLatin1Literal("/icon-theme.cache")); QFileInfo info(dirName + QLatin1String("/icon-theme.cache"));
if (!info.exists() || info.lastModified() < QFileInfo(dirName).lastModified()) if (!info.exists() || info.lastModified() < QFileInfo(dirName).lastModified())
return; return;
m_file.setFileName(info.absoluteFilePath()); m_file.setFileName(info.absoluteFilePath());
@ -245,7 +179,7 @@ static quint32 icon_name_hash(const char *p)
with this name is present. The char* are pointers to the mapped data. with this name is present. The char* are pointers to the mapped data.
For example, this would return { "32x32/apps", "24x24/apps" , ... } For example, this would return { "32x32/apps", "24x24/apps" , ... }
*/ */
QVector<const char *> QIconCacheGtkReader::lookup(const QString &name) QVector<const char *> QIconCacheGtkReader::lookup(const QStringRef &name)
{ {
QVector<const char *> ret; QVector<const char *> ret;
if (!isValid()) if (!isValid())
@ -295,12 +229,13 @@ QVector<const char *> QIconCacheGtkReader::lookup(const QString &name)
return ret; return ret;
} }
QIconTheme::QIconTheme(const QString &themeName) XdgIconTheme::XdgIconTheme(const QString &themeName)
: m_valid(false) : m_valid(false)
, m_followsColorScheme(false)
{ {
QFile themeIndex; QFile themeIndex;
QStringList iconDirs = QIcon::themeSearchPaths(); const QStringList iconDirs = QIcon::themeSearchPaths();
for ( int i = 0 ; i < iconDirs.size() ; ++i) { for ( int i = 0 ; i < iconDirs.size() ; ++i) {
QDir iconDir(iconDirs[i]); QDir iconDir(iconDirs[i]);
QString themeDir = iconDir.path() + QLatin1Char('/') + themeName; QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
@ -320,27 +255,26 @@ QIconTheme::QIconTheme(const QString &themeName)
#ifndef QT_NO_SETTINGS #ifndef QT_NO_SETTINGS
if (themeIndex.exists()) { if (themeIndex.exists()) {
const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat); const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
QStringListIterator keyIterator(indexReader.allKeys()); m_followsColorScheme = indexReader.value(QStringLiteral("Icon Theme/FollowsColorScheme"), false).toBool();
while (keyIterator.hasNext()) { const QStringList keys = indexReader.allKeys();
for (auto const &key : keys) {
const QString key = keyIterator.next();
if (key.endsWith(QLatin1String("/Size"))) { if (key.endsWith(QLatin1String("/Size"))) {
// Note the QSettings ini-format does not accept // Note the QSettings ini-format does not accept
// slashes in key names, hence we have to cheat // slashes in key names, hence we have to cheat
if (int size = indexReader.value(key).toInt()) { if (int size = indexReader.value(key).toInt()) {
QString directoryKey = key.left(key.size() - 5); QString directoryKey = key.left(key.size() - 5);
XdgIconDirInfo dirInfo(directoryKey); QIconDirInfo dirInfo(directoryKey);
dirInfo.size = size; dirInfo.size = size;
QString type = indexReader.value(directoryKey + QString type = indexReader.value(directoryKey +
QLatin1String("/Type") QLatin1String("/Type")
).toString(); ).toString();
if (type == QLatin1String("Fixed")) if (type == QLatin1String("Fixed"))
dirInfo.type = XdgIconDirInfo::Fixed; dirInfo.type = QIconDirInfo::Fixed;
else if (type == QLatin1String("Scalable")) else if (type == QLatin1String("Scalable"))
dirInfo.type = XdgIconDirInfo::Scalable; dirInfo.type = QIconDirInfo::Scalable;
else else
dirInfo.type = XdgIconDirInfo::Threshold; dirInfo.type = QIconDirInfo::Threshold;
dirInfo.threshold = indexReader.value(directoryKey + dirInfo.threshold = indexReader.value(directoryKey +
QLatin1String("/Threshold"), QLatin1String("/Threshold"),
@ -362,6 +296,7 @@ QIconTheme::QIconTheme(const QString &themeName)
m_parents = indexReader.value( m_parents = indexReader.value(
QLatin1String("Icon Theme/Inherits")).toStringList(); QLatin1String("Icon Theme/Inherits")).toStringList();
m_parents.removeAll(QString()); m_parents.removeAll(QString());
m_parents.removeAll(QLatin1String("hicolor"));
// Ensure a default platform fallback for all themes // Ensure a default platform fallback for all themes
if (m_parents.isEmpty()) { if (m_parents.isEmpty()) {
@ -369,33 +304,51 @@ QIconTheme::QIconTheme(const QString &themeName)
if (!fallback.isEmpty()) if (!fallback.isEmpty())
m_parents.append(fallback); m_parents.append(fallback);
} }
// Ensure that all themes fall back to hicolor
if (!m_parents.contains(QLatin1String("hicolor")))
m_parents.append(QLatin1String("hicolor"));
} }
#endif //QT_NO_SETTINGS #endif //QT_NO_SETTINGS
} }
/* WARNING:
*
* https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
*
* <cite>
* The dash - character is used to separate levels of specificity in icon
* names, for all contexts other than MimeTypes. For instance, we use
* input-mouse as the generic item for all mouse devices, and we use
* input-mouse-usb for a USB mouse device. However, if the more specific
* item does not exist in the current theme, and does exist in a parent
* theme, the generic icon from the current theme is preferred, in order
* to keep consistent style.
* </cite>
*
* But we believe, that using the more specific icon (even from parents)
* is better for user experience. So we are violating the standard
* intentionally.
*
* Ref.
* https://github.com/lxde/lxqt/issues/1252
* https://github.com/lxde/libqtxdg/pull/116
*/
QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName, QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName,
const QString &iconName, const QString &iconName,
QStringList &visited) const QStringList &visited,
bool dashFallback) const
{ {
QThemeIconInfo info; QThemeIconInfo info;
Q_ASSERT(!themeName.isEmpty()); Q_ASSERT(!themeName.isEmpty());
QPixmap pixmap;
// Used to protect against potential recursions // Used to protect against potential recursions
visited << themeName; visited << themeName;
QIconTheme theme = themeList.value(themeName); XdgIconTheme &theme = themeList[themeName];
if (!theme.isValid()) { if (!theme.isValid()) {
theme = QIconTheme(themeName); theme = XdgIconTheme(themeName);
if (!theme.isValid()) if (!theme.isValid()) {
theme = QIconTheme(fallbackTheme()); const QString fallback = fallbackTheme();
if (!fallback.isEmpty())
themeList.insert(themeName, theme); theme = XdgIconTheme(fallback);
}
} }
const QStringList contentDirs = theme.contentDirs(); const QStringList contentDirs = theme.contentDirs();
@ -405,7 +358,7 @@ QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName,
const QString xpmext(QLatin1String(".xpm")); const QString xpmext(QLatin1String(".xpm"));
QString iconNameFallback = iconName; QStringRef iconNameFallback(&iconName);
// Iterate through all icon's fallbacks in current theme // Iterate through all icon's fallbacks in current theme
while (info.entries.isEmpty()) { while (info.entries.isEmpty()) {
@ -415,21 +368,21 @@ QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName,
// Add all relevant files // Add all relevant files
for (int i = 0; i < contentDirs.size(); ++i) { for (int i = 0; i < contentDirs.size(); ++i) {
QVector<XdgIconDirInfo> subDirs = theme.keyList(); QVector<QIconDirInfo> subDirs = theme.keyList();
// Try to reduce the amount of subDirs by looking in the GTK+ cache in order to save // Try to reduce the amount of subDirs by looking in the GTK+ cache in order to save
// a massive amount of file stat (especially if the icon is not there) // a massive amount of file stat (especially if the icon is not there)
auto cache = theme.m_gtkCaches.at(i); auto cache = theme.m_gtkCaches.at(i);
if (cache->isValid()) { if (cache->isValid()) {
auto result = cache->lookup(iconNameFallback); const auto result = cache->lookup(iconNameFallback);
if (cache->isValid()) { if (cache->isValid()) {
const QVector<XdgIconDirInfo> subDirsCopy = subDirs; const QVector<QIconDirInfo> subDirsCopy = subDirs;
subDirs.clear(); subDirs.clear();
subDirs.reserve(result.count()); subDirs.reserve(result.count());
foreach (const char *s, result) { for (const char *s : result) {
QString path = QString::fromUtf8(s); QString path = QString::fromUtf8(s);
auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(), auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(),
[&](const XdgIconDirInfo &info) { [&](const QIconDirInfo &info) {
return info.path == path; } ); return info.path == path; } );
if (it != subDirsCopy.cend()) { if (it != subDirsCopy.cend()) {
subDirs.append(*it); subDirs.append(*it);
@ -440,45 +393,41 @@ QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName,
QString contentDir = contentDirs.at(i) + QLatin1Char('/'); QString contentDir = contentDirs.at(i) + QLatin1Char('/');
for (int j = 0; j < subDirs.size() ; ++j) { for (int j = 0; j < subDirs.size() ; ++j) {
const XdgIconDirInfo &dirInfo = subDirs.at(j); const QIconDirInfo &dirInfo = subDirs.at(j);
QString subdir = dirInfo.path; const QString subDir = contentDir + dirInfo.path + QLatin1Char('/');
QDir currentDir(contentDir + subdir); const QString pngPath = subDir + pngIconName;
if (currentDir.exists(pngIconName)) { if (QFile::exists(pngPath)) {
PixmapEntry *iconEntry = new PixmapEntry; PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->dir = dirInfo; iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(pngIconName); iconEntry->filename = pngPath;
// Notice we ensure that pixmap entries always come before // Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards // scalable to preserve search order afterwards
info.entries.prepend(iconEntry); info.entries.prepend(iconEntry);
} else if (m_supportsSvg && } else {
currentDir.exists(svgIconName)) { const QString svgPath = subDir + svgIconName;
ScalableEntry *iconEntry = new ScalableEntry; if (gSupportsSvg && QFile::exists(svgPath)) {
iconEntry->dir = dirInfo; ScalableEntry *iconEntry = (followColorScheme() && theme.followsColorScheme()) ? new ScalableFollowsColorEntry : new ScalableEntry;
iconEntry->filename = currentDir.filePath(svgIconName); iconEntry->dir = dirInfo;
info.entries.append(iconEntry); iconEntry->filename = svgPath;
} else if(currentDir.exists(iconName + xpmext)) { info.entries.append(iconEntry);
}
}
const QString xpmPath = subDir + xpmIconName;
if (QFile::exists(xpmPath)) {
PixmapEntry *iconEntry = new PixmapEntry; PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->dir = dirInfo; iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + xpmext); iconEntry->filename = xpmPath;
// Notice we ensure that pixmap entries always come before // Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards // scalable to preserve search order afterwards
info.entries.append(iconEntry); info.entries.append(iconEntry);
break;
} }
} }
} }
if (!info.entries.isEmpty()) { if (!info.entries.isEmpty())
info.iconName = iconNameFallback; info.iconName = iconNameFallback.toString();
break;
}
// If it's possible - find next fallback for the icon
const int indexOfDash = iconNameFallback.lastIndexOf(QLatin1Char('-'));
if (indexOfDash == -1)
break;
iconNameFallback.truncate(indexOfDash); break;
} }
if (info.entries.isEmpty()) { if (info.entries.isEmpty()) {
@ -496,83 +445,80 @@ QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName,
} }
} }
if (info.entries.isEmpty()) { if (dashFallback && info.entries.isEmpty()) {
// Search for unthemed icons in main dir of search paths // If it's possible - find next fallback for the icon
QStringList themeSearchPaths = QIcon::themeSearchPaths(); const int indexOfDash = iconNameFallback.lastIndexOf(QLatin1Char('-'));
foreach (QString contentDir, themeSearchPaths) { if (indexOfDash != -1) {
QDir currentDir(contentDir); iconNameFallback.truncate(indexOfDash);
QStringList _visited;
if (currentDir.exists(iconName + pngext)) { info = findIconHelper(themeName, iconNameFallback.toString(), _visited, true);
PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->filename = currentDir.filePath(iconName + pngext);
// Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards
info.entries.prepend(iconEntry);
} else if (m_supportsSvg &&
currentDir.exists(iconName + svgext)) {
ScalableEntry *iconEntry = new ScalableEntry;
iconEntry->filename = currentDir.filePath(iconName + svgext);
info.entries.append(iconEntry);
break;
} else if (currentDir.exists(iconName + xpmext)) {
PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->filename = currentDir.filePath(iconName + xpmext);
// Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards
info.entries.append(iconEntry);
break;
}
} }
} }
return info;
}
/********************************************************************* QThemeIconInfo XdgIconLoader::unthemedFallback(const QString &iconName, const QStringList &searchPaths) const
Author: Kaitlin Rupert <kaitlin.rupert@intel.com> {
Date: Aug 12, 2010 QThemeIconInfo info;
Description: Make it so that the QIcon loader honors /usr/share/pixmaps
directory. This is a valid directory per the Freedesktop.org const QString svgext(QLatin1String(".svg"));
icon theme specification. const QString pngext(QLatin1String(".png"));
Bug: https://bugreports.qt.nokia.com/browse/QTBUG-12874 const QString xpmext(QLatin1String(".xpm"));
*********************************************************************/
#ifdef Q_OS_LINUX for (const auto &contentDir : searchPaths) {
/* Freedesktop standard says to look in /usr/share/pixmaps last */ QDir currentDir(contentDir);
if (info.entries.isEmpty()) {
const QString pixmaps(QLatin1String("/usr/share/pixmaps"));
const QDir currentDir(pixmaps);
const XdgIconDirInfo dirInfo(pixmaps);
if (currentDir.exists(iconName + pngext)) { if (currentDir.exists(iconName + pngext)) {
PixmapEntry *iconEntry = new PixmapEntry; PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + pngext); iconEntry->filename = currentDir.filePath(iconName + pngext);
// Notice we ensure that pixmap entries always come before // Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards // scalable to preserve search order afterwards
info.entries.prepend(iconEntry); info.entries.prepend(iconEntry);
} else if (m_supportsSvg && } else if (gSupportsSvg &&
currentDir.exists(iconName + svgext)) { currentDir.exists(iconName + svgext)) {
ScalableEntry *iconEntry = new ScalableEntry; ScalableEntry *iconEntry = new ScalableEntry;
iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + svgext); iconEntry->filename = currentDir.filePath(iconName + svgext);
info.entries.append(iconEntry); info.entries.append(iconEntry);
} else if (currentDir.exists(iconName + xpmext)) { } else if (currentDir.exists(iconName + xpmext)) {
PixmapEntry *iconEntry = new PixmapEntry; PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + xpmext); iconEntry->filename = currentDir.filePath(iconName + xpmext);
// Notice we ensure that pixmap entries always come before // Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards // scalable to preserve search order afterwards
info.entries.append(iconEntry); info.entries.append(iconEntry);
} }
} }
#endif
return info; return info;
} }
QThemeIconInfo XdgIconLoader::loadIcon(const QString &name) const QThemeIconInfo XdgIconLoader::loadIcon(const QString &name) const
{ {
if (!themeName().isEmpty()) { const QString theme_name = QIconLoader::instance()->themeName();
if (!theme_name.isEmpty()) {
QStringList visited; QStringList visited;
return findIconHelper(themeName(), name, visited); auto info = findIconHelper(theme_name, name, visited, true);
if (info.entries.isEmpty()) {
const auto hicolorInfo = findIconHelper(QLatin1String("hicolor"), name, visited, true);
if (hicolorInfo.entries.isEmpty()) {
const auto unthemedInfo = unthemedFallback(name, QIcon::themeSearchPaths());
if (unthemedInfo.entries.isEmpty()) {
/* Freedesktop standard says to look in /usr/share/pixmaps last */
const QStringList pixmapPath = (QStringList() << QString::fromLatin1("/usr/share/pixmaps"));
const auto pixmapInfo = unthemedFallback(name, pixmapPath);
if (pixmapInfo.entries.isEmpty()) {
return QThemeIconInfo();
} else {
return pixmapInfo;
}
} else {
return unthemedInfo;
}
} else {
return hicolorInfo;
}
} else {
return info;
}
} }
return QThemeIconInfo(); return QThemeIconInfo();
@ -623,14 +569,14 @@ bool XdgIconLoaderEngine::hasIcon() const
// Lazily load the icon // Lazily load the icon
void XdgIconLoaderEngine::ensureLoaded() void XdgIconLoaderEngine::ensureLoaded()
{ {
if (!(XdgIconLoader::instance()->themeKey() == m_key)) { if (!(QIconLoader::instance()->themeKey() == m_key)) {
qDeleteAll(m_info.entries); qDeleteAll(m_info.entries);
m_info.entries.clear(); m_info.entries.clear();
m_info.iconName.clear(); m_info.iconName.clear();
Q_ASSERT(m_info.entries.size() == 0); Q_ASSERT(m_info.entries.size() == 0);
m_info = XdgIconLoader::instance()->loadIcon(m_iconName); m_info = XdgIconLoader::instance()->loadIcon(m_iconName);
m_key = XdgIconLoader::instance()->themeKey(); m_key = QIconLoader::instance()->themeKey();
} }
} }
@ -648,16 +594,16 @@ void XdgIconLoaderEngine::paint(QPainter *painter, const QRect &rect,
* This algorithm is defined by the freedesktop spec: * This algorithm is defined by the freedesktop spec:
* http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html * http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
*/ */
static bool directoryMatchesSize(const XdgIconDirInfo &dir, int iconsize) static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize)
{ {
if (dir.type == XdgIconDirInfo::Fixed) { if (dir.type == QIconDirInfo::Fixed) {
return dir.size == iconsize; return dir.size == iconsize;
} else if (dir.type == XdgIconDirInfo::Scalable) { } else if (dir.type == QIconDirInfo::Scalable) {
return iconsize <= dir.maxSize && return iconsize <= dir.maxSize &&
iconsize >= dir.minSize; iconsize >= dir.minSize;
} else if (dir.type == XdgIconDirInfo::Threshold) { } else if (dir.type == QIconDirInfo::Threshold) {
return iconsize >= dir.size - dir.threshold && return iconsize >= dir.size - dir.threshold &&
iconsize <= dir.size + dir.threshold; iconsize <= dir.size + dir.threshold;
} }
@ -670,12 +616,12 @@ static bool directoryMatchesSize(const XdgIconDirInfo &dir, int iconsize)
* This algorithm is defined by the freedesktop spec: * This algorithm is defined by the freedesktop spec:
* http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html * http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
*/ */
static int directorySizeDistance(const XdgIconDirInfo &dir, int iconsize) static int directorySizeDistance(const QIconDirInfo &dir, int iconsize)
{ {
if (dir.type == XdgIconDirInfo::Fixed) { if (dir.type == QIconDirInfo::Fixed) {
return qAbs(dir.size - iconsize); return qAbs(dir.size - iconsize);
} else if (dir.type == XdgIconDirInfo::Scalable) { } else if (dir.type == QIconDirInfo::Scalable) {
if (iconsize < dir.minSize) if (iconsize < dir.minSize)
return dir.minSize - iconsize; return dir.minSize - iconsize;
else if (iconsize > dir.maxSize) else if (iconsize > dir.maxSize)
@ -683,7 +629,7 @@ static int directorySizeDistance(const XdgIconDirInfo &dir, int iconsize)
else else
return 0; return 0;
} else if (dir.type == XdgIconDirInfo::Threshold) { } else if (dir.type == QIconDirInfo::Threshold) {
if (iconsize < dir.size - dir.threshold) if (iconsize < dir.size - dir.threshold)
return dir.minSize - iconsize; return dir.minSize - iconsize;
else if (iconsize > dir.size + dir.threshold) else if (iconsize > dir.size + dir.threshold)
@ -695,7 +641,7 @@ static int directorySizeDistance(const XdgIconDirInfo &dir, int iconsize)
return INT_MAX; return INT_MAX;
} }
XdgIconLoaderEngineEntry *XdgIconLoaderEngine::entryForSize(const QSize &size) QIconLoaderEngineEntry *XdgIconLoaderEngine::entryForSize(const QSize &size)
{ {
int iconsize = qMin(size.width(), size.height()); int iconsize = qMin(size.width(), size.height());
@ -706,7 +652,7 @@ XdgIconLoaderEngineEntry *XdgIconLoaderEngine::entryForSize(const QSize &size)
// Search for exact matches first // Search for exact matches first
for (int i = 0; i < numEntries; ++i) { for (int i = 0; i < numEntries; ++i) {
XdgIconLoaderEngineEntry *entry = m_info.entries.at(i); QIconLoaderEngineEntry *entry = m_info.entries.at(i);
if (directoryMatchesSize(entry->dir, iconsize)) { if (directoryMatchesSize(entry->dir, iconsize)) {
return entry; return entry;
} }
@ -714,9 +660,9 @@ XdgIconLoaderEngineEntry *XdgIconLoaderEngine::entryForSize(const QSize &size)
// Find the minimum distance icon // Find the minimum distance icon
int minimalSize = INT_MAX; int minimalSize = INT_MAX;
XdgIconLoaderEngineEntry *closestMatch = 0; QIconLoaderEngineEntry *closestMatch = 0;
for (int i = 0; i < numEntries; ++i) { for (int i = 0; i < numEntries; ++i) {
XdgIconLoaderEngineEntry *entry = m_info.entries.at(i); QIconLoaderEngineEntry *entry = m_info.entries.at(i);
int distance = directorySizeDistance(entry->dir, iconsize); int distance = directorySizeDistance(entry->dir, iconsize);
if (distance < minimalSize) { if (distance < minimalSize) {
minimalSize = distance; minimalSize = distance;
@ -737,10 +683,10 @@ QSize XdgIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
{ {
ensureLoaded(); ensureLoaded();
XdgIconLoaderEngineEntry *entry = entryForSize(size); QIconLoaderEngineEntry *entry = entryForSize(size);
if (entry) { if (entry) {
const XdgIconDirInfo &dir = entry->dir; const QIconDirInfo &dir = entry->dir;
if (dir.type == XdgIconDirInfo::Scalable || dynamic_cast<ScalableEntry *>(entry)) if (dir.type == QIconDirInfo::Scalable || dynamic_cast<ScalableEntry *>(entry))
return size; return size;
else { else {
int dir_size = dir.size; int dir_size = dir.size;
@ -756,9 +702,10 @@ QSize XdgIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
return QSize(result, result); return QSize(result, result);
} }
} }
return QIconEngine::actualSize(size, mode, state); return {0, 0};
} }
// XXX: duplicated from qiconloader.cpp, because this symbol isn't exported :(
QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
{ {
Q_UNUSED(state); Q_UNUSED(state);
@ -794,6 +741,7 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st
return cachedPixmap; return cachedPixmap;
} }
// XXX: duplicated from qiconloader.cpp, because this symbol isn't exported :(
QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
{ {
if (svgIcon.isNull()) if (svgIcon.isNull())
@ -803,12 +751,90 @@ QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State
return svgIcon.pixmap(size, mode, state); return svgIcon.pixmap(size, mode, state);
} }
// XXX: duplicated from qicon.cpp, because the symbol qt_iconEngineFactoryLoader isn't exported :(
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, qt_iconEngineFactoryLoader,
(QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
//extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp
QPixmap ScalableFollowsColorEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
{
QIcon & icon = QIcon::Selected == mode ? svgSelectedIcon : svgIcon;
if (icon.isNull())
{
// The following lines are adapted and updated from KDE's "kiconloader.cpp" ->
// KIconLoaderPrivate::processSvg() and KIconLoaderPrivate::createIconImage().
// They read the SVG color scheme of SVG icons and give images based on the icon mode.
QByteArray processedContents;
QFile device{filename};;
if (device.open(QIODevice::ReadOnly))
{
const QPalette pal = qApp->palette();
QString styleSheet = QStringLiteral(".ColorScheme-Text{color:%1;}")
.arg(mode == QIcon::Selected
? pal.highlightedText().color().name()
: pal.windowText().color().name());
QXmlStreamReader xmlReader(&device);
QXmlStreamWriter writer(&processedContents);
while (!xmlReader.atEnd())
{
if (xmlReader.readNext() == QXmlStreamReader::StartElement
&& xmlReader.qualifiedName() == QLatin1String("style")
&& xmlReader.attributes().value(QLatin1String("id")) == QLatin1String("current-color-scheme"))
{
writer.writeStartElement(QLatin1String("style"));
writer.writeAttributes(xmlReader.attributes());
writer.writeCharacters(styleSheet);
writer.writeEndElement();
while (xmlReader.tokenType() != QXmlStreamReader::EndElement)
xmlReader.readNext();
}
else if (xmlReader.tokenType() != QXmlStreamReader::Invalid)
writer.writeCurrentToken(xmlReader);
}
}
// use the QSvgIconEngine
// - assemble the content as it is done by the QSvgIconEngine::write() (operator <<)
// - create the QIcon with QSvgIconEngine initialized from the content
const int index = qt_iconEngineFactoryLoader()->indexOf(QStringLiteral("svg"));
if (index != -1)
{
if (QIconEnginePlugin * factory = qobject_cast<QIconEnginePlugin*>(qt_iconEngineFactoryLoader()->instance(index)))
{
if (QIconEngine * engine = factory->create())
{
QByteArray engine_arr;
QDataStream str{&engine_arr, QIODevice::WriteOnly};
str.setVersion(QDataStream::Qt_4_4);
QHash<int, QString> filenames;
filenames[0] = filename;
QHash<int, QByteArray> svg_buffers;
svg_buffers[0] = processedContents;
str << filenames << static_cast<int>(0)/*isCompressed*/ << svg_buffers << static_cast<int>(0)/*hasAddedPimaps*/;
QDataStream str_read{&engine_arr, QIODevice::ReadOnly};
str_read.setVersion(QDataStream::Qt_4_4);
engine->read(str_read);
icon = QIcon{engine};
}
}
}
// load the icon directly from file, if still null
if (icon.isNull())
icon = QIcon(filename);
}
return icon.pixmap(size, mode, state);
}
QPixmap XdgIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode, QPixmap XdgIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode,
QIcon::State state) QIcon::State state)
{ {
ensureLoaded(); ensureLoaded();
XdgIconLoaderEngineEntry *entry = entryForSize(size); QIconLoaderEngineEntry *entry = entryForSize(size);
if (entry) if (entry)
return entry->pixmap(size, mode, state); return entry->pixmap(size, mode, state);

@ -31,8 +31,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef QICONLOADER_P_H #ifndef XDGICONLOADER_P_H
#define QICONLOADER_P_H #define XDGICONLOADER_P_H
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
@ -52,65 +52,19 @@
#include <QtGui/QIcon> #include <QtGui/QIcon>
#include <QtGui/QIconEngine> #include <QtGui/QIconEngine>
#include <QtGui/QPixmapCache>
#include <private/qicon_p.h> #include <private/qicon_p.h>
#include <private/qfactoryloader_p.h> #include <private/qiconloader_p.h>
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QVector> #include <QtCore/QVector>
#include <QtCore/QTypeInfo>
//QT_BEGIN_NAMESPACE //QT_BEGIN_NAMESPACE
class XdgIconLoader; class XdgIconLoader;
struct XdgIconDirInfo struct ScalableFollowsColorEntry : public ScalableEntry
{
enum Type { Fixed, Scalable, Threshold };
XdgIconDirInfo(const QString &_path = QString()) :
path(_path),
size(0),
maxSize(0),
minSize(0),
threshold(0),
type(Threshold) {}
QString path;
short size;
short maxSize;
short minSize;
short threshold;
Type type;
};
class XdgIconLoaderEngineEntry
{
public:
virtual ~XdgIconLoaderEngineEntry() {}
virtual QPixmap pixmap(const QSize &size,
QIcon::Mode mode,
QIcon::State state) = 0;
QString filename;
XdgIconDirInfo dir;
static int count;
};
struct ScalableEntry : public XdgIconLoaderEngineEntry
{
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QIcon svgIcon;
};
struct PixmapEntry : public XdgIconLoaderEngineEntry
{ {
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QPixmap basePixmap; QIcon svgSelectedIcon;
};
typedef QList<XdgIconLoaderEngineEntry*> QThemeIconEntries;
struct QThemeIconInfo
{
QThemeIconEntries entries;
QString iconName;
}; };
//class QIconLoaderEngine : public QIconEngine //class QIconLoaderEngine : public QIconEngine
@ -120,19 +74,19 @@ public:
XdgIconLoaderEngine(const QString& iconName = QString()); XdgIconLoaderEngine(const QString& iconName = QString());
~XdgIconLoaderEngine(); ~XdgIconLoaderEngine();
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state); void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state); QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state); QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QIconEngine *clone() const; QIconEngine *clone() const Q_DECL_OVERRIDE;
bool read(QDataStream &in); bool read(QDataStream &in) Q_DECL_OVERRIDE;
bool write(QDataStream &out) const; bool write(QDataStream &out) const Q_DECL_OVERRIDE;
private: private:
QString key() const; QString key() const Q_DECL_OVERRIDE;
bool hasIcon() const; bool hasIcon() const;
void ensureLoaded(); void ensureLoaded();
void virtual_hook(int id, void *data); void virtual_hook(int id, void *data) Q_DECL_OVERRIDE;
XdgIconLoaderEngineEntry *entryForSize(const QSize &size); QIconLoaderEngineEntry *entryForSize(const QSize &size);
XdgIconLoaderEngine(const XdgIconLoaderEngine &other); XdgIconLoaderEngine(const XdgIconLoaderEngine &other);
QThemeIconInfo m_info; QThemeIconInfo m_info;
QString m_iconName; QString m_iconName;
@ -143,20 +97,24 @@ private:
class QIconCacheGtkReader; class QIconCacheGtkReader;
class QIconTheme // Note: We can't simply reuse the QIconTheme from Qt > 5.7 because
// the QIconTheme constructor symbol isn't exported.
class XdgIconTheme
{ {
public: public:
QIconTheme(const QString &name); XdgIconTheme(const QString &name);
QIconTheme() : m_valid(false) {} XdgIconTheme() = default;
QStringList parents() { return m_parents; } QStringList parents() { return m_parents; }
QVector <XdgIconDirInfo> keyList() { return m_keyList; } QVector <QIconDirInfo> keyList() { return m_keyList; }
QStringList contentDirs() { return m_contentDirs; } QStringList contentDirs() { return m_contentDirs; }
bool isValid() { return m_valid; } bool isValid() const { return m_valid; }
bool followsColorScheme() const { return m_followsColorScheme; }
private: private:
QStringList m_contentDirs; QStringList m_contentDirs;
QVector <XdgIconDirInfo> m_keyList; QVector <QIconDirInfo> m_keyList;
QStringList m_parents; QStringList m_parents;
bool m_valid; bool m_valid = false;
bool m_followsColorScheme = false;
public: public:
QVector<QSharedPointer<QIconCacheGtkReader>> m_gtkCaches; QVector<QSharedPointer<QIconCacheGtkReader>> m_gtkCaches;
}; };
@ -164,43 +122,39 @@ public:
class XDGICONLOADER_EXPORT XdgIconLoader class XDGICONLOADER_EXPORT XdgIconLoader
{ {
public: public:
XdgIconLoader();
QThemeIconInfo loadIcon(const QString &iconName) const; QThemeIconInfo loadIcon(const QString &iconName) const;
uint themeKey() const { return m_themeKey; }
/* TODO: deprecate & remove all QIconLoader wrappers */
QString themeName() const { return m_userTheme.isEmpty() ? m_systemTheme : m_userTheme; } inline uint themeKey() const { return QIconLoader::instance()->themeKey(); }
void setThemeName(const QString &themeName); inline QString themeName() const { return QIconLoader::instance()->themeName(); }
QIconTheme theme() { return themeList.value(themeName()); } inline void setThemeName(const QString &themeName) { QIconLoader::instance()->setThemeName(themeName); }
void setThemeSearchPath(const QStringList &searchPaths); inline void setThemeSearchPath(const QStringList &searchPaths) { QIconLoader::instance()->setThemeSearchPath(searchPaths); }
QStringList themeSearchPaths() const; inline QIconDirInfo dirInfo(int dirindex) { return QIconLoader::instance()->dirInfo(dirindex); }
XdgIconDirInfo dirInfo(int dirindex); inline QStringList themeSearchPaths() const { return QIconLoader::instance()->themeSearchPaths(); }
inline void updateSystemTheme() { QIconLoader::instance()->updateSystemTheme(); }
inline void invalidateKey() { QIconLoader::instance()->invalidateKey(); }
inline void ensureInitialized() { QIconLoader::instance()->ensureInitialized(); }
inline bool hasUserTheme() const { return QIconLoader::instance()->hasUserTheme(); }
/*!
* Flag if the "FollowsColorScheme" hint (the KDE extension to XDG
* themes) should be honored.
*/
inline bool followColorScheme() const { return m_followColorScheme; }
void setFollowColorScheme(bool enable);
XdgIconTheme theme() { return themeList.value(QIconLoader::instance()->themeName()); }
static XdgIconLoader *instance(); static XdgIconLoader *instance();
void updateSystemTheme();
void invalidateKey() { m_themeKey++; }
void ensureInitialized();
bool hasUserTheme() const { return !m_userTheme.isEmpty(); }
private: private:
QThemeIconInfo findIconHelper(const QString &themeName, QThemeIconInfo findIconHelper(const QString &themeName,
const QString &iconName, const QString &iconName,
QStringList &visited) const; QStringList &visited,
uint m_themeKey; bool dashFallback = false) const;
bool m_supportsSvg; QThemeIconInfo unthemedFallback(const QString &iconName, const QStringList &searchPaths) const;
bool m_initialized; mutable QHash <QString, XdgIconTheme> themeList;
bool m_followColorScheme = true;
mutable QString m_userTheme;
mutable QString m_systemTheme;
mutable QStringList m_iconDirs;
mutable QHash <QString, QIconTheme> themeList;
}; };
// Note: class template specialization of 'QTypeInfo' must occur at
// global scope
Q_DECLARE_TYPEINFO(XdgIconDirInfo, Q_MOVABLE_TYPE);
//QT_END_NAMESPACE
#endif // QT_NO_ICON #endif // QT_NO_ICON
#endif // QICONLOADER_P_H #endif // XDGICONLOADER_P_H

Loading…
Cancel
Save