Adding upstream version 1.3.1~50-g4fde773.
This commit is contained in:
parent
9e92aa7936
commit
7aa602d177
7
AUTHORS
7
AUTHORS
@ -4,7 +4,8 @@ Upstream Authors:
|
|||||||
|
|
||||||
Copyright:
|
Copyright:
|
||||||
Copyright (c) 2010-2012 Razor team
|
Copyright (c) 2010-2012 Razor team
|
||||||
Copyright (c) 2012-2014 LXQt team
|
Copyright (c) 2012-2016 LXQt team
|
||||||
|
|
||||||
License: GPL-2 and LGPL-2.1+
|
License: LGPL-2.1+ and LGPL-2.1-or-3-with-Digia-1.1-exception
|
||||||
The full text of the licenses can be found in the 'COPYING' file.
|
The full text of the LGPL-2.1+ license can be found in the 'COPYING' file.
|
||||||
|
The Digia-1.1 exception can be found in the 'Digia-Qt-LGPL-Exception-1.1' file.
|
||||||
|
301
CMakeLists.txt
301
CMakeLists.txt
@ -2,10 +2,29 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|||||||
project(libqtxdg)
|
project(libqtxdg)
|
||||||
|
|
||||||
option(BUILD_TESTS "Builds tests" OFF)
|
option(BUILD_TESTS "Builds tests" OFF)
|
||||||
|
option(BUILD_DEV_UTILS "Builds and install development utils" OFF)
|
||||||
|
|
||||||
# additional cmake files
|
# additional cmake files
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||||
|
if(COMPILER_SUPPORTS_CXX11)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
else()
|
||||||
|
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||||
|
# -std=c++0x is deprecated but some tools e.g. qmake or older gcc are still using it
|
||||||
|
if(COMPILER_SUPPORTS_CXX0X)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} does not support c++11/c++0x")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(QTXDG_MAJOR_VERSION 1)
|
set(QTXDG_MAJOR_VERSION 1)
|
||||||
set(QTXDG_MINOR_VERSION 3)
|
set(QTXDG_MINOR_VERSION 3)
|
||||||
set(QTXDG_PATCH_VERSION 0)
|
set(QTXDG_PATCH_VERSION 0)
|
||||||
@ -13,6 +32,7 @@ set(QTXDG_VERSION_STRING ${QTXDG_MAJOR_VERSION}.${QTXDG_MINOR_VERSION}.${QTXDG_P
|
|||||||
|
|
||||||
include(GNUInstallDirs) # Standard directories for installation
|
include(GNUInstallDirs) # Standard directories for installation
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
include(GenerateExportHeader)
|
||||||
include(create_portable_headers)
|
include(create_portable_headers)
|
||||||
include(create_pkgconfig_file)
|
include(create_pkgconfig_file)
|
||||||
include(compiler_settings NO_POLICY_SCOPE)
|
include(compiler_settings NO_POLICY_SCOPE)
|
||||||
@ -20,6 +40,7 @@ include(compiler_settings NO_POLICY_SCOPE)
|
|||||||
find_package(Qt5Widgets REQUIRED QUIET)
|
find_package(Qt5Widgets REQUIRED QUIET)
|
||||||
find_package(Qt5Xml REQUIRED QUIET)
|
find_package(Qt5Xml REQUIRED QUIET)
|
||||||
find_package(Qt5DBus REQUIRED QUIET)
|
find_package(Qt5DBus REQUIRED QUIET)
|
||||||
|
|
||||||
if (BUILD_TESTS)
|
if (BUILD_TESTS)
|
||||||
find_package(Qt5Test REQUIRED QUIET)
|
find_package(Qt5Test REQUIRED QUIET)
|
||||||
endif()
|
endif()
|
||||||
@ -28,206 +49,25 @@ endif()
|
|||||||
set(QTXDGX_LIBRARY_NAME "Qt5Xdg")
|
set(QTXDGX_LIBRARY_NAME "Qt5Xdg")
|
||||||
set(QTXDGX_FILE_NAME "qt5xdg")
|
set(QTXDGX_FILE_NAME "qt5xdg")
|
||||||
|
|
||||||
|
set(QTXDGX_ICONLOADER_LIBRARY_NAME "Qt5XdgIconLoader")
|
||||||
|
set(QTXDGX_ICONLOADER_FILE_NAME "qt5xdgiconloader")
|
||||||
|
|
||||||
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")
|
set(QTXDGX_PKG_CONFIG_REQUIRES "Qt5Core, Qt5Xml, Qt5Widgets, Qt5DBus, Qt5XdgIconLoader")
|
||||||
|
|
||||||
|
set(QTXDGX_ICONLOADER_PKG_CONFIG_DESCRIPTION "Qt5XdgIconLader, a Qt5 XDG Icon Loader")
|
||||||
|
set(QTXDGX_ICONLOADER_PKG_CONFIG_REQUIRES "Qt5Gui")
|
||||||
|
|
||||||
set(QTXDGX_INTREE_INCLUDEDIR "${CMAKE_CURRENT_BINARY_DIR}/InTreeBuild/include")
|
set(QTXDGX_INTREE_INCLUDEDIR "${CMAKE_CURRENT_BINARY_DIR}/InTreeBuild/include")
|
||||||
|
|
||||||
include_directories(
|
|
||||||
"${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
|
|
||||||
)
|
|
||||||
|
|
||||||
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
|
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
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 with Qt ${Qt5Core_VERSION_STRING}")
|
||||||
|
|
||||||
set(libqtxdg_PUBLIC_H_FILES
|
add_subdirectory(xdgiconloader)
|
||||||
xdgaction.h
|
add_subdirectory(qtxdg)
|
||||||
xdgdesktopfile.h
|
|
||||||
xdgdirs.h
|
|
||||||
xdgicon.h
|
|
||||||
xdgmenu.h
|
|
||||||
xdgmenuwidget.h
|
|
||||||
xmlhelper.h
|
|
||||||
xdgautostart.h
|
|
||||||
xdgmacros.h
|
|
||||||
xdgmimetype.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(libqtxdg_PUBLIC_CLASSES
|
|
||||||
XdgAction
|
|
||||||
XdgDesktopFile
|
|
||||||
XdgDirs
|
|
||||||
XdgIcon
|
|
||||||
XdgMenu
|
|
||||||
XdgMenuWidget
|
|
||||||
XmlHelper
|
|
||||||
XdgAutoStart
|
|
||||||
XdgMimeType
|
|
||||||
)
|
|
||||||
|
|
||||||
set(libqtxdg_PRIVATE_H_FILES
|
|
||||||
xdgmenuapplinkprocessor.h
|
|
||||||
xdgmenulayoutprocessor.h
|
|
||||||
xdgmenu_p.h
|
|
||||||
xdgmenureader.h
|
|
||||||
xdgmenurules.h
|
|
||||||
xdgdesktopfile_p.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(libqtxdg_CPP_FILES
|
|
||||||
xdgaction.cpp
|
|
||||||
xdgdesktopfile.cpp
|
|
||||||
xdgdirs.cpp
|
|
||||||
xdgicon.cpp
|
|
||||||
xdgmenuapplinkprocessor.cpp
|
|
||||||
xdgmenu.cpp
|
|
||||||
xdgmenulayoutprocessor.cpp
|
|
||||||
xdgmenureader.cpp
|
|
||||||
xdgmenurules.cpp
|
|
||||||
xdgmenuwidget.cpp
|
|
||||||
xmlhelper.cpp
|
|
||||||
xdgautostart.cpp
|
|
||||||
xdgmimetype.cpp
|
|
||||||
qiconfix/qiconloader.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(libqtxdg_MOCS
|
|
||||||
xdgaction.h
|
|
||||||
xdgmenuapplinkprocessor.h
|
|
||||||
xdgmenu.h
|
|
||||||
xdgmenu_p.h
|
|
||||||
xdgmenureader.h
|
|
||||||
xdgmenurules.h
|
|
||||||
xdgmenuwidget.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(libqtxdg_PRIVATE_INSTALLABLE_H_FILES
|
|
||||||
qiconfix/qiconloader_p.h
|
|
||||||
)
|
|
||||||
|
|
||||||
QT5_WRAP_CPP(libqtxdg_CXX_FILES ${libqtxdg_MOCS})
|
|
||||||
|
|
||||||
add_library(${QTXDGX_LIBRARY_NAME} SHARED
|
|
||||||
${libqtxdg_PUBLIC_H_FILES}
|
|
||||||
${libqtxdg_PRIVATE_H_FILES}
|
|
||||||
${libqtxdg_PRIVATE_INSTALLABLE_H_FILES}
|
|
||||||
${libqtxdg_PRIVATE_H_FILES}
|
|
||||||
${libqtxdg_CPP_FILES}
|
|
||||||
${libqtxdg_CXX_FILES}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(${QTXDGX_LIBRARY_NAME}
|
|
||||||
PUBLIC
|
|
||||||
${QTX_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(${QTXDGX_LIBRARY_NAME} PROPERTIES
|
|
||||||
VERSION ${QTXDG_VERSION_STRING}
|
|
||||||
SOVERSION ${QTXDG_MAJOR_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${QTXDGX_FILE_NAME}-config.cmake.in"
|
|
||||||
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config.cmake"
|
|
||||||
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_FILE_NAME}"
|
|
||||||
)
|
|
||||||
|
|
||||||
write_basic_package_version_file(
|
|
||||||
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config-version.cmake"
|
|
||||||
VERSION ${QTXDG_VERSION_STRING}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
create_pkgconfig_file(
|
|
||||||
PACKAGE_NAME ${QTXDGX_LIBRARY_NAME}
|
|
||||||
DESCRIPTIVE_NAME ${QTXDGX_LIBRARY_NAME}
|
|
||||||
DESCRIPTION ${QTXDGX_PKG_CONFIG_DESCRIPTION}
|
|
||||||
INCLUDEDIRS ${QTXDGX_FILE_NAME}
|
|
||||||
LIBS ${QTXDGX_LIBRARY_NAME}
|
|
||||||
REQUIRES ${QTXDGX_PKG_CONFIG_REQUIRES}
|
|
||||||
VERSION ${QTXDG_VERSION_STRING}
|
|
||||||
INSTALL
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(${QTXDGX_LIBRARY_NAME}
|
|
||||||
PRIVATE "QTXDG_COMPILATION=\"1\""
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(${QTXDGX_LIBRARY_NAME}
|
|
||||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}>"
|
|
||||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
|
||||||
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${QTXDG_VERSION_STRING}>"
|
|
||||||
)
|
|
||||||
|
|
||||||
# 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}>"
|
|
||||||
INTERFACE "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${QTXDG_VERSION_STRING}>"
|
|
||||||
)
|
|
||||||
|
|
||||||
export(TARGETS ${QTXDGX_LIBRARY_NAME} FILE "${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-targets.cmake")
|
|
||||||
# end of in tree build stuff
|
|
||||||
|
|
||||||
# create the portble headers
|
|
||||||
create_portable_headers(libqtxdg_PORTABLE_HEADERS
|
|
||||||
HEADER_NAMES ${libqtxdg_PUBLIC_CLASSES}
|
|
||||||
OUTPUT_DIR "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy public headers (in tree building)
|
|
||||||
foreach(h ${libqtxdg_PUBLIC_H_FILES})
|
|
||||||
get_filename_component(bh ${h} NAME)
|
|
||||||
configure_file(${h} "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${bh}" COPYONLY)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Copy private headers (in tree building)
|
|
||||||
foreach(h ${libqtxdg_PRIVATE_INSTALLABLE_H_FILES})
|
|
||||||
get_filename_component(bh ${h} NAME)
|
|
||||||
configure_file(${h} "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${QTXDG_VERSION_STRING}/private/qtxdg/${bh}" COPYONLY)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
install(TARGETS
|
|
||||||
${QTXDGX_LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
EXPORT "${QTXDGX_FILE_NAME}-targets"
|
|
||||||
COMPONENT Runtime
|
|
||||||
)
|
|
||||||
|
|
||||||
install(EXPORT
|
|
||||||
"${QTXDGX_FILE_NAME}-targets"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_FILE_NAME}"
|
|
||||||
COMPONENT Devel
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
${libqtxdg_PUBLIC_H_FILES}
|
|
||||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}"
|
|
||||||
COMPONENT Devel
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
${libqtxdg_PRIVATE_INSTALLABLE_H_FILES}
|
|
||||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${QTXDG_VERSION_STRING}/private/qtxdg"
|
|
||||||
COMPONENT Devel
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config.cmake"
|
|
||||||
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config-version.cmake"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_FILE_NAME}"
|
|
||||||
COMPONENT Devel
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
|
||||||
${libqtxdg_PORTABLE_HEADERS}
|
|
||||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}"
|
|
||||||
COMPONENT Devel
|
|
||||||
)
|
|
||||||
|
|
||||||
if(BUILD_TESTS)
|
if(BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
@ -241,6 +81,85 @@ else()
|
|||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (BUILD_DEV_UTILS)
|
||||||
|
add_subdirectory(util)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/${QTXDGX_FILE_NAME}-config.cmake.in"
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config.cmake"
|
||||||
|
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_FILE_NAME}"
|
||||||
|
)
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config-version.cmake"
|
||||||
|
VERSION ${QTXDG_VERSION_STRING}
|
||||||
|
COMPATIBILITY AnyNewerVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/${QTXDGX_ICONLOADER_FILE_NAME}-config.cmake.in"
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_ICONLOADER_FILE_NAME}-config.cmake"
|
||||||
|
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_ICONLOADER_FILE_NAME}"
|
||||||
|
)
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_ICONLOADER_FILE_NAME}-config-version.cmake"
|
||||||
|
VERSION ${QTXDG_VERSION_STRING}
|
||||||
|
COMPATIBILITY AnyNewerVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
create_pkgconfig_file(
|
||||||
|
PACKAGE_NAME ${QTXDGX_LIBRARY_NAME}
|
||||||
|
DESCRIPTIVE_NAME ${QTXDGX_LIBRARY_NAME}
|
||||||
|
DESCRIPTION ${QTXDGX_PKG_CONFIG_DESCRIPTION}
|
||||||
|
INCLUDEDIRS ${QTXDGX_FILE_NAME}
|
||||||
|
LIBS ${QTXDGX_LIBRARY_NAME}
|
||||||
|
REQUIRES ${QTXDGX_PKG_CONFIG_REQUIRES}
|
||||||
|
REQUIRES_PRIVATE ${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
VERSION ${QTXDG_VERSION_STRING}
|
||||||
|
INSTALL
|
||||||
|
)
|
||||||
|
|
||||||
|
create_pkgconfig_file(
|
||||||
|
PACKAGE_NAME ${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
DESCRIPTIVE_NAME ${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
DESCRIPTION ${QTXDGX_ICONLOADER_PKG_CONFIG_DESCRIPTION}
|
||||||
|
INCLUDEDIRS ${QTXDGX_ICONLOADER_FILE_NAME}
|
||||||
|
LIBS ${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
REQUIRES ${QTXDGX_ICONLOADER_PKG_CONFIG_REQUIRES}
|
||||||
|
VERSION ${QTXDG_VERSION_STRING}
|
||||||
|
INSTALL
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config.cmake"
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_FILE_NAME}-config-version.cmake"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_FILE_NAME}"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_ICONLOADER_FILE_NAME}-config.cmake"
|
||||||
|
"${CMAKE_BINARY_DIR}/${QTXDGX_ICONLOADER_FILE_NAME}-config-version.cmake"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_ICONLOADER_FILE_NAME}"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
install(EXPORT
|
||||||
|
"${QTXDGX_FILE_NAME}-targets"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_FILE_NAME}"
|
||||||
|
FILE "${QTXDGX_FILE_NAME}-targets.cmake"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
install(EXPORT
|
||||||
|
"${QTXDGX_ICONLOADER_FILE_NAME}-targets"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${QTXDGX_ICONLOADER_FILE_NAME}"
|
||||||
|
FILE "${QTXDGX_ICONLOADER_FILE_NAME}-targets.cmake"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
# uninstall target
|
# uninstall target
|
||||||
configure_file(
|
configure_file(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||||
|
22
Digia-Qt-LGPL-Exception-1.1
Normal file
22
Digia-Qt-LGPL-Exception-1.1
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Digia Qt LGPL Exception version 1.1
|
||||||
|
|
||||||
|
As an additional permission to the GNU Lesser General Public License version
|
||||||
|
2.1, the object code form of a "work that uses the Library" may incorporate
|
||||||
|
material from a header file that is part of the Library. You may distribute
|
||||||
|
such object code under terms of your choice, provided that:
|
||||||
|
(i) the header files of the Library have not been modified; and
|
||||||
|
(ii) the incorporated material is limited to numerical parameters, data
|
||||||
|
structure layouts, accessors, macros, inline functions and
|
||||||
|
templates; and
|
||||||
|
(iii) you comply with the terms of Section 6 of the GNU Lesser General
|
||||||
|
Public License version 2.1.
|
||||||
|
|
||||||
|
Moreover, you may apply this exception to a modified version of the Library,
|
||||||
|
provided that such modification does not involve copying material from the
|
||||||
|
Library into the modified Library's header files unless such material is
|
||||||
|
limited to (i) numerical parameters; (ii) data structure layouts;
|
||||||
|
(iii) accessors; and (iv) small macros, templates and inline functions of
|
||||||
|
five lines or less in length.
|
||||||
|
|
||||||
|
Furthermore, you are not required to apply this additional permission to a
|
||||||
|
modified version of the Library.
|
25
README
25
README
@ -1,25 +0,0 @@
|
|||||||
Overview
|
|
||||||
========
|
|
||||||
libqtxdg is An Qt implementation of freedesktop.org xdg specifications.
|
|
||||||
It's built with Qt5.
|
|
||||||
|
|
||||||
|
|
||||||
Dependencies
|
|
||||||
============
|
|
||||||
Qt5
|
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
============
|
|
||||||
libqtxdg uses the CMake build system. Everything that applies to CMake also
|
|
||||||
applies here.
|
|
||||||
|
|
||||||
Configuration options:
|
|
||||||
BUILD_TESTS Builds tests, defaults to OFF
|
|
||||||
|
|
||||||
Configuration Examples:
|
|
||||||
Build library and build self tests:
|
|
||||||
cmake -DBUILD_TESTS=ON ..
|
|
||||||
|
|
||||||
Build the library without building self tests
|
|
||||||
cmake ..
|
|
21
README.md
Normal file
21
README.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
##Overview
|
||||||
|
|
||||||
|
```libqtxdg``` is a Qt implementation of freedesktop.org XDG specifications which is built with Qt5.
|
||||||
|
|
||||||
|
##Dependencies
|
||||||
|
|
||||||
|
- Qt5
|
||||||
|
|
||||||
|
##Configuration
|
||||||
|
|
||||||
|
```libqtxdg``` uses the CMake build system. Everything that applies to CMake also
|
||||||
|
applies here.
|
||||||
|
|
||||||
|
###Configuration options:
|
||||||
|
BUILD_TESTS Builds tests, defaults to OFF
|
||||||
|
BUILD_DEV_UTILS Builds and install development utils, defaults to OFF
|
||||||
|
|
||||||
|
###Configuration Examples:
|
||||||
|
Build library and build self tests: ```cmake -DBUILD_TESTS=ON ..```
|
||||||
|
|
||||||
|
Build the library without building self tests : ```cmake ..```
|
@ -92,3 +92,14 @@ set(QTXDG_COMMON_WARNING_FLAGS "-Wall")
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
list(APPEND QTXDG_WARNING_FLAGS ${QTXDG_COMMON_WARNING_FLAGS})
|
list(APPEND QTXDG_WARNING_FLAGS ${QTXDG_COMMON_WARNING_FLAGS})
|
||||||
add_definitions(${QTXDG_WARNING_FLAGS})
|
add_definitions(${QTXDG_WARNING_FLAGS})
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# String conversion flags
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
add_definitions(
|
||||||
|
-DQT_USE_QSTRINGBUILDER
|
||||||
|
-DQT_NO_CAST_FROM_ASCII
|
||||||
|
-DQT_NO_CAST_TO_ASCII
|
||||||
|
-DQT_NO_URL_CAST_FROM_STRING
|
||||||
|
-DQT_NO_CAST_FROM_BYTEARRAY
|
||||||
|
)
|
||||||
|
@ -5,6 +5,7 @@ include(CMakeFindDependencyMacro)
|
|||||||
find_dependency(Qt5Widgets)
|
find_dependency(Qt5Widgets)
|
||||||
find_dependency(Qt5Xml)
|
find_dependency(Qt5Xml)
|
||||||
find_dependency(Qt5DBus)
|
find_dependency(Qt5DBus)
|
||||||
|
find_dependency(Qt5XdgIconLoader)
|
||||||
|
|
||||||
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 OLD)
|
||||||
|
10
cmake/qt5xdgiconloader-config.cmake.in
Normal file
10
cmake/qt5xdgiconloader-config.cmake.in
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
|
find_dependency(Qt5Gui)
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_GREATER 2.8.12)
|
||||||
|
cmake_policy(SET CMP0024 OLD)
|
||||||
|
endif()
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/qt5xdgiconloader-targets.cmake")
|
146
qtxdg/CMakeLists.txt
Normal file
146
qtxdg/CMakeLists.txt
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
"${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
set(libqtxdg_PUBLIC_H_FILES
|
||||||
|
xdgaction.h
|
||||||
|
xdgdesktopfile.h
|
||||||
|
xdgdirs.h
|
||||||
|
xdgicon.h
|
||||||
|
xdgmenu.h
|
||||||
|
xdgmenuwidget.h
|
||||||
|
xmlhelper.h
|
||||||
|
xdgautostart.h
|
||||||
|
xdgmacros.h
|
||||||
|
xdgmimetype.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(libqtxdg_PUBLIC_CLASSES
|
||||||
|
XdgAction
|
||||||
|
XdgDesktopFile
|
||||||
|
XdgDirs
|
||||||
|
XdgIcon
|
||||||
|
XdgMenu
|
||||||
|
XdgMenuWidget
|
||||||
|
XmlHelper
|
||||||
|
XdgAutoStart
|
||||||
|
XdgMimeType
|
||||||
|
)
|
||||||
|
|
||||||
|
set(libqtxdg_PRIVATE_H_FILES
|
||||||
|
xdgmenuapplinkprocessor.h
|
||||||
|
xdgmenulayoutprocessor.h
|
||||||
|
xdgmenu_p.h
|
||||||
|
xdgmenureader.h
|
||||||
|
xdgmenurules.h
|
||||||
|
xdgdesktopfile_p.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(libqtxdg_CPP_FILES
|
||||||
|
xdgaction.cpp
|
||||||
|
xdgdesktopfile.cpp
|
||||||
|
xdgdirs.cpp
|
||||||
|
xdgicon.cpp
|
||||||
|
xdgmenuapplinkprocessor.cpp
|
||||||
|
xdgmenu.cpp
|
||||||
|
xdgmenulayoutprocessor.cpp
|
||||||
|
xdgmenureader.cpp
|
||||||
|
xdgmenurules.cpp
|
||||||
|
xdgmenuwidget.cpp
|
||||||
|
xmlhelper.cpp
|
||||||
|
xdgautostart.cpp
|
||||||
|
xdgmimetype.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(libqtxdg_MOCS
|
||||||
|
xdgaction.h
|
||||||
|
xdgmenuapplinkprocessor.h
|
||||||
|
xdgmenu.h
|
||||||
|
xdgmenu_p.h
|
||||||
|
xdgmenureader.h
|
||||||
|
xdgmenurules.h
|
||||||
|
xdgmenuwidget.h
|
||||||
|
)
|
||||||
|
|
||||||
|
QT5_WRAP_CPP(libqtxdg_CXX_FILES ${libqtxdg_MOCS})
|
||||||
|
|
||||||
|
add_library(${QTXDGX_LIBRARY_NAME} SHARED
|
||||||
|
${libqtxdg_PUBLIC_H_FILES}
|
||||||
|
${libqtxdg_PRIVATE_H_FILES}
|
||||||
|
${libqtxdg_PRIVATE_H_FILES}
|
||||||
|
${libqtxdg_CPP_FILES}
|
||||||
|
${libqtxdg_CXX_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${QTXDGX_LIBRARY_NAME}
|
||||||
|
PUBLIC
|
||||||
|
${QTX_LIBRARIES}
|
||||||
|
${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(${QTXDGX_LIBRARY_NAME} PROPERTIES
|
||||||
|
VERSION ${QTXDG_VERSION_STRING}
|
||||||
|
SOVERSION ${QTXDG_MAJOR_VERSION}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${QTXDGX_LIBRARY_NAME}
|
||||||
|
PRIVATE "QTXDG_COMPILATION=\"1\""
|
||||||
|
PRIVATE "QTXDG_VERSION=\"${QTXDG_VERSION_STRING}\""
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${QTXDGX_LIBRARY_NAME}
|
||||||
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}>"
|
||||||
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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_portable_headers(libqtxdg_PORTABLE_HEADERS
|
||||||
|
HEADER_NAMES ${libqtxdg_PUBLIC_CLASSES}
|
||||||
|
OUTPUT_DIR "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Copy public headers (in tree building)
|
||||||
|
foreach(h ${libqtxdg_PUBLIC_H_FILES})
|
||||||
|
get_filename_component(bh ${h} NAME)
|
||||||
|
configure_file(${h} "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${bh}" COPYONLY)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Copy private headers (in tree building)
|
||||||
|
foreach(h ${libqtxdg_PRIVATE_INSTALLABLE_H_FILES})
|
||||||
|
get_filename_component(bh ${h} NAME)
|
||||||
|
configure_file(${h} "${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${QTXDG_VERSION_STRING}/private/qtxdg/${bh}" COPYONLY)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
install(TARGETS
|
||||||
|
${QTXDGX_LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
EXPORT "${QTXDGX_FILE_NAME}-targets"
|
||||||
|
COMPONENT Runtime
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${libqtxdg_PUBLIC_H_FILES}
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${libqtxdg_PRIVATE_INSTALLABLE_H_FILES}
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}/${QTXDG_VERSION_STRING}/private/qtxdg"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${libqtxdg_PORTABLE_HEADERS}
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_FILE_NAME}"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
@ -91,7 +91,7 @@ void XdgAction::load(const XdgDesktopFile& desktopFile)
|
|||||||
if (mDesktopFile.isValid())
|
if (mDesktopFile.isValid())
|
||||||
{
|
{
|
||||||
// & is reserved for mnemonics
|
// & is reserved for mnemonics
|
||||||
setText(mDesktopFile.name().replace('&', QLatin1String("&&")));
|
setText(mDesktopFile.name().replace(QLatin1Char('&'), QLatin1String("&&")));
|
||||||
setToolTip(mDesktopFile.comment());
|
setToolTip(mDesktopFile.comment());
|
||||||
|
|
||||||
connect(this, SIGNAL(triggered()), this, SLOT(runConmmand()));
|
connect(this, SIGNAL(triggered()), this, SLOT(runConmmand()));
|
||||||
@ -117,6 +117,6 @@ void XdgAction::updateIcon()
|
|||||||
{
|
{
|
||||||
setIcon(mDesktopFile.icon());
|
setIcon(mDesktopFile.icon());
|
||||||
if (icon().isNull())
|
if (icon().isNull())
|
||||||
setIcon(XdgIcon::fromTheme("application-x-executable"));
|
setIcon(XdgIcon::fromTheme(QLatin1String("application-x-executable")));
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
@ -57,14 +57,14 @@ XdgDesktopFileList XdgAutoStart::desktopFileList(QStringList dirs, bool excludeH
|
|||||||
|
|
||||||
QSet<QString> processed;
|
QSet<QString> processed;
|
||||||
XdgDesktopFileList ret;
|
XdgDesktopFileList ret;
|
||||||
foreach (QString dirName, dirs)
|
foreach (const QString &dirName, dirs)
|
||||||
{
|
{
|
||||||
QDir dir(dirName);
|
QDir dir(dirName);
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QFileInfoList files = dir.entryInfoList(QStringList("*.desktop"), QDir::Files | QDir::Readable);
|
const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files | QDir::Readable);
|
||||||
foreach (QFileInfo fi, files)
|
foreach (const QFileInfo &fi, files)
|
||||||
{
|
{
|
||||||
if (processed.contains(fi.fileName()))
|
if (processed.contains(fi.fileName()))
|
||||||
continue;
|
continue;
|
||||||
@ -88,5 +88,5 @@ XdgDesktopFileList XdgAutoStart::desktopFileList(QStringList dirs, bool excludeH
|
|||||||
QString XdgAutoStart::localPath(const XdgDesktopFile& file)
|
QString XdgAutoStart::localPath(const XdgDesktopFile& file)
|
||||||
{
|
{
|
||||||
QFileInfo fi(file.fileName());
|
QFileInfo fi(file.fileName());
|
||||||
return QString("%1/%2").arg(XdgDirs::autostartHome(), fi.fileName());
|
return QString::fromLatin1("%1/%2").arg(XdgDirs::autostartHome(), fi.fileName());
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -79,7 +79,7 @@ public:
|
|||||||
- ApplicationType, "value" should be the Exec value;
|
- ApplicationType, "value" should be the Exec value;
|
||||||
- LinkType, "value" should be the URL;
|
- LinkType, "value" should be the URL;
|
||||||
- DirectoryType, "value" should be omitted */
|
- DirectoryType, "value" should be omitted */
|
||||||
XdgDesktopFile(XdgDesktopFile::Type type, const QString& name, const QString& value = 0);
|
XdgDesktopFile(XdgDesktopFile::Type type, const QString& name, const QString& value = QString());
|
||||||
|
|
||||||
//! Destroys the object.
|
//! Destroys the object.
|
||||||
virtual ~XdgDesktopFile();
|
virtual ~XdgDesktopFile();
|
||||||
@ -146,11 +146,18 @@ public:
|
|||||||
//! Returns an icon name specified in this file.
|
//! Returns an icon name specified in this file.
|
||||||
QString const iconName() const;
|
QString const iconName() const;
|
||||||
|
|
||||||
|
//! Returns an list of mimetypes specified in this file.
|
||||||
|
/*! @return Returns a list of the "MimeType=" entries.
|
||||||
|
* If the file doens't contain the MimeType entry, an empty QStringList is
|
||||||
|
* returned. Empty values are removed from the returned list.
|
||||||
|
*/
|
||||||
|
QStringList mimeTypes() const;
|
||||||
|
|
||||||
//! This function is provided for convenience. It's equivalent to calling localizedValue("Name").toString().
|
//! This function is provided for convenience. It's equivalent to calling localizedValue("Name").toString().
|
||||||
QString name() const { return localizedValue("Name").toString(); }
|
QString name() const { return localizedValue(QLatin1String("Name")).toString(); }
|
||||||
|
|
||||||
//! This function is provided for convenience. It's equivalent to calling localizedValue("Comment").toString().
|
//! This function is provided for convenience. It's equivalent to calling localizedValue("Comment").toString().
|
||||||
QString comment() const { return localizedValue("Comment").toString(); }
|
QString comment() const { return localizedValue(QLatin1String("Comment")).toString(); }
|
||||||
|
|
||||||
/*! Returns the desktop file type.
|
/*! Returns the desktop file type.
|
||||||
@see XdgDesktopFile::Type */
|
@see XdgDesktopFile::Type */
|
||||||
@ -177,9 +184,16 @@ public:
|
|||||||
/*! Returns the URL for the Link desktop file; otherwise an empty string is returned. */
|
/*! Returns the URL for the Link desktop file; otherwise an empty string is returned. */
|
||||||
QString url() const;
|
QString url() const;
|
||||||
|
|
||||||
/*! The desktop entry specification defines a number of fields to control the visibility of the application menu. This function
|
/*! Computes the desktop file ID. It is the identifier of an installed
|
||||||
checks whether to display a this application or not. */
|
* desktop entry file.
|
||||||
QTXDG_DEPRECATED bool isShow(const QString& environment = "Razor") const;
|
* @par fileName - The desktop file complete name.
|
||||||
|
* @par checkFileExists If true and the file doesn't exist the computed ID
|
||||||
|
* will be an empty QString(). Defaults to true.
|
||||||
|
* @return The computed ID. Returns an empty QString() if it's impossible to
|
||||||
|
* compute the ID. Reference:
|
||||||
|
* https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id
|
||||||
|
*/
|
||||||
|
static QString id(const QString &fileName, bool checkFileExists = true);
|
||||||
|
|
||||||
/*! The desktop entry specification defines a number of fields to control
|
/*! The desktop entry specification defines a number of fields to control
|
||||||
the visibility of the application menu. Thisfunction checks whether
|
the visibility of the application menu. Thisfunction checks whether
|
||||||
@ -192,12 +206,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isShown(const QString &environment = QString()) const;
|
bool isShown(const QString &environment = QString()) const;
|
||||||
|
|
||||||
/*! This fuction returns true if the desktop file is applicable to the current environment.
|
|
||||||
@par excludeHidden - if set to true (default), files with "Hidden=true" will be considered "not applicable".
|
|
||||||
Setting this to false is be useful when the user wants to enable/disable items and wants to see those
|
|
||||||
that are Hidden */
|
|
||||||
QTXDG_DEPRECATED bool isApplicable(bool excludeHidden = true, const QString& environment = "Razor") const;
|
|
||||||
|
|
||||||
/*! This fuction returns true if the desktop file is applicable to the
|
/*! This fuction returns true if the desktop file is applicable to the
|
||||||
current environment.
|
current environment.
|
||||||
@par excludeHidden - if set to true (default), files with
|
@par excludeHidden - if set to true (default), files with
|
||||||
@ -213,7 +221,7 @@ public:
|
|||||||
bool isSuitable(bool excludeHidden = true, const QString &environment = QString()) const;
|
bool isSuitable(bool excludeHidden = true, const QString &environment = QString()) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString prefix() const { return "Desktop Entry"; }
|
virtual QString prefix() const { return QLatin1String("Desktop Entry"); }
|
||||||
virtual bool check() const { return true; }
|
virtual bool check() const { return true; }
|
||||||
private:
|
private:
|
||||||
/*! Returns the localized version of the key if the Desktop File already contains a localized version of it.
|
/*! Returns the localized version of the key if the Desktop File already contains a localized version of it.
|
||||||
@ -261,5 +269,3 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
#endif // QTXDG_XDGDESKTOPFILE_H
|
#endif // QTXDG_XDGDESKTOPFILE_H
|
||||||
|
|
||||||
|
|
@ -28,21 +28,20 @@
|
|||||||
#include "xdgdirs.h"
|
#include "xdgdirs.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStringBuilder> // for the % operator
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
|
||||||
static const QString userDirectoryString[8] =
|
static const QString userDirectoryString[8] =
|
||||||
{
|
{
|
||||||
"Desktop",
|
QLatin1String("Desktop"),
|
||||||
"Download",
|
QLatin1String("Download"),
|
||||||
"Templates",
|
QLatin1String("Templates"),
|
||||||
"Publicshare",
|
QLatin1String("Publicshare"),
|
||||||
"Documents",
|
QLatin1String("Documents"),
|
||||||
"Music",
|
QLatin1String("Music"),
|
||||||
"Pictures",
|
QLatin1String("Pictures"),
|
||||||
"Videos"
|
QLatin1String("Videos")
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper functions prototypes
|
// Helper functions prototypes
|
||||||
@ -51,7 +50,7 @@ void removeEndingSlash(QString &s);
|
|||||||
QString createDirectory(const QString &dir);
|
QString createDirectory(const QString &dir);
|
||||||
|
|
||||||
void cleanAndAddPostfix(QStringList &dirs, const QString& postfix);
|
void cleanAndAddPostfix(QStringList &dirs, const QString& postfix);
|
||||||
|
QString userDirFallback(XdgDirs::UserDirectory dir);
|
||||||
|
|
||||||
/************************************************
|
/************************************************
|
||||||
Helper func.
|
Helper func.
|
||||||
@ -59,7 +58,7 @@ void cleanAndAddPostfix(QStringList &dirs, const QString& postfix);
|
|||||||
void fixBashShortcuts(QString &s)
|
void fixBashShortcuts(QString &s)
|
||||||
{
|
{
|
||||||
if (s.startsWith(QLatin1Char('~')))
|
if (s.startsWith(QLatin1Char('~')))
|
||||||
s = QString(getenv("HOME")) + (s).mid(1);
|
s = QFile::decodeName(qgetenv("HOME")) + (s).mid(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,9 +77,9 @@ QString createDirectory(const QString &dir)
|
|||||||
QDir d(dir);
|
QDir d(dir);
|
||||||
if (!d.exists())
|
if (!d.exists())
|
||||||
{
|
{
|
||||||
if (!d.mkpath("."))
|
if (!d.mkpath(QLatin1String(".")))
|
||||||
{
|
{
|
||||||
qWarning() << QString("Can't create %1 directory.").arg(d.absolutePath());
|
qWarning() << QString::fromLatin1("Can't create %1 directory.").arg(d.absolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString r = d.absolutePath();
|
QString r = d.absolutePath();
|
||||||
@ -101,31 +100,53 @@ void cleanAndAddPostfix(QStringList &dirs, const QString& postfix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString userDirFallback(XdgDirs::UserDirectory dir)
|
||||||
|
{
|
||||||
|
QString fallback;
|
||||||
|
const QString home = QFile::decodeName(qgetenv("HOME"));
|
||||||
|
|
||||||
|
if (home.isEmpty())
|
||||||
|
return QString::fromLatin1("/tmp");
|
||||||
|
else if (dir == XdgDirs::Desktop)
|
||||||
|
fallback = QString::fromLatin1("%1/%2").arg(home).arg(QLatin1String("Desktop"));
|
||||||
|
else
|
||||||
|
fallback = home;
|
||||||
|
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString XdgDirs::userDirDefault(XdgDirs::UserDirectory dir)
|
||||||
|
{
|
||||||
|
// possible values for UserDirectory
|
||||||
|
Q_ASSERT(!(dir < XdgDirs::Desktop || dir > XdgDirs::Videos));
|
||||||
|
if (dir < XdgDirs::Desktop || dir > XdgDirs::Videos)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
return userDirFallback(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString XdgDirs::userDir(XdgDirs::UserDirectory dir)
|
QString XdgDirs::userDir(XdgDirs::UserDirectory dir)
|
||||||
{
|
{
|
||||||
// possible values for UserDirectory
|
// possible values for UserDirectory
|
||||||
if (dir < 0 || dir > 7)
|
Q_ASSERT(!(dir < XdgDirs::Desktop || dir > XdgDirs::Videos));
|
||||||
|
if (dir < XdgDirs::Desktop || dir > XdgDirs::Videos)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString folderName = userDirectoryString[dir];
|
QString folderName = userDirectoryString[dir];
|
||||||
|
|
||||||
QString fallback;
|
const QString fallback = userDirFallback(dir);
|
||||||
if (getenv("HOME") == NULL)
|
|
||||||
return QString("/tmp");
|
|
||||||
else if (dir == XdgDirs::Desktop)
|
|
||||||
fallback = QString("%1/%2").arg(getenv("HOME")).arg("Desktop");
|
|
||||||
else
|
|
||||||
fallback = QString(getenv("HOME"));
|
|
||||||
|
|
||||||
QString configDir(configHome());
|
QString configDir(configHome());
|
||||||
QFile configFile(configDir + "/user-dirs.dirs");
|
QFile configFile(configDir + QLatin1String("/user-dirs.dirs"));
|
||||||
if (!configFile.exists())
|
if (!configFile.exists())
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|
||||||
if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|
||||||
QString userDirVar("XDG_" + folderName.toUpper() + "_DIR");
|
QString userDirVar(QLatin1String("XDG_") + folderName.toUpper() + QLatin1String("_DIR"));
|
||||||
QTextStream in(&configFile);
|
QTextStream in(&configFile);
|
||||||
QString line;
|
QString line;
|
||||||
while (!in.atEnd())
|
while (!in.atEnd())
|
||||||
@ -137,6 +158,8 @@ QString XdgDirs::userDir(XdgDirs::UserDirectory dir)
|
|||||||
|
|
||||||
// get path between quotes
|
// get path between quotes
|
||||||
line = line.section(QLatin1Char('"'), 1, 1);
|
line = line.section(QLatin1Char('"'), 1, 1);
|
||||||
|
if (line.isEmpty())
|
||||||
|
return fallback;
|
||||||
line.replace(QLatin1String("$HOME"), QLatin1String("~"));
|
line.replace(QLatin1String("$HOME"), QLatin1String("~"));
|
||||||
fixBashShortcuts(line);
|
fixBashShortcuts(line);
|
||||||
return line;
|
return line;
|
||||||
@ -151,18 +174,19 @@ QString XdgDirs::userDir(XdgDirs::UserDirectory dir)
|
|||||||
bool XdgDirs::setUserDir(XdgDirs::UserDirectory dir, const QString& value, bool createDir)
|
bool XdgDirs::setUserDir(XdgDirs::UserDirectory dir, const QString& value, bool createDir)
|
||||||
{
|
{
|
||||||
// possible values for UserDirectory
|
// possible values for UserDirectory
|
||||||
if (dir < 0 || dir > 7)
|
Q_ASSERT(!(dir < XdgDirs::Desktop || dir > XdgDirs::Videos));
|
||||||
|
if (dir < XdgDirs::Desktop || dir > XdgDirs::Videos)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(value.startsWith(QLatin1String("$HOME"))
|
if (!(value.startsWith(QLatin1String("$HOME"))
|
||||||
|| value.startsWith(QLatin1String("~/"))
|
|| value.startsWith(QLatin1String("~/"))
|
||||||
|| value.startsWith(QString(getenv("HOME")))))
|
|| value.startsWith(QFile::decodeName(qgetenv("HOME")))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString folderName = userDirectoryString[dir];
|
QString folderName = userDirectoryString[dir];
|
||||||
|
|
||||||
QString configDir(configHome());
|
QString configDir(configHome());
|
||||||
QFile configFile(configDir % QLatin1String("/user-dirs.dirs"));
|
QFile configFile(configDir + QLatin1String("/user-dirs.dirs"));
|
||||||
|
|
||||||
// create the file if doesn't exist and opens it
|
// create the file if doesn't exist and opens it
|
||||||
if (!configFile.open(QIODevice::ReadWrite | QIODevice::Text))
|
if (!configFile.open(QIODevice::ReadWrite | QIODevice::Text))
|
||||||
@ -191,10 +215,10 @@ 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("XDG_%1_DIR=\"%2\"\n").arg(folderName.toUpper()).arg(value);
|
stream << QString::fromLatin1("XDG_%1_DIR=\"%2\"\n").arg(folderName.toUpper()).arg(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 << "\n";
|
stream << *i << QLatin1Char('\n');
|
||||||
|
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
@ -293,7 +317,7 @@ QString XdgDirs::runtimeDir()
|
|||||||
|
|
||||||
QString XdgDirs::autostartHome(bool createDir)
|
QString XdgDirs::autostartHome(bool createDir)
|
||||||
{
|
{
|
||||||
QString s = QString("%1/autostart").arg(configHome(createDir));
|
QString s = QString::fromLatin1("%1/autostart").arg(configHome(createDir));
|
||||||
fixBashShortcuts(s);
|
fixBashShortcuts(s);
|
||||||
|
|
||||||
if (createDir)
|
if (createDir)
|
||||||
@ -309,9 +333,9 @@ QString XdgDirs::autostartHome(bool createDir)
|
|||||||
QStringList XdgDirs::autostartDirs(const QString &postfix)
|
QStringList XdgDirs::autostartDirs(const QString &postfix)
|
||||||
{
|
{
|
||||||
QStringList dirs;
|
QStringList dirs;
|
||||||
QStringList s = configDirs();
|
const QStringList s = configDirs();
|
||||||
foreach(QString dir, s)
|
foreach(const QString &dir, s)
|
||||||
dirs << QString("%1/autostart").arg(dir) + postfix;
|
dirs << QString::fromLatin1("%1/autostart").arg(dir) + postfix;
|
||||||
|
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
@ -62,6 +62,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
static QString userDir(UserDirectory dir);
|
static QString userDir(UserDirectory dir);
|
||||||
|
|
||||||
|
|
||||||
|
/*! @brief Returns the default path to the user specified directory.
|
||||||
|
* Returns /tmp if no $HOME defined, $HOME/Desktop if dir equals
|
||||||
|
* XdgDirs::Desktop or $HOME othewise. If dir value is invalid, an empty
|
||||||
|
* QString is returned.
|
||||||
|
*/
|
||||||
|
static QString userDirDefault(UserDirectory dir);
|
||||||
|
|
||||||
/*! @brief Returns true if writting into configuration file $XDG_CONFIG_HOME/user-dirs.dirs
|
/*! @brief Returns true if writting into configuration file $XDG_CONFIG_HOME/user-dirs.dirs
|
||||||
* the path in value for the directory in dir is succesfull. Returns false otherwise. If
|
* the path in value for the directory in dir is succesfull. Returns false otherwise. If
|
||||||
* createDir is true, dir will be created if it doesn't exist.
|
* createDir is true, dir will be created if it doesn't exist.
|
@ -33,10 +33,10 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QCache>
|
#include <QCache>
|
||||||
#include "qiconfix/qiconloader_p.h"
|
#include "../xdgiconloader/xdgiconloader_p.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#define DEFAULT_APP_ICON "application-x-executable"
|
static const QLatin1String DEFAULT_APP_ICON("application-x-executable");
|
||||||
|
|
||||||
static void qt_cleanup_icon_cache();
|
static void qt_cleanup_icon_cache();
|
||||||
typedef QCache<QString, QIcon> IconCache;
|
typedef QCache<QString, QIcon> IconCache;
|
||||||
@ -83,7 +83,7 @@ QString XdgIcon::themeName()
|
|||||||
void XdgIcon::setThemeName(const QString& themeName)
|
void XdgIcon::setThemeName(const QString& themeName)
|
||||||
{
|
{
|
||||||
QIcon::setThemeName(themeName);
|
QIcon::setThemeName(themeName);
|
||||||
QtXdg::QIconLoader::instance()->updateSystemTheme();
|
XdgIconLoader::instance()->updateSystemTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,12 +96,12 @@ QIcon XdgIcon::fromTheme(const QString& iconName, const QIcon& fallback)
|
|||||||
if (iconName.isEmpty())
|
if (iconName.isEmpty())
|
||||||
return fallback;
|
return fallback;
|
||||||
|
|
||||||
bool isAbsolute = (iconName[0] == '/');
|
bool isAbsolute = (iconName[0] == QLatin1Char('/'));
|
||||||
|
|
||||||
QString name = QFileInfo(iconName).fileName();
|
QString name = QFileInfo(iconName).fileName();
|
||||||
if (name.endsWith(".png", Qt::CaseInsensitive) ||
|
if (name.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) ||
|
||||||
name.endsWith(".svg", Qt::CaseInsensitive) ||
|
name.endsWith(QLatin1String(".svg"), Qt::CaseInsensitive) ||
|
||||||
name.endsWith(".xpm", Qt::CaseInsensitive))
|
name.endsWith(QLatin1String(".xpm"), Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
name.truncate(name.length() - 4);
|
name.truncate(name.length() - 4);
|
||||||
}
|
}
|
||||||
@ -113,11 +113,12 @@ QIcon XdgIcon::fromTheme(const QString& iconName, const QIcon& fallback)
|
|||||||
} else {
|
} else {
|
||||||
QIcon *cachedIcon;
|
QIcon *cachedIcon;
|
||||||
if (!isAbsolute)
|
if (!isAbsolute)
|
||||||
cachedIcon = new QIcon(new QtXdg::QIconLoaderEngineFixed(name));
|
cachedIcon = new QIcon(new XdgIconLoaderEngine(name));
|
||||||
else
|
else
|
||||||
cachedIcon = new QIcon(iconName);
|
cachedIcon = new QIcon(iconName);
|
||||||
qtIconCache()->insert(name, cachedIcon);
|
|
||||||
icon = *cachedIcon;
|
icon = *cachedIcon;
|
||||||
|
|
||||||
|
qtIconCache()->insert(name, cachedIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note the qapp check is to allow lazy loading of static icons
|
// Note the qapp check is to allow lazy loading of static icons
|
||||||
@ -136,7 +137,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 (QString iconName, iconNames)
|
foreach (const QString &iconName, iconNames)
|
||||||
{
|
{
|
||||||
QIcon icon = fromTheme(iconName);
|
QIcon icon = fromTheme(iconName);
|
||||||
if (!icon.isNull())
|
if (!icon.isNull())
|
@ -157,37 +157,37 @@ bool XdgMenu::read(const QString& menuFileName)
|
|||||||
|
|
||||||
d->mXml = reader.xml();
|
d->mXml = reader.xml();
|
||||||
QDomElement root = d->mXml.documentElement();
|
QDomElement root = d->mXml.documentElement();
|
||||||
d->saveLog("00-reader.xml");
|
d->saveLog(QLatin1String("00-reader.xml"));
|
||||||
|
|
||||||
d->simplify(root);
|
d->simplify(root);
|
||||||
d->saveLog("01-simplify.xml");
|
d->saveLog(QLatin1String("01-simplify.xml"));
|
||||||
|
|
||||||
d->mergeMenus(root);
|
d->mergeMenus(root);
|
||||||
d->saveLog("02-mergeMenus.xml");
|
d->saveLog(QLatin1String("02-mergeMenus.xml"));
|
||||||
|
|
||||||
d->moveMenus(root);
|
d->moveMenus(root);
|
||||||
d->saveLog("03-moveMenus.xml");
|
d->saveLog(QLatin1String("03-moveMenus.xml"));
|
||||||
|
|
||||||
d->mergeMenus(root);
|
d->mergeMenus(root);
|
||||||
d->saveLog("04-mergeMenus.xml");
|
d->saveLog(QLatin1String("04-mergeMenus.xml"));
|
||||||
|
|
||||||
d->deleteDeletedMenus(root);
|
d->deleteDeletedMenus(root);
|
||||||
d->saveLog("05-deleteDeletedMenus.xml");
|
d->saveLog(QLatin1String("05-deleteDeletedMenus.xml"));
|
||||||
|
|
||||||
d->processDirectoryEntries(root, QStringList());
|
d->processDirectoryEntries(root, QStringList());
|
||||||
d->saveLog("06-processDirectoryEntries.xml");
|
d->saveLog(QLatin1String("06-processDirectoryEntries.xml"));
|
||||||
|
|
||||||
d->processApps(root);
|
d->processApps(root);
|
||||||
d->saveLog("07-processApps.xml");
|
d->saveLog(QLatin1String("07-processApps.xml"));
|
||||||
|
|
||||||
d->processLayouts(root);
|
d->processLayouts(root);
|
||||||
d->saveLog("08-processLayouts.xml");
|
d->saveLog(QLatin1String("08-processLayouts.xml"));
|
||||||
|
|
||||||
d->deleteEmpty(root);
|
d->deleteEmpty(root);
|
||||||
d->saveLog("09-deleteEmpty.xml");
|
d->saveLog(QLatin1String("09-deleteEmpty.xml"));
|
||||||
|
|
||||||
d->fixSeparators(root);
|
d->fixSeparators(root);
|
||||||
d->saveLog("10-fixSeparators.xml");
|
d->saveLog(QLatin1String("10-fixSeparators.xml"));
|
||||||
|
|
||||||
|
|
||||||
d->mOutDated = false;
|
d->mOutDated = false;
|
||||||
@ -204,7 +204,7 @@ void XdgMenu::save(const QString& fileName)
|
|||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QFile::WriteOnly | QFile::Text))
|
if (!file.open(QFile::WriteOnly | QFile::Text))
|
||||||
{
|
{
|
||||||
qWarning() << QString("Cannot write file %1:\n%2.")
|
qWarning() << QString::fromLatin1("Cannot write file %1:\n%2.")
|
||||||
.arg(fileName)
|
.arg(fileName)
|
||||||
.arg(file.errorString());
|
.arg(file.errorString());
|
||||||
return;
|
return;
|
||||||
@ -225,7 +225,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("%1 not loading: %2").arg(fileName).arg(file.errorString());
|
qWarning() << QString::fromLatin1("%1 not loading: %2").arg(fileName).arg(file.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mXml.setContent(&file, true);
|
mXml.setContent(&file, true);
|
||||||
@ -236,7 +236,7 @@ void XdgMenuPrivate::saveLog(const QString& logFileName)
|
|||||||
{
|
{
|
||||||
Q_Q(XdgMenu);
|
Q_Q(XdgMenu);
|
||||||
if (!mLogDir.isEmpty())
|
if (!mLogDir.isEmpty())
|
||||||
q->save(mLogDir + "/" + logFileName);
|
q->save(mLogDir + QLatin1Char('/') + logFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -244,13 +244,13 @@ void XdgMenuPrivate::mergeMenus(QDomElement& element)
|
|||||||
{
|
{
|
||||||
QHash<QString, QDomElement> menus;
|
QHash<QString, QDomElement> menus;
|
||||||
|
|
||||||
MutableDomElementIterator it(element, "Menu");
|
MutableDomElementIterator it(element, QLatin1String("Menu"));
|
||||||
|
|
||||||
it.toFront();
|
it.toFront();
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
it.next();
|
it.next();
|
||||||
menus[it.current().attribute("name")] = it.current();
|
menus[it.current().attribute(QLatin1String("name"))] = it.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void XdgMenuPrivate::mergeMenus(QDomElement& element)
|
|||||||
while (it.hasPrevious())
|
while (it.hasPrevious())
|
||||||
{
|
{
|
||||||
QDomElement src = it.previous();
|
QDomElement src = it.previous();
|
||||||
QDomElement dest = menus[src.attribute("name")];
|
QDomElement dest = menus[src.attribute(QLatin1String("name"))];
|
||||||
if (dest != src)
|
if (dest != src)
|
||||||
{
|
{
|
||||||
prependChilds(src, dest);
|
prependChilds(src, dest);
|
||||||
@ -267,11 +267,11 @@ void XdgMenuPrivate::mergeMenus(QDomElement& element)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDomElement n = element.firstChildElement("Menu");
|
QDomElement n = element.firstChildElement(QLatin1String("Menu"));
|
||||||
while (!n.isNull())
|
while (!n.isNull())
|
||||||
{
|
{
|
||||||
mergeMenus(n);
|
mergeMenus(n);
|
||||||
n = n.nextSiblingElement("Menu");
|
n = n.nextSiblingElement(QLatin1String("Menu"));
|
||||||
}
|
}
|
||||||
|
|
||||||
it.toFront();
|
it.toFront();
|
||||||
@ -288,46 +288,46 @@ void XdgMenuPrivate::simplify(QDomElement& element)
|
|||||||
{
|
{
|
||||||
QDomElement n = it.next();
|
QDomElement n = it.next();
|
||||||
|
|
||||||
if (n.tagName() == "Name")
|
if (n.tagName() == QLatin1String("Name"))
|
||||||
{
|
{
|
||||||
// The <Name> field must not contain the slash character ("/");
|
// The <Name> field must not contain the slash character ("/");
|
||||||
// implementations should discard any name containing a slash.
|
// implementations should discard any name containing a slash.
|
||||||
element.setAttribute("name", n.text().remove('/'));
|
element.setAttribute(QLatin1String("name"), n.text().remove(QLatin1Char('/')));
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ......................................
|
// ......................................
|
||||||
else if(n.tagName() == "Deleted")
|
else if(n.tagName() == QLatin1String("Deleted"))
|
||||||
{
|
{
|
||||||
element.setAttribute("deleted", true);
|
element.setAttribute(QLatin1String("deleted"), true);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
else if(n.tagName() == "NotDeleted")
|
else if(n.tagName() == QLatin1String("NotDeleted"))
|
||||||
{
|
{
|
||||||
element.setAttribute("deleted", false);
|
element.setAttribute(QLatin1String("deleted"), false);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ......................................
|
// ......................................
|
||||||
else if(n.tagName() == "OnlyUnallocated")
|
else if(n.tagName() == QLatin1String("OnlyUnallocated"))
|
||||||
{
|
{
|
||||||
element.setAttribute("onlyUnallocated", true);
|
element.setAttribute(QLatin1String("onlyUnallocated"), true);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
else if(n.tagName() == "NotOnlyUnallocated")
|
else if(n.tagName() == QLatin1String(QLatin1String("NotOnlyUnallocated")))
|
||||||
{
|
{
|
||||||
element.setAttribute("onlyUnallocated", false);
|
element.setAttribute(QLatin1String("onlyUnallocated"), false);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ......................................
|
// ......................................
|
||||||
else if(n.tagName() == "FileInfo")
|
else if(n.tagName() == QLatin1String("FileInfo"))
|
||||||
{
|
{
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ......................................
|
// ......................................
|
||||||
else if(n.tagName() == "Menu")
|
else if(n.tagName() == QLatin1String("Menu"))
|
||||||
{
|
{
|
||||||
simplify(n);
|
simplify(n);
|
||||||
}
|
}
|
||||||
@ -348,15 +348,15 @@ void XdgMenuPrivate::prependChilds(QDomElement& srcElement, QDomElement& destEle
|
|||||||
destElement.insertBefore(n, destElement.firstChild());
|
destElement.insertBefore(n, destElement.firstChild());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srcElement.attributes().contains("deleted") &&
|
if (srcElement.attributes().contains(QLatin1String("deleted")) &&
|
||||||
!destElement.attributes().contains("deleted")
|
!destElement.attributes().contains(QLatin1String("deleted"))
|
||||||
)
|
)
|
||||||
destElement.setAttribute("deleted", srcElement.attribute("deleted"));
|
destElement.setAttribute(QLatin1String("deleted"), srcElement.attribute(QLatin1String("deleted")));
|
||||||
|
|
||||||
if (srcElement.attributes().contains("onlyUnallocated") &&
|
if (srcElement.attributes().contains(QLatin1String("onlyUnallocated")) &&
|
||||||
!destElement.attributes().contains("onlyUnallocated")
|
!destElement.attributes().contains(QLatin1String("onlyUnallocated"))
|
||||||
)
|
)
|
||||||
destElement.setAttribute("onlyUnallocated", srcElement.attribute("onlyUnallocated"));
|
destElement.setAttribute(QLatin1String("onlyUnallocated"), srcElement.attribute(QLatin1String("onlyUnallocated")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -367,11 +367,11 @@ void XdgMenuPrivate::appendChilds(QDomElement& srcElement, QDomElement& destElem
|
|||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
destElement.appendChild(it.next());
|
destElement.appendChild(it.next());
|
||||||
|
|
||||||
if (srcElement.attributes().contains("deleted"))
|
if (srcElement.attributes().contains(QLatin1String("deleted")))
|
||||||
destElement.setAttribute("deleted", srcElement.attribute("deleted"));
|
destElement.setAttribute(QLatin1String("deleted"), srcElement.attribute(QLatin1String("deleted")));
|
||||||
|
|
||||||
if (srcElement.attributes().contains("onlyUnallocated"))
|
if (srcElement.attributes().contains(QLatin1String("onlyUnallocated")))
|
||||||
destElement.setAttribute("onlyUnallocated", srcElement.attribute("onlyUnallocated"));
|
destElement.setAttribute(QLatin1String("onlyUnallocated"), srcElement.attribute(QLatin1String("onlyUnallocated")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -384,10 +384,10 @@ QDomElement XdgMenu::findMenu(QDomElement& baseElement, const QString& path, boo
|
|||||||
{
|
{
|
||||||
Q_D(XdgMenu);
|
Q_D(XdgMenu);
|
||||||
// Absolute path ..................
|
// Absolute path ..................
|
||||||
if (path.startsWith('/'))
|
if (path.startsWith(QLatin1Char('/')))
|
||||||
{
|
{
|
||||||
QDomElement root = d->mXml.documentElement();
|
QDomElement root = d->mXml.documentElement();
|
||||||
return findMenu(root, path.section('/', 2), createNonExisting);
|
return findMenu(root, path.section(QLatin1Char('/'), 2), createNonExisting);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relative path ..................
|
// Relative path ..................
|
||||||
@ -395,13 +395,13 @@ QDomElement XdgMenu::findMenu(QDomElement& baseElement, const QString& path, boo
|
|||||||
return baseElement;
|
return baseElement;
|
||||||
|
|
||||||
|
|
||||||
QString name = path.section('/', 0, 0);
|
QString name = path.section(QLatin1Char('/'), 0, 0);
|
||||||
MutableDomElementIterator it(baseElement);
|
MutableDomElementIterator it(baseElement);
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement n = it.next();
|
QDomElement n = it.next();
|
||||||
if (n.attribute("name") == name)
|
if (n.attribute(QLatin1String("name")) == name)
|
||||||
return findMenu(n, path.section('/', 1), createNonExisting);
|
return findMenu(n, path.section(QLatin1Char('/'), 1), createNonExisting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,14 +411,14 @@ QDomElement XdgMenu::findMenu(QDomElement& baseElement, const QString& path, boo
|
|||||||
return QDomElement();
|
return QDomElement();
|
||||||
|
|
||||||
|
|
||||||
QStringList names = path.split('/', QString::SkipEmptyParts);
|
const QStringList names = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
|
||||||
QDomElement el = baseElement;
|
QDomElement el = baseElement;
|
||||||
foreach (QString name, names)
|
foreach (const QString &name, names)
|
||||||
{
|
{
|
||||||
QDomElement p = el;
|
QDomElement p = el;
|
||||||
el = d->mXml.createElement("Menu");
|
el = d->mXml.createElement(QLatin1String("Menu"));
|
||||||
p.appendChild(el);
|
p.appendChild(el);
|
||||||
el.setAttribute("name", name);
|
el.setAttribute(QLatin1String("name"), name);
|
||||||
}
|
}
|
||||||
return el;
|
return el;
|
||||||
|
|
||||||
@ -454,17 +454,17 @@ void XdgMenuPrivate::moveMenus(QDomElement& element)
|
|||||||
Q_Q(XdgMenu);
|
Q_Q(XdgMenu);
|
||||||
|
|
||||||
{
|
{
|
||||||
MutableDomElementIterator i(element, "Menu");
|
MutableDomElementIterator i(element, QLatin1String("Menu"));
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
moveMenus(i.next());
|
moveMenus(i.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
MutableDomElementIterator i(element, "Move");
|
MutableDomElementIterator i(element, QLatin1String("Move"));
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
i.next();
|
i.next();
|
||||||
QString oldPath = i.current().lastChildElement("Old").text();
|
QString oldPath = i.current().lastChildElement(QLatin1String("Old")).text();
|
||||||
QString newPath = i.current().lastChildElement("New").text();
|
QString newPath = i.current().lastChildElement(QLatin1String("New")).text();
|
||||||
|
|
||||||
element.removeChild(i.current());
|
element.removeChild(i.current());
|
||||||
|
|
||||||
@ -494,12 +494,12 @@ void XdgMenuPrivate::moveMenus(QDomElement& element)
|
|||||||
************************************************/
|
************************************************/
|
||||||
void XdgMenuPrivate::deleteDeletedMenus(QDomElement& element)
|
void XdgMenuPrivate::deleteDeletedMenus(QDomElement& element)
|
||||||
{
|
{
|
||||||
MutableDomElementIterator i(element, "Menu");
|
MutableDomElementIterator i(element, QLatin1String("Menu"));
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement e = i.next();
|
QDomElement e = i.next();
|
||||||
if (e.attribute("deleted") == "1" ||
|
if (e.attribute(QLatin1String("deleted")) == QLatin1String("1") ||
|
||||||
e.attribute("name") == ".hidden"
|
e.attribute(QLatin1String("name")) == QLatin1String(".hidden")
|
||||||
)
|
)
|
||||||
element.removeChild(e);
|
element.removeChild(e);
|
||||||
else
|
else
|
||||||
@ -514,7 +514,7 @@ void XdgMenuPrivate::processDirectoryEntries(QDomElement& element, const QString
|
|||||||
QStringList dirs;
|
QStringList dirs;
|
||||||
QStringList files;
|
QStringList files;
|
||||||
|
|
||||||
element.setAttribute("title", element.attribute("name"));
|
element.setAttribute(QLatin1String("title"), element.attribute(QLatin1String("name")));
|
||||||
|
|
||||||
MutableDomElementIterator i(element, QString());
|
MutableDomElementIterator i(element, QString());
|
||||||
i.toBack();
|
i.toBack();
|
||||||
@ -522,13 +522,13 @@ void XdgMenuPrivate::processDirectoryEntries(QDomElement& element, const QString
|
|||||||
{
|
{
|
||||||
QDomElement e = i.previous();
|
QDomElement e = i.previous();
|
||||||
|
|
||||||
if (e.tagName() == "Directory")
|
if (e.tagName() == QLatin1String("Directory"))
|
||||||
{
|
{
|
||||||
files << e.text();
|
files << e.text();
|
||||||
element.removeChild(e);
|
element.removeChild(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (e.tagName() == "DirectoryDir")
|
else if (e.tagName() == QLatin1String("DirectoryDir"))
|
||||||
{
|
{
|
||||||
dirs << e.text();
|
dirs << e.text();
|
||||||
element.removeChild(e);
|
element.removeChild(e);
|
||||||
@ -538,14 +538,14 @@ void XdgMenuPrivate::processDirectoryEntries(QDomElement& element, const QString
|
|||||||
dirs << parentDirs;
|
dirs << parentDirs;
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(QString file, files){
|
foreach(const QString &file, files){
|
||||||
if (file.startsWith('/'))
|
if (file.startsWith(QLatin1Char('/')))
|
||||||
found = loadDirectoryFile(file, element);
|
found = loadDirectoryFile(file, element);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (QString dir, dirs)
|
foreach (const QString &dir, dirs)
|
||||||
{
|
{
|
||||||
found = loadDirectoryFile(dir + "/" + file, element);
|
found = loadDirectoryFile(dir + QLatin1Char('/') + file, element);
|
||||||
if (found) break;
|
if (found) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,7 +553,7 @@ void XdgMenuPrivate::processDirectoryEntries(QDomElement& element, const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MutableDomElementIterator it(element, "Menu");
|
MutableDomElementIterator it(element, QLatin1String("Menu"));
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement e = it.next();
|
QDomElement e = it.next();
|
||||||
@ -572,9 +572,9 @@ bool XdgMenuPrivate::loadDirectoryFile(const QString& fileName, QDomElement& ele
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
element.setAttribute("title", file.localizedValue("Name").toString());
|
element.setAttribute(QLatin1String("title"), file.localizedValue(QLatin1String("Name")).toString());
|
||||||
element.setAttribute("comment", file.localizedValue("Comment").toString());
|
element.setAttribute(QLatin1String("comment"), file.localizedValue(QLatin1String("Comment")).toString());
|
||||||
element.setAttribute("icon", file.value("Icon").toString());
|
element.setAttribute(QLatin1String("icon"), file.value(QLatin1String("Icon")).toString());
|
||||||
|
|
||||||
Q_Q(XdgMenu);
|
Q_Q(XdgMenu);
|
||||||
q->addWatchPath(QFileInfo(file.fileName()).absolutePath());
|
q->addWatchPath(QFileInfo(file.fileName()).absolutePath());
|
||||||
@ -592,15 +592,15 @@ void XdgMenuPrivate::processApps(QDomElement& element)
|
|||||||
|
|
||||||
void XdgMenuPrivate::deleteEmpty(QDomElement& element)
|
void XdgMenuPrivate::deleteEmpty(QDomElement& element)
|
||||||
{
|
{
|
||||||
MutableDomElementIterator it(element, "Menu");
|
MutableDomElementIterator it(element, QLatin1String("Menu"));
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
deleteEmpty(it.next());
|
deleteEmpty(it.next());
|
||||||
|
|
||||||
if (element.attribute("keep") == "true")
|
if (element.attribute(QLatin1String("keep")) == QLatin1String("true"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QDomElement childMenu = element.firstChildElement("Menu");
|
QDomElement childMenu = element.firstChildElement(QLatin1String("Menu"));
|
||||||
QDomElement childApps = element.firstChildElement("AppLink");
|
QDomElement childApps = element.firstChildElement(QLatin1String("AppLink"));
|
||||||
|
|
||||||
if (childMenu.isNull() && childApps.isNull())
|
if (childMenu.isNull() && childApps.isNull())
|
||||||
{
|
{
|
||||||
@ -619,25 +619,25 @@ void XdgMenuPrivate::processLayouts(QDomElement& element)
|
|||||||
void XdgMenuPrivate::fixSeparators(QDomElement& element)
|
void XdgMenuPrivate::fixSeparators(QDomElement& element)
|
||||||
{
|
{
|
||||||
|
|
||||||
MutableDomElementIterator it(element, "Separator");
|
MutableDomElementIterator it(element, QLatin1String("Separator"));
|
||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement s = it.next();
|
QDomElement s = it.next();
|
||||||
if (s.previousSiblingElement().tagName() == "Separator")
|
if (s.previousSiblingElement().tagName() == QLatin1String("Separator"))
|
||||||
element.removeChild(s);
|
element.removeChild(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDomElement first = element.firstChild().toElement();
|
QDomElement first = element.firstChild().toElement();
|
||||||
if (first.tagName() == "Separator")
|
if (first.tagName() == QLatin1String("Separator"))
|
||||||
element.removeChild(first);
|
element.removeChild(first);
|
||||||
|
|
||||||
QDomElement last = element.lastChild().toElement();
|
QDomElement last = element.lastChild().toElement();
|
||||||
if (last.tagName() == "Separator")
|
if (last.tagName() == QLatin1String("Separator"))
|
||||||
element.removeChild(last);
|
element.removeChild(last);
|
||||||
|
|
||||||
|
|
||||||
MutableDomElementIterator mi(element, "Menu");
|
MutableDomElementIterator mi(element, QLatin1String("Menu"));
|
||||||
while(mi.hasNext())
|
while(mi.hasNext())
|
||||||
fixSeparators(mi.next());
|
fixSeparators(mi.next());
|
||||||
}
|
}
|
||||||
@ -649,32 +649,32 @@ void XdgMenuPrivate::fixSeparators(QDomElement& element)
|
|||||||
************************************************/
|
************************************************/
|
||||||
QString XdgMenu::getMenuFileName(const QString& baseName)
|
QString XdgMenu::getMenuFileName(const QString& baseName)
|
||||||
{
|
{
|
||||||
QStringList configDirs = XdgDirs::configDirs();
|
const QStringList configDirs = XdgDirs::configDirs();
|
||||||
QString menuPrefix = getenv("XDG_MENU_PREFIX");
|
QString menuPrefix = QString::fromLocal8Bit(qgetenv("XDG_MENU_PREFIX"));
|
||||||
|
|
||||||
foreach(QString configDir, configDirs)
|
foreach(const QString &configDir, configDirs)
|
||||||
{
|
{
|
||||||
QFileInfo file(QString("%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())
|
||||||
return file.filePath();
|
return file.filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList wellKnownFiles;
|
QStringList wellKnownFiles;
|
||||||
// razor- is a priority for us
|
// razor- is a priority for us
|
||||||
wellKnownFiles << "razor-applications.menu";
|
wellKnownFiles << QLatin1String("razor-applications.menu");
|
||||||
// the "global" menu file name on suse and fedora
|
// the "global" menu file name on suse and fedora
|
||||||
wellKnownFiles << "applications.menu";
|
wellKnownFiles << QLatin1String("applications.menu");
|
||||||
// rest files ordered by priority (descending)
|
// rest files ordered by priority (descending)
|
||||||
wellKnownFiles << "kde4-applications.menu";
|
wellKnownFiles << QLatin1String("kde4-applications.menu");
|
||||||
wellKnownFiles << "kde-applications.menu";
|
wellKnownFiles << QLatin1String("kde-applications.menu");
|
||||||
wellKnownFiles << "gnome-applications.menu";
|
wellKnownFiles << QLatin1String("gnome-applications.menu");
|
||||||
wellKnownFiles << "lxde-applications.menu";
|
wellKnownFiles << QLatin1String("lxde-applications.menu");
|
||||||
|
|
||||||
foreach(QString configDir, configDirs)
|
foreach(const QString &configDir, configDirs)
|
||||||
{
|
{
|
||||||
foreach (QString f, wellKnownFiles)
|
foreach (const QString &f, wellKnownFiles)
|
||||||
{
|
{
|
||||||
QFileInfo file(QString("%1/menus/%2").arg(configDir, f));
|
QFileInfo file(QString::fromLatin1("%1/menus/%2").arg(configDir, f));
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
return file.filePath();
|
return file.filePath();
|
||||||
}
|
}
|
@ -108,7 +108,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setLogDir(const QString& directory);
|
void setLogDir(const QString& directory);
|
||||||
|
|
||||||
static QString getMenuFileName(const QString& baseName = "applications.menu");
|
static QString getMenuFileName(const QString& baseName = QLatin1String("applications.menu"));
|
||||||
|
|
||||||
bool isOutDated() const;
|
bool isOutDated() const;
|
||||||
|
|
@ -40,9 +40,9 @@ XdgMenuApplinkProcessor::XdgMenuApplinkProcessor(QDomElement& element, XdgMenu*
|
|||||||
mParent = parent;
|
mParent = parent;
|
||||||
mMenu = menu;
|
mMenu = menu;
|
||||||
|
|
||||||
mOnlyUnallocated = element.attribute("onlyUnallocated") == "1";
|
mOnlyUnallocated = element.attribute(QLatin1String("onlyUnallocated")) == QLatin1String("1");
|
||||||
|
|
||||||
MutableDomElementIterator i(element, "Menu");
|
MutableDomElementIterator i(element, QLatin1String("Menu"));
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement e = i.next();
|
QDomElement e = i.next();
|
||||||
@ -122,18 +122,18 @@ void XdgMenuApplinkProcessor::step2()
|
|||||||
if (!show)
|
if (!show)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QDomElement appLink = doc.createElement("AppLink");
|
QDomElement appLink = doc.createElement(QLatin1String("AppLink"));
|
||||||
|
|
||||||
appLink.setAttribute("id", fileInfo->id());
|
appLink.setAttribute(QLatin1String("id"), fileInfo->id());
|
||||||
appLink.setAttribute("title", file->localizedValue("Name").toString());
|
appLink.setAttribute(QLatin1String("title"), file->localizedValue(QLatin1String("Name")).toString());
|
||||||
appLink.setAttribute("comment", file->localizedValue("Comment").toString());
|
appLink.setAttribute(QLatin1String("comment"), file->localizedValue(QLatin1String("Comment")).toString());
|
||||||
appLink.setAttribute("genericName", file->localizedValue("GenericName").toString());
|
appLink.setAttribute(QLatin1String("genericName"), file->localizedValue(QLatin1String("GenericName")).toString());
|
||||||
appLink.setAttribute("exec", file->value("Exec").toString());
|
appLink.setAttribute(QLatin1String("exec"), file->value(QLatin1String("Exec")).toString());
|
||||||
appLink.setAttribute("terminal", file->value("Terminal").toBool());
|
appLink.setAttribute(QLatin1String("terminal"), file->value(QLatin1String("Terminal")).toBool());
|
||||||
appLink.setAttribute("startupNotify", file->value("StartupNotify").toBool());
|
appLink.setAttribute(QLatin1String("startupNoify"), file->value(QLatin1String("StartupNotify")).toBool());
|
||||||
appLink.setAttribute("path", file->value("Path").toString());
|
appLink.setAttribute(QLatin1String("path"), file->value(QLatin1String("Path")).toString());
|
||||||
appLink.setAttribute("icon", file->value("Icon").toString());
|
appLink.setAttribute(QLatin1String("icon"), file->value(QLatin1String("Icon")).toString());
|
||||||
appLink.setAttribute("desktopFile", file->fileName());
|
appLink.setAttribute(QLatin1String("desktopFile"), file->fileName());
|
||||||
|
|
||||||
mElement.appendChild(appLink);
|
mElement.appendChild(appLink);
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ void XdgMenuApplinkProcessor::fillAppFileInfoList()
|
|||||||
{
|
{
|
||||||
// Build a pool by collecting entries found in <AppDir>
|
// Build a pool by collecting entries found in <AppDir>
|
||||||
{
|
{
|
||||||
MutableDomElementIterator i(mElement, "AppDir");
|
MutableDomElementIterator i(mElement, QLatin1String("AppDir"));
|
||||||
i.toBack();
|
i.toBack();
|
||||||
while(i.hasPrevious())
|
while(i.hasPrevious())
|
||||||
{
|
{
|
||||||
@ -187,9 +187,9 @@ void XdgMenuApplinkProcessor::findDesktopFiles(const QString& dirName, const QSt
|
|||||||
{
|
{
|
||||||
QDir dir(dirName);
|
QDir dir(dirName);
|
||||||
mMenu->addWatchPath(dir.absolutePath());
|
mMenu->addWatchPath(dir.absolutePath());
|
||||||
QFileInfoList files = dir.entryInfoList(QStringList("*.desktop"), QDir::Files);
|
const QFileInfoList files = dir.entryInfoList(QStringList(QLatin1String("*.desktop")), QDir::Files);
|
||||||
|
|
||||||
foreach (QFileInfo file, files)
|
foreach (const QFileInfo &file, files)
|
||||||
{
|
{
|
||||||
XdgDesktopFile* f = XdgDesktopFileCache::getFile(file.canonicalFilePath());
|
XdgDesktopFile* f = XdgDesktopFileCache::getFile(file.canonicalFilePath());
|
||||||
if (f)
|
if (f)
|
||||||
@ -198,13 +198,13 @@ void XdgMenuApplinkProcessor::findDesktopFiles(const QString& dirName, const QSt
|
|||||||
|
|
||||||
|
|
||||||
// Working recursively ............
|
// Working recursively ............
|
||||||
QFileInfoList dirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot);
|
const QFileInfoList dirs = dir.entryInfoList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
foreach (QFileInfo d, dirs)
|
foreach (const QFileInfo &d, dirs)
|
||||||
{
|
{
|
||||||
QString dn = d.canonicalFilePath();
|
QString dn = d.canonicalFilePath();
|
||||||
if (dn != dirName)
|
if (dn != dirName)
|
||||||
{
|
{
|
||||||
findDesktopFiles(dn, QString("%1%2-").arg(prefix, d.fileName()));
|
findDesktopFiles(dn, QString::fromLatin1("%1%2-").arg(prefix, d.fileName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,13 +216,13 @@ void XdgMenuApplinkProcessor::createRules()
|
|||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement e = i.next();
|
QDomElement e = i.next();
|
||||||
if (e.tagName()=="Include")
|
if (e.tagName()== QLatin1String("Include"))
|
||||||
{
|
{
|
||||||
mRules.addInclude(e);
|
mRules.addInclude(e);
|
||||||
mElement.removeChild(e);
|
mElement.removeChild(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (e.tagName()=="Exclude")
|
else if (e.tagName()== QLatin1String("Exclude"))
|
||||||
{
|
{
|
||||||
mRules.addExclude(e);
|
mRules.addExclude(e);
|
||||||
mElement.removeChild(e);
|
mElement.removeChild(e);
|
||||||
@ -240,9 +240,9 @@ bool XdgMenuApplinkProcessor::checkTryExec(const QString& progName)
|
|||||||
if (progName.startsWith(QDir::separator()))
|
if (progName.startsWith(QDir::separator()))
|
||||||
return QFileInfo(progName).isExecutable();
|
return QFileInfo(progName).isExecutable();
|
||||||
|
|
||||||
QStringList dirs = QString(getenv("PATH")).split(":");
|
const QStringList dirs = QFile::decodeName(qgetenv("PATH")).split(QLatin1Char(':'));
|
||||||
|
|
||||||
foreach (QString dir, dirs)
|
foreach (const QString &dir, dirs)
|
||||||
{
|
{
|
||||||
if (QFileInfo(QDir(dir), progName).isExecutable())
|
if (QFileInfo(QDir(dir), progName).isExecutable())
|
||||||
return true;
|
return true;
|
||||||
@ -250,4 +250,3 @@ bool XdgMenuApplinkProcessor::checkTryExec(const QString& progName)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -68,20 +68,20 @@ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element):
|
|||||||
mDefaultParams.mInlineHeader = true;
|
mDefaultParams.mInlineHeader = true;
|
||||||
mDefaultParams.mInlineAlias = false;
|
mDefaultParams.mInlineAlias = false;
|
||||||
|
|
||||||
mDefaultLayout = findLastElementByTag(element, "DefaultLayout");
|
mDefaultLayout = findLastElementByTag(element, QLatin1String("DefaultLayout"));
|
||||||
|
|
||||||
if (mDefaultLayout.isNull())
|
if (mDefaultLayout.isNull())
|
||||||
{
|
{
|
||||||
// Create DefaultLayout node
|
// Create DefaultLayout node
|
||||||
QDomDocument doc = element.ownerDocument();
|
QDomDocument doc = element.ownerDocument();
|
||||||
mDefaultLayout = doc.createElement("DefaultLayout");
|
mDefaultLayout = doc.createElement(QLatin1String("DefaultLayout"));
|
||||||
|
|
||||||
QDomElement menus = doc.createElement("Merge");
|
QDomElement menus = doc.createElement(QLatin1String("Merge"));
|
||||||
menus.setAttribute("type", "menus");
|
menus.setAttribute(QLatin1String("type"), QLatin1String("menus"));
|
||||||
mDefaultLayout.appendChild(menus);
|
mDefaultLayout.appendChild(menus);
|
||||||
|
|
||||||
QDomElement files = doc.createElement("Merge");
|
QDomElement files = doc.createElement(QLatin1String("Merge"));
|
||||||
files.setAttribute("type", "files");
|
files.setAttribute(QLatin1String("type"), QLatin1String("files"));
|
||||||
mDefaultLayout.appendChild(files);
|
mDefaultLayout.appendChild(files);
|
||||||
|
|
||||||
mElement.appendChild(mDefaultLayout);
|
mElement.appendChild(mDefaultLayout);
|
||||||
@ -91,7 +91,7 @@ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element):
|
|||||||
|
|
||||||
// If a menu does not contain a <Layout> element or if it contains an empty <Layout> element
|
// If a menu does not contain a <Layout> element or if it contains an empty <Layout> element
|
||||||
// then the default layout should be used.
|
// then the default layout should be used.
|
||||||
mLayout = findLastElementByTag(element, "Layout");
|
mLayout = findLastElementByTag(element, QLatin1String("Layout"));
|
||||||
if (mLayout.isNull() || !mLayout.hasChildNodes())
|
if (mLayout.isNull() || !mLayout.hasChildNodes())
|
||||||
mLayout = mDefaultLayout;
|
mLayout = mDefaultLayout;
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element, XdgMenuLayo
|
|||||||
mDefaultParams = parent->mDefaultParams;
|
mDefaultParams = parent->mDefaultParams;
|
||||||
|
|
||||||
// DefaultLayout ............................
|
// DefaultLayout ............................
|
||||||
QDomElement defaultLayout = findLastElementByTag(element, "DefaultLayout");
|
QDomElement defaultLayout = findLastElementByTag(element, QLatin1String("DefaultLayout"));
|
||||||
|
|
||||||
if (defaultLayout.isNull())
|
if (defaultLayout.isNull())
|
||||||
mDefaultLayout = parent->mDefaultLayout;
|
mDefaultLayout = parent->mDefaultLayout;
|
||||||
@ -114,7 +114,7 @@ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element, XdgMenuLayo
|
|||||||
|
|
||||||
// If a menu does not contain a <Layout> element or if it contains an empty <Layout> element
|
// If a menu does not contain a <Layout> element or if it contains an empty <Layout> element
|
||||||
// then the default layout should be used.
|
// then the default layout should be used.
|
||||||
mLayout = findLastElementByTag(element, "Layout");
|
mLayout = findLastElementByTag(element, QLatin1String("Layout"));
|
||||||
if (mLayout.isNull() || !mLayout.hasChildNodes())
|
if (mLayout.isNull() || !mLayout.hasChildNodes())
|
||||||
mLayout = mDefaultLayout;
|
mLayout = mDefaultLayout;
|
||||||
|
|
||||||
@ -123,20 +123,20 @@ XdgMenuLayoutProcessor::XdgMenuLayoutProcessor(QDomElement& element, XdgMenuLayo
|
|||||||
|
|
||||||
void XdgMenuLayoutProcessor::setParams(QDomElement defaultLayout, LayoutParams *result)
|
void XdgMenuLayoutProcessor::setParams(QDomElement defaultLayout, LayoutParams *result)
|
||||||
{
|
{
|
||||||
if (defaultLayout.hasAttribute("show_empty"))
|
if (defaultLayout.hasAttribute(QLatin1String("show_empty")))
|
||||||
result->mShowEmpty = defaultLayout.attribute("show_empty") == "true";
|
result->mShowEmpty = defaultLayout.attribute(QLatin1String("show_empty")) == QLatin1String("true");
|
||||||
|
|
||||||
if (defaultLayout.hasAttribute("inline"))
|
if (defaultLayout.hasAttribute(QLatin1String("inline")))
|
||||||
result->mInline = defaultLayout.attribute("inline") == "true";
|
result->mInline = defaultLayout.attribute(QLatin1String("inline")) == QLatin1String("true");
|
||||||
|
|
||||||
if (defaultLayout.hasAttribute("inline_limit"))
|
if (defaultLayout.hasAttribute(QLatin1String("inline_limit")))
|
||||||
result->mInlineLimit = defaultLayout.attribute("inline_limit").toInt();
|
result->mInlineLimit = defaultLayout.attribute(QLatin1String("inline_limit")).toInt();
|
||||||
|
|
||||||
if (defaultLayout.hasAttribute("inline_header"))
|
if (defaultLayout.hasAttribute(QLatin1String("inline_header")))
|
||||||
result->mInlineHeader = defaultLayout.attribute("inline_header") == "true";
|
result->mInlineHeader = defaultLayout.attribute(QLatin1String("inline_header")) == QLatin1String("true");
|
||||||
|
|
||||||
if (defaultLayout.hasAttribute("inline_alias"))
|
if (defaultLayout.hasAttribute(QLatin1String("inline_alias")))
|
||||||
result->mInlineAlias = defaultLayout.attribute("inline_alias") == "true";
|
result->mInlineAlias = defaultLayout.attribute(QLatin1String("inline_alias")) == QLatin1String("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ int childsCount(const QDomElement& element)
|
|||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
QString tag = it.next().tagName();
|
QString tag = it.next().tagName();
|
||||||
if (tag == "AppLink" || tag == "Menu" || tag == "Separator")
|
if (tag == QLatin1String("AppLink") || tag == QLatin1String("Menu") || tag == QLatin1String("Separator"))
|
||||||
count ++;
|
count ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,12 +174,12 @@ int childsCount(const QDomElement& element)
|
|||||||
void XdgMenuLayoutProcessor::run()
|
void XdgMenuLayoutProcessor::run()
|
||||||
{
|
{
|
||||||
QDomDocument doc = mLayout.ownerDocument();
|
QDomDocument doc = mLayout.ownerDocument();
|
||||||
mResult = doc.createElement("Result");
|
mResult = doc.createElement(QLatin1String("Result"));
|
||||||
mElement.appendChild(mResult);
|
mElement.appendChild(mResult);
|
||||||
|
|
||||||
// Process childs menus ...............................
|
// Process childs menus ...............................
|
||||||
{
|
{
|
||||||
DomElementIterator it(mElement, "Menu");
|
DomElementIterator it(mElement, QLatin1String("Menu"));
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
QDomElement e = it.next();
|
QDomElement e = it.next();
|
||||||
@ -196,26 +196,26 @@ void XdgMenuLayoutProcessor::run()
|
|||||||
{
|
{
|
||||||
QDomElement e = it.next();
|
QDomElement e = it.next();
|
||||||
|
|
||||||
if (e.tagName() == "Filename")
|
if (e.tagName() == QLatin1String("Filename"))
|
||||||
processFilenameTag(e);
|
processFilenameTag(e);
|
||||||
|
|
||||||
else if (e.tagName() == "Menuname")
|
else if (e.tagName() == QLatin1String("Menuname"))
|
||||||
processMenunameTag(e);
|
processMenunameTag(e);
|
||||||
|
|
||||||
else if (e.tagName() == "Separator")
|
else if (e.tagName() == QLatin1String("Separator"))
|
||||||
processSeparatorTag(e);
|
processSeparatorTag(e);
|
||||||
|
|
||||||
else if (e.tagName() == "Merge")
|
else if (e.tagName() == QLatin1String("Merge"))
|
||||||
{
|
{
|
||||||
QDomElement merge = mResult.ownerDocument().createElement("Merge");
|
QDomElement merge = mResult.ownerDocument().createElement(QLatin1String("Merge"));
|
||||||
merge.setAttribute("type", e.attribute("type"));
|
merge.setAttribute(QLatin1String("type"), e.attribute(QLatin1String("type")));
|
||||||
mResult.appendChild(merge);
|
mResult.appendChild(merge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2 ...................................
|
// Step 2 ...................................
|
||||||
{
|
{
|
||||||
MutableDomElementIterator ri(mResult, "Merge");
|
MutableDomElementIterator ri(mResult, QLatin1String("Merge"));
|
||||||
while (ri.hasNext())
|
while (ri.hasNext())
|
||||||
{
|
{
|
||||||
processMergeTag(ri.next());
|
processMergeTag(ri.next());
|
||||||
@ -249,7 +249,7 @@ void XdgMenuLayoutProcessor::processFilenameTag(const QDomElement &element)
|
|||||||
{
|
{
|
||||||
QString id = element.text();
|
QString id = element.text();
|
||||||
|
|
||||||
QDomElement appLink = searchElement("AppLink", "id", id);
|
QDomElement appLink = searchElement(QLatin1String("AppLink"), QLatin1String("id"), id);
|
||||||
if (!appLink.isNull())
|
if (!appLink.isNull())
|
||||||
mResult.appendChild(appLink);
|
mResult.appendChild(appLink);
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ void XdgMenuLayoutProcessor::processFilenameTag(const QDomElement &element)
|
|||||||
void XdgMenuLayoutProcessor::processMenunameTag(const QDomElement &element)
|
void XdgMenuLayoutProcessor::processMenunameTag(const QDomElement &element)
|
||||||
{
|
{
|
||||||
QString id = element.text();
|
QString id = element.text();
|
||||||
QDomElement menu = searchElement("Menu", "name", id);
|
QDomElement menu = searchElement(QLatin1String("Menu"), QLatin1String("name"), id);
|
||||||
if (menu.isNull())
|
if (menu.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ void XdgMenuLayoutProcessor::processMenunameTag(const QDomElement &element)
|
|||||||
{
|
{
|
||||||
if (params.mShowEmpty)
|
if (params.mShowEmpty)
|
||||||
{
|
{
|
||||||
menu.setAttribute("keep", "true");
|
menu.setAttribute(QLatin1String("keep"), QLatin1String("true"));
|
||||||
mResult.appendChild(menu);
|
mResult.appendChild(menu);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -330,7 +330,7 @@ void XdgMenuLayoutProcessor::processMenunameTag(const QDomElement &element)
|
|||||||
// Header ....................................
|
// Header ....................................
|
||||||
if (doHeader)
|
if (doHeader)
|
||||||
{
|
{
|
||||||
QDomElement header = mLayout.ownerDocument().createElement("Header");
|
QDomElement header = mLayout.ownerDocument().createElement(QLatin1String("Header"));
|
||||||
|
|
||||||
QDomNamedNodeMap attrs = menu.attributes();
|
QDomNamedNodeMap attrs = menu.attributes();
|
||||||
for (int i=0; i < attrs.count(); ++i)
|
for (int i=0; i < attrs.count(); ++i)
|
||||||
@ -344,7 +344,7 @@ void XdgMenuLayoutProcessor::processMenunameTag(const QDomElement &element)
|
|||||||
// Alias .....................................
|
// Alias .....................................
|
||||||
if (doAlias)
|
if (doAlias)
|
||||||
{
|
{
|
||||||
menu.firstChild().toElement().setAttribute("title", menu.attribute("title"));
|
menu.firstChild().toElement().setAttribute(QLatin1String("title"), menu.attribute(QLatin1String("title")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inline ....................................
|
// Inline ....................................
|
||||||
@ -364,7 +364,7 @@ void XdgMenuLayoutProcessor::processMenunameTag(const QDomElement &element)
|
|||||||
************************************************/
|
************************************************/
|
||||||
void XdgMenuLayoutProcessor::processSeparatorTag(const QDomElement &element)
|
void XdgMenuLayoutProcessor::processSeparatorTag(const QDomElement &element)
|
||||||
{
|
{
|
||||||
QDomElement separator = element.ownerDocument().createElement("Separator");
|
QDomElement separator = element.ownerDocument().createElement(QLatin1String("Separator"));
|
||||||
mResult.appendChild(separator);
|
mResult.appendChild(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ void XdgMenuLayoutProcessor::processSeparatorTag(const QDomElement &element)
|
|||||||
************************************************/
|
************************************************/
|
||||||
void XdgMenuLayoutProcessor::processMergeTag(const QDomElement &element)
|
void XdgMenuLayoutProcessor::processMergeTag(const QDomElement &element)
|
||||||
{
|
{
|
||||||
QString type = element.attribute("type");
|
QString type = element.attribute(QLatin1String("type"));
|
||||||
QMap<QString, QDomElement> map;
|
QMap<QString, QDomElement> map;
|
||||||
MutableDomElementIterator it(mElement);
|
MutableDomElementIterator it(mElement);
|
||||||
|
|
||||||
@ -395,10 +395,10 @@ void XdgMenuLayoutProcessor::processMergeTag(const QDomElement &element)
|
|||||||
{
|
{
|
||||||
QDomElement e = it.next();
|
QDomElement e = it.next();
|
||||||
if (
|
if (
|
||||||
((type == "menus" || type == "all") && e.tagName() == "Menu" ) ||
|
((type == QLatin1String("menus") || type == QLatin1String("all")) && e.tagName() == QLatin1String("Menu" )) ||
|
||||||
((type == "files" || type == "all") && e.tagName() == "AppLink")
|
((type == QLatin1String("files") || type == QLatin1String("all")) && e.tagName() == QLatin1String("AppLink"))
|
||||||
)
|
)
|
||||||
map.insert(e.attribute("title"), e);
|
map.insert(e.attribute(QLatin1String("title")), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMapIterator<QString, QDomElement> mi(map);
|
QMapIterator<QString, QDomElement> mi(map);
|
@ -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("%1 not loading: %2").arg(fileName).arg(file.errorString());
|
mErrorStr = QString::fromLatin1("%1 not loading: %2").arg(fileName).arg(file.errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//qDebug() << "Load file:" << mFileName;
|
//qDebug() << "Load file:" << mFileName;
|
||||||
@ -88,7 +88,7 @@ bool XdgMenuReader::load(const QString& fileName, const QString& baseDir)
|
|||||||
|
|
||||||
if (!mXml.setContent(&file, true, &errorStr, &errorLine, &errorColumn))
|
if (!mXml.setContent(&file, true, &errorStr, &errorLine, &errorColumn))
|
||||||
{
|
{
|
||||||
mErrorStr = QString("Parse error at line %1, column %2:\n%3")
|
mErrorStr = QString::fromLatin1("Parse error at line %1, column %2:\n%3")
|
||||||
.arg(errorLine)
|
.arg(errorLine)
|
||||||
.arg(errorColumn)
|
.arg(errorColumn)
|
||||||
.arg(errorStr);
|
.arg(errorStr);
|
||||||
@ -97,10 +97,10 @@ bool XdgMenuReader::load(const QString& fileName, const QString& baseDir)
|
|||||||
|
|
||||||
QDomElement root = mXml.documentElement();
|
QDomElement root = mXml.documentElement();
|
||||||
|
|
||||||
QDomElement debugElement = mXml.createElement("FileInfo");
|
QDomElement debugElement = mXml.createElement(QLatin1String("FileInfo"));
|
||||||
debugElement.setAttribute("file", mFileName);
|
debugElement.setAttribute(QLatin1String("file"), mFileName);
|
||||||
if (mParentReader)
|
if (mParentReader)
|
||||||
debugElement.setAttribute("parent", mParentReader->fileName());
|
debugElement.setAttribute(QLatin1String("parent"), mParentReader->fileName());
|
||||||
|
|
||||||
QDomNode null;
|
QDomNode null;
|
||||||
root.insertBefore(debugElement, null);
|
root.insertBefore(debugElement, null);
|
||||||
@ -124,49 +124,49 @@ void XdgMenuReader::processMergeTags(QDomElement& element)
|
|||||||
{
|
{
|
||||||
QDomElement next = n.previousSiblingElement();
|
QDomElement next = n.previousSiblingElement();
|
||||||
// MergeFile ..................
|
// MergeFile ..................
|
||||||
if (n.tagName() == "MergeFile")
|
if (n.tagName() == QLatin1String("MergeFile"))
|
||||||
{
|
{
|
||||||
processMergeFileTag(n, &mergedFiles);
|
processMergeFileTag(n, &mergedFiles);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MergeDir ...................
|
// MergeDir ...................
|
||||||
else if(n.tagName() == "MergeDir")
|
else if(n.tagName() == QLatin1String("MergeDir"))
|
||||||
{
|
{
|
||||||
processMergeDirTag(n, &mergedFiles);
|
processMergeDirTag(n, &mergedFiles);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultMergeDirs ...........
|
// DefaultMergeDirs ...........
|
||||||
else if (n.tagName() == "DefaultMergeDirs")
|
else if (n.tagName() == QLatin1String("DefaultMergeDirs"))
|
||||||
{
|
{
|
||||||
processDefaultMergeDirsTag(n, &mergedFiles);
|
processDefaultMergeDirsTag(n, &mergedFiles);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppDir ...................
|
// AppDir ...................
|
||||||
else if(n.tagName() == "AppDir")
|
else if(n.tagName() == QLatin1String("AppDir"))
|
||||||
{
|
{
|
||||||
processAppDirTag(n);
|
processAppDirTag(n);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultAppDirs .............
|
// DefaultAppDirs .............
|
||||||
else if(n.tagName() == "DefaultAppDirs")
|
else if(n.tagName() == QLatin1String("DefaultAppDirs"))
|
||||||
{
|
{
|
||||||
processDefaultAppDirsTag(n);
|
processDefaultAppDirsTag(n);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirectoryDir ...................
|
// DirectoryDir ...................
|
||||||
else if(n.tagName() == "DirectoryDir")
|
else if(n.tagName() == QLatin1String("DirectoryDir"))
|
||||||
{
|
{
|
||||||
processDirectoryDirTag(n);
|
processDirectoryDirTag(n);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultDirectoryDirs ...........
|
// DefaultDirectoryDirs ...........
|
||||||
else if(n.tagName() == "DefaultDirectoryDirs")
|
else if(n.tagName() == QLatin1String("DefaultDirectoryDirs"))
|
||||||
{
|
{
|
||||||
processDefaultDirectoryDirsTag(n);
|
processDefaultDirectoryDirsTag(n);
|
||||||
n.parentNode().removeChild(n);
|
n.parentNode().removeChild(n);
|
||||||
@ -174,7 +174,7 @@ void XdgMenuReader::processMergeTags(QDomElement& element)
|
|||||||
|
|
||||||
|
|
||||||
// Menu .......................
|
// Menu .......................
|
||||||
else if(n.tagName() == "Menu")
|
else if(n.tagName() == QLatin1String("Menu"))
|
||||||
{
|
{
|
||||||
processMergeTags(n);
|
processMergeTags(n);
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ void XdgMenuReader::processMergeFileTag(QDomElement& element, QStringList* merge
|
|||||||
{
|
{
|
||||||
//qDebug() << "Process " << element;// << "in" << mFileName;
|
//qDebug() << "Process " << element;// << "in" << mFileName;
|
||||||
|
|
||||||
if (element.attribute("type") != "parent")
|
if (element.attribute(QLatin1String("type")) != QLatin1String("parent"))
|
||||||
{
|
{
|
||||||
mergeFile(element.text(), element, mergedFiles);
|
mergeFile(element.text(), element, mergedFiles);
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ void XdgMenuReader::processMergeFileTag(QDomElement& element, QStringList* merge
|
|||||||
QString relativeName;
|
QString relativeName;
|
||||||
QStringList configDirs = XdgDirs::configDirs();
|
QStringList configDirs = XdgDirs::configDirs();
|
||||||
|
|
||||||
foreach (QString configDir, configDirs)
|
foreach (const QString &configDir, configDirs)
|
||||||
{
|
{
|
||||||
if (mFileName.startsWith(configDir))
|
if (mFileName.startsWith(configDir))
|
||||||
{
|
{
|
||||||
@ -236,7 +236,7 @@ void XdgMenuReader::processMergeFileTag(QDomElement& element, QStringList* merge
|
|||||||
if (relativeName.isEmpty())
|
if (relativeName.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (QString configDir, configDirs)
|
foreach (const QString &configDir, configDirs)
|
||||||
{
|
{
|
||||||
if (QFileInfo(configDir + relativeName).exists())
|
if (QFileInfo(configDir + relativeName).exists())
|
||||||
{
|
{
|
||||||
@ -288,20 +288,20 @@ void XdgMenuReader::processDefaultMergeDirsTag(QDomElement& element, QStringList
|
|||||||
//qDebug() << "Process " << element;// << "in" << mFileName;
|
//qDebug() << "Process " << element;// << "in" << mFileName;
|
||||||
|
|
||||||
QString menuBaseName = QFileInfo(mMenu->menuFileName()).baseName();
|
QString menuBaseName = QFileInfo(mMenu->menuFileName()).baseName();
|
||||||
int n = menuBaseName.lastIndexOf('-');
|
int n = menuBaseName.lastIndexOf(QLatin1Char('-'));
|
||||||
if (n>-1)
|
if (n>-1)
|
||||||
menuBaseName = menuBaseName.mid(n+1);
|
menuBaseName = menuBaseName.mid(n+1);
|
||||||
|
|
||||||
QStringList dirs = XdgDirs::configDirs();
|
QStringList dirs = XdgDirs::configDirs();
|
||||||
dirs << XdgDirs::configHome();
|
dirs << XdgDirs::configHome();
|
||||||
|
|
||||||
foreach (QString dir, dirs)
|
foreach (const QString &dir, dirs)
|
||||||
{
|
{
|
||||||
mergeDir(QString("%1/menus/%2-merged").arg(dir).arg(menuBaseName), element, mergedFiles);
|
mergeDir(QString::fromLatin1("%1/menus/%2-merged").arg(dir).arg(menuBaseName), element, mergedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuBaseName == "applications")
|
if (menuBaseName == QLatin1String("applications"))
|
||||||
mergeFile(QString("%1/menus/applications-kmenuedit.menu").arg(XdgDirs::configHome()), element, mergedFiles);
|
mergeFile(QString::fromLatin1("%1/menus/applications-kmenuedit.menu").arg(XdgDirs::configHome()), element, mergedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ void XdgMenuReader::processDefaultMergeDirsTag(QDomElement& element, QStringList
|
|||||||
void XdgMenuReader::processAppDirTag(QDomElement& element)
|
void XdgMenuReader::processAppDirTag(QDomElement& element)
|
||||||
{
|
{
|
||||||
//qDebug() << "Process " << element;
|
//qDebug() << "Process " << element;
|
||||||
addDirTag(element, "AppDir", element.text());
|
addDirTag(element, QLatin1String("AppDir"), element.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -329,10 +329,10 @@ void XdgMenuReader::processDefaultAppDirsTag(QDomElement& element)
|
|||||||
QStringList dirs = XdgDirs::dataDirs();
|
QStringList dirs = XdgDirs::dataDirs();
|
||||||
dirs.prepend(XdgDirs::dataHome(false));
|
dirs.prepend(XdgDirs::dataHome(false));
|
||||||
|
|
||||||
foreach (QString dir, dirs)
|
foreach (const QString &dir, dirs)
|
||||||
{
|
{
|
||||||
//qDebug() << "Add AppDir: " << dir + "/applications/";
|
//qDebug() << "Add AppDir: " << dir + "/applications/";
|
||||||
addDirTag(element, "AppDir", dir + "/applications/");
|
addDirTag(element, QLatin1String("AppDir"), dir + QLatin1String("/applications/"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ void XdgMenuReader::processDefaultAppDirsTag(QDomElement& element)
|
|||||||
void XdgMenuReader::processDirectoryDirTag(QDomElement& element)
|
void XdgMenuReader::processDirectoryDirTag(QDomElement& element)
|
||||||
{
|
{
|
||||||
//qDebug() << "Process " << element;
|
//qDebug() << "Process " << element;
|
||||||
addDirTag(element, "DirectoryDir", element.text());
|
addDirTag(element, QLatin1String("DirectoryDir"), element.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -360,8 +360,8 @@ void XdgMenuReader::processDefaultDirectoryDirsTag(QDomElement& element)
|
|||||||
QStringList dirs = XdgDirs::dataDirs();
|
QStringList dirs = XdgDirs::dataDirs();
|
||||||
dirs.prepend(XdgDirs::dataHome(false));
|
dirs.prepend(XdgDirs::dataHome(false));
|
||||||
|
|
||||||
foreach (QString dir, dirs)
|
foreach (const QString &dir, dirs)
|
||||||
addDirTag(element, "DirectoryDir", dir + "/desktop-directories/");
|
addDirTag(element, QLatin1String("DirectoryDir"), dir + QLatin1String("/desktop-directories/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************
|
/************************************************
|
||||||
@ -409,7 +409,7 @@ void XdgMenuReader::mergeFile(const QString& fileName, QDomElement& element, QSt
|
|||||||
{
|
{
|
||||||
// As a special exception, remove the <Name> element from the root
|
// As a special exception, remove the <Name> element from the root
|
||||||
// element of each file being merged.
|
// element of each file being merged.
|
||||||
if (n.tagName() != "Name")
|
if (n.tagName() != QLatin1String("Name"))
|
||||||
{
|
{
|
||||||
QDomNode imp = mXml.importNode(n, true);
|
QDomNode imp = mXml.importNode(n, true);
|
||||||
element.parentNode().insertBefore(imp, element);
|
element.parentNode().insertBefore(imp, element);
|
||||||
@ -429,9 +429,9 @@ void XdgMenuReader::mergeDir(const QString& dirName, QDomElement& element, QStri
|
|||||||
{
|
{
|
||||||
//qDebug() << "Merge dir: " << dirInfo.canonicalFilePath();
|
//qDebug() << "Merge dir: " << dirInfo.canonicalFilePath();
|
||||||
QDir dir = QDir(dirInfo.canonicalFilePath());
|
QDir dir = QDir(dirInfo.canonicalFilePath());
|
||||||
const QFileInfoList files = dir.entryInfoList(QStringList() << "*.menu", QDir::Files | QDir::Readable);
|
const QFileInfoList files = dir.entryInfoList(QStringList() << QLatin1String("*.menu"), QDir::Files | QDir::Readable);
|
||||||
|
|
||||||
foreach (QFileInfo file, files)
|
foreach (const QFileInfo &file, files)
|
||||||
mergeFile(file.canonicalFilePath(), element, mergedFiles);
|
mergeFile(file.canonicalFilePath(), element, mergedFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -63,26 +63,26 @@ XdgMenuRuleOr::XdgMenuRuleOr(const QDomElement& element, QObject* parent) :
|
|||||||
{
|
{
|
||||||
QDomElement e = iter.next();
|
QDomElement e = iter.next();
|
||||||
|
|
||||||
if (e.tagName() == "Or")
|
if (e.tagName() == QLatin1String("Or"))
|
||||||
mChilds.append(new XdgMenuRuleOr(e, this));
|
mChilds.append(new XdgMenuRuleOr(e, this));
|
||||||
|
|
||||||
else if (e.tagName() == "And")
|
else if (e.tagName() == QLatin1String("And"))
|
||||||
mChilds.append(new XdgMenuRuleAnd(e, this));
|
mChilds.append(new XdgMenuRuleAnd(e, this));
|
||||||
|
|
||||||
else if (e.tagName() == "Not")
|
else if (e.tagName() == QLatin1String("Not"))
|
||||||
mChilds.append(new XdgMenuRuleNot(e, this));
|
mChilds.append(new XdgMenuRuleNot(e, this));
|
||||||
|
|
||||||
else if (e.tagName() == "Filename")
|
else if (e.tagName() == QLatin1String("Filename"))
|
||||||
mChilds.append(new XdgMenuRuleFileName(e, this));
|
mChilds.append(new XdgMenuRuleFileName(e, this));
|
||||||
|
|
||||||
else if (e.tagName() == "Category")
|
else if (e.tagName() == QLatin1String("Category"))
|
||||||
mChilds.append(new XdgMenuRuleCategory(e, this));
|
mChilds.append(new XdgMenuRuleCategory(e, this));
|
||||||
|
|
||||||
else if (e.tagName() == "All")
|
else if (e.tagName() == QLatin1String("All"))
|
||||||
mChilds.append(new XdgMenuRuleAll(e, this));
|
mChilds.append(new XdgMenuRuleAll(e, this));
|
||||||
|
|
||||||
else
|
else
|
||||||
qWarning() << "Unknown rule" << e.tagName();
|
qWarning() << QString::fromLatin1("Unknown rule") << e.tagName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -99,13 +99,13 @@ void XdgMenuWidgetPrivate::init(const QDomElement& xml)
|
|||||||
q->clear();
|
q->clear();
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
if (! xml.attribute("title").isEmpty())
|
if (! xml.attribute(QLatin1String("title")).isEmpty())
|
||||||
title = xml.attribute("title");
|
title = xml.attribute(QLatin1String("title"));
|
||||||
else
|
else
|
||||||
title = xml.attribute("name");
|
title = xml.attribute(QLatin1String("name"));
|
||||||
q->setTitle(escape(title));
|
q->setTitle(escape(title));
|
||||||
|
|
||||||
q->setToolTip(xml.attribute("comment"));
|
q->setToolTip(xml.attribute(QLatin1String("comment")));
|
||||||
|
|
||||||
|
|
||||||
QIcon parentIcon;
|
QIcon parentIcon;
|
||||||
@ -113,7 +113,7 @@ void XdgMenuWidgetPrivate::init(const QDomElement& xml)
|
|||||||
if (parentMenu)
|
if (parentMenu)
|
||||||
parentIcon = parentMenu->icon();
|
parentIcon = parentMenu->icon();
|
||||||
|
|
||||||
q->setIcon(XdgIcon::fromTheme(mXml.attribute("icon"), parentIcon));
|
q->setIcon(XdgIcon::fromTheme(mXml.attribute(QLatin1String("icon")), parentIcon));
|
||||||
|
|
||||||
buildMenu();
|
buildMenu();
|
||||||
}
|
}
|
||||||
@ -195,15 +195,15 @@ void XdgMenuWidgetPrivate::buildMenu()
|
|||||||
QDomElement xml = it.next();
|
QDomElement xml = it.next();
|
||||||
|
|
||||||
// Build submenu ........................
|
// Build submenu ........................
|
||||||
if (xml.tagName() == "Menu")
|
if (xml.tagName() == QLatin1String("Menu"))
|
||||||
q->insertMenu(first, new XdgMenuWidget(xml, q));
|
q->insertMenu(first, new XdgMenuWidget(xml, q));
|
||||||
|
|
||||||
//Build application link ................
|
//Build application link ................
|
||||||
else if (xml.tagName() == "AppLink")
|
else if (xml.tagName() == QLatin1String("AppLink"))
|
||||||
q->insertAction(first, createAction(xml));
|
q->insertAction(first, createAction(xml));
|
||||||
|
|
||||||
//Build separator .......................
|
//Build separator .......................
|
||||||
else if (xml.tagName() == "Separator")
|
else if (xml.tagName() == QLatin1String("Separator"))
|
||||||
q->insertSeparator(first);
|
q->insertSeparator(first);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -213,18 +213,18 @@ void XdgMenuWidgetPrivate::buildMenu()
|
|||||||
XdgAction* XdgMenuWidgetPrivate::createAction(const QDomElement& xml)
|
XdgAction* XdgMenuWidgetPrivate::createAction(const QDomElement& xml)
|
||||||
{
|
{
|
||||||
Q_Q(XdgMenuWidget);
|
Q_Q(XdgMenuWidget);
|
||||||
XdgAction* action = new XdgAction(xml.attribute("desktopFile"), q);
|
XdgAction* action = new XdgAction(xml.attribute(QLatin1String("desktopFile")), q);
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
if (!xml.attribute("title").isEmpty())
|
if (!xml.attribute(QLatin1String("title")).isEmpty())
|
||||||
title = xml.attribute("title");
|
title = xml.attribute(QLatin1String("title"));
|
||||||
else
|
else
|
||||||
title = xml.attribute("name");
|
title = xml.attribute(QLatin1String("name"));
|
||||||
|
|
||||||
|
|
||||||
if (!xml.attribute("genericName").isEmpty() &&
|
if (!xml.attribute(QLatin1String("genericName")).isEmpty() &&
|
||||||
xml.attribute("genericName") != title)
|
xml.attribute(QLatin1String("genericName")) != title)
|
||||||
title += QString(" (%1)").arg(xml.attribute("genericName"));
|
title += QString::fromLatin1(" (%1)").arg(xml.attribute(QLatin1String("genericName")));
|
||||||
|
|
||||||
action->setText(escape(title));
|
action->setText(escape(title));
|
||||||
return action;
|
return action;
|
||||||
@ -237,5 +237,5 @@ XdgAction* XdgMenuWidgetPrivate::createAction(const QDomElement& xml)
|
|||||||
************************************************/
|
************************************************/
|
||||||
QString XdgMenuWidgetPrivate::escape(QString string)
|
QString XdgMenuWidgetPrivate::escape(QString string)
|
||||||
{
|
{
|
||||||
return string.replace("&", "&&");
|
return string.replace(QLatin1Char('&'), QLatin1String("&&"));
|
||||||
}
|
}
|
@ -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 (QString s, names) {
|
foreach (const QString &s, names) {
|
||||||
if (!XdgIcon::fromTheme(s).isNull()) {
|
if (!XdgIcon::fromTheme(s).isNull()) {
|
||||||
dx->iconName = s;
|
dx->iconName = s;
|
||||||
break;
|
break;
|
@ -39,10 +39,8 @@ QDebug operator<<(QDebug dbg, const QDomElement &el)
|
|||||||
|
|
||||||
QString args;
|
QString args;
|
||||||
for (int i=0; i<map.count(); ++i)
|
for (int i=0; i<map.count(); ++i)
|
||||||
args += " " + map.item(i).nodeName() + "='" + map.item(i).nodeValue() + "'";
|
args += QLatin1Char(' ') + map.item(i).nodeName() + QLatin1Char('=') + map.item(i).nodeValue() + QLatin1Char('\'');
|
||||||
|
|
||||||
dbg.nospace() << QString("<%1%2>%3</%1>").arg(el.tagName()).arg(args).arg(el.text());
|
dbg.nospace() << QString::fromLatin1("<%1%2>%3</%1>").arg(el.tagName()).arg(args).arg(el.text());
|
||||||
return dbg.space();
|
return dbg.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,4 +25,4 @@ sha256sum --tag *.tar.gz *.tar.xz >> CHECKSUMS
|
|||||||
cd ..
|
cd ..
|
||||||
echo "Uploading to lxqt.org..."
|
echo "Uploading to lxqt.org..."
|
||||||
|
|
||||||
scp -r "$version" "lxde.org:/var/www/lxqt/downloads/$PROJECT/"
|
scp -r "$version" "downloads.lxqt.org:/srv/downloads.lxqt.org/$PROJECT/"
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
set(PROJECT_NAME "qtxdg_test")
|
set(PROJECT_NAME "qtxdg_test")
|
||||||
|
|
||||||
|
remove_definitions(
|
||||||
|
-DQT_USE_QSTRINGBUILDER
|
||||||
|
-DQT_NO_CAST_FROM_ASCII
|
||||||
|
)
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC TRUE)
|
set(CMAKE_AUTOMOC TRUE)
|
||||||
|
|
||||||
macro(qtxdg_add_test)
|
macro(qtxdg_add_test)
|
||||||
@ -11,7 +16,7 @@ macro(qtxdg_add_test)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
include_directories (
|
include_directories (
|
||||||
${CMAKE_SOURCE_DIR}
|
"${CMAKE_SOURCE_DIR}/qtxdg"
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,4 +27,5 @@ set_property(DIRECTORY APPEND
|
|||||||
qtxdg_add_test(
|
qtxdg_add_test(
|
||||||
qtxdg_test
|
qtxdg_test
|
||||||
tst_xdgdirs
|
tst_xdgdirs
|
||||||
|
tst_xdgdesktopfile
|
||||||
)
|
)
|
||||||
|
118
test/tst_xdgdesktopfile.cpp
Normal file
118
test/tst_xdgdesktopfile.cpp
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* libqtxdg - An Qt implementation of freedesktop.org xdg specs.
|
||||||
|
* Copyright (C) 2016 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 "tst_xdgdesktopfile.h"
|
||||||
|
#include "XdgDesktopFile"
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
|
||||||
|
class Language
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Language (const QString& lang)
|
||||||
|
: mPreviousLang(QString::fromLocal8Bit(qgetenv("LANG")))
|
||||||
|
{
|
||||||
|
qputenv("LANG", lang.toLocal8Bit());
|
||||||
|
}
|
||||||
|
~Language()
|
||||||
|
{
|
||||||
|
qputenv("LANG", mPreviousLang.toLocal8Bit());
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
QString mPreviousLang;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
QTEST_MAIN(tst_xdgdesktopfile);
|
||||||
|
|
||||||
|
void tst_xdgdesktopfile::testRead()
|
||||||
|
{
|
||||||
|
QTemporaryFile file("testReadXXXXXX.desktop");
|
||||||
|
QVERIFY(file.open());
|
||||||
|
const QString fileName = file.fileName();
|
||||||
|
QTextStream ts(&file);
|
||||||
|
ts <<
|
||||||
|
"[Desktop Entry]\n"
|
||||||
|
"Type=Application\n"
|
||||||
|
"Name=MyApp\n"
|
||||||
|
"Icon=foobar\n"
|
||||||
|
"MimeType=text/plain;image/png;;\n"
|
||||||
|
"\n";
|
||||||
|
file.close();
|
||||||
|
QVERIFY(QFile::exists(fileName));
|
||||||
|
|
||||||
|
XdgDesktopFile df;
|
||||||
|
df.load(fileName);
|
||||||
|
|
||||||
|
QVERIFY(df.isValid());
|
||||||
|
QCOMPARE(df.type(), XdgDesktopFile::ApplicationType);
|
||||||
|
QCOMPARE(df.name(), QString::fromLatin1("MyApp"));
|
||||||
|
QCOMPARE(df.iconName(), QString::fromLatin1("foobar"));
|
||||||
|
QCOMPARE(df.mimeTypes(), QStringList() << QString::fromLatin1("text/plain")
|
||||||
|
<< QString::fromLatin1("image/png"));
|
||||||
|
QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_xdgdesktopfile::testReadLocalized_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QString>("locale");
|
||||||
|
QTest::addColumn<QString>("translation");
|
||||||
|
|
||||||
|
const QString pt = QString::fromUtf8("A Minha Aplicação");
|
||||||
|
const QString pt_BR = QString::fromUtf8("O Meu Aplicativo");
|
||||||
|
|
||||||
|
QTest::newRow("pt") << QStringLiteral("pt") << pt;
|
||||||
|
QTest::newRow("pt_PT") << QStringLiteral("pt_PT") << pt;
|
||||||
|
QTest::newRow("pt_BR") << QStringLiteral("pt_BR") << pt_BR;
|
||||||
|
|
||||||
|
QTest::newRow("de") << QStringLiteral("de") << QStringLiteral("My Application");
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_xdgdesktopfile::testReadLocalized()
|
||||||
|
{
|
||||||
|
QTemporaryFile file("testReadLocalizedXXXXXX.desktop");
|
||||||
|
QVERIFY(file.open());
|
||||||
|
const QString fileName = file.fileName();
|
||||||
|
QTextStream ts(&file);
|
||||||
|
ts << QString::fromUtf8(
|
||||||
|
"[Desktop Entry]\n"
|
||||||
|
"Type=Application\n"
|
||||||
|
"Name=My Application\n"
|
||||||
|
"Name[pt]=A Minha Aplicação\n"
|
||||||
|
"Name[pt_BR]=O Meu Aplicativo\n"
|
||||||
|
"Icon=foo\n"
|
||||||
|
"\n");
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
QVERIFY(QFile::exists(fileName));
|
||||||
|
|
||||||
|
XdgDesktopFile df;
|
||||||
|
df.load(fileName);
|
||||||
|
QVERIFY(df.isValid());
|
||||||
|
|
||||||
|
QFETCH(QString, locale);
|
||||||
|
QFETCH(QString, translation);
|
||||||
|
|
||||||
|
Language lang(locale);
|
||||||
|
|
||||||
|
QCOMPARE(df.localizedValue("Name").toString(), translation);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "test/tst_xdgdesktopfile.moc"
|
35
test/tst_xdgdesktopfile.h
Normal file
35
test/tst_xdgdesktopfile.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* libqtxdg - An Qt implementation of freedesktop.org xdg specs.
|
||||||
|
* Copyright (C) 2016 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TST_XDGDESKTOPFILE_H
|
||||||
|
#define TST_XDGDESKTOPFILE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class tst_xdgdesktopfile : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void testRead();
|
||||||
|
void testReadLocalized();
|
||||||
|
void testReadLocalized_data();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TST_XDGDESKTOPFILE_H
|
26
util/CMakeLists.txt
Normal file
26
util/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
include_directories (
|
||||||
|
"${CMAKE_PROJECT_DIR}/qtxdg"
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(QTXDG_DESKTOP_FILE_START_SRCS
|
||||||
|
qtxdg-desktop-file-start.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(qtxdg-desktop-file-start
|
||||||
|
${QTXDG_DESKTOP_FILE_START_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(qtxdg-desktop-file-start
|
||||||
|
PRIVATE "-DQTXDG_VERSION=\"${QTXDG_VERSION_STRING}\""
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(qtxdg-desktop-file-start
|
||||||
|
${QTXDGX_LIBRARY_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS
|
||||||
|
qtxdg-desktop-file-start
|
||||||
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
COMPONENT Runtime
|
||||||
|
)
|
71
util/qtxdg-desktop-file-start.cpp
Normal file
71
util/qtxdg-desktop-file-start.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* libqtxdg - An Qt implementation of freedesktop.org xdg specs
|
||||||
|
* Copyright (C) 2016 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 <QCoreApplication>
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include <XdgDesktopFile>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
static void printErr(const QString & out)
|
||||||
|
{
|
||||||
|
std::cerr << qPrintable(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication app(argc, argv);
|
||||||
|
QCoreApplication::setApplicationName(QLatin1String("qtxdg-desktop-file-start"));
|
||||||
|
QCoreApplication::setApplicationVersion(QLatin1String(QTXDG_VERSION));
|
||||||
|
|
||||||
|
QCommandLineParser parser;
|
||||||
|
parser.setApplicationDescription(QLatin1String("QtXdg XdgDesktopFile start Tester"));
|
||||||
|
parser.addHelpOption();
|
||||||
|
parser.addVersionOption();
|
||||||
|
parser.addPositionalArgument(QLatin1String("file [urls...]"), QLatin1String("desktop file to start and it's urls"),QLatin1String("file [urls...]"));
|
||||||
|
parser.process(app);
|
||||||
|
|
||||||
|
if (parser.positionalArguments().isEmpty()) {
|
||||||
|
parser.showHelp(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList userArgs = parser.positionalArguments();
|
||||||
|
const QString userFileName = userArgs.takeFirst();
|
||||||
|
const QFileInfo fileInfo(userFileName);
|
||||||
|
const QString canonicalFileName = fileInfo.canonicalFilePath();
|
||||||
|
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
printErr(QString::fromLatin1("File %1 does not exist\n").arg(userFileName));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
XdgDesktopFile f;
|
||||||
|
const bool valid = f.load(canonicalFileName);
|
||||||
|
if (valid) {
|
||||||
|
f.startDetached(userArgs);
|
||||||
|
} else {
|
||||||
|
printErr(QString::fromLatin1("%1 is not a valid .desktop file\n").arg(canonicalFileName));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
82
xdgiconloader/CMakeLists.txt
Normal file
82
xdgiconloader/CMakeLists.txt
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
include_directories(
|
||||||
|
"${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(xdgiconloader_PUBLIC_H_FILES
|
||||||
|
)
|
||||||
|
|
||||||
|
set(xdgiconloader_PUBLIC_CLASSES
|
||||||
|
)
|
||||||
|
|
||||||
|
set(xdgiconloader_PRIVATE_H_FILES
|
||||||
|
)
|
||||||
|
|
||||||
|
set(xdgiconloader_CPP_FILES
|
||||||
|
xdgiconloader.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(xdgiconloader_MOCS
|
||||||
|
)
|
||||||
|
|
||||||
|
set(xdgiconloader_PRIVATE_INSTALLABLE_H_FILES
|
||||||
|
xdgiconloader_p.h
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(${QTXDGX_ICONLOADER_LIBRARY_NAME} SHARED
|
||||||
|
${xdgiconloader_CPP_FILES}
|
||||||
|
${xdgiconloader_PRIVATE_INSTALLABLE_H_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
generate_export_header(${QTXDGX_ICONLOADER_LIBRARY_NAME} BASE_NAME XdgIconLoader)
|
||||||
|
|
||||||
|
# Copy public headers (in tree building)
|
||||||
|
set(XDGICONLOADER_EXPORT_FILE "xdgiconloader_export.h")
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${XDGICONLOADER_EXPORT_FILE}"
|
||||||
|
"${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${XDGICONLOADER_EXPORT_FILE}"
|
||||||
|
COPYONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}>"
|
||||||
|
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
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}
|
||||||
|
PUBLIC "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}>"
|
||||||
|
PUBLIC "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}>"
|
||||||
|
PUBLIC "$<BUILD_INTERFACE:${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}>"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
PUBLIC
|
||||||
|
Qt5::Gui
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(${QTXDGX_ICONLOADER_LIBRARY_NAME}
|
||||||
|
PROPERTIES
|
||||||
|
VERSION ${QTXDG_VERSION_STRING}
|
||||||
|
SOVERSION ${QTXDG_MAJOR_VERSION}
|
||||||
|
)
|
||||||
|
|
||||||
|
export(TARGETS ${QTXDGX_ICONLOADER_LIBRARY_NAME} FILE "${CMAKE_BINARY_DIR}/${QTXDGX_ICONLOADER_FILE_NAME}-targets.cmake")
|
||||||
|
|
||||||
|
install(TARGETS
|
||||||
|
${QTXDGX_ICONLOADER_LIBRARY_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
EXPORT "${QTXDGX_ICONLOADER_FILE_NAME}-targets"
|
||||||
|
COMPONENT Runtime
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${xdgiconloader_PRIVATE_INSTALLABLE_H_FILES}
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${QTXDG_VERSION_STRING}/private/xdgiconloader"
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
"${QTXDGX_INTREE_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}/${XDGICONLOADER_EXPORT_FILE}"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${QTXDGX_ICONLOADER_FILE_NAME}"
|
||||||
|
)
|
@ -31,7 +31,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef QT_NO_ICON
|
#ifndef QT_NO_ICON
|
||||||
#include "qiconloader_p.h"
|
#include "xdgiconloader_p.h"
|
||||||
|
|
||||||
#include <private/qguiapplication_p.h>
|
#include <private/qguiapplication_p.h>
|
||||||
#include <private/qicon_p.h>
|
#include <private/qicon_p.h>
|
||||||
@ -55,9 +55,8 @@
|
|||||||
|
|
||||||
//QT_BEGIN_NAMESPACE
|
//QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QtXdg {
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
|
Q_GLOBAL_STATIC(XdgIconLoader, iconLoaderInstance)
|
||||||
|
|
||||||
/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
|
/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
|
||||||
static QString fallbackTheme()
|
static QString fallbackTheme()
|
||||||
@ -67,10 +66,10 @@ static QString fallbackTheme()
|
|||||||
if (themeHint.isValid())
|
if (themeHint.isValid())
|
||||||
return themeHint.toString();
|
return themeHint.toString();
|
||||||
}
|
}
|
||||||
return QString("hicolor");
|
return QLatin1String("hicolor");
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconLoader::QIconLoader() :
|
XdgIconLoader::XdgIconLoader() :
|
||||||
m_themeKey(1), m_supportsSvg(false), m_initialized(false)
|
m_themeKey(1), m_supportsSvg(false), m_initialized(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -102,7 +101,7 @@ static inline QStringList systemIconSearchPaths()
|
|||||||
//extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp
|
//extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void QIconLoader::ensureInitialized()
|
void XdgIconLoader::ensureInitialized()
|
||||||
{
|
{
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
@ -120,7 +119,7 @@ void QIconLoader::ensureInitialized()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconLoader *QIconLoader::instance()
|
XdgIconLoader *XdgIconLoader::instance()
|
||||||
{
|
{
|
||||||
iconLoaderInstance()->ensureInitialized();
|
iconLoaderInstance()->ensureInitialized();
|
||||||
return iconLoaderInstance();
|
return iconLoaderInstance();
|
||||||
@ -128,7 +127,7 @@ QIconLoader *QIconLoader::instance()
|
|||||||
|
|
||||||
// Queries the system theme and invalidates existing
|
// Queries the system theme and invalidates existing
|
||||||
// icons if the theme has changed.
|
// icons if the theme has changed.
|
||||||
void QIconLoader::updateSystemTheme()
|
void XdgIconLoader::updateSystemTheme()
|
||||||
{
|
{
|
||||||
// Only change if this is not explicitly set by the user
|
// Only change if this is not explicitly set by the user
|
||||||
if (m_userTheme.isEmpty()) {
|
if (m_userTheme.isEmpty()) {
|
||||||
@ -142,20 +141,20 @@ void QIconLoader::updateSystemTheme()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QIconLoader::setThemeName(const QString &themeName)
|
void XdgIconLoader::setThemeName(const QString &themeName)
|
||||||
{
|
{
|
||||||
m_userTheme = themeName;
|
m_userTheme = themeName;
|
||||||
invalidateKey();
|
invalidateKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QIconLoader::setThemeSearchPath(const QStringList &searchPaths)
|
void XdgIconLoader::setThemeSearchPath(const QStringList &searchPaths)
|
||||||
{
|
{
|
||||||
m_iconDirs = searchPaths;
|
m_iconDirs = searchPaths;
|
||||||
themeList.clear();
|
themeList.clear();
|
||||||
invalidateKey();
|
invalidateKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QIconLoader::themeSearchPaths() const
|
QStringList XdgIconLoader::themeSearchPaths() const
|
||||||
{
|
{
|
||||||
if (m_iconDirs.isEmpty()) {
|
if (m_iconDirs.isEmpty()) {
|
||||||
m_iconDirs = systemIconSearchPaths();
|
m_iconDirs = systemIconSearchPaths();
|
||||||
@ -182,7 +181,7 @@ QIconTheme::QIconTheme(const QString &themeName)
|
|||||||
QStringList themeSearchPaths = QIcon::themeSearchPaths();
|
QStringList themeSearchPaths = QIcon::themeSearchPaths();
|
||||||
foreach (QString path, themeSearchPaths)
|
foreach (QString path, themeSearchPaths)
|
||||||
{
|
{
|
||||||
if (!path.startsWith(':') && QFileInfo(path).isDir())
|
if (!path.startsWith(QLatin1Char(':')) && QFileInfo(path).isDir())
|
||||||
m_contentDirs.append(path + QLatin1Char('/') + themeName);
|
m_contentDirs.append(path + QLatin1Char('/') + themeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,18 +200,18 @@ QIconTheme::QIconTheme(const QString &themeName)
|
|||||||
// 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);
|
||||||
QIconDirInfo dirInfo(directoryKey);
|
XdgIconDirInfo 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 = QIconDirInfo::Fixed;
|
dirInfo.type = XdgIconDirInfo::Fixed;
|
||||||
else if (type == QLatin1String("Scalable"))
|
else if (type == QLatin1String("Scalable"))
|
||||||
dirInfo.type = QIconDirInfo::Scalable;
|
dirInfo.type = XdgIconDirInfo::Scalable;
|
||||||
else
|
else
|
||||||
dirInfo.type = QIconDirInfo::Threshold;
|
dirInfo.type = XdgIconDirInfo::Threshold;
|
||||||
|
|
||||||
dirInfo.threshold = indexReader.value(directoryKey +
|
dirInfo.threshold = indexReader.value(directoryKey +
|
||||||
QLatin1String("/Threshold"),
|
QLatin1String("/Threshold"),
|
||||||
@ -249,7 +248,7 @@ QIconTheme::QIconTheme(const QString &themeName)
|
|||||||
#endif //QT_NO_SETTINGS
|
#endif //QT_NO_SETTINGS
|
||||||
}
|
}
|
||||||
|
|
||||||
QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
QThemeIconInfo XdgIconLoader::findIconHelper(const QString &themeName,
|
||||||
const QString &iconName,
|
const QString &iconName,
|
||||||
QStringList &visited) const
|
QStringList &visited) const
|
||||||
{
|
{
|
||||||
@ -271,7 +270,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QStringList contentDirs = theme.contentDirs();
|
const QStringList contentDirs = theme.contentDirs();
|
||||||
const QVector<QIconDirInfo> subDirs = theme.keyList();
|
const QVector<XdgIconDirInfo> subDirs = theme.keyList();
|
||||||
|
|
||||||
const QString svgext(QLatin1String(".svg"));
|
const QString svgext(QLatin1String(".svg"));
|
||||||
const QString pngext(QLatin1String(".png"));
|
const QString pngext(QLatin1String(".png"));
|
||||||
@ -290,7 +289,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
for (int i = 0; i < contentDirs.size(); ++i) {
|
for (int i = 0; i < contentDirs.size(); ++i) {
|
||||||
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 QIconDirInfo &dirInfo = subDirs.at(j);
|
const XdgIconDirInfo &dirInfo = subDirs.at(j);
|
||||||
QString subdir = dirInfo.path;
|
QString subdir = dirInfo.path;
|
||||||
QDir currentDir(contentDir + subdir);
|
QDir currentDir(contentDir + subdir);
|
||||||
if (currentDir.exists(pngIconName)) {
|
if (currentDir.exists(pngIconName)) {
|
||||||
@ -390,7 +389,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
const QString pixmaps(QLatin1String("/usr/share/pixmaps"));
|
const QString pixmaps(QLatin1String("/usr/share/pixmaps"));
|
||||||
|
|
||||||
const QDir currentDir(pixmaps);
|
const QDir currentDir(pixmaps);
|
||||||
const QIconDirInfo dirInfo(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->dir = dirInfo;
|
||||||
@ -418,7 +417,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
QThemeIconInfo QIconLoader::loadIcon(const QString &name) const
|
QThemeIconInfo XdgIconLoader::loadIcon(const QString &name) const
|
||||||
{
|
{
|
||||||
if (!themeName().isEmpty()) {
|
if (!themeName().isEmpty()) {
|
||||||
QStringList visited;
|
QStringList visited;
|
||||||
@ -432,59 +431,59 @@ QThemeIconInfo QIconLoader::loadIcon(const QString &name) const
|
|||||||
// -------- Icon Loader Engine -------- //
|
// -------- Icon Loader Engine -------- //
|
||||||
|
|
||||||
|
|
||||||
QIconLoaderEngineFixed::QIconLoaderEngineFixed(const QString& iconName)
|
XdgIconLoaderEngine::XdgIconLoaderEngine(const QString& iconName)
|
||||||
: m_iconName(iconName), m_key(0)
|
: m_iconName(iconName), m_key(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconLoaderEngineFixed::~QIconLoaderEngineFixed()
|
XdgIconLoaderEngine::~XdgIconLoaderEngine()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_info.entries);
|
qDeleteAll(m_info.entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconLoaderEngineFixed::QIconLoaderEngineFixed(const QIconLoaderEngineFixed &other)
|
XdgIconLoaderEngine::XdgIconLoaderEngine(const XdgIconLoaderEngine &other)
|
||||||
: QIconEngine(other),
|
: QIconEngine(other),
|
||||||
m_iconName(other.m_iconName),
|
m_iconName(other.m_iconName),
|
||||||
m_key(0)
|
m_key(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconEngine *QIconLoaderEngineFixed::clone() const
|
QIconEngine *XdgIconLoaderEngine::clone() const
|
||||||
{
|
{
|
||||||
return new QIconLoaderEngineFixed(*this);
|
return new XdgIconLoaderEngine(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QIconLoaderEngineFixed::read(QDataStream &in) {
|
bool XdgIconLoaderEngine::read(QDataStream &in) {
|
||||||
in >> m_iconName;
|
in >> m_iconName;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QIconLoaderEngineFixed::write(QDataStream &out) const
|
bool XdgIconLoaderEngine::write(QDataStream &out) const
|
||||||
{
|
{
|
||||||
out << m_iconName;
|
out << m_iconName;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QIconLoaderEngineFixed::hasIcon() const
|
bool XdgIconLoaderEngine::hasIcon() const
|
||||||
{
|
{
|
||||||
return !(m_info.entries.isEmpty());
|
return !(m_info.entries.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lazily load the icon
|
// Lazily load the icon
|
||||||
void QIconLoaderEngineFixed::ensureLoaded()
|
void XdgIconLoaderEngine::ensureLoaded()
|
||||||
{
|
{
|
||||||
if (!(QIconLoader::instance()->themeKey() == m_key)) {
|
if (!(XdgIconLoader::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 = QIconLoader::instance()->loadIcon(m_iconName);
|
m_info = XdgIconLoader::instance()->loadIcon(m_iconName);
|
||||||
m_key = QIconLoader::instance()->themeKey();
|
m_key = XdgIconLoader::instance()->themeKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QIconLoaderEngineFixed::paint(QPainter *painter, const QRect &rect,
|
void XdgIconLoaderEngine::paint(QPainter *painter, const QRect &rect,
|
||||||
QIcon::Mode mode, QIcon::State state)
|
QIcon::Mode mode, QIcon::State state)
|
||||||
{
|
{
|
||||||
QSize pixmapSize = rect.size();
|
QSize pixmapSize = rect.size();
|
||||||
@ -498,16 +497,16 @@ void QIconLoaderEngineFixed::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 QIconDirInfo &dir, int iconsize)
|
static bool directoryMatchesSize(const XdgIconDirInfo &dir, int iconsize)
|
||||||
{
|
{
|
||||||
if (dir.type == QIconDirInfo::Fixed) {
|
if (dir.type == XdgIconDirInfo::Fixed) {
|
||||||
return dir.size == iconsize;
|
return dir.size == iconsize;
|
||||||
|
|
||||||
} else if (dir.type == QIconDirInfo::Scalable) {
|
} else if (dir.type == XdgIconDirInfo::Scalable) {
|
||||||
return dir.size <= dir.maxSize &&
|
return iconsize <= dir.maxSize &&
|
||||||
iconsize >= dir.minSize;
|
iconsize >= dir.minSize;
|
||||||
|
|
||||||
} else if (dir.type == QIconDirInfo::Threshold) {
|
} else if (dir.type == XdgIconDirInfo::Threshold) {
|
||||||
return iconsize >= dir.size - dir.threshold &&
|
return iconsize >= dir.size - dir.threshold &&
|
||||||
iconsize <= dir.size + dir.threshold;
|
iconsize <= dir.size + dir.threshold;
|
||||||
}
|
}
|
||||||
@ -520,12 +519,12 @@ static bool directoryMatchesSize(const QIconDirInfo &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 QIconDirInfo &dir, int iconsize)
|
static int directorySizeDistance(const XdgIconDirInfo &dir, int iconsize)
|
||||||
{
|
{
|
||||||
if (dir.type == QIconDirInfo::Fixed) {
|
if (dir.type == XdgIconDirInfo::Fixed) {
|
||||||
return qAbs(dir.size - iconsize);
|
return qAbs(dir.size - iconsize);
|
||||||
|
|
||||||
} else if (dir.type == QIconDirInfo::Scalable) {
|
} else if (dir.type == XdgIconDirInfo::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)
|
||||||
@ -533,7 +532,7 @@ static int directorySizeDistance(const QIconDirInfo &dir, int iconsize)
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if (dir.type == QIconDirInfo::Threshold) {
|
} else if (dir.type == XdgIconDirInfo::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)
|
||||||
@ -545,7 +544,7 @@ static int directorySizeDistance(const QIconDirInfo &dir, int iconsize)
|
|||||||
return INT_MAX;
|
return INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIconLoaderEngineEntry *QIconLoaderEngineFixed::entryForSize(const QSize &size)
|
XdgIconLoaderEngineEntry *XdgIconLoaderEngine::entryForSize(const QSize &size)
|
||||||
{
|
{
|
||||||
int iconsize = qMin(size.width(), size.height());
|
int iconsize = qMin(size.width(), size.height());
|
||||||
|
|
||||||
@ -556,7 +555,7 @@ QIconLoaderEngineEntry *QIconLoaderEngineFixed::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) {
|
||||||
QIconLoaderEngineEntry *entry = m_info.entries.at(i);
|
XdgIconLoaderEngineEntry *entry = m_info.entries.at(i);
|
||||||
if (directoryMatchesSize(entry->dir, iconsize)) {
|
if (directoryMatchesSize(entry->dir, iconsize)) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@ -564,9 +563,9 @@ QIconLoaderEngineEntry *QIconLoaderEngineFixed::entryForSize(const QSize &size)
|
|||||||
|
|
||||||
// Find the minimum distance icon
|
// Find the minimum distance icon
|
||||||
int minimalSize = INT_MAX;
|
int minimalSize = INT_MAX;
|
||||||
QIconLoaderEngineEntry *closestMatch = 0;
|
XdgIconLoaderEngineEntry *closestMatch = 0;
|
||||||
for (int i = 0; i < numEntries; ++i) {
|
for (int i = 0; i < numEntries; ++i) {
|
||||||
QIconLoaderEngineEntry *entry = m_info.entries.at(i);
|
XdgIconLoaderEngineEntry *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;
|
||||||
@ -582,18 +581,27 @@ QIconLoaderEngineEntry *QIconLoaderEngineFixed::entryForSize(const QSize &size)
|
|||||||
* we can never return a bigger size than the requested size.
|
* we can never return a bigger size than the requested size.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
QSize QIconLoaderEngineFixed::actualSize(const QSize &size, QIcon::Mode mode,
|
QSize XdgIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
|
||||||
QIcon::State state)
|
QIcon::State state)
|
||||||
{
|
{
|
||||||
ensureLoaded();
|
ensureLoaded();
|
||||||
|
|
||||||
QIconLoaderEngineEntry *entry = entryForSize(size);
|
XdgIconLoaderEngineEntry *entry = entryForSize(size);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
const QIconDirInfo &dir = entry->dir;
|
const XdgIconDirInfo &dir = entry->dir;
|
||||||
if (dir.type == QIconDirInfo::Scalable)
|
if (dir.type == XdgIconDirInfo::Scalable || dynamic_cast<ScalableEntry *>(entry))
|
||||||
return size;
|
return size;
|
||||||
else {
|
else {
|
||||||
int result = qMin<int>(dir.size, qMin(size.width(), size.height()));
|
int dir_size = dir.size;
|
||||||
|
//Note: fallback for directories that don't have its content size defined
|
||||||
|
// -> get the actual size based on the image if possible
|
||||||
|
PixmapEntry * pix_e;
|
||||||
|
if (0 == dir_size && nullptr != (pix_e = dynamic_cast<PixmapEntry *>(entry)))
|
||||||
|
{
|
||||||
|
QSize pix_size = pix_e->basePixmap.size();
|
||||||
|
dir_size = qMin(pix_size.width(), pix_size.height());
|
||||||
|
}
|
||||||
|
int result = qMin(dir_size, qMin(size.width(), size.height()));
|
||||||
return QSize(result, result);
|
return QSize(result, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -644,24 +652,24 @@ QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State
|
|||||||
return svgIcon.pixmap(size, mode, state);
|
return svgIcon.pixmap(size, mode, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap QIconLoaderEngineFixed::pixmap(const QSize &size, QIcon::Mode mode,
|
QPixmap XdgIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode,
|
||||||
QIcon::State state)
|
QIcon::State state)
|
||||||
{
|
{
|
||||||
ensureLoaded();
|
ensureLoaded();
|
||||||
|
|
||||||
QIconLoaderEngineEntry *entry = entryForSize(size);
|
XdgIconLoaderEngineEntry *entry = entryForSize(size);
|
||||||
if (entry)
|
if (entry)
|
||||||
return entry->pixmap(size, mode, state);
|
return entry->pixmap(size, mode, state);
|
||||||
|
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QIconLoaderEngineFixed::key() const
|
QString XdgIconLoaderEngine::key() const
|
||||||
{
|
{
|
||||||
return QLatin1String("QIconLoaderEngineFixed");
|
return QLatin1String("XdgIconLoaderEngine");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QIconLoaderEngineFixed::virtual_hook(int id, void *data)
|
void XdgIconLoaderEngine::virtual_hook(int id, void *data)
|
||||||
{
|
{
|
||||||
ensureLoaded();
|
ensureLoaded();
|
||||||
|
|
||||||
@ -693,7 +701,6 @@ void QIconLoaderEngineFixed::virtual_hook(int id, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // QtXdg
|
|
||||||
|
|
||||||
//QT_END_NAMESPACE
|
//QT_END_NAMESPACE
|
||||||
|
|
@ -48,6 +48,8 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <xdgiconloader_export.h>
|
||||||
|
|
||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
#include <QtGui/QIconEngine>
|
#include <QtGui/QIconEngine>
|
||||||
#include <QtGui/QPixmapCache>
|
#include <QtGui/QPixmapCache>
|
||||||
@ -59,14 +61,12 @@
|
|||||||
|
|
||||||
//QT_BEGIN_NAMESPACE
|
//QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QtXdg {
|
class XdgIconLoader;
|
||||||
|
|
||||||
class QIconLoader;
|
struct XdgIconDirInfo
|
||||||
|
|
||||||
struct QIconDirInfo
|
|
||||||
{
|
{
|
||||||
enum Type { Fixed, Scalable, Threshold };
|
enum Type { Fixed, Scalable, Threshold };
|
||||||
QIconDirInfo(const QString &_path = QString()) :
|
XdgIconDirInfo(const QString &_path = QString()) :
|
||||||
path(_path),
|
path(_path),
|
||||||
size(0),
|
size(0),
|
||||||
maxSize(0),
|
maxSize(0),
|
||||||
@ -81,31 +81,31 @@ struct QIconDirInfo
|
|||||||
Type type : 4;
|
Type type : 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QIconLoaderEngineEntry
|
class XdgIconLoaderEngineEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~QIconLoaderEngineEntry() {}
|
virtual ~XdgIconLoaderEngineEntry() {}
|
||||||
virtual QPixmap pixmap(const QSize &size,
|
virtual QPixmap pixmap(const QSize &size,
|
||||||
QIcon::Mode mode,
|
QIcon::Mode mode,
|
||||||
QIcon::State state) = 0;
|
QIcon::State state) = 0;
|
||||||
QString filename;
|
QString filename;
|
||||||
QIconDirInfo dir;
|
XdgIconDirInfo dir;
|
||||||
static int count;
|
static int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ScalableEntry : public QIconLoaderEngineEntry
|
struct ScalableEntry : 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;
|
||||||
QIcon svgIcon;
|
QIcon svgIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PixmapEntry : public QIconLoaderEngineEntry
|
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;
|
QPixmap basePixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<QIconLoaderEngineEntry*> QThemeIconEntries;
|
typedef QList<XdgIconLoaderEngineEntry*> QThemeIconEntries;
|
||||||
|
|
||||||
struct QThemeIconInfo
|
struct QThemeIconInfo
|
||||||
{
|
{
|
||||||
@ -114,11 +114,11 @@ struct QThemeIconInfo
|
|||||||
};
|
};
|
||||||
|
|
||||||
//class QIconLoaderEngine : public QIconEngine
|
//class QIconLoaderEngine : public QIconEngine
|
||||||
class QIconLoaderEngineFixed : public QIconEngine
|
class XDGICONLOADER_EXPORT XdgIconLoaderEngine : public QIconEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QIconLoaderEngineFixed(const QString& iconName = QString());
|
XdgIconLoaderEngine(const QString& iconName = QString());
|
||||||
~QIconLoaderEngineFixed();
|
~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);
|
||||||
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
|
||||||
@ -132,13 +132,13 @@ private:
|
|||||||
bool hasIcon() const;
|
bool hasIcon() const;
|
||||||
void ensureLoaded();
|
void ensureLoaded();
|
||||||
void virtual_hook(int id, void *data);
|
void virtual_hook(int id, void *data);
|
||||||
QIconLoaderEngineEntry *entryForSize(const QSize &size);
|
XdgIconLoaderEngineEntry *entryForSize(const QSize &size);
|
||||||
QIconLoaderEngineFixed(const QIconLoaderEngineFixed &other);
|
XdgIconLoaderEngine(const XdgIconLoaderEngine &other);
|
||||||
QThemeIconInfo m_info;
|
QThemeIconInfo m_info;
|
||||||
QString m_iconName;
|
QString m_iconName;
|
||||||
uint m_key;
|
uint m_key;
|
||||||
|
|
||||||
friend class QIconLoader;
|
friend class XdgIconLoader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QIconTheme
|
class QIconTheme
|
||||||
@ -147,21 +147,21 @@ public:
|
|||||||
QIconTheme(const QString &name);
|
QIconTheme(const QString &name);
|
||||||
QIconTheme() : m_valid(false) {}
|
QIconTheme() : m_valid(false) {}
|
||||||
QStringList parents() { return m_parents; }
|
QStringList parents() { return m_parents; }
|
||||||
QVector <QIconDirInfo> keyList() { return m_keyList; }
|
QVector <XdgIconDirInfo> keyList() { return m_keyList; }
|
||||||
QStringList contentDirs() { return m_contentDirs; }
|
QStringList contentDirs() { return m_contentDirs; }
|
||||||
bool isValid() { return m_valid; }
|
bool isValid() { return m_valid; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList m_contentDirs;
|
QStringList m_contentDirs;
|
||||||
QVector <QIconDirInfo> m_keyList;
|
QVector <XdgIconDirInfo> m_keyList;
|
||||||
QStringList m_parents;
|
QStringList m_parents;
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_GUI_EXPORT QIconLoader
|
class XDGICONLOADER_EXPORT XdgIconLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QIconLoader();
|
XdgIconLoader();
|
||||||
QThemeIconInfo loadIcon(const QString &iconName) const;
|
QThemeIconInfo loadIcon(const QString &iconName) const;
|
||||||
uint themeKey() const { return m_themeKey; }
|
uint themeKey() const { return m_themeKey; }
|
||||||
|
|
||||||
@ -170,8 +170,8 @@ public:
|
|||||||
QIconTheme theme() { return themeList.value(themeName()); }
|
QIconTheme theme() { return themeList.value(themeName()); }
|
||||||
void setThemeSearchPath(const QStringList &searchPaths);
|
void setThemeSearchPath(const QStringList &searchPaths);
|
||||||
QStringList themeSearchPaths() const;
|
QStringList themeSearchPaths() const;
|
||||||
QIconDirInfo dirInfo(int dirindex);
|
XdgIconDirInfo dirInfo(int dirindex);
|
||||||
static QIconLoader *instance();
|
static XdgIconLoader *instance();
|
||||||
void updateSystemTheme();
|
void updateSystemTheme();
|
||||||
void invalidateKey() { m_themeKey++; }
|
void invalidateKey() { m_themeKey++; }
|
||||||
void ensureInitialized();
|
void ensureInitialized();
|
||||||
@ -190,11 +190,10 @@ private:
|
|||||||
mutable QHash <QString, QIconTheme> themeList;
|
mutable QHash <QString, QIconTheme> themeList;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // QtXdg
|
|
||||||
|
|
||||||
// Note: class template specialization of 'QTypeInfo' must occur at
|
// Note: class template specialization of 'QTypeInfo' must occur at
|
||||||
// global scope
|
// global scope
|
||||||
Q_DECLARE_TYPEINFO(QtXdg::QIconDirInfo, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(XdgIconDirInfo, Q_MOVABLE_TYPE);
|
||||||
|
|
||||||
//QT_END_NAMESPACE
|
//QT_END_NAMESPACE
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user