diff --git a/CMakeLists.txt b/CMakeLists.txt index b969f47..3f83d13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,95 +1,95 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.66.0") # handled by release scripts set(KF5_DEP_VERSION "5.65.0") # handled by release scripts project(KCMUtils VERSION ${KF5_VERSION}) include(FeatureSummary) find_package(ECM 5.65.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) set(REQUIRED_QT_VERSION 5.12.0) find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Widgets DBus Qml Quick QuickWidgets) set(KCMUtils_AUTOMOC_MACRO_NAMES "KCMODULECONTAINER") if(NOT CMAKE_VERSION VERSION_LESS "3.10.0") # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros. # 3.10+ lets us provide more macro names that require automoc. list(APPEND CMAKE_AUTOMOC_MACRO_NAMES ${KCMUtils_AUTOMOC_MACRO_NAMES}) endif() -include(GenerateExportHeader) +include(ECMGenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(ECMAddQch) 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 KCMUTILS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kcmutils_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5KCMUtilsConfigVersion.cmake" SOVERSION 5) find_package(KF5ItemViews ${KF5_DEP_VERSION} REQUIRED) find_package(KF5ConfigWidgets ${KF5_DEP_VERSION} REQUIRED) find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5GuiAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Service ${KF5_DEP_VERSION} REQUIRED) find_package(KF5XmlGui ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Declarative ${KF5_DEP_VERSION} REQUIRED) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054100) add_definitions(-DTRANSLATION_DOMAIN=\"kcmutils5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() add_definitions(-DQT_NO_FOREACH) add_subdirectory(src) # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5KCMUtils") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5KCMUtils_QCH FILE KF5KCMUtilsQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5KCMUtilsQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5KCMUtilsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5KCMUtilsConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5KCMUtilsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5KCMUtilsConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5KCMUtilsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5KCMUtilsTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kcmutils_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ac2aa19..aaa87c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,114 +1,120 @@ ########### kcmutils ############### set(kcmutils_LIB_SRCS kcmoduleinfo.cpp kcmoduleloader.cpp kcmoduleqml.cpp kcmultidialog.cpp kcmoduleproxy.cpp kpluginselector.cpp kcmodulecontainer.cpp ksettingswidgetadaptor.cpp ksettings/dispatcher.cpp ksettings/dialog.cpp ksettings/pluginpage.cpp ksettings/componentsdialog.cpp ) add_library(KF5KCMUtils ${kcmutils_LIB_SRCS}) -generate_export_header(KF5KCMUtils BASE_NAME KCMUtils) - +ecm_generate_export_header(KF5KCMUtils + BASE_NAME KCMUtils + GROUP_BASE_NAME KF + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 5.66 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) target_include_directories(KF5KCMUtils INTERFACE "$") target_link_libraries(KF5KCMUtils PUBLIC Qt5::Widgets KF5::ConfigWidgets # KCModule KF5::Service # KService PRIVATE Qt5::DBus # dbus usage in kcmoduleproxy.cpp Qt5::Qml Qt5::Quick Qt5::QuickWidgets KF5::CoreAddons KF5::GuiAddons # KIconUtils KF5::I18n KF5::ItemViews # KWidgetItemDelegate KF5::XmlGui # KAboutApplicationDialog KF5::QuickAddons KF5::Declarative KF5::Package ) set_target_properties(KF5KCMUtils PROPERTIES VERSION ${KCMUTILS_VERSION_STRING} SOVERSION ${KCMUTILS_SOVERSION} EXPORT_NAME KCMUtils) ecm_generate_headers(KCMUtils_HEADERS HEADER_NAMES KCModuleInfo KCModuleLoader KCMultiDialog KCModuleProxy KPluginSelector KCModuleContainer REQUIRED_HEADERS KCMUtils_HEADERS ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kcmutils_export.h ${KCMUtils_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KCMUtils COMPONENT Devel ) ecm_generate_headers(KSettings_HEADERS HEADER_NAMES Dispatcher Dialog PluginPage RELATIVE ksettings REQUIRED_HEADERS KSettings_HEADERS ) install(FILES ${KSettings_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KCMUtils/ksettings COMPONENT Devel ) install(TARGETS KF5KCMUtils EXPORT KF5KCMUtilsTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES kcmodule.desktop kcmoduleinit.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR} ) if(BUILD_QCH) ecm_add_qch( KF5KCMUtils_QCH NAME KCMUtils BASE_NAME KF5KCMUtils VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KCMUtils_HEADERS} ${KSettings_HEADERS} ksettings/README.dox MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Widgets_QCH KF5ConfigWidgets_QCH KF5Service_QCH INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} BLANK_MACROS KCMUTILS_EXPORT KCMUTILS_DEPRECATED KCMUTILS_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KCMUtils LIB_NAME KF5KCMUtils DEPS "widgets KConfigWidgets KService" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KCMUtils) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/kcmodulecontainer.cpp b/src/kcmodulecontainer.cpp index a78b64c..b604a72 100644 --- a/src/kcmodulecontainer.cpp +++ b/src/kcmodulecontainer.cpp @@ -1,186 +1,190 @@ /* This file is part of the KDE libraries Copyright (C) 2004 Frans Englich 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. */ #include "kcmodulecontainer.h" #include #include #include #include #include #include #include #include typedef QList ModuleList; +#if KCMUTILS_BUILD_DEPRECATED_SINCE(5,66) + /***********************************************************************/ class Q_DECL_HIDDEN KCModuleContainer::KCModuleContainerPrivate { public: KCModuleContainerPrivate(const QStringList &mods) : modules(mods) {} QStringList modules; QTabWidget *tabWidget = nullptr; KCModule::Buttons buttons; QVBoxLayout *topLayout = nullptr; /** * A list containing KCModuleProxy objects which * have changed and must be saved. */ ModuleList changedModules; /** * A list of all modules which are encapsulated. */ ModuleList allModules; }; /***********************************************************************/ // The KCModuleContainer is only a wrapper around real KCModules. /***********************************************************************/ KCModuleContainer::KCModuleContainer(QWidget *parent, const QString &mods) : KCModule(parent), d(new KCModuleContainerPrivate(QString(mods).remove(QLatin1Char(' ')).split(QLatin1Char(','), QString::SkipEmptyParts))) { init(); } KCModuleContainer::KCModuleContainer(QWidget *parent, const QStringList &mods) : KCModule(parent), d(new KCModuleContainerPrivate(mods)) { init(); } void KCModuleContainer::init() { d->topLayout = new QVBoxLayout(this); d->topLayout->setContentsMargins(0, 0, 0, 0); d->topLayout->setObjectName(QStringLiteral("topLayout")); d->tabWidget = new QTabWidget(this); d->tabWidget->setObjectName(QStringLiteral("tabWidget")); connect(d->tabWidget, &QTabWidget::currentChanged, this, &KCModuleContainer::tabSwitched); d->topLayout->addWidget(d->tabWidget); if (!d->modules.isEmpty()) { /* Add our modules */ for (QStringList::const_iterator it = d->modules.constBegin(), total = d->modules.constEnd(); it != total; ++it) { addModule((*it)); } } } void KCModuleContainer::addModule(const QString &module) { /* In case it doesn't exist we just silently drop it. * This allows people to easily extend containers. * For example, KCM monitor gamma can be in kdegraphics. */ KService::Ptr service = KService::serviceByDesktopName(module); if (!service) { // qDebug() << "KCModuleContainer: module '" << // module << "' was not found and thus not loaded" << endl; return; } if (service->noDisplay()) { return; } KCModuleProxy *proxy = new KCModuleProxy(service, d->tabWidget); d->allModules.append(proxy); proxy->setObjectName(module); d->tabWidget->addTab(proxy, QIcon::fromTheme(proxy->moduleInfo().icon()), /* Qt eats ampersands for dinner. But not this time. */ proxy->moduleInfo().moduleName().replace(QLatin1Char('&'), QStringLiteral("&&"))); d->tabWidget->setTabToolTip(d->tabWidget->indexOf(proxy), proxy->moduleInfo().comment()); connect(proxy, SIGNAL(changed(KCModuleProxy*)), SLOT(moduleChanged(KCModuleProxy*))); /* Collect our buttons - we go for the common deliminator */ setButtons(buttons() | proxy->realModule()->buttons()); } void KCModuleContainer::tabSwitched(int index) { KCModuleProxy *mod = static_cast(d->tabWidget->widget(index)); setQuickHelp(mod->quickHelp()); setAboutData(mod->aboutData()); } void KCModuleContainer::save() { ModuleList list = d->changedModules; ModuleList::iterator it; for (it = list.begin(); it != list.end(); ++it) { (*it)->save(); } emit changed(false); } void KCModuleContainer::load() { ModuleList list = d->allModules; ModuleList::iterator it; for (it = list.begin(); it != list.end(); ++it) { (*it)->load(); } emit changed(false); } void KCModuleContainer::defaults() { ModuleList list = d->allModules; ModuleList::iterator it; for (it = list.begin(); it != list.end(); ++it) { (*it)->defaults(); } emit changed(true); } void KCModuleContainer::moduleChanged(KCModuleProxy *proxy) { d->changedModules.append(proxy); if (d->changedModules.isEmpty()) { return; } emit changed(true); } KCModuleContainer::~KCModuleContainer() { delete d; } +#endif + /***********************************************************************/ diff --git a/src/kcmodulecontainer.h b/src/kcmodulecontainer.h index 95eedbb..1e0ec54 100644 --- a/src/kcmodulecontainer.h +++ b/src/kcmodulecontainer.h @@ -1,158 +1,172 @@ /* This file is part of the KDE libraries Copyright (C) 2004 Frans Englich 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 KCMODULECONTAINER_H #define KCMODULECONTAINER_H #include #include #include #include class QWidget; class KCModuleProxy; +#if KCMUTILS_ENABLE_DEPRECATED_SINCE(5,66) /** * @brief KCModuleContainer is a convenience class encapsulating several KCModules. * * The KCModuleContainer class is a convenience class for organizing a multiple set * of KCModule. KCModuleContainer is a sub class of KCModule and builds an interface mainly * consisting of a tab widget where each tab contains one of the modules specified via one of the * constructors. KCModuleContainer can handle modules which requires root permissions. What you * most likely want is the KCMODULECONTAINER macro. \n * Sometimes it is of interest to detect in runtime whether a module should be loaded or not. This * can be achieved by sub classing KCModuleContainer, doing the probing/testing checks and then manually * call addModule for each module which should be displayed. When all calls to addModule is done, call * finalize() which performs some necessary final steps. * + * @deprecated since 5.66, no known users. + * * @author Frans Englich */ class KCMUTILS_EXPORT KCModuleContainer : public KCModule { Q_OBJECT public: /** * Creates a KCModuleContainer with tabs, each one containing one of the * specified modules in @p mods. * * @param parent the parent QWidget. * @param mods The list of KCModules to be loaded. The name of each * KCModule is its service name, that is the name of the desktop file without * the ".desktop" part * + * @deprecated since 5.66, no known users. */ + KCMUTILS_DEPRECATED_VERSION(5, 66, "No known users") KCModuleContainer(QWidget *parent, const QStringList &mods); /** * This is a convenience function, instead of building a QStringList you * can specify the modules in a comma separated QString. For example; * \code * KCModuleContainer* cont = KCModuleContainer( this, "kcm_misc", QString("kcm_energy, kcm_keyboard ,kcm_useraccount, kcm_mouse") ); * \endcode * The other constructor takes its modules in a QStringlist which also can be constructed from a * string and thus you will have to be explicit on the data type. * * What you probably want is the KCMODULECONTAINER macro which builds an KCModule * for you, taking the modules you want as argument. * * @param parent The parent widget * @param mods The modules to load * @return The KCModule containing the requested modules. + * + * @deprecated since 5.66, no known users. */ + KCMUTILS_DEPRECATED_VERSION(5, 66, "No known users") explicit KCModuleContainer(QWidget *parent, const QString &mods = QString()); /** * Adds the specified module to the tab widget. Setting the tab icon, text, * tool tip, connecting the signals is what it does. * * @param module the name of the module to add. The name is the desktop file's name * without the ".desktop" part. + * + * @deprecated since 5.66, no known users. */ + KCMUTILS_DEPRECATED_VERSION(5, 66, "No known users") void addModule(const QString &module); /** * Default destructor. */ ~KCModuleContainer() override; /** * @reimp */ void save() override; /** * @reimp */ void load() override; /** * @reimp */ void defaults() override; private Q_SLOTS: /** * Enables/disables the Admin Mode button, as appropriate. */ void tabSwitched(int); void moduleChanged(KCModuleProxy *proxy); private: void init(); class KCModuleContainerPrivate; KCModuleContainerPrivate *const d; }; /** * This macro creates an factory declaration which when run creates an KCModule with specified * modules. For example: * \code * KCMODULECONTAINER("kcm_fonts,kcm_keyboard,kcm_foo", misc_modules) * \endcode * would create a KCModule with three tabs, each containing one of the specified KCMs. Each * use of the macro must be accompanied by a desktop file where the factory name equals * the second argument in the macro(in this example, misc_modules). \n * The module container takes care of testing the contained modules when being shown, as well * as when the module itself is asked whether it should be shown. * * @param modules the modules to put in the container * @param factoryName what factory name the module should have + * + * @deprecated since 5.66, no known users. */ #define KCMODULECONTAINER(modules, factoryName) \ class KCModuleContainer##factoryName : public KCModuleContainer \ { \ public: \ KCModuleContainer##factoryName(QWidget *parent, const QVariantList &) \ : KCModuleContainer(parent, QLatin1String(modules)) \ { \ } \ }; \ K_PLUGIN_FACTORY(KCModuleContainer##factoryName##Factory, \ registerPlugin(); \ ) +#endif #endif // KCMODULECONTAINER_H