diff --git a/CMakeLists.txt b/CMakeLists.txt index 872bfbfb9..fbb532e40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,229 +1,229 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.64.0") # handled by release scripts set(KF5_DEP_VERSION "5.63.0") # handled by release scripts project(Plasma VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) find_package(ECM 5.63.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) -include(GenerateExportHeader) +include(ECMGenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(ECMQtDeclareLoggingCategory) include(ECMAddQch) include(KDEPackageAppTemplates) include(ECMGenerateQmlTypes) include(ECMSetupQtPluginMacroNames) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX PLASMA VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/plasma_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaConfigVersion.cmake" SOVERSION 5) if(KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED) set(KDE_NO_DEPRECATED TRUE) set(CMAKE_AUTOMOC_MOC_OPTIONS "-DKDE_NO_DEPRECATED") endif() ################# now find all used packages ################# set (REQUIRED_QT_VERSION 5.11.0) find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Quick Gui Sql Qml Svg QuickControls2) find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Activities Archive Config ConfigWidgets CoreAddons DBusAddons Declarative GlobalAccel GuiAddons I18n IconThemes KIO Service WindowSystem XmlGui Notifications Package Kirigami2 OPTIONAL_COMPONENTS Wayland DocTools ) set_package_properties(KF5Wayland PROPERTIES DESCRIPTION "Integration with the Wayland compositor" TYPE OPTIONAL ) if(KF5Wayland_FOUND) set(HAVE_KWAYLAND 1) endif() set_package_properties(KF5DocTools PROPERTIES DESCRIPTION "Tools to generate documentation" TYPE OPTIONAL ) #optional features find_package(X11 MODULE) set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries" URL "https://www.x.org/" TYPE OPTIONAL ) find_package(XCB MODULE COMPONENTS XCB COMPOSITE DAMAGE SHAPE XFIXES RENDER) set_package_properties(XCB PROPERTIES DESCRIPTION "X protocol C-language Binding" URL "https://xcb.freedesktop.org/" TYPE OPTIONAL ) if(X11_FOUND AND XCB_XCB_FOUND) set(HAVE_X11 1) find_package(Qt5 REQUIRED NO_MODULE COMPONENTS X11Extras) #X11_Xrender discovery is done by FindX11 #add_feature_info("X Rendering Extension (libXrender)" X11_Xrender_FOUND "Support for compositing, rendering operations, and alpha-blending. STRONGLY RECOMMENDED") endif() find_package(OpenGL) set_package_properties(OpenGL PROPERTIES DESCRIPTION "The OpenGL libraries" URL "https://www.opengl.org/" TYPE OPTIONAL ) find_package(EGL) set_package_properties(EGL PROPERTIES PURPOSE "Support for Window Thumbnail on EGL platform" TYPE OPTIONAL ) set(HAVE_EGL ${EGL_FOUND}) if(OPENGL_FOUND AND (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GL")) set(HAVE_GLX ${HAVE_X11}) else() set(HAVE_GLX 0) endif() ######################################################################### ecm_setup_qtplugin_macro_names( JSON_NONE "K_EXPORT_PLASMA_SERVICE" "K_EXPORT_PLASMA_APPLET" "K_EXPORT_PLASMA_PACKAGE" "K_EXPORT_PLASMA_APPLETSCRIPTENGINE" "K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE" "K_EXPORT_PLASMA_DATAENGINE" JSON_ARG2 "K_EXPORT_PLASMA_PACKAGE_WITH_JSON" JSON_ARG3 "K_EXPORT_PLASMA_SERVICE_WITH_JSON" "K_EXPORT_PLASMA_APPLET_WITH_JSON" "K_EXPORT_PLASMA_APPLETSCRIPTENGINE_WITH_JSON" "K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE_WITH_JSON" "K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON" "K_EXPORT_PLASMA_DATAENGINE_WITH_JSON" CONFIG_CODE_VARIABLE PACKAGE_SETUP_AUTOMOC_VARIABLES ) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) #add_definitions(-Wno-deprecated) include(KF5PlasmaMacros.cmake) ######################################################################### option(BUILD_EXAMPLES "Build and install Plasma examples." OFF) option(BUILD_COVERAGE "Build Plasma Frameworks with gcov support" OFF) if(BUILD_COVERAGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") endif() # make plasma_version.h available include_directories(${CMAKE_CURRENT_BINARY_DIR}) ################# list the subdirectories ################# if (KF5DocTools_FOUND) add_subdirectory(docs) endif() add_definitions(-DTRANSLATION_DOMAIN=\"libplasma5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) if (KF5DocTools_FOUND) kdoctools_install(po) endif() endif() add_subdirectory(src) if (BUILD_EXAMPLES) add_subdirectory(examples) endif() if (BUILD_TESTING) add_subdirectory(autotests) add_subdirectory(tests) endif() add_subdirectory(templates) ################ create PlasmaConfig.cmake and install it ########################### # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Plasma") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5Plasma_QCH FILE KF5PlasmaQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5PlasmaQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PlasmaConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} PATH_VARS KF5_INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaConfigVersion.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/KF5PlasmaMacros.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5PlasmaTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PlasmaTargets.cmake NAMESPACE KF5:: COMPONENT Devel) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plasma_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) install(FILES plasma-framework.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt index 619601206..807107b54 100644 --- a/src/plasma/CMakeLists.txt +++ b/src/plasma/CMakeLists.txt @@ -1,235 +1,242 @@ add_subdirectory(packagestructure) # This option should be removed, or moved down as far as possible. # That means porting the existing frameworks to the CMake automoc # feature. Porting is mostly removing explicit moc includes, and # leaving the ones which are truly needed (ie, if you remove # them, the build fails). set(CMAKE_AUTOMOC_RELAXED_MODE ON) if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) set(PLASMA_NO_PACKAGE_EXTRADATA TRUE) endif() #find_package(KdepimLibs 4.5.60) #find_package(Gpgme) #set_package_properties(KDEPIMLIBS PROPERTIES DESCRIPTION "KDE PIM libraries" # URL "https://www.kde.org" TYPE OPTIONAL # PURPOSE "Needed for building several Plasma DataEngines") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-plasma.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-plasma.h) #FIXME: gpgme++ is in kdepimlibs, must move somewhere else! include_directories(${KDEPIMLIBS_INCLUDE_DIRS} ${GPGME_INCLUDES}) add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1209) ########### next target ############### set(Plasma_LIB_SRCS #global plasma.cpp pluginloader.cpp version.cpp #applets,containments,corona applet.cpp containment.cpp containmentactions.cpp corona.cpp private/applet_p.cpp private/associatedapplicationmanager.cpp private/containment_p.cpp private/timetracker.cpp #Dataengines, services datacontainer.cpp dataengine.cpp dataengineconsumer.cpp service.cpp servicejob.cpp private/datacontainer_p.cpp private/dataenginemanager.cpp private/storage.cpp private/storagethread.cpp #packages package.cpp packagestructure.cpp #graphics framesvg.cpp svg.cpp theme.cpp private/theme_p.cpp #scripting scripting/appletscript.cpp scripting/dataenginescript.cpp scripting/scriptengine.cpp ) if(HAVE_X11) set(Plasma_LIB_SRCS ${Plasma_LIB_SRCS} private/effectwatcher.cpp) endif() kconfig_add_kcfg_files(Plasma_LIB_SRCS data/kconfigxt/libplasma-theme-global.kcfgc) #NEPOMUK_GENERATE_FROM_ONTOLOGY( # nwc.nrl # ${metadata_test_BINARY_DIR} # TEST_HEADERS # TEST_SOURCES # TEST_INCLUDES #) ecm_qt_declare_logging_category(Plasma_LIB_SRCS HEADER debug_p.h IDENTIFIER LOG_PLASMA CATEGORY_NAME org.kde.plasma) add_library(KF5Plasma ${Plasma_LIB_SRCS}) add_library(KF5::Plasma ALIAS KF5Plasma) +ecm_generate_export_header(KF5Plasma + EXPORT_FILE_NAME plasma/plasma_export.h + BASE_NAME Plasma + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 5.6 5.19 5.28 5.30 5.36 5.46 +) +# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all Plasma libs +# needs fixing of undeprecated API being still implemented using own deprecated API if(HAVE_X11) set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} Qt5::X11Extras ${X11_LIBRARIES} XCB::XCB) endif() if(DL_LIBRARY) set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} ${DL_LIBRARY}) endif() target_link_libraries(KF5Plasma PUBLIC KF5::Service # For kplugininfo.h and kservice.h Qt5::Gui KF5::Package PRIVATE Qt5::Sql Qt5::Svg Qt5::DBus KF5::Archive KF5::GuiAddons #kimagecache KF5::I18n KF5::KIOCore #ServiceJob KF5::KIOWidgets #KRun KF5::WindowSystem #compositingActive KF5::Declarative #runtimePlatform KF5::XmlGui #KActionCollection KF5::GlobalAccel #Applet::setGlobalShortcut KF5::Notifications KF5::IconThemes ${PLASMA_EXTRA_LIBS} ) set(Plasma_BUILD_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/Plasma ) target_include_directories(KF5Plasma PUBLIC "$" ) target_include_directories(KF5Plasma INTERFACE "$" ) set_target_properties(KF5Plasma PROPERTIES VERSION ${PLASMA_VERSION_STRING} SOVERSION ${PLASMA_SOVERSION} EXPORT_NAME Plasma ) ########### install files ############### -generate_export_header(KF5Plasma - BASE_NAME Plasma - EXPORT_FILE_NAME plasma/plasma_export.h) ecm_generate_headers(Plasma_CamelCase_HEADERS HEADER_NAMES Applet Containment ContainmentActions Corona DataContainer DataEngine DataEngineConsumer PluginLoader FrameSvg Package PackageStructure Service ServiceJob Svg Theme Plasma REQUIRED_HEADERS Plasma_HEADERS PREFIX Plasma ) set(Plasma_HEADERS ${Plasma_HEADERS} version.h ) set(PlasmaScripting_HEADERS scripting/appletscript.h scripting/dataenginescript.h scripting/scriptengine.h ) install(FILES ${Plasma_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/plasma/plasma_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/plasma COMPONENT Devel) install(FILES ${Plasma_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/Plasma COMPONENT Devel) install(FILES ${PlasmaScripting_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/plasma/scripting COMPONENT Devel) install(FILES data/servicetypes/plasma-applet.desktop data/servicetypes/plasma-containment.desktop data/servicetypes/plasma-containmentactions.desktop data/servicetypes/plasma-dataengine.desktop data/servicetypes/plasma-generic.desktop data/servicetypes/plasma-packagestructure.desktop data/servicetypes/plasma-scriptengine.desktop data/servicetypes/plasma-service.desktop data/servicetypes/plasma-shell.desktop data/servicetypes/plasma-lookandfeel.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) install(FILES data/operations/dataengineservice.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) install(FILES data/operations/plasmoidservice.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) install(FILES data/operations/storage.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) install(TARGETS KF5Plasma EXPORT KF5PlasmaTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) if(BUILD_QCH) ecm_add_qch( KF5Plasma_QCH NAME Plasma BASE_NAME KF5Plasma VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${Plasma_HEADERS} ${PlasmaScripting_HEADERS} Mainpage.dox MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Gui_QCH KF5Service_QCH KF5Package_QCH INCLUDE_DIRS ${Plasma_BUILD_INCLUDE_DIRS} BLANK_MACROS PLASMA_EXPORT PLASMA_DEPRECATED PLASMA_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() diff --git a/src/plasma/applet.h b/src/plasma/applet.h index a48b68dec..b34ba0812 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -1,726 +1,736 @@ /* * Copyright 2006-2007 by Aaron Seigo * Copyright 2007 by Riccardo Iaconelli * Copyright 2008 by Ménard Alexis * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLASMA_APPLET_H #define PLASMA_APPLET_H #include #include #include #include #include #include #include #include #include class KActionCollection; class KConfigLoader; namespace Plasma { class AppletPrivate; class Containment; class DataEngine; class Package; /** * @class Applet plasma/applet.h * * @short The base Applet class * * Applet provides several important roles for add-ons widgets in Plasma. * * First, it is the base class for the plugin system and therefore is the * interface to applets for host applications. It also handles the life time * management of data engines (e.g. all data engines accessed via * Applet::dataEngine(const QString&) are properly deref'd on Applet * destruction), background painting (allowing for consistent and complex * look and feel in just one line of code for applets), loading and starting * of scripting support for each applet, providing access to the associated * plasmoid package (if any) and access to configuration data. * * See techbase.kde.org for tutorials on writing Applets using this class. */ class PLASMA_EXPORT Applet : public QObject { Q_OBJECT Q_PROPERTY(Plasma::Types::ItemStatus status READ status WRITE setStatus NOTIFY statusChanged) Q_PROPERTY(Plasma::Types::ImmutabilityType immutability READ immutability WRITE setImmutability NOTIFY immutabilityChanged) Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged) Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged) Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged FINAL) Q_PROPERTY(bool busy READ isBusy WRITE setBusy NOTIFY busyChanged FINAL) public: //CONSTRUCTORS /** * @param parent the QObject this applet is parented to * @param serviceId the name of the .desktop file containing the * information about the widget * @param appletId a unique id used to differentiate between multiple * instances of the same Applet type */ explicit Applet(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) /** * @param parent the QObject this applet is parented to * @param info the plugin information object for this Applet * @param appletId a unique id used to differentiate between multiple * instances of the same Applet type * @since 4.6 * - * @deprecated prefer using KPluginMetaData + * @deprecated Since 5.28, prefer using KPluginMetaData */ - PLASMA_DEPRECATED explicit Applet(const KPluginInfo &info, QObject *parent = nullptr, uint appletId = 0); + PLASMA_DEPRECATED_VERSION(5, 28, "Use Applet(const KPluginMetaData &, QObject *, uint") + explicit Applet(const KPluginInfo &info, QObject *parent = nullptr, uint appletId = 0); +#endif /** * @param parent the QObject this applet is parented to * @param metadata the plugin information object for this Applet * @param appletId a unique id used to differentiate between multiple * instances of the same Applet type * @since 5.27 */ explicit Applet(const KPluginMetaData &metadata, QObject *parent = nullptr, uint appletId = 0); ~Applet() override; //BOOKKEEPING /** * @return the id of this applet */ uint id() const; /** * @return The type of immutability of this applet */ Types::ImmutabilityType immutability() const; /** * If for some reason, the applet fails to get up on its feet (the * library couldn't be loaded, necessary hardware support wasn't found, * etc..) this method returns the reason why, in an user-readable way. * @since 5.0 **/ QString launchErrorMessage() const; /** * If for some reason, the applet fails to get up on its feet (the * library couldn't be loaded, necessary hardware support wasn't found, * etc..) this method returns true. **/ bool failedToLaunch() const; /** * @return true if destroy() was called; useful for Applets which should avoid * certain tasks if they are about to be deleted permanently */ bool destroyed() const; /** * @return the Containment, if any, this applet belongs to **/ Containment *containment() const; /** * @return true if this Applet is currently being used as a Containment, false otherwise */ bool isContainment() const; /** * @return the status of the applet * @since 4.4 */ Types::ItemStatus status() const; /** * Returns the current form factor the applet is being displayed in. * * @see Plasma::FormFactor */ Types::FormFactor formFactor() const; /** * Returns the location of the scene which is displaying applet. * * @see Plasma::Types::Location */ Types::Location location() const; //CONFIGURATION /** * Returns the KConfigGroup to access the applets configuration. * * This config object will write to an instance * specific config file named \\rc * in the Plasma appdata directory. **/ KConfigGroup config() const; /** * Returns a KConfigGroup object to be shared by all applets of this * type. * * This config object will write to an applet-specific config object * named plasma_\rc in the local config directory. */ KConfigGroup globalConfig() const; /** * Returns the config skeleton object from this applet's package, * if any. * * @return config skeleton object, or 0 if none **/ KConfigLoader *configScheme() const; /** * Saves state information about this applet that will * be accessed when next instantiated in the restore(KConfigGroup&) method. * * This method does not need to be reimplmented by Applet * subclasses, but can be useful for Applet specializations * (such as Containment) to do so. * * Applet subclasses may instead want to reimplement saveState(). **/ virtual void save(KConfigGroup &group) const; /** * Restores state information about this applet saved previously * in save(KConfigGroup&). * * This method does not need to be reimplmented by Applet * subclasses, but can be useful for Applet specializations * (such as Containment) to do so. **/ virtual void restore(KConfigGroup &group); /** * @return true if the applet currently needs to be configured, * otherwise, false */ bool configurationRequired() const; /** * @return A translated message for the user explaining that the * applet needs configuring; this should note what needs * to be configured * * @see setConfigurationRequired * @since 5.20 */ QString configurationRequiredReason() const; /** * @return true when the configuration interface is being shown * @since 4.5 */ bool isUserConfiguring() const; /** * Tells the applet the user is configuring * @param configuring true if the configuration ui is showing */ void setUserConfiguring(bool configuring); //UTILS -#ifndef PLASMA_NO_DEPRECATED +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) /** * Accessor for the associated Package object if any. * Generally, only Plasmoids come in a Package. * - * @deprecated use kPackage() instead * @return the Package object, or an invalid one if none + * @deprecated Since 5.6, use kPackage() instead **/ - PLASMA_DEPRECATED Package package() const; + PLASMA_DEPRECATED_VERSION(5, 6, "Use Applet::kPackage()") + Package package() const; #endif /** * Accessor for the associated Package object if any. * Generally, only Plasmoids come in a Package. * * @return the Package object, or an invalid one if none * @since 5.6 **/ KPackage::Package kPackage() const; /** * Called when any of the geometry constraints have been updated. * This method calls constraintsEvent, which may be reimplemented, * once the Applet has been prepared for updating the constraints. * * @param constraints the type of constraints that were updated */ void updateConstraints(Plasma::Types::Constraints constraints = Plasma::Types::AllConstraints); //METADATA +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) /** * @return metadata information about this plugin * @see KPluginInfo, pluginMetaData * @since 5.0 - * @deprecated use pluginMetaData instead + * @deprecated Since 5.28, use pluginMetaData instead */ - PLASMA_DEPRECATED KPluginInfo pluginInfo() const; + PLASMA_DEPRECATED_VERSION(5, 28, "Use Applet::pluginMetaData()") + KPluginInfo pluginInfo() const; +#endif /** * @return metadata information about this plugin * * @since 5.27 */ KPluginMetaData pluginMetaData() const; /** * Returns the user-visible title for the applet, as specified in the * Name field of the .desktop file. Can be changed with @see setTitle * * @since 5.0 * @return the user-visible title for the applet. **/ QString title() const; /** * Sets a custom title for this instance of the applet. E.g. a clock might * use the timezone as its name rather than the .desktop file * * @since 5.0 * @param title the user-visible title for the applet. */ void setTitle(const QString &title); +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 19) /** * Attempts to load an applet from a package * * Returns a pointer to the applet if successful. * The caller takes responsibility for the applet, including * deleting it when no longer needed. * If you instance a plasmoid with this deprecated API, the * automated default setup scripts won't be executed for that plasmoid * * @param path the path to the package * @param appletId unique ID to assign the applet, or zero to have one * assigned automatically. * @return a pointer to the loaded applet, or 0 on load failure * @since 4.3 * - * @deprecated use Containment::createApplet() instead, you are not + * @deprecated Since 5.19, use Containment::createApplet() instead, you are not * supposed to have applets without containments **/ - PLASMA_DEPRECATED static Applet *loadPlasmoid(const QString &path, uint appletId = 0); + PLASMA_DEPRECATED_VERSION(5, 19, "Use Containment::createApplet(...)") + static Applet *loadPlasmoid(const QString &path, uint appletId = 0); +#endif /** * @returns The icon name related to this applet * By default is the one in the plasmoid desktop file **/ QString icon() const; /** * Sets an icon name for this applet * @param icon Freedesktop compatible icon name */ void setIcon(const QString &icon); /** * @returns true if the applet should show a busy status, for instance doing * some network operation * @since 5.21 */ bool isBusy() const; /** * Sets the Applet to have a busy status hint, for instance the applet doing * some network operation. * The graphical representation of the busy status depends completely from * the visualization. * @param busy true if the applet is busy * @since 5.21 */ void setBusy(bool busy); //ACTIONS /** * Returns a list of context-related QAction instances. * * This is used e.g. within the \a DesktopView to display a * contextmenu. * * @return A list of actions. The default implementation returns an * empty list. **/ virtual QList contextualActions(); /** * Returns the collection of actions for this Applet */ KActionCollection *actions() const; /** * Sets the global shortcut to associate with this widget. */ void setGlobalShortcut(const QKeySequence &shortcut); /** * @return the global shortcut associated with this wiget, or * an empty shortcut if no global shortcut is associated. */ QKeySequence globalShortcut() const; // ASSOCIATED APPLICATION /** * Sets an application associated to this applet, that will be * regarded as a full view of what is represented in the applet * * @param string the name of the application. it can be * \li a name understood by KService::serviceByDesktopName * (e.g. "konqueror") * \li a command in $PATH * \li or an absolute path to an executable * @since 4.4 */ void setAssociatedApplication(const QString &string); /** * Sets a list of urls associated to this application, * they will be used as parameters for the associated application * @see setAssociatedApplication() * * @param urls */ void setAssociatedApplicationUrls(const QList &urls); /** * @return the application associated to this applet * @since 4.4 */ QString associatedApplication() const; /** * @return the urls associated to this applet * @since 4.4 */ QList associatedApplicationUrls() const; /** * @return true if the applet has a valid associated application or urls * @since 4.4 */ bool hasValidAssociatedApplication() const; //Completely UI-specific, remove or move to scriptengine /** * @return true if this plasmoid provides a GUI configuration **/ bool hasConfigurationInterface() const; Q_SIGNALS: //BOOKEEPING /** * Emitted when the immutability changes * @since 4.4 */ void immutabilityChanged(Plasma::Types::ImmutabilityType immutable); /** * Emitted when the applet status changes * @since 4.4 */ void statusChanged(Plasma::Types::ItemStatus status); /** * Emitted when the applet has been scheduled for destruction * or the destruction has been undone * @since 5.4 */ void destroyedChanged(bool destroyed); /** * Emitted when the title has changed * @since 5.20 */ void titleChanged(const QString &title); /** * Emitted when the icon name for the applet has changed * @since 5.20 */ void iconChanged(const QString &icon); /** * Emitted when the busy status has changed * @since 5.21 */ void busyChanged(bool busy); //CONFIGURATION /** * Emitted when an applet has changed values in its configuration * and wishes for them to be saved at the next save point. As this implies * disk activity, this signal should be used with care. * * @note This does not need to be emitted from saveState by individual * applets. */ void configNeedsSaving(); /** * emitted when the config ui appears or disappears */ void userConfiguringChanged(bool configuring); //ACTIONS /** * Emitted just before the contextual actions are about to show * For instance just before the context menu containing the actions * added with setAction() is shown */ void contextualActionsAboutToShow(); /** * Emitted when activation is requested due to, for example, a global * keyboard shortcut. By default the wiget is given focus. */ void activated(); //TODO: fix usage in containment, port to QObject::destroyed /** * Emitted when the applet is deleted */ void appletDeleted(Plasma::Applet *applet); /** * Emitted when the formfactor changes */ void formFactorChanged(Plasma::Types::FormFactor formFactor); /** * Emitted when the location changes */ void locationChanged(Plasma::Types::Location location); /** * Emitted when setConfigurationRequired was called * @see setConfigurationRequired * @since 5.20 */ void configurationRequiredChanged(bool needsConfig, const QString &reason); public Q_SLOTS: //BOOKKEEPING /** * Call this method when the applet fails to launch properly. An * optional reason can be provided. * * Not that all children items will be deleted when this method is * called. If you have pointers to these items, you will need to * reset them after calling this method. * * @param failed true when the applet failed, false when it succeeded * @param reason an optional reason to show the user why the applet * failed to launch * @since 5.0 **/ void setLaunchErrorMessage(const QString &reason = QString()); /** * Sets the immutability type for this applet (not immutable, * user immutable or system immutable) * @param immutable the new immutability type of this applet */ void setImmutability(const Types::ImmutabilityType immutable); /** * Destroys the applet; it will be removed nicely and deleted. * Its configuration will also be deleted. * If you want to remove the Applet configuration, use this, don't just delete the Applet * */ void destroy(); /** * sets the status for this applet * @since 4.4 */ void setStatus(const Types::ItemStatus stat); //CONFIGURATION /** * Called when applet configuration values have changed. */ virtual void configChanged(); //UTILS /** * Sends all pending constraints updates to the applet. Will usually * be called automatically, but can also be called manually if needed. */ void flushPendingConstraintsEvents(); /** * This method is called once the applet is loaded and added to a Corona. * If the applet requires a Scene or has an particularly intensive * set of initialization routines to go through, consider implementing it * in this method instead of the constructor. * * Note: paintInterface may get called before init() depending on initialization * order. Painting is managed by the canvas (QGraphisScene), and may schedule a * paint event prior to init() being called. **/ virtual void init(); //ASSOCIATED APPLICATION /** * Open the application associated to this applet, if it's not set * but some urls are, open those urls with the proper application * for their mimetype * @see setAssociatedApplication() * @see setAssociatedApplicationUrls() * @since 4.4 */ void runAssociatedApplication(); protected: //CONSTRUCTORS /** * This constructor is to be used with the plugin loading systems * found in KPluginInfo and KService. The argument list is expected * to have two elements: the KService service ID for the desktop entry * and an applet ID which must be a base 10 number. * * @param parent a QObject parent; you probably want to pass in 0 * @param args a list of strings containing two entries: the service id * and the applet id */ Applet(QObject *parent, const QVariantList &args); //CONFIGURATION /** * When called, the Applet should write any information needed as part * of the Applet's running state to the configuration object in config() * and/or globalConfig(). * * Applets that always sync their settings/state with the config * objects when these settings/states change do not need to reimplement * this method. **/ virtual void saveState(KConfigGroup &config) const; /** * Sets whether or not this applet provides a user interface for * configuring the applet. * * It defaults to false, and if true is passed in you should * also reimplement createConfigurationInterface() * * @param hasInterface whether or not there is a user interface available **/ void setHasConfigurationInterface(bool hasInterface); /** * When the applet needs to be configured before being usable, this * method can be called to show a standard interface prompting the user * to configure the applet * * @param needsConfiguring true if the applet needs to be configured, * or false if it doesn't * @param reason a translated message for the user explaining that the * applet needs configuring; this should note what needs * to be configured */ void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); //UTILS /** * Called when any of the constraints for the applet have been updated. These constraints * range from notifying when the applet has officially "started up" to when geometry changes * to when the form factor changes. * * Each constraint that has been changed is passed in the constraints flag. * All of the constraints and how they work is documented in the @see Plasma::Constraints * enumeration. * * On applet creation, this is always called prior to painting and can be used as an * opportunity to layout the widget, calculate sizings, etc. * * Do not call update() from this method; an update() will be triggered * at the appropriate time for the applet. * * @param constraints the type of constraints that were updated * @property constraint */ virtual void constraintsEvent(Plasma::Types::Constraints constraints); //TODO: timerEvent should go into AppletPrivate /** * Reimplemented from QObject */ void timerEvent(QTimerEvent *event) override; private: /** * @internal This constructor is to be used with the Package loading system. * * @param parent a QObject parent; you probably want to pass in 0 * @param args a list of strings containing two entries: the service id * and the applet id * @since 4.3 */ Applet(const QString &packagePath, uint appletId); Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) Q_PRIVATE_SLOT(d, void askDestroy()) Q_PRIVATE_SLOT(d, void updateShortcuts()) Q_PRIVATE_SLOT(d, void globalShortcutChanged()) Q_PRIVATE_SLOT(d, void propagateConfigChanged()) Q_PRIVATE_SLOT(d, void requestConfiguration()) AppletPrivate *const d; //Corona needs to access setLaunchErrorMessage and init friend class Corona; friend class CoronaPrivate; friend class Containment; friend class ContainmentPrivate; friend class AppletScript; friend class AppletPrivate; friend class AccessAppletJobPrivate; friend class GraphicsViewAppletPrivate; friend class PluginLoader; friend class AssociatedApplicationManager; }; } // Plasma namespace /** * Register an applet when it is contained in a loadable module */ #define K_EXPORT_PLASMA_APPLET(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #define K_EXPORT_PLASMA_APPLET_WITH_JSON(libname, classname, jsonFile) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard diff --git a/src/plasma/corona.h b/src/plasma/corona.h index 9eb8163a8..5a655a48d 100644 --- a/src/plasma/corona.h +++ b/src/plasma/corona.h @@ -1,448 +1,461 @@ /* * Copyright 2007 Aaron Seigo * Copyright 2007 Matt Broadstone * Copyright 2012 Marco MArtin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLASMA_CORONA_H #define PLASMA_CORONA_H #include #include #include class QAction; namespace Plasma { class CoronaPrivate; /** * @class Corona plasma/Corona.h * * @short A bookkeeping Scene for Plasma::Applets */ class PLASMA_EXPORT Corona : public QObject { Q_OBJECT Q_PROPERTY(bool isStartupCompleted READ isStartupCompleted NOTIFY startupCompleted) Q_PROPERTY(Package package READ package NOTIFY packageChanged) Q_PROPERTY(KPackage::Package kPackage READ kPackage NOTIFY kPackageChanged) public: explicit Corona(QObject *parent = nullptr); ~Corona(); -#ifndef PLASMA_NO_DEPRECATED +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) /** * Accessor for the associated Package object if any. * A Corona package defines how Containments are laid out in a View, * ToolBoxes, default layout, error messages * and in genelal all the furniture specific of a particular * device form factor. * - * @deprecated use kPackage instead * @return the Package object, or an invalid one if none * @since 5.0 + * @deprecated Since 5.6, use kPackage instead **/ - PLASMA_DEPRECATED Plasma::Package package() const; + PLASMA_DEPRECATED_VERSION(5, 6, "Use Corona::kPackage()") + Plasma::Package package() const; +#endif +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) /** * Setting the package name - * @deprecated use setKPackage instead + * @deprecated Since 5.6, use setKPackage instead */ - PLASMA_DEPRECATED void setPackage(const Plasma::Package &package); + PLASMA_DEPRECATED_VERSION(5, 6, "Use Corona::setKPackage(const KPackage::Package &)") + void setPackage(const Plasma::Package &package); #endif /** * Accessor for the associated Package object if any. * A Corona package defines how Containments are laid out in a View, * ToolBoxes, default layout, error messages * and in genelal all the furniture specific of a particular * device form factor. * * @return the Package object, or an invalid one if none * @since 5.5 **/ KPackage::Package kPackage() const; /** * Setting the package for the corona * @since 5.5 */ void setKPackage(const KPackage::Package &package); /** * @return all containments on this Corona */ QList containments() const; /** * @returns true when the startup is over, and * all the ui graphics has been instantiated */ bool isStartupCompleted() const; /** * Returns the config file used to store the configuration for this Corona */ KSharedConfig::Ptr config() const; /** * Adds a Containment to the Corona * * @param name the plugin name for the containment, as given by * KPluginInfo::pluginName(). If an empty string is passed in, the default * containment plugin will be used (usually DesktopContainment). If the * string literal "null" is passed in, then no plugin will be loaded and * a simple Containment object will be created instead. * @param args argument list to pass to the containment * * @return a pointer to the containment on success, or 0 on failure. Failure can be * caused by too restrictive of an Immutability type, as containments cannot be added * when widgets are locked. * If the requested containment plugin can not be located or successfully loaded, the Containment will have an invalid pluginInfo(). */ Containment *createContainment(const QString &name, const QVariantList &args = QVariantList()); /** * Returns the Containment for a given physical screen and desktop, creating one * if none exists * * @param screen number of the physical screen to locate * @param activity the activity id of the containment we want, * and empty string if the activity is not important * @param defaultPluginIfNonExistent the plugin to load by default; "null" won't * create it and "default" creates the default plugin * @param defaultArgs optional arguments to pass in when creating a Containment if needed * @since 5.45 */ Containment *containmentForScreen(int screen, const QString &activity, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs = QVariantList()); //TODO KF6: add activity here, can't be done now as the overload would get confused +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 46) /** * Returns the Containment, if any, for a given physical screen * * @param screen number of the physical screen to locate + * @deprecated Since 5.46, use containmentForScreen(int, const QString &, const QString &, const QVariantList &) */ - PLASMA_DEPRECATED Containment *containmentForScreen(int screen) const; + PLASMA_DEPRECATED_VERSION(5, 46, "Use Corona::containmentForScreen(int, const QString &, const QString &, const QVariantList &)") + Containment *containmentForScreen(int screen) const; +#endif +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 46) /** * Returns the Containment for a given physical screen and desktop, creating one * if none exists * * @param screen number of the physical screen to locate * @param defaultPluginIfNonExistent the plugin to load by default; "null" is an empty * Containment and "default" creates the default plugin * @param defaultArgs optional arguments to pass in when creating a Containment if needed + * @deprecated Since 5.46, use containmentForScreen(int, const QString &, const QString &, const QVariantList &) */ - PLASMA_DEPRECATED PLASMA_DEPRECATED Containment *containmentForScreen(int screen, + PLASMA_DEPRECATED_VERSION(5, 46, "Use Corona::containmentForScreen(int, const QString &, const QString &, const QVariantList &)") + Containment *containmentForScreen(int screen, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs = QVariantList()); +#endif /** * Returns all containments which match a particular activity, for any screen * @param activity the activity id we want * @returns the list of matching containments if any, empty if activity is an empty string * @since 5.45 */ QList containmentsForActivity(const QString &activity); /** * Returns all containments which match a particular screen, for any activity * @param screen the screen number we want * @returns the list of matching containments if any, empty if screen is < 0 * @since 5.45 */ QList containmentsForScreen(int screen); /** * Returns the number of screens available to plasma. * Subclasses should override this method as the default * implementation returns a meaningless value. */ virtual int numScreens() const; /** * Returns the geometry of a given screen. * Valid screen ids are 0 to numScreen()-1, or -1 for the full desktop geometry. * Subclasses should override this method as the default * implementation returns a meaningless value. */ virtual QRect screenGeometry(int id) const = 0; /** * Returns the available region for a given screen. * The available region excludes panels and similar windows. * Valid screen ids are 0 to numScreens()-1. * By default this method returns a rectangular region * equal to screenGeometry(id); subclasses that need another * behavior should override this method. */ virtual QRegion availableScreenRegion(int id) const; /** * Returns the available rect for a given screen. * The difference between this and availableScreenRegion() * is that this method returns only a rectangular * available space (it doesn't care if your panel is not 100% width). * The available rect excludes panels and similar windows. * Valid screen ids are 0 to numScreens()-1. * By default this method returns a rectangular region * equal to screenGeometry(id); subclasses that need another * behavior should override this method. */ virtual QRect availableScreenRect(int id) const; /** * This method is useful in order to retrieve the list of available * screen edges for panel type containments. * @param screen the id of the screen to look for free edges. * @returns a list of free edges not filled with panel type containments. */ QList freeEdges(int screen) const; /** * The actions associated with this Corona */ KActionCollection *actions() const; /** * Imports an applet layout from a config file. The results will be added to the * current set of Containments. * * @param config the name of the config file to load from, * or the default config file if QString() * @return the list of containments that were loaded * @since 4.6 */ QList importLayout(const KConfigGroup &config); /** * Exports a set of containments to a config file. * * @param config the config group to save to * @param containments the list of containments to save * @since 4.6 */ void exportLayout(KConfigGroup &config, QList containments); /** * @returns the id of the screen which is showing @p containment * -1 is returned if the containment is not associated with a screen. */ virtual int screenForContainment(const Containment *containment) const; /** * @return The type of immutability of this Corona */ Types::ImmutabilityType immutability() const; /** * Set the Corona globally into "edit mode" * Only when the corona is of mutable type can be set of edit mode. * This indicates the UI to make easy for the user to manipulate applets. * @param edit * @since 5.63 */ void setEditMode(bool edit); /** * @returns true if the corona is in edit mode * @since 5.63 */ bool isEditMode() const; public Q_SLOTS: /** * Load applet layout from a config file. The results will be added to the * current set of Containments. * * @param config the name of the config file to load from, * or the default config file if QString() */ void loadLayout(const QString &config = QString()); /** * Save applets layout to file * @param config the file to save to, or the default config file if QString() */ void saveLayout(const QString &config = QString()) const; /** * Sets the immutability type for this Corona (not immutable, * user immutable or system immutable) * @param immutable the new immutability type of this applet */ void setImmutability(const Types::ImmutabilityType immutable); /** * Schedules a flush-to-disk synchronization of the configuration state * at the next convenient moment. */ void requestConfigSync(); /** * Schedules a time sensitive flush-to-disk synchronization of the * configuration state. Since this method does not provide any sort of * event compression, it should only be used when an *immediate* disk * sync is *absolutely* required. Otherwise, use @see requestConfigSync() * which does do event compression. */ void requireConfigSync(); Q_SIGNALS: /** * This signal indicates a new containment has been added to * the Corona: it may occur after creation or restore from config */ void containmentAdded(Plasma::Containment *containment); /** * This signal indicates a new containment has been created * in the Corona. Compared to containmentAdded it can only happen * after the creation of a new containment. * * @see containmentAdded * @since 5.16 */ void containmentCreated(Plasma::Containment *containment); /** * This signal indicates that a containment has been newly * associated (or dissociated) with a physical screen. * * @param isScreen the screen it is now associated with */ void screenOwnerChanged(int isScreen); /** * This signal indicates that the configuration file was flushed to disk. */ void configSynced(); /** * This signal indicates that a change in available screen geometry occurred. */ void availableScreenRegionChanged(); /** * This signal indicates that a change in available screen geometry occurred. */ void availableScreenRectChanged(); /** * This signal indicates that a change in geometry for the screen occurred. */ void screenGeometryChanged(int id); /** * emitted when immutability changes. * this is for use by things that don't get constraints events, like plasmaapp. * it's NOT for containments or applets or any of the other stuff on the scene. * if your code's not in shells/ it probably shouldn't be using it. */ void immutabilityChanged(Plasma::Types::ImmutabilityType immutability); /** This signal indicates the screen with the specified id was removed. * @since 5.40 */ void screenRemoved(int id); /** This signal indicates a new screen with the specified id was added. * @since 5.40 */ void screenAdded(int id); /** * emitted when the editMode state changes * @see isEditMode() * @since 5.63 */ void editModeChanged(); -#ifndef PLASMA_NO_DEPRECATED +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) /** * Emitted when the package for this corona has been changed. * Shells must support changing the shell package on the fly (for instance due to device form factor changing) * - * @deprecated use kPackageChanged instead * @param package the new package that defines the Corona furniture and behavior + * @deprecated Since 5.6, use kPackageChanged instead */ - PLASMA_DEPRECATED void packageChanged(const Plasma::Package &package); + PLASMA_DEPRECATED_VERSION(5, 6, "Use Corona::kPackageChanged(const KPackage::Package &)") + void packageChanged(const Plasma::Package &package); #endif /** * Emitted when the package for this corona has been changed. * Shells must support changing the shell package on the fly (for instance due to device form factor changing) * * @param package the new package that defines the Corona furniture and behavior */ void kPackageChanged(const KPackage::Package &package); /** * Emitted when the startup phase has been completed */ void startupCompleted(); protected: /** * Loads the default (system wide) layout for this user **/ virtual void loadDefaultLayout(); /** * Loads a containment with delayed initialization, primarily useful * for implementations of loadDefaultLayout. The caller is responsible * for all initialization, saving and notification of a new containment. * * @param name the plugin name for the containment, as given by * KPluginInfo::pluginName(). If an empty string is passed in, the default * containment plugin will be used (usually DesktopContainment). If the * string literal "null" is passed in, then no plugin will be loaded and * a simple Containment object will be created instead. * @param args argument list to pass to the containment * * @return a pointer to the containment on success, or 0 on failure. Failure can * be caused by the Immutability type being too restrictive, as containments can't be added * when widgets are locked, or if the requested containment plugin can not be located * or successfully loaded. * @see addContainment **/ Containment *createContainmentDelayed(const QString &name, const QVariantList &args = QVariantList()); private: CoronaPrivate *const d; Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject *)) Q_PRIVATE_SLOT(d, void syncConfig()) Q_PRIVATE_SLOT(d, void toggleImmutability()) Q_PRIVATE_SLOT(d, void containmentReady(bool)) friend class CoronaPrivate; friend class View; }; } // namespace Plasma #endif diff --git a/src/plasma/package.h b/src/plasma/package.h index 9276801aa..8afdae825 100644 --- a/src/plasma/package.h +++ b/src/plasma/package.h @@ -1,376 +1,384 @@ /****************************************************************************** * Copyright 2007-2011 by Aaron Seigo * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 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 * * 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 PLASMA_PACKAGE_H #define PLASMA_PACKAGE_H #include #include #include #include class KJob; -#ifndef PLASMA_NO_DEPRECATED +// not 5.6, as last Plasma API using this class only got removed later +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) namespace KPackage { class Package; } namespace Plasma { /** * @class Package plasma/package.h * * @short object representing an installed Plasma package * - * @deprecated USe KPackage::Package instead * Package defines what is in a package and provides easy access to the contents. * * To define a package, one might write the following code: * @code Package package; package.addDirectoryDefinition("images", "pics/", i18n("Images")); QStringList mimeTypes; mimeTypes << "image/svg" << "image/png" << "image/jpeg"; package.setMimeTypes("images", mimeTypes); package.addDirectoryDefinition("scripts", "code/", i18n("Executable Scripts")); mimeTypes.clear(); mimeTypes << "text/\*"; package.setMimeTypes("scripts", mimeTypes); package.addFileDefinition("mainscript", "code/main.js", i18n("Main Script File")); package.setRequired("mainscript", true); @endcode * One may also choose to create a subclass of PackageStructure and include the setup * in the constructor. * * Either way, Package creates a self-documenting contract between the packager and * the application without exposing package internals such as actual on-disk structure * of the package or requiring that all contents be explicitly known ahead of time. * * Subclassing PackageStructure does have provide a number of potential const benefits: * * the package can be notified of path changes via the virtual pathChanged() method * * the subclass may implement mechanisms to install and remove packages using the * virtual install and uninstall methods * * subclasses can be compiled as plugins for easy re-use + * + * @deprecated Since 5.6, use KPackage::Package instead **/ //TODO: write documentation on USING a package class PackagePrivate; class PackageStructure; class PLASMA_EXPORT Package { public: /** * Default constructor * * @param structure if a NULL pointer is passed in, this will creates an empty (invalid) Package; * otherwise the structure is allowed to set up the Package's initial layout * @since 4.6 */ - PLASMA_DEPRECATED explicit Package(PackageStructure *structure = nullptr); + PLASMA_DEPRECATED_VERSION(5, 6, "Use KPackage API") + explicit Package(PackageStructure *structure = nullptr); /** * Copy constructore * @since 4.6 */ - PLASMA_DEPRECATED Package(const KPackage::Package &other); + PLASMA_DEPRECATED_VERSION(5, 6, "Use KPackage API") + Package(const KPackage::Package &other); /** * Copy constructore * @since 4.6 */ - PLASMA_DEPRECATED Package(const Package &other); + PLASMA_DEPRECATED_VERSION(5, 6, "Use KPackage API") + Package(const Package &other); ~Package(); /** * Assignment operator * @since 4.6 */ - PLASMA_DEPRECATED Package &operator=(const Package &rhs); + Package &operator=(const Package &rhs); /** * @return true if this package has a valid PackageStructure associatedw it with it. * A package may not be valid, but have a valid structure. Useful when dealing with * Package objects in a semi-initialized state (e.g. before calling setPath()) * @since 5.1 */ - PLASMA_DEPRECATED bool hasValidStructure() const; + bool hasValidStructure() const; /** * @return true if all the required components exist **/ - PLASMA_DEPRECATED bool isValid() const; + bool isValid() const; /** * Sets the path to the root of this package * @param path an absolute path, or a relative path to the default package root * @since 4.3 */ - PLASMA_DEPRECATED void setPath(const QString &path); + void setPath(const QString &path); /** * @return the path to the root of this particular package */ - PLASMA_DEPRECATED const QString path() const; + const QString path() const; /** * Get the path to a given file based on the key and an optional filename. * Example: finding the main script in a scripting package: * filePath("mainscript") * * Example: finding a specific image in the images directory: * filePath("images", "myimage.png") * * @param key the key of the file type to look for, * @param filename optional name of the file to locate within the package * @return path to the file on disk. QString() if not found. **/ - PLASMA_DEPRECATED QString filePath(const char *key, const QString &filename = QString()) const; + QString filePath(const char *key, const QString &filename = QString()) const; /** * Get the list of files of a given type. * * @param fileType the type of file to look for, as defined in the * package structure. * @return list of files by name, suitable for passing to filePath **/ - PLASMA_DEPRECATED QStringList entryList(const char *key) const; + QStringList entryList(const char *key) const; /** * @return user visible name for the given entry **/ - PLASMA_DEPRECATED QString name(const char *key) const; + QString name(const char *key) const; /** * @return true if the item at path exists and is required **/ - PLASMA_DEPRECATED bool isRequired(const char *key) const; + bool isRequired(const char *key) const; /** * @return the mimeTypes associated with the path, if any **/ - PLASMA_DEPRECATED QStringList mimeTypes(const char *key) const; + QStringList mimeTypes(const char *key) const; /** * @return the prefix paths inserted between the base path and content entries, in order of priority. * When searching for a file, all paths will be tried in order. * @since 4.6 */ - PLASMA_DEPRECATED QStringList contentsPrefixPaths() const; + QStringList contentsPrefixPaths() const; /** * @return preferred package root. This defaults to plasma/plasmoids/ */ - PLASMA_DEPRECATED QString defaultPackageRoot() const; + QString defaultPackageRoot() const; /** * @return service prefix used in desktop files. This defaults to plasma-applet- */ - PLASMA_DEPRECATED QString servicePrefix() const; + QString servicePrefix() const; /** * @return true if paths/symlinks outside the package itself should be followed. * By default this is set to false for security reasons. */ - PLASMA_DEPRECATED bool allowExternalPaths() const; + bool allowExternalPaths() const; /** * @return the package metadata object. */ - PLASMA_DEPRECATED KPluginInfo metadata() const; + KPluginInfo metadata() const; /** * @return a SHA1 hash digest of the contents of the package in hexadecimal form * @since 4.4 */ - PLASMA_DEPRECATED QString contentsHash() const; + QString contentsHash() const; /** * Adds a directory to the structure of the package. It is added as * a not-required element with no associated mimeTypes. * * Starting in 4.6, if an entry with the given key * already exists, the path is added to it as a search alternative. * * @param key used as an internal label for this directory * @param path the path within the package for this directory * @param name the user visible (translated) name for the directory **/ - PLASMA_DEPRECATED void addDirectoryDefinition(const char *key, const QString &path, const QString &name); + void addDirectoryDefinition(const char *key, const QString &path, const QString &name); /** * Adds a file to the structure of the package. It is added as * a not-required element with no associated mimeTypes. * * Starting in 4.6, if an entry with the given key * already exists, the path is added to it as a search alternative. * * @param key used as an internal label for this file * @param path the path within the package for this file * @param name the user visible (translated) name for the file **/ - PLASMA_DEPRECATED void addFileDefinition(const char *key, const QString &path, const QString &name); + void addFileDefinition(const char *key, const QString &path, const QString &name); /** * Removes a definition from the structure of the package. * @since 4.6 * @param key the internal label of the file or directory to remove */ - PLASMA_DEPRECATED void removeDefinition(const char *key); + void removeDefinition(const char *key); /** * Sets whether or not a given part of the structure is required or not. * The path must already have been added using addDirectoryDefinition * or addFileDefinition. * * @param key the entry within the package * @param required true if this entry is required, false if not */ - PLASMA_DEPRECATED void setRequired(const char *key, bool required); + void setRequired(const char *key, bool required); /** * Defines the default mimeTypes for any definitions that do not have * associated mimeTypes. Handy for packages with only one or predominantly * one file type. * * @param mimeTypes a list of mimeTypes **/ - PLASMA_DEPRECATED void setDefaultMimeTypes(QStringList mimeTypes); + void setDefaultMimeTypes(QStringList mimeTypes); /** * Define mimeTypes for a given part of the structure * The path must already have been added using addDirectoryDefinition * or addFileDefinition. * * @param key the entry within the package * @param mimeTypes a list of mimeTypes **/ - PLASMA_DEPRECATED void setMimeTypes(const char *key, QStringList mimeTypes); + void setMimeTypes(const char *key, QStringList mimeTypes); /** * Sets the prefixes that all the contents in this package should * appear under. This defaults to "contents/" and is added automatically * between the base path and the entries as defined by the package * structure. Multiple entries can be added. * In this case each file request will be searched in all prefixes in order, * and the first found will be returned. * * @param prefix paths the directory prefix to use * @since 4.6 */ - PLASMA_DEPRECATED void setContentsPrefixPaths(const QStringList &prefixPaths); + void setContentsPrefixPaths(const QStringList &prefixPaths); /** * Sets service prefix. */ - PLASMA_DEPRECATED void setServicePrefix(const QString &servicePrefix); + void setServicePrefix(const QString &servicePrefix); /** * Sets whether or not external paths/symlinks can be followed by a package * @param allow true if paths/symlinks outside of the package should be followed, * false if they should be rejected. */ - PLASMA_DEPRECATED void setAllowExternalPaths(bool allow); + void setAllowExternalPaths(bool allow); /** * Sets preferred package root. */ - PLASMA_DEPRECATED void setDefaultPackageRoot(const QString &packageRoot); + void setDefaultPackageRoot(const QString &packageRoot); /** * Sets the fallback package root path * If a file won't be found in this package, it will search it in the package * with the same structure identified by path * It is intended to be used by the packageStructure * @param path package root path @see setPath */ - PLASMA_DEPRECATED void setFallbackPackage(const Plasma::Package &package); + void setFallbackPackage(const Plasma::Package &package); /** * @return The fallback package root path */ - PLASMA_DEPRECATED Plasma::Package fallbackPackage() const; + Plasma::Package fallbackPackage() const; // Content structure description methods /** * @return all directories registered as part of this Package's structure */ - PLASMA_DEPRECATED QList directories() const; + QList directories() const; /** * @return all directories registered as part of this Package's required structure */ - PLASMA_DEPRECATED QList requiredDirectories() const; + QList requiredDirectories() const; /** * @return all files registered as part of this Package's structure */ - PLASMA_DEPRECATED QList files() const; + QList files() const; /** * @return all files registered as part of this Package's required structure */ - PLASMA_DEPRECATED QList requiredFiles() const; + QList requiredFiles() const; /** * Installs a package matching this package structure. By default installs a * native Plasma::Package. * * @return KJob to track installation progress and result **/ - PLASMA_DEPRECATED KJob *install(const QString &sourcePackage, const QString &packageRoot = QString()); + KJob *install(const QString &sourcePackage, const QString &packageRoot = QString()); /** * Uninstalls a package matching this package structure. * * @return KJob to track removal progress and result */ - PLASMA_DEPRECATED KJob *uninstall(const QString &packageName, const QString &packageRoot); + KJob *uninstall(const QString &packageName, const QString &packageRoot); /** * @returns the wrapped KPackage::Package instance, which deprecated this class * * @since 5.28 */ KPackage::Package kPackage() const; private: QExplicitlySharedDataPointer d; friend class PackagePrivate; friend class PackageStructure; friend class AppletPrivate; friend class Applet; friend class Corona; }; } -#endif Q_DECLARE_METATYPE(Plasma::Package) + +#endif // PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) + + #endif diff --git a/src/plasma/packagestructure.h b/src/plasma/packagestructure.h index 2173314cf..217edf671 100644 --- a/src/plasma/packagestructure.h +++ b/src/plasma/packagestructure.h @@ -1,116 +1,117 @@ /****************************************************************************** * Copyright 2011 by Aaron Seigo * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 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 * * 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 PLASMA_PACKAGESTRUCTURE_H #define PLASMA_PACKAGESTRUCTURE_H #include #include #include #include #include #include -#ifndef PLASMA_NO_DEPRECATED +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) namespace Plasma { class PackageStructurePrivate; class PLASMA_EXPORT PackageStructure : public QObject { Q_OBJECT public: - PLASMA_DEPRECATED explicit PackageStructure(QObject *parent = nullptr, const QVariantList &args = QVariantList()); + PLASMA_DEPRECATED_VERSION(5, 6, "Use KPackage API") + explicit PackageStructure(QObject *parent = nullptr, const QVariantList &args = QVariantList()); ~PackageStructure(); /** * Called when a the PackageStructure should initialize a Package with the initial * structure. This allows setting paths before setPath is called. * * Note: one special value is "metadata" which can be set to the location of KPluginInfo * compatible .desktop file within the package. If not defined, it is assumed that this file * exists under the top level directory of the package. * * @param package the Package to set up. The object is empty of all definition when * first passed in. */ - PLASMA_DEPRECATED virtual void initPackage(Package *package); + virtual void initPackage(Package *package); /** * Called whenever the path changes so that subclasses may take * package specific actions. */ - PLASMA_DEPRECATED virtual void pathChanged(Package *package); + virtual void pathChanged(Package *package); /** * Installs a package matching this package structure. By default installs a * native Plasma::Package. * * @param package the instance of Package that is being used for the install; useful for * accessing file paths * @param archivePath path to the package archive file * @param packageRoot path to the directory where the package should be * installed to * @return KJob* to track the installation status **/ - PLASMA_DEPRECATED virtual KJob *install(Package *package, const QString &archivePath, const QString &packageRoot); + virtual KJob *install(Package *package, const QString &archivePath, const QString &packageRoot); /** * Uninstalls a package matching this package structure. * * @param package the instance of Package that is being used for the install; useful for * accessing file paths * @param packageName the name of the package to remove * @param packageRoot path to the directory where the package should be installed to * @return KJob* to track the installation status */ - PLASMA_DEPRECATED virtual KJob *uninstall(Package *package, const QString &packageRoot); + virtual KJob *uninstall(Package *package, const QString &packageRoot); private: PackageStructurePrivate *d; friend class Package; friend class PluginLoader; friend class PackageStructurePrivate; Q_PRIVATE_SLOT(d, void installPathChanged(const QString &path)) }; } // Plasma namespace /** * Register a Package class when it is contained in a loadable module */ #define K_EXPORT_PLASMA_PACKAGE(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #define K_EXPORT_PLASMA_PACKAGE_WITH_JSON(classname, jsonFile) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#endif +#endif // PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) #endif diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 1e778076c..f4fc21f8d 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -1,905 +1,901 @@ /* * Copyright 2010 Ryan Rix * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "pluginloader.h" #include #include #include #include #include #include #include #include #include "config-plasma.h" #include "applet.h" #include "containment.h" #include "containmentactions.h" #include "dataengine.h" #include "package.h" #include "private/applet_p.h" #include "private/service_p.h" // for NullService #include "private/storage_p.h" #include "private/package_p.h" #include "private/packagestructure_p.h" #include #include "debug_p.h" namespace Plasma { static PluginLoader *s_pluginLoader = nullptr; class PluginLoaderPrivate { public: PluginLoaderPrivate() : isDefaultLoader(false) { } static QSet knownCategories(); static QSet s_customCategories; QHash > structures; bool isDefaultLoader; static QString s_dataEnginePluginDir; static QString s_packageStructurePluginDir; static QString s_plasmoidsPluginDir; static QString s_servicesPluginDir; static QString s_containmentActionsPluginDir; class Cache { // We only use this cache during start of the process to speed up many consecutive calls // After that, we're too afraid to produce race conditions and it's not that time-critical anyway // the 20 seconds here means that the cache is only used within 20sec during startup, after that, // complexity goes up and we'd have to update the cache in order to avoid subtle bugs // just not using the cache is way easier then, since it doesn't make *that* much of a difference, // anyway int maxCacheAge = 20; qint64 pluginCacheAge = 0; QHash> plugins; public: QVector findPluginsById(const QString& name, const QStringList &dirs); }; Cache plasmoidCache; Cache dataengineCache; Cache containmentactionCache; }; QSet PluginLoaderPrivate::s_customCategories; QString PluginLoaderPrivate::s_dataEnginePluginDir = QStringLiteral("plasma/dataengine"); QString PluginLoaderPrivate::s_packageStructurePluginDir = QStringLiteral("plasma/packagestructure"); QString PluginLoaderPrivate::s_plasmoidsPluginDir = QStringLiteral("plasma/applets"); QString PluginLoaderPrivate::s_servicesPluginDir = QStringLiteral("plasma/services"); QString PluginLoaderPrivate::s_containmentActionsPluginDir = QStringLiteral("plasma/containmentactions"); QSet PluginLoaderPrivate::knownCategories() { // this is to trick the translation tools into making the correct // strings for translation QSet categories = s_customCategories; categories << QStringLiteral(I18N_NOOP("Accessibility")).toLower() << QStringLiteral(I18N_NOOP("Application Launchers")).toLower() << QStringLiteral(I18N_NOOP("Astronomy")).toLower() << QStringLiteral(I18N_NOOP("Date and Time")).toLower() << QStringLiteral(I18N_NOOP("Development Tools")).toLower() << QStringLiteral(I18N_NOOP("Education")).toLower() << QStringLiteral(I18N_NOOP("Environment and Weather")).toLower() << QStringLiteral(I18N_NOOP("Examples")).toLower() << QStringLiteral(I18N_NOOP("File System")).toLower() << QStringLiteral(I18N_NOOP("Fun and Games")).toLower() << QStringLiteral(I18N_NOOP("Graphics")).toLower() << QStringLiteral(I18N_NOOP("Language")).toLower() << QStringLiteral(I18N_NOOP("Mapping")).toLower() << QStringLiteral(I18N_NOOP("Miscellaneous")).toLower() << QStringLiteral(I18N_NOOP("Multimedia")).toLower() << QStringLiteral(I18N_NOOP("Online Services")).toLower() << QStringLiteral(I18N_NOOP("Productivity")).toLower() << QStringLiteral(I18N_NOOP("System Information")).toLower() << QStringLiteral(I18N_NOOP("Utilities")).toLower() << QStringLiteral(I18N_NOOP("Windows and Tasks")).toLower() << QStringLiteral(I18N_NOOP("Clipboard")).toLower() << QStringLiteral(I18N_NOOP("Tasks")).toLower(); return categories; } PluginLoader::PluginLoader() : d(new PluginLoaderPrivate) { } PluginLoader::~PluginLoader() { typedef QPointer pswp; foreach (pswp wp, d->structures) { delete wp.data(); } delete d; } void PluginLoader::setPluginLoader(PluginLoader *loader) { if (!s_pluginLoader) { s_pluginLoader = loader; } else { #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "Cannot set pluginLoader, already set!" << s_pluginLoader; #endif } } PluginLoader *PluginLoader::self() { if (!s_pluginLoader) { // we have been called before any PluginLoader was set, so just use the default // implementation. this prevents plugins from nefariously injecting their own // plugin loader if the app doesn't s_pluginLoader = new PluginLoader; s_pluginLoader->d->isDefaultLoader = true; } return s_pluginLoader; } Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVariantList &args) { if (name.isEmpty()) { return nullptr; } Applet *applet = d->isDefaultLoader ? nullptr : internalLoadApplet(name, appletId, args); if (applet) { return applet; } if (appletId == 0) { appletId = ++AppletPrivate::s_maxAppletId; } // Need to pass the empty directory because it's where plasmoids used to be auto plugins = d->plasmoidCache.findPluginsById(name, { PluginLoaderPrivate::s_plasmoidsPluginDir, {} }); const KPackage::Package p = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Applet"), name); // If the applet is using another applet package, search for the plugin of the other applet if (plugins.isEmpty()) { const QString parentPlugin = p.metadata().value(QStringLiteral("X-Plasma-RootPath")); if (!parentPlugin.isEmpty()) { plugins = d->plasmoidCache.findPluginsById(parentPlugin, { PluginLoaderPrivate::s_plasmoidsPluginDir, {} }); } } if (!plugins.isEmpty()) { KPluginLoader loader(plugins.first().fileName()); if (!isPluginVersionCompatible(loader)) { return nullptr; } KPluginFactory *factory = loader.factory(); if (factory) { QVariantList allArgs; allArgs << QVariant::fromValue(p) << loader.metaData().toVariantMap() << appletId << args; applet = factory->create(nullptr, allArgs); } } if (applet) { return applet; } if (!applet) { //qCDebug(LOG_PLASMA) << name << "not a C++ applet: Falling back to an empty one"; QVariantList allArgs; allArgs << QVariant::fromValue(p) << p.metadata().fileName() << appletId << args; if (p.metadata().serviceTypes().contains(QLatin1String("Plasma/Containment"))) { applet = new Containment(nullptr, allArgs); } else { applet = new Applet(nullptr, allArgs); } } const QString localePath = p.filePath("translations"); if (!localePath.isEmpty()) { KLocalizedString::addDomainLocaleDir(QByteArray("plasma_applet_") + name.toLatin1(), localePath); } return applet; } DataEngine *PluginLoader::loadDataEngine(const QString &name) { DataEngine *engine = d->isDefaultLoader ? nullptr : internalLoadDataEngine(name); if (engine) { return engine; } // Look for C++ plugins first const QVector plugins = d->dataengineCache.findPluginsById(name, {PluginLoaderPrivate::s_dataEnginePluginDir}); if (!plugins.isEmpty()) { KPluginLoader loader(plugins.constFirst().fileName()); const QVariantList argsWithMetaData = QVariantList() << loader.metaData().toVariantMap(); KPluginFactory *factory = loader.factory(); return factory ? factory->create(nullptr, argsWithMetaData) : nullptr; } if (engine) { return engine; } const KPackage::Package p = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/DataEngine"), name); if (!p.isValid()) { return nullptr; } return new DataEngine(KPluginInfo(p.metadata().fileName()), nullptr); } QStringList PluginLoader::listAllEngines(const QString &parentApp) { QStringList engines; // Look for C++ plugins first auto filter = [&parentApp](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp; }; QVector plugins; if (parentApp.isEmpty()) { plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir); } else { plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir, filter); } foreach (auto& plugin, plugins) { engines << plugin.pluginId(); } const QList packagePlugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/DataEngine")); for (auto& plugin : packagePlugins) { engines << plugin.pluginId(); } return engines; } KPluginInfo::List PluginLoader::listEngineInfo(const QString &parentApp) { return PluginLoader::self()->listDataEngineInfo(parentApp); } KPluginInfo::List PluginLoader::listEngineInfoByCategory(const QString &category, const QString &parentApp) { KPluginInfo::List list; // Look for C++ plugins first auto filterNormal = [&category](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-PluginInfo-Category")) == category; }; auto filterParentApp = [&category, &parentApp](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp && md.value(QStringLiteral("X-KDE-PluginInfo-Category")) == category; }; QVector plugins; if (parentApp.isEmpty()) { plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir, filterNormal); } else { plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir, filterParentApp); } list = KPluginInfo::fromMetaData(plugins); //TODO FIXME: PackageLoader needs to have a function to inject packageStructures const QList packagePlugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/DataEngine")); list << KPluginInfo::fromMetaData(packagePlugins.toVector()); return list; } Service *PluginLoader::loadService(const QString &name, const QVariantList &args, QObject *parent) { Service *service = d->isDefaultLoader ? nullptr : internalLoadService(name, args, parent); if (service) { return service; } //TODO: scripting API support if (name.isEmpty()) { return new NullService(QString(), parent); } else if (name == QLatin1String("org.kde.servicestorage")) { return new Storage(parent); } // Look for C++ plugins first auto filter = [&name](const KPluginMetaData &md) -> bool { return md.pluginId() == name; }; QVector plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_servicesPluginDir, filter); if (!plugins.isEmpty()) { KPluginLoader loader(plugins.first().fileName()); if (!isPluginVersionCompatible(loader)) { return nullptr; } KPluginFactory *factory = loader.factory(); if (factory) { service = factory->create(nullptr, args); } } if (service) { if (service->name().isEmpty()) { service->setName(name); } return service; } else { return new NullService(name, parent); } } ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, const QString &name, const QVariantList &args) { if (name.isEmpty()) { return nullptr; } ContainmentActions *actions = d->isDefaultLoader ? nullptr : internalLoadContainmentActions(parent, name, args); if (actions) { return actions; } const QVector plugins = d->containmentactionCache.findPluginsById(name, {PluginLoaderPrivate::s_containmentActionsPluginDir}); if (!plugins.isEmpty()) { KPluginLoader loader(plugins.first().fileName()); KPluginFactory *factory = loader.factory(); if (factory) { actions = factory->create(nullptr, {QVariant::fromValue(plugins.first())}); } } if (actions) { return actions; } //FIXME: this is only for backwards compatibility, but probably will have to stay //for the time being QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(name); KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint); if (offers.isEmpty()) { #ifndef NDEBUG qCDebug(LOG_PLASMA) << "offers is empty for " << name; #endif return nullptr; } KService::Ptr offer = offers.first(); KPluginLoader plugin(*offer); if (!isPluginVersionCompatible(plugin)) { return nullptr; } QVariantList allArgs; allArgs << offer->storageId() << args; QString error; actions = offer->createInstance(parent, allArgs, &error); if (!actions) { #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "Couldn't load containmentActions \"" << name << "\"! reason given: " << error; #endif } return actions; } -#ifndef PLASMA_NO_DEPRECATED Package PluginLoader::loadPackage(const QString &packageFormat, const QString &specialization) { if (!d->isDefaultLoader) { Package p = internalLoadPackage(packageFormat, specialization); if (p.hasValidStructure()) { return p; } } if (packageFormat.isEmpty()) { return Package(); } const QString hashkey = packageFormat + QLatin1Char('%') + specialization; PackageStructure *structure = d->structures.value(hashkey).data(); if (structure) { return Package(structure); } KPackage::PackageStructure *internalStructure = KPackage::PackageLoader::self()->loadPackageStructure(packageFormat); if (internalStructure) { structure = new PackageStructure(); structure->d->internalStructure = internalStructure; //fallback to old structures } else { const QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat); structure = KPluginTrader::createInstanceFromQuery(PluginLoaderPrivate::s_packageStructurePluginDir, QStringLiteral("Plasma/PackageStructure"), constraint, nullptr); if (structure) { structure->d->internalStructure = new PackageStructureWrapper(structure); } } if (structure) { d->structures.insert(hashkey, structure); return Package(structure); } #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "Couldn't load Package for" << packageFormat << "! reason given: " << error; #endif return Package(); } -#endif QList PluginLoader::listAppletMetaData(const QString &category, const QString &parentApp) { //FIXME: this assumes we are always use packages.. no pure c++ std::function filter; if (category.isEmpty()) { //use all but the excluded categories KConfigGroup group(KSharedConfig::openConfig(), "General"); QStringList excluded = group.readEntry("ExcludeCategories", QStringList()); filter = [excluded, parentApp](const KPluginMetaData &md) -> bool { const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); return (parentApp.isEmpty() || pa == parentApp) && !excluded.contains(md.category()); }; } else { //specific category (this could be an excluded one - is that bad?) filter = [category, parentApp](const KPluginMetaData &md) -> bool { const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); if (category == QLatin1String("Miscellaneous")) { return (parentApp.isEmpty() || pa == parentApp) && (md.category() == category || md.category().isEmpty()); } else { return (parentApp.isEmpty() || pa == parentApp) && md.category() == category; } }; } QList list; if (!d->isDefaultLoader && (parentApp.isEmpty() || parentApp == QCoreApplication::instance()->applicationName())) { list = KPluginInfo::toMetaData(internalAppletInfo(category)).toList(); } return KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); } KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QString &parentApp) { KPluginInfo::List list; const auto plugins = listAppletMetaData(category, parentApp); //NOTE: it still produces kplugininfos from KServices because some user code expects //info.service() to be valid and would crash otherwise foreach (auto& md, plugins) { auto pi = md.metaDataFileName().endsWith(QLatin1String(".json")) ? KPluginInfo(md) : KPluginInfo(KService::serviceByStorageId(md.metaDataFileName())); if (!pi.isValid()) { qCWarning(LOG_PLASMA) << "Could not load plugin info for plugin :" << md.pluginId() << "skipping plugin"; continue; } list << pi; } return list; } QList PluginLoader::listAppletMetaDataForMimeType(const QString &mimeType) { auto filter = [&mimeType](const KPluginMetaData &md) -> bool { return KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimeType); }; return KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); } KPluginInfo::List PluginLoader::listAppletInfoForMimeType(const QString &mimeType) { return KPluginInfo::fromMetaData(listAppletMetaDataForMimeType(mimeType).toVector()); } QList PluginLoader::listAppletMetaDataForUrl(const QUrl &url) { QString parentApp; QCoreApplication *app = QCoreApplication::instance(); if (app) { parentApp = app->applicationName(); } auto filter = [&parentApp](const KPluginMetaData &md) -> bool { const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); return (parentApp.isEmpty() || pa == parentApp) && !KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty(); }; const QList allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); QList filtered; foreach (const KPluginMetaData &md, allApplets) { QStringList urlPatterns = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns")); foreach (const QString &glob, urlPatterns) { QRegExp rx(glob); rx.setPatternSyntax(QRegExp::Wildcard); if (rx.exactMatch(url.toString())) { #ifndef NDEBUG // qCDebug(LOG_PLASMA) << md.name() << "matches" << glob << url; #endif filtered << md; } } } return filtered; } KPluginInfo::List PluginLoader::listAppletInfoForUrl(const QUrl &url) { return KPluginInfo::fromMetaData(listAppletMetaDataForUrl(url).toVector()); } QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool visibleOnly) { KConfigGroup group(KSharedConfig::openConfig(), "General"); const QStringList excluded = group.readEntry("ExcludeCategories", QStringList()); auto filter = [&parentApp, &excluded, visibleOnly](const KPluginMetaData &md) -> bool { const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); return (parentApp.isEmpty() || pa == parentApp) && (excluded.isEmpty() || excluded.contains(md.value(QStringLiteral("X-KDE-PluginInfo-Category")))) && (!visibleOnly || !md.isHidden()); }; const QList allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); QStringList categories; foreach (auto& plugin, allApplets) { if (plugin.category().isEmpty()) { if (!categories.contains(i18nc("misc category", "Miscellaneous"))) { categories << i18nc("misc category", "Miscellaneous"); } } else { categories << plugin.category(); } } categories.sort(); return categories; } void PluginLoader::setCustomAppletCategories(const QStringList &categories) { PluginLoaderPrivate::s_customCategories = QSet::fromList(categories); } QStringList PluginLoader::customAppletCategories() const { return PluginLoaderPrivate::s_customCategories.toList(); } QString PluginLoader::appletCategory(const QString &appletName) { if (appletName.isEmpty()) { return QString(); } const KPackage::Package p = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Applet"), appletName); if (!p.isValid()) { return QString(); } return p.metadata().category(); } KPluginInfo::List PluginLoader::listContainments(const QString &category, const QString &parentApp) { return listContainmentsOfType(QString(), category, parentApp); } KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, const QString &category, const QString &parentApp) { KConfigGroup group(KSharedConfig::openConfig(), "General"); auto filter = [&type, &category, &parentApp](const KPluginMetaData &md) -> bool { if (!md.serviceTypes().contains(QLatin1String("Plasma/Containment"))) { return false; } if (!parentApp.isEmpty() && md.value(QStringLiteral("X-KDE-ParentApp")) != parentApp) { return false; } if (!type.isEmpty() && md.value(QStringLiteral("X-Plasma-ContainmentType")) != type) { return false; } if (!category.isEmpty() && md.value(QStringLiteral("X-KDE-PluginInfo-Category")) != category) { return false; } return true; }; return KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter).toVector()); } KPluginInfo::List PluginLoader::listContainmentsForMimeType(const QString &mimeType) { auto filter = [&mimeType](const KPluginMetaData &md) -> bool { return md.serviceTypes().contains(QLatin1String("Plasma/Containment")) && KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimeType); }; return KPluginInfo::fromMetaData(KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter).toVector()); } QStringList PluginLoader::listContainmentTypes() { KPluginInfo::List containmentInfos = listContainments(); QSet types; foreach (const KPluginInfo &containmentInfo, containmentInfos) { QStringList theseTypes = containmentInfo.service()->property(QStringLiteral("X-Plasma-ContainmentType")).toStringList(); foreach (const QString &type, theseTypes) { types.insert(type); } } return types.toList(); } KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp) { KPluginInfo::List list; if (!d->isDefaultLoader && (parentApp.isEmpty() || parentApp == QCoreApplication::instance()->applicationName())) { list = internalDataEngineInfo(); } QString constraint; if (!parentApp.isEmpty()) { constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\''); } list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_dataEnginePluginDir, QStringLiteral("Plasma/DataEngine"), constraint)); return list; } KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parentApp) { KPluginInfo::List list; if (!d->isDefaultLoader && (parentApp.isEmpty() || parentApp == QCoreApplication::instance()->applicationName())) { list = internalContainmentActionsInfo(); } QString constraint; if (!parentApp.isEmpty()) { constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\''); } list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_containmentActionsPluginDir, QStringLiteral("Plasma/ContainmentActions"), constraint)); QSet knownPlugins; foreach (const KPluginInfo &p, list) { knownPlugins.insert(p.pluginName()); } //FIXME: this is only for backwards compatibility, but probably will have to stay //for the time being KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint); foreach (KService::Ptr s, offers) { if (!knownPlugins.contains(s->pluginKeyword())) { list.append(KPluginInfo(s)); } } return list; } Applet *PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args) { Q_UNUSED(name) Q_UNUSED(appletId) Q_UNUSED(args) return nullptr; } DataEngine *PluginLoader::internalLoadDataEngine(const QString &name) { Q_UNUSED(name) return nullptr; } ContainmentActions *PluginLoader::internalLoadContainmentActions(Containment *containment, const QString &name, const QVariantList &args) { Q_UNUSED(containment) Q_UNUSED(name) Q_UNUSED(args) return nullptr; } Service *PluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent) { Q_UNUSED(name) Q_UNUSED(args) Q_UNUSED(parent) return nullptr; } -#ifndef PLASMA_NO_DEPRECATED Package PluginLoader::internalLoadPackage(const QString &name, const QString &specialization) { Q_UNUSED(name); Q_UNUSED(specialization); return Package(); } -#endif KPluginInfo::List PluginLoader::internalAppletInfo(const QString &category) const { Q_UNUSED(category) return KPluginInfo::List(); } KPluginInfo::List PluginLoader::internalDataEngineInfo() const { return KPluginInfo::List(); } KPluginInfo::List PluginLoader::internalServiceInfo() const { return KPluginInfo::List(); } KPluginInfo::List PluginLoader::internalContainmentActionsInfo() const { return KPluginInfo::List(); } static KPluginInfo::List standardInternalInfo(const QString &type, const QString &category = QString()) { QStringList files = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/internal/") + type + QLatin1String("/*.desktop"), QStandardPaths::LocateFile); KPluginInfo::List allInfo = KPluginInfo::fromFiles(files); if (category.isEmpty() || allInfo.isEmpty()) { return allInfo; } KPluginInfo::List matchingInfo; foreach (const KPluginInfo &info, allInfo) { if (info.category().compare(category, Qt::CaseInsensitive) == 0) { matchingInfo << info; } } return matchingInfo; } KPluginInfo::List PluginLoader::standardInternalAppletInfo(const QString &category) const { return standardInternalInfo(QStringLiteral("applets"), category); } KPluginInfo::List PluginLoader::standardInternalDataEngineInfo() const { return standardInternalInfo(QStringLiteral("dataengines")); } KPluginInfo::List PluginLoader::standardInternalServiceInfo() const { return standardInternalInfo(QStringLiteral("services")); } bool PluginLoader::isPluginVersionCompatible(KPluginLoader &loader) { const quint32 version = loader.pluginVersion(); if (version == quint32(-1)) { // unversioned, just let it through qCWarning(LOG_PLASMA) << loader.fileName() << "unversioned plugin detected, may result in instability"; return true; } // we require PLASMA_VERSION_MAJOR and PLASMA_VERSION_MINOR const quint32 minVersion = PLASMA_MAKE_VERSION(PLASMA_VERSION_MAJOR, 0, 0); const quint32 maxVersion = PLASMA_MAKE_VERSION(PLASMA_VERSION_MAJOR, PLASMA_VERSION_MINOR, 60); if (version < minVersion || version > maxVersion) { qCWarning(LOG_PLASMA) << loader.fileName() << ": this plugin is compiled against incompatible Plasma version" << version << "This build is compatible with" << PLASMA_VERSION_MAJOR << ".0.0 (" << minVersion << ") to" << PLASMA_VERSION_STRING << "(" << maxVersion << ")"; return false; } return true; } QVector PluginLoaderPrivate::Cache::findPluginsById(const QString& name, const QStringList &dirs) { const qint64 now = qRound64(QDateTime::currentMSecsSinceEpoch() / 1000.0); bool useRuntimeCache = true; if (pluginCacheAge == 0) { // Find all the plugins now, but only once pluginCacheAge = now; auto insertIntoCache = [this](const QString &pluginPath) { KPluginMetaData metadata(pluginPath); if (!metadata.isValid()) { qCWarning(LOG_PLASMA) << "invalid metadata" << pluginPath; return; } plugins[metadata.pluginId()].append(metadata); }; for (const QString &dir : dirs) KPluginLoader::forEachPlugin(dir, insertIntoCache); } else if (now - pluginCacheAge > maxCacheAge) { // cache is old and we're not within a few seconds of startup anymore useRuntimeCache = false; plugins.clear(); } //if name wasn't a path, pluginName == name const QString pluginName = name.section(QLatin1Char('/'), -1); QVector ret; if (useRuntimeCache) { auto it = plugins.constFind(pluginName); if (it != plugins.constEnd()) { ret = *it; } qCDebug(LOG_PLASMA) << "loading applet by name" << name << useRuntimeCache << ret.size(); } else { for (const auto& dir : dirs) { ret = KPluginLoader::findPluginsById(dir, pluginName); if (!ret.isEmpty()) break; } } return ret; } } // Plasma Namespace diff --git a/src/plasma/pluginloader.h b/src/plasma/pluginloader.h index 313ed337d..b68c299c8 100644 --- a/src/plasma/pluginloader.h +++ b/src/plasma/pluginloader.h @@ -1,525 +1,534 @@ /* * Copyright 2010 by Ryan Rix * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLUGIN_LOADER_H #define PLUGIN_LOADER_H #include #include #include namespace Plasma { class Applet; class Containment; class ContainmentActions; class DataEngine; class Service; class PluginLoaderPrivate; //TODO: // * add loadWallpaper // * add KPluginInfo listing support for Containments (already loaded via the applet loading code) /** * @class PluginLoader plasma/pluginloader.h * * This is an abstract base class which defines an interface to which Plasma's * Applet Loading logic can communicate with a parent application. The plugin loader * must be set before any plugins are loaded, otherwise (for safety reasons), the * default PluginLoader implementation will be used. The reimplemented version should * not do more than simply returning a loaded plugin. It should not init() it, and it should not * hang on to it. The associated methods will be called only when a component of Plasma * needs to load a _new_ plugin. (e.g. DataEngine does its own caching). * * @author Ryan Rix * @since 4.6 **/ class PLASMA_EXPORT PluginLoader { public: /** * Load an Applet plugin. * * @param name the plugin name, as returned by KPluginInfo::pluginName() * @param appletId unique ID to assign the applet, or zero to have one * assigned automatically. * @param args to send the applet extra arguments * @return a pointer to the loaded applet, or 0 on load failure **/ Applet *loadApplet(const QString &name, uint appletId = 0, const QVariantList &args = QVariantList()); /** * Load a dataengine plugin. * * @param name the name of the engine * @return the dataengine that was loaded, or the NullEngine on failure. **/ DataEngine *loadDataEngine(const QString &name); /** * @return a listing of all known dataengines by name * * @param parentApp the application to filter dataengines on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all dataengines. */ static QStringList listAllEngines(const QString &parentApp = QString()); /** * Returns a list of all known dataengines. * * @param parentApp the application to filter dataengines on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all dataengines. * @return list of dataengines **/ static KPluginInfo::List listEngineInfo(const QString &parentApp = QString()); /** * Returns a list of all known dataengines filtering by category. * * @param category the category to filter dataengines on. Uses the * X-KDE-PluginInfo-Category entry (if any) in the * plugin info. The value of QString() will * result in a list of dataengines with an empty category. * * @param parentApp the application to filter dataengines on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all dataengines in specified categories. * @return list of dataengines * @since 4.3 **/ static KPluginInfo::List listEngineInfoByCategory(const QString &category, const QString &parentApp = QString()); /** * Load a Service plugin. * * @param name the plugin name of the service to load * @param args a list of arguments to supply to the service plugin when loading it * @param parent the parent object, if any, for the service * * @return a Service object, unlike Plasma::Service::loadService, this can return null. **/ Service *loadService(const QString &name, const QVariantList &args, QObject *parent = nullptr); /** * Load a ContainmentActions plugin. * * Returns a pointer to the containmentactions if successful. * The caller takes responsibility for the containmentactions, including * deleting it when no longer needed. * * @param parent the parent containment. @since 4.6 null is allowed. * @param name the plugin name, as returned by KPluginInfo::pluginName() * @param args to send the containmentactions extra arguments * @return a ContainmentActions object **/ ContainmentActions *loadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args = QVariantList()); +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 30) /** * Load a Package plugin. * * @param name the plugin name of the package to load * @param specialization used to find script extensions for the given format, e.g. "QML" for "Plasma/Applet" * * @return a Package object matching name, or an invalid package on failure - * @deprecated Since 5.29, use KPackage::PackageLoader::loadPackage(const QString& packageFormat, const QString& packagePath) instead. + * @deprecated Since 5.30, use KPackage::PackageLoader::loadPackage(const QString& packageFormat, const QString& packagePath) instead. **/ -#ifndef PLASMA_NO_DEPRECATED - PLASMA_DEPRECATED Package loadPackage(const QString &packageFormat, const QString &specialization = QString()); + PLASMA_DEPRECATED_VERSION(5, 30, "Use KPackage::PackageLoader::loadPackage(const QString&, const QString&") + Package loadPackage(const QString &packageFormat, const QString &specialization = QString()); #endif +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) /** * Returns a list of all known applets. * This may skip applets based on security settings and ExcludeCategories in the application's config. * * @param category Only applets matching this category will be returned. * Useful in conjunction with knownCategories. * If "Misc" is passed in, then applets without a * Categories= entry are also returned. * If an empty string is passed in, all applets are * returned. * @param parentApp the application to filter applets on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all applets in specified category. * @return list of applets * - * @deprecated Doesn't support metadata.json packages. - * Since 5.28, use listAppletMetaData(const QString &category, const QString &parentApp) instead. + * @deprecated Since 5.28. Doesn't support metadata.json packages. + * Use listAppletMetaData(const QString &category, const QString &parentApp) instead. **/ - PLASMA_DEPRECATED KPluginInfo::List listAppletInfo(const QString &category, const QString &parentApp = QString()); + PLASMA_DEPRECATED_VERSION(5, 28, "Use PluginLoader::listAppletMetaData(const QString &, const QString &)") + KPluginInfo::List listAppletInfo(const QString &category, const QString &parentApp = QString()); +#endif /** * Returns a list of all known applets. * This may skip applets based on security settings and ExcludeCategories in the application's config. * * @param category Only applets matchin this category will be returned. * Useful in conjunction with knownCategories. * If "Misc" is passed in, then applets without a * Categories= entry are also returned. * If an empty string is passed in, all applets are * returned. * @param parentApp the application to filter applets on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all applets in specified categories. * @return list of applets * * @since 5.28 **/ QList listAppletMetaData(const QString &category, const QString &parentApp = QString()); +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 36) /** * Returns a list of all known applets associated with a certain mimetype. * * @return list of applets * * @deprecated Since 5.36, use listAppletMetaDataForMimeType(const QString &mimetype) instead. **/ - PLASMA_DEPRECATED KPluginInfo::List listAppletInfoForMimeType(const QString &mimetype); + PLASMA_DEPRECATED_VERSION(5, 36, "Use PluginLoader::listAppletMetaDataForMimeType(const QString &)") + KPluginInfo::List listAppletInfoForMimeType(const QString &mimetype); +#endif /** * Returns a list of all known applets associated with a certain mimetype. * * @return list of applets * @since 5.36 **/ QList listAppletMetaDataForMimeType(const QString &mimetype); +#if PLASMA_ENABLE_DEPRECATED_SINCE(5, 36) /** * Returns a list of all known applets associated with a certain URL. * * @return list of applets * * @deprecated Since 5.36, use listAppletMetaDataForUrl(const QUrl &url) instead. **/ - PLASMA_DEPRECATED KPluginInfo::List listAppletInfoForUrl(const QUrl &url); + PLASMA_DEPRECATED_VERSION(5, 36, "Use PluginLoader::listAppletMetaDataForUrl(const QUrl &)") + KPluginInfo::List listAppletInfoForUrl(const QUrl &url); +#endif /** * Returns a list of all known applets associated with a certain URL. * * @return list of applets * @since 5.36 **/ QList listAppletMetaDataForUrl(const QUrl &url); /** * Returns a list of all the categories used by installed applets. * * @param parentApp the application to filter applets on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all Applets. * @return list of categories * @param visibleOnly true if it should only return applets that are marked as visible */ QStringList listAppletCategories(const QString &parentApp = QString(), bool visibleOnly = true); /** * Sets the list of custom categories that are used in addition to the default * set of categories known to libplasma for applets. * @param categories a list of categories * @since 4.3 */ void setCustomAppletCategories(const QStringList &categories); /** * @return the list of custom categories known to libplasma * @since 4.3 */ QStringList customAppletCategories() const; /** * Get the category of the given applet * * @param appletName the name of the applet */ QString appletCategory(const QString &appletName); /** * Returns a list of all known containments. * * @param category Only containments matching this category will be returned. * Useful in conjunction with knownCategories. * If "Miscellaneous" is passed in, then containments without a * Categories= entry are also returned. * If an empty string is passed in, all containments are * returned. * @param parentApp the application to filter containments on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all containments. * @return list of containments **/ static KPluginInfo::List listContainments(const QString &category = QString(), const QString &parentApp = QString()); /** * Returns a list of all known containments that match the parameters. * * @param type Only containments with this string in X-Plasma-ContainmentType * in their .desktop files will be returned. Common values are panel and * desktop * @param category Only containments matching this category will be returned. * Useful in conjunction with knownCategories. * If "Miscellaneous" is passed in, then containments without a * Categories= entry are also returned. * If an empty string is passed in, all containments are * returned. * @param parentApp the application to filter containments on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all containments, matching categories/type. * @return list of containments **/ static KPluginInfo::List listContainmentsOfType(const QString &type, const QString &category = QString(), const QString &parentApp = QString()); /** * @return a list of all known types of containments on this system */ static QStringList listContainmentTypes(); /** * Returns a list of all known containments associated with a certain MimeType * * @return list of containments **/ static KPluginInfo::List listContainmentsForMimeType(const QString &mimeType); /** * Returns a list of all known dataengines. * * @param parentApp the application to filter dataengines on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all dataengines * @return list of dataengines **/ KPluginInfo::List listDataEngineInfo(const QString &parentApp = QString()); /** * Returns a list of all known ContainmentActions. * * @param parentApp the application to filter ContainmentActions on. Uses the * X-KDE-ParentApp entry (if any) in the plugin info. * The default value of QString() will result in a * list of all ContainmentActions. * @return list of ContainmentActions **/ KPluginInfo::List listContainmentActionsInfo(const QString &parentApp); /** * Set the plugin loader which will be queried for all loads. * * @param loader A subclass of PluginLoader which will be supplied * by the application **/ static void setPluginLoader(PluginLoader *loader); /** * Return the active plugin loader **/ static PluginLoader *self(); protected: /** * A re-implementable method that allows subclasses to override * the default behaviour of loadApplet. If the applet requested is not recognized, * then the implementation should return a NULL pointer. This method is called * by loadApplet prior to attempting to load an applet using the standard Plasma * plugin mechanisms. * * @param name the plugin name, as returned by KPluginInfo::pluginName() * @param appletId unique ID to assign the applet, or zero to have one * assigned automatically. * @param args to send the applet extra arguments * @return a pointer to the loaded applet, or 0 on load failure **/ virtual Applet *internalLoadApplet(const QString &name, uint appletId = 0, const QVariantList &args = QVariantList()); /** * A re-implementable method that allows subclasses to override * the default behaviour of loadDataEngine. If the engine requested is not recognized, * then the implementation should return a NULL pointer. This method is called * by loadDataEngine prior to attempting to load a DataEgine using the standard Plasma * plugin mechanisms. * * @param name the name of the engine * @return the data engine that was loaded, or the NullEngine on failure. **/ virtual DataEngine *internalLoadDataEngine(const QString &name); /** * A re-implementable method that allows subclasses to override * the default behaviour of loadService. If the service requested is not recognized, * then the implementation should return a NULL pointer. This method is called * by loadService prior to attempting to load a Service using the standard Plasma * plugin mechanisms. * * @param name the plugin name of the service to load * @param args a list of arguments to supply to the service plugin when loading it * @param parent the parent object, if any, for the service * * @return a Service object, unlike Plasma::Service::loadService, this can return null. **/ virtual Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = nullptr); /** * A re-implementable method that allows subclasses to override * the default behaviour of loadContainmentActions. If the ContainmentActions requested is not recognized, * then the implementation should return a NULL pointer. This method is called * by loadService prior to attempting to load a Service using the standard Plasma * plugin mechanisms. * * Returns a pointer to the containmentactions if successful. * The caller takes responsibility for the containmentactions, including * deleting it when no longer needed. * * @param parent the parent containment. @since 4.6 null is allowed. * @param name the plugin name, as returned by KPluginInfo::pluginName() * @param args to send the containmentactions extra arguments * @return a ContainmentActions object **/ virtual ContainmentActions *internalLoadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args); /** * A re-implementable method that allows subclasses to override * the default behaviour of loadPackage. If the service requested is not recognized, * then the implementation should return a NULL pointer. This method is called * by loadService prior to attempting to load a Service using the standard Plasma * plugin mechanisms. * * @param name the plugin name of the service to load * @param args a list of arguments to supply to the service plugin when loading it * @param parent the parent object, if any, for the service * * @return a Service object, unlike Plasma::Service::loadService, this can return null. - * @deprecated since 5.29 + * @deprecated since 5.30, use KPackage API **/ -#ifndef PLASMA_NO_DEPRECATED - virtual PLASMA_DEPRECATED Package internalLoadPackage(const QString &name, const QString &specialization); -#endif + PLASMA_DEPRECATED_VERSION(5, 30, "Use KPackage API") + virtual Package internalLoadPackage(const QString &name, const QString &specialization); /** * A re-implementable method that allows subclasses to provide additional applets * for listAppletInfo. If the application has no applets to give to the application, * then the implementation should return an empty list. * * This method is called by listAppletInfo prior to generating the list of applets installed * on the system using the standard Plasma plugin mechanisms, and will try to find .desktop * files for your applets. * * @param category Only applets matching this category will be returned. * Useful in conjunction with knownCategories. * If "Misc" is passed in, then applets without a * Categories= entry are also returned. * If an empty string is passed in, all applets are * returned. * @return list of applets **/ virtual KPluginInfo::List internalAppletInfo(const QString &category) const; /** * A re-implementable method that allows subclasses to provide additional dataengines * for DataEngine::listDataEngines. * * @return list of dataengine info, or an empty list if none **/ virtual KPluginInfo::List internalDataEngineInfo() const; /** * Returns a list of all known Service implementations * * @return list of Service info, or an empty list if none */ virtual KPluginInfo::List internalServiceInfo() const; /** * Returns a list of all known ContainmentActions implementations * * @return list of ContainmentActions info, or an empty list if none */ virtual KPluginInfo::List internalContainmentActionsInfo() const; /** * Standardized mechanism for providing internal applets by install .desktop files * in $APPPDATA/plasma/internal/applets/ * * For applications that do this, internalAppletInfo can be implemented as a one-liner * call to this method. * * @param category Only applets matching this category will be returned. * Useful in conjunction with knownCategories. * If "Misc" is passed in, then applets without a * Categories= entry are also returned. * If an empty string is passed in, all applets are * returned. * @return list of applets, or an empty list if none */ KPluginInfo::List standardInternalAppletInfo(const QString &category) const; /** * Standardized mechanism for providing internal dataengines by install .desktop files * in $APPPDATA/plasma/internal/dataengines/ * * For applications that do this, internalDataEngineInfo can be implemented as a one-liner * call to this method. * * @return list of dataengines */ KPluginInfo::List standardInternalDataEngineInfo() const; /** * Standardized mechanism for providing internal services by install .desktop files * in $APPPDATA/plasma/internal/services/ * * For applications that do this, internalServiceInfo can be implemented as a one-liner * call to this method. * * @return list of services */ KPluginInfo::List standardInternalServiceInfo() const; PluginLoader(); virtual ~PluginLoader(); private: bool isPluginVersionCompatible(KPluginLoader &loader); PluginLoaderPrivate *const d; }; } Q_DECLARE_METATYPE(Plasma::PluginLoader *) #endif diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index d0f1e3c51..016b3d38a 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -1,119 +1,127 @@ if(HAVE_X11 AND XCB_XCB_FOUND AND XCB_SHAPE_FOUND) add_definitions(-DHAVE_XCB_SHAPE=1) else() add_definitions(-DHAVE_XCB_SHAPE=0) endif() set(plasmaquick_LIB_SRC appletquickitem.cpp debug_p.cpp dialog.cpp dialogshadows.cpp view.cpp containmentview.cpp configmodel.cpp shellpluginloader.cpp configview.cpp packageurlinterceptor.cpp private/configcategory_p.cpp private/packages.cpp ../declarativeimports/core/framesvgitem.cpp ../declarativeimports/core/units.cpp ) ecm_qt_declare_logging_category(PlasmaQuick_LIB_SRCS HEADER debug_p.h IDENTIFIER LOG_PLASMAQUICK CATEGORY_NAME org.kde.plasmaquick) add_library(KF5PlasmaQuick SHARED ${plasmaquick_LIB_SRC}) add_library(KF5::PlasmaQuick ALIAS KF5PlasmaQuick) target_include_directories(KF5PlasmaQuick PUBLIC "$") target_link_libraries(KF5PlasmaQuick PUBLIC Qt5::Gui Qt5::Quick Qt5::Qml KF5::Plasma KF5::WindowSystem PRIVATE KF5::KIOWidgets KF5::I18n KF5::IconThemes KF5::Service KF5::CoreAddons KF5::XmlGui KF5::Declarative KF5::QuickAddons ) if(HAVE_KWAYLAND) target_link_libraries(KF5PlasmaQuick PRIVATE KF5::WaylandClient ) endif() if(HAVE_X11) target_link_libraries(KF5PlasmaQuick PRIVATE Qt5::X11Extras ${X11_LIBRARIES} XCB::XCB ) if(XCB_SHAPE_FOUND) target_link_libraries(KF5PlasmaQuick PRIVATE XCB::SHAPE) endif() endif() set_target_properties(KF5PlasmaQuick PROPERTIES VERSION ${PLASMA_VERSION_STRING} SOVERSION ${PLASMA_SOVERSION} EXPORT_NAME PlasmaQuick ) install(TARGETS KF5PlasmaQuick EXPORT KF5PlasmaQuickTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) -generate_export_header(KF5PlasmaQuick BASE_NAME PlasmaQuick) +ecm_generate_export_header(KF5PlasmaQuick + BASE_NAME PlasmaQuick + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 5.12 5.25 5.36 +) +# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all Plasma libs +# needs fixing of undeprecated API being still implemented using own deprecated API set(plasmaquick_LIB_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/plasmaquick_export.h packageurlinterceptor.h ) ecm_generate_headers(PlasmaQuick_CamelCase_HEADERS HEADER_NAMES AppletQuickItem ContainmentView ConfigView ConfigModel Dialog REQUIRED_HEADERS plasmaquick_LIB_INCLUDES PREFIX PlasmaQuick ) install(FILES ${plasmaquick_LIB_INCLUDES} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/plasmaquick COMPONENT Devel) install(FILES ${PlasmaQuick_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/PlasmaQuick COMPONENT Devel) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5PlasmaQuick") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PlasmaQuickConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaQuickConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} PATH_VARS KF5_INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX ) ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX PLASMAQUICK PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaQuickConfigVersion.cmake" ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaQuickConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PlasmaQuickConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5PlasmaQuickTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PlasmaQuickTargets.cmake NAMESPACE KF5:: ) diff --git a/src/plasmaquick/appletquickitem.h b/src/plasmaquick/appletquickitem.h index 34c91ab2e..aa7114bbe 100644 --- a/src/plasmaquick/appletquickitem.h +++ b/src/plasmaquick/appletquickitem.h @@ -1,180 +1,186 @@ /* * Copyright 2014 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef APPLETQUICKITEM_H #define APPLETQUICKITEM_H #include #include #include #include #include #include // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // namespace Plasma { class Applet; } namespace KDeclarative { class QmlObject; } namespace PlasmaQuick { class AppletQuickItemPrivate; class PLASMAQUICK_EXPORT AppletQuickItem : public QQuickItem { Q_OBJECT Q_PROPERTY(int switchWidth READ switchWidth WRITE setSwitchWidth NOTIFY switchWidthChanged) Q_PROPERTY(int switchHeight READ switchHeight WRITE setSwitchHeight NOTIFY switchHeightChanged) Q_PROPERTY(QQmlComponent *compactRepresentation READ compactRepresentation WRITE setCompactRepresentation NOTIFY compactRepresentationChanged) Q_PROPERTY(QQuickItem *compactRepresentationItem READ compactRepresentationItem NOTIFY compactRepresentationItemChanged) Q_PROPERTY(QQmlComponent *fullRepresentation READ fullRepresentation WRITE setFullRepresentation NOTIFY fullRepresentationChanged) Q_PROPERTY(QQuickItem *fullRepresentationItem READ fullRepresentationItem NOTIFY fullRepresentationItemChanged) /** * this is supposed to be either one between compactRepresentation or fullRepresentation */ Q_PROPERTY(QQmlComponent *preferredRepresentation READ preferredRepresentation WRITE setPreferredRepresentation NOTIFY preferredRepresentationChanged) /** * True when the applet is showing its full representation. either as the main only view, or in a popup. * Setting it will open or close the popup if the plasmoid is iconified, however it won't have effect if the applet is open */ Q_PROPERTY(bool expanded WRITE setExpanded READ isExpanded NOTIFY expandedChanged) /** * True when the applet wants the activation signal act in toggle mode, i.e. while being expanded * the signal shrinks the applet to its not expanded state instead of reexpanding it. */ Q_PROPERTY(bool activationTogglesExpanded WRITE setActivationTogglesExpanded READ isActivationTogglesExpanded NOTIFY activationTogglesExpandedChanged) /** * the applet root QML item: sometimes is the same as fullRepresentationItem * if a fullrepresentation was not declared explicitly */ Q_PROPERTY(QObject *rootItem READ rootItem CONSTANT) public: AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent = nullptr); ~AppletQuickItem() override; ////API NOT SUPPOSED TO BE USED BY QML Plasma::Applet *applet() const; //Make the constructor lighter and delay the actual instantiation of the qml in the applet virtual void init(); - PLASMA_DEPRECATED Plasma::Package appletPackage() const; - PLASMA_DEPRECATED void setAppletPackage(const Plasma::Package &package); - - PLASMA_DEPRECATED Plasma::Package coronaPackage() const; - PLASMA_DEPRECATED void setCoronaPackage(const Plasma::Package &package); +#if PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 36) + PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use") + Plasma::Package appletPackage() const; + PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use") + void setAppletPackage(const Plasma::Package &package); + + PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use") + Plasma::Package coronaPackage() const; + PLASMAQUICK_DEPRECATED_VERSION(5, 36, "No longer use") + void setCoronaPackage(const Plasma::Package &package); +#endif QQuickItem *compactRepresentationItem(); QQuickItem *fullRepresentationItem(); QObject *rootItem(); QObject *testItem(); ////PROPERTY ACCESSORS int switchWidth() const; void setSwitchWidth(int width); int switchHeight() const; void setSwitchHeight(int width); QQmlComponent *compactRepresentation(); void setCompactRepresentation(QQmlComponent *component); QQmlComponent *fullRepresentation(); void setFullRepresentation(QQmlComponent *component); QQmlComponent *preferredRepresentation(); void setPreferredRepresentation(QQmlComponent *component); bool isExpanded() const; void setExpanded(bool expanded); bool isActivationTogglesExpanded() const; void setActivationTogglesExpanded(bool activationTogglesExpanded); ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static AppletQuickItem *qmlAttachedProperties(QObject *object); Q_SIGNALS: //Property signals void switchWidthChanged(int width); void switchHeightChanged(int height); void expandedChanged(bool expanded); void activationTogglesExpandedChanged(bool activationTogglesExpanded); void compactRepresentationChanged(QQmlComponent *compactRepresentation); void fullRepresentationChanged(QQmlComponent *fullRepresentation); void preferredRepresentationChanged(QQmlComponent *preferredRepresentation); void compactRepresentationItemChanged(QObject *compactRepresentationItem); void fullRepresentationItemChanged(QObject *fullRepresentationItem); protected: KDeclarative::QmlObject *qmlObject(); //Reimplementation void childEvent(QChildEvent *event) override; void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void itemChange(ItemChange change, const ItemChangeData &value) override; private: AppletQuickItemPrivate *const d; Q_PRIVATE_SLOT(d, void minimumWidthChanged()) Q_PRIVATE_SLOT(d, void minimumHeightChanged()) Q_PRIVATE_SLOT(d, void preferredWidthChanged()) Q_PRIVATE_SLOT(d, void preferredHeightChanged()) Q_PRIVATE_SLOT(d, void maximumWidthChanged()) Q_PRIVATE_SLOT(d, void maximumHeightChanged()) Q_PRIVATE_SLOT(d, void fillWidthChanged()) Q_PRIVATE_SLOT(d, void fillHeightChanged()) }; } QML_DECLARE_TYPEINFO(PlasmaQuick::AppletQuickItem, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/plasmaquick/shellpluginloader.h b/src/plasmaquick/shellpluginloader.h index 18a8815f3..daeea435d 100644 --- a/src/plasmaquick/shellpluginloader.h +++ b/src/plasmaquick/shellpluginloader.h @@ -1,42 +1,47 @@ /* * Copyright 2013 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SHELLPLUGINLOADER_H #define SHELLPLUGINLOADER_H #include #include +#if PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 25) + /** - * @deprecated, don't use + * @deprecated Since 5.25, use Plasma::PluginLoader */ -class PLASMAQUICK_DEPRECATED_EXPORT ShellPluginLoader : public Plasma::PluginLoader +class PLASMAQUICK_EXPORT ShellPluginLoader : public Plasma::PluginLoader { public: + PLASMAQUICK_DEPRECATED_VERSION(5, 25, "Use PluginLoader") ShellPluginLoader(); ~ShellPluginLoader() override; static void init(); protected: Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization) override; }; +#endif // PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 25) + #endif diff --git a/src/plasmaquick/view.h b/src/plasmaquick/view.h index b1538a326..340bffec2 100644 --- a/src/plasmaquick/view.h +++ b/src/plasmaquick/view.h @@ -1,139 +1,144 @@ /* * Copyright 2012 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLASMAQUICKVIEW_H #define PLASMAQUICKVIEW_H #include #include #include "plasma/corona.h" #include "plasma/containment.h" // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // +#if PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 12) + namespace PlasmaQuick { class ViewPrivate; /** - * Deprecated, use ContainmentView instead. + * @deprecated Since 5.12, use ContainmentView instead. */ class PLASMAQUICK_EXPORT View : public QQuickView { Q_OBJECT Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged) Q_PROPERTY(QRectF screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) public: /** * @param corona the corona of this view * @param parent the QWindow this View is parented to **/ - PLASMA_DEPRECATED explicit View(Plasma::Corona *corona, QWindow *parent = nullptr); - PLASMA_DEPRECATED virtual ~View(); + PLASMAQUICK_DEPRECATED_VERSION(5, 12, "Use ContainmentView") + explicit View(Plasma::Corona *corona, QWindow *parent = nullptr); + virtual ~View(); /** * @return the corona of this view **/ - PLASMA_DEPRECATED Plasma::Corona *corona() const; + Plasma::Corona *corona() const; /** * @return the KConfigGroup of this view **/ - PLASMA_DEPRECATED virtual KConfigGroup config() const; + virtual KConfigGroup config() const; /** * sets the containment for this view * @param cont the containment of this view **/ - PLASMA_DEPRECATED void setContainment(Plasma::Containment *cont); + void setContainment(Plasma::Containment *cont); /** * @return the containment of this View **/ - PLASMA_DEPRECATED Plasma::Containment *containment() const; + Plasma::Containment *containment() const; /** * @return the location of this View **/ - PLASMA_DEPRECATED Plasma::Types::Location location() const; + Plasma::Types::Location location() const; /** * Sets the location of the View * @param location the location of the View **/ - PLASMA_DEPRECATED void setLocation(Plasma::Types::Location location); + void setLocation(Plasma::Types::Location location); /** * @return the formfactor of the View **/ - PLASMA_DEPRECATED Plasma::Types::FormFactor formFactor() const; + Plasma::Types::FormFactor formFactor() const; /** * @return the screenGeometry of the View **/ - PLASMA_DEPRECATED QRectF screenGeometry(); + QRectF screenGeometry(); protected Q_SLOTS: /** * It will be called when the configuration is requested */ - PLASMA_DEPRECATED virtual void showConfigurationInterface(Plasma::Applet *applet); + virtual void showConfigurationInterface(Plasma::Applet *applet); Q_SIGNALS: /** * emitted when the location is changed **/ - PLASMA_DEPRECATED void locationChanged(Plasma::Types::Location location); + void locationChanged(Plasma::Types::Location location); /** * emitted when the formfactor is changed **/ - PLASMA_DEPRECATED void formFactorChanged(Plasma::Types::FormFactor formFactor); + void formFactorChanged(Plasma::Types::FormFactor formFactor); /** * emitted when the containment is changed **/ - PLASMA_DEPRECATED void containmentChanged(); + void containmentChanged(); /** * emitted when the screenGeometry is changed **/ - PLASMA_DEPRECATED void screenGeometryChanged(); + void screenGeometryChanged(); private: ViewPrivate *const d; Q_PRIVATE_SLOT(d, void updateDestroyed(bool)) friend class ViewPrivate; }; } +#endif // PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 12) + #endif // View_H