diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df86d61..1413ec4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,114 +1,114 @@ add_subdirectory(tools/kiconfinder) if (APPLE) add_subdirectory(tools/ksvg2icns) endif() set(kiconthemes_SRCS kiconbutton.cpp kicondialog.cpp kiconeffect.cpp kiconengine.cpp kiconloader.cpp kicontheme.cpp ) qt5_add_resources(kiconthemes_SRCS hicolor.qrc ) ecm_qt_declare_logging_category(kiconthemes_SRCS HEADER debug.h IDENTIFIER KICONTHEMES CATEGORY_NAME kf5.kiconthemes) add_library(KF5IconThemes ${kiconthemes_SRCS}) add_library(KF5::IconThemes ALIAS KF5IconThemes) ecm_generate_export_header(KF5IconThemes BASE_NAME KIconThemes GROUP_BASE_NAME KF VERSION ${KF5_VERSION} DEPRECATED_BASE_VERSION 0 - DEPRECATION_VERSIONS 4.8 5.0 5.63 + DEPRECATION_VERSIONS 4.8 5.0 5.63 5.64 EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} ) target_include_directories(KF5IconThemes INTERFACE "$") target_link_libraries(KF5IconThemes PUBLIC Qt5::Widgets PRIVATE Qt5::Svg KF5::Archive # for KCompressionDevice KF5::I18n # for i18n in KIconDialog KF5::WidgetsAddons # for KPixmapSequence family KF5::ItemViews # for KListWidgetSearchLine KF5::ConfigWidgets # for KColorScheme KF5::CoreAddons # for kshareddatacache.h ) if (TARGET Qt5::DBus) target_link_libraries(KF5IconThemes PRIVATE Qt5::DBus) endif() set_target_properties(KF5IconThemes PROPERTIES VERSION ${KICONTHEMES_VERSION_STRING} SOVERSION ${KICONTHEMES_SOVERSION} EXPORT_NAME IconThemes ) ecm_generate_headers(KIconThemes_HEADERS HEADER_NAMES KIconButton KIconDialog KIconEffect KIconLoader KIconTheme KIconEngine REQUIRED_HEADERS KIconThemes_HEADERS ) install(TARGETS KF5IconThemes EXPORT KF5IconThemesTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kiconthemes_export.h ${KIconThemes_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KIconThemes COMPONENT Devel ) if(BUILD_DESIGNERPLUGIN) add_subdirectory(designer) endif() if(BUILD_QCH) ecm_add_qch( KF5IconThemes_QCH NAME KIconThemes BASE_NAME KF5IconThemes VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KIconThemes_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" IMAGE_DIRS "${CMAKE_SOURCE_DIR}/docs/pics" LINK_QCHS Qt5Widgets_QCH INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} BLANK_MACROS KICONTHEMES_EXPORT KICONTHEMES_DEPRECATED KICONTHEMES_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KIconThemes LIB_NAME KF5IconThemes DEPS "widgets" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KIconThemes) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) add_library(KIconEnginePlugin MODULE kiconengineplugin.cpp) target_link_libraries(KIconEnginePlugin PRIVATE Qt5::Gui KF5::IconThemes ) install(TARGETS KIconEnginePlugin DESTINATION ${KDE_INSTALL_QTPLUGINDIR}/iconengines) diff --git a/src/kicontheme.h b/src/kicontheme.h index 6934140..79d4def 100644 --- a/src/kicontheme.h +++ b/src/kicontheme.h @@ -1,293 +1,299 @@ /* vi: ts=8 sts=4 sw=4 * * This file is part of the KDE project, module kdecore. * Copyright (C) 2000 Geert Jansen * Antonio Larrosa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation. * * 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef KICONTHEME_H #define KICONTHEME_H #include #include #include #include #include "kiconloader.h" class QAction; class KIconThemeDir; /** * @internal * Class to use/access icon themes in KDE. This class is used by the * iconloader but can be used by others too. * @warning You should not use this class externally. This class is exported because * the KCM needs it. * @see KIconLoader */ class KICONTHEMES_EXPORT KIconTheme { public: /** * Load an icon theme by name. * @param name the name of the theme (e.g. "hicolor" or "keramik") * @param appName the name of the application. Can be null. This argument * allows applications to have themed application icons. * @param basePathHint optional hint where to search the app themes. * This is appended at the end of the search paths */ explicit KIconTheme(const QString &name, const QString &appName = QString(), const QString &basePathHint = QString()); ~KIconTheme(); KIconTheme(const KIconTheme &) = delete; KIconTheme &operator=(const KIconTheme &) = delete; /** * The stylized name of the icon theme. * @return the (human-readable) name of the theme */ QString name() const; /** * The internal name of the icon theme (same as the name argument passed * to the constructor). * @return the internal name of the theme */ QString internalName() const; /** * A description for the icon theme. * @return a human-readable description of the theme, QString() * if there is none */ QString description() const; /** * Return the name of the "example" icon. This can be used to * present the theme to the user. * @return the name of the example icon, QString() if there is none */ QString example() const; /** * Return the name of the screenshot. * @return the name of the screenshot, QString() if there is none */ QString screenshot() const; /** * Returns the toplevel theme directory. * @return the directory of the theme */ QString dir() const; /** * The themes this icon theme falls back on. * @return a list of icon themes that are used as fall-backs */ QStringList inherits() const; /** * The icon theme exists? * @return true if the icon theme is valid */ bool isValid() const; /** * The icon theme should be hidden to the user? * @return true if the icon theme is hidden */ bool isHidden() const; /** * The minimum display depth required for this theme. This can either * be 8 or 32. * @return the minimum bpp (8 or 32) */ int depth() const; /** * The default size of this theme for a certain icon group. * @param group The icon group. See KIconLoader::Group. * @return The default size in pixels for the given icon group. */ int defaultSize(KIconLoader::Group group) const; /** * Query available sizes for a group. * @param group The icon group. See KIconLoader::Group. * @return a list of available sizes for the given group */ QList querySizes(KIconLoader::Group group) const; /** * Query available icons for a size and context. * @param size the size of the icons * @param context the context of the icons * @return the list of icon names */ QStringList queryIcons(int size, KIconLoader::Context context = KIconLoader::Any) const; /** * Query available icons for a context and preferred size. * @param size the size of the icons * @param context the context of the icons * @return the list of icon names */ QStringList queryIconsByContext(int size, KIconLoader::Context context = KIconLoader::Any) const; /** * Lookup an icon in the theme. * @param name The name of the icon, with extension. * @param size The desired size of the icon. * @param match The matching mode. KIconLoader::MatchExact returns an icon * only if matches exactly. KIconLoader::MatchBest returns the best matching * icon. * @return An absolute path to the file of the icon if it's found, QString() otherwise. * @see KIconLoader::isValid will return true, and false otherwise. */ QString iconPath(const QString &name, int size, KIconLoader::MatchType match) const; /** * Lookup an icon in the theme. * @param name The name of the icon, with extension. * @param size The desired size of the icon. * @param match The matching mode. KIconLoader::MatchExact returns an icon * only if matches exactly. KIconLoader::MatchBest returns the best matching * icon. * @param scale The scale of the icon group. * @return An absolute path to the file of the icon if it's found, QString() otherwise. * @see KIconLoader::isValid will return true, and false otherwise. * @since 5.48 */ // TODO KF6 merge iconPath() with and without "scale" and move that argument after "size" QString iconPath(const QString &name, int size, KIconLoader::MatchType match, qreal scale) const; /** * Lookup an icon in the theme. * @param name The name of the icon, without extension. * @param size The desired size of the icon. * @param match The matching mode. KIconLoader::MatchExact returns an icon * only if matches exactly. KIconLoader::MatchBest returns the best matching * icon. * @return An absolute path to the file of the icon if it's found, QString() otherwise. * @see KIconLoader::isValid will return true, and false otherwise. * * @since 5.22 */ QString iconPathByName(const QString &name, int size, KIconLoader::MatchType match) const; /** * Lookup an icon in the theme. * @param name The name of the icon, without extension. * @param size The desired size of the icon. * @param match The matching mode. KIconLoader::MatchExact returns an icon * only if matches exactly. KIconLoader::MatchBest returns the best matching * icon. * @param scale The scale of the icon group. * @return An absolute path to the file of the icon if it's found, QString() otherwise. * @see KIconLoader::isValid will return true, and false otherwise. * * @since 5.48 */ // TODO KF6 merge iconPathByName() with and without "scale" and move that argument after "size" QString iconPathByName(const QString &name, int size, KIconLoader::MatchType match, qreal scale) const; /** * Returns true if the theme has any icons for the given context. */ bool hasContext(KIconLoader::Context context) const; /** * If true, this theme is made of SVG icons that will be colorized following the system * color scheme. This is necessary for monochrome themes that should look visible on both * light and dark color schemes. * @return true if the SVG will be colorized with a stylesheet. * @since 5.22 */ bool followsColorScheme() const; /** * List all icon themes installed on the system, global and local. * @return the list of all icon themes */ static QStringList list(); /** * Returns the current icon theme. * @return the name of the current theme */ static QString current(); /** * Force a current theme and disable automatic resolution of the current * theme in favor of the forced theme. * * To reset a forced theme, simply set an empty themeName. * * @param themeName name of the theme to force as current theme, or an * empty string to unset theme forcing. * * @note This should only be used when a very precise expectation about * the current theme is present. Most notably in unit tests * this can be used to force a given theme. * * @warning A forced theme persists across reconfigure() calls! * * @see current * @since 5.23 */ static void forceThemeForTests(const QString &themeName); /** * Reconfigure the theme. */ static void reconfigure(); /** * Returns the default icon theme. * @return the name of the default theme name */ static QString defaultThemeName(); +#if KICONTHEMES_ENABLE_DEPRECATED_SINCE(5, 64) /** * Defines the context menus that assignIconsToContextMenus is * aware of. * * For ReadOnlyText the menu is expected to have one entry. * * TextEditor is expected to have the full complement of * undo, redo, cut, copy, paste and clear. + * + * @deprecated since 5.64 no longer needed */ enum ContextMenus { TextEditor, ReadOnlyText - }; + }; // TODO KF6 remove /** * Assigns standard icons to the various standard text edit context menus. + * + * @deprecated since 5.64, no longer necessary, Qt assigns icon itself by now. */ - static void assignIconsToContextMenu(ContextMenus type, QList actions); + KICONTHEMES_DEPRECATED_VERSION(5, 64, "No longer necessary") static void assignIconsToContextMenu(ContextMenus type, QList actions); // TODO KF6 remove +#endif private: class KIconThemePrivate; KIconThemePrivate *const d; }; #endif