diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,14 +15,16 @@ include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) -include(GenerateExportHeader) +include(ECMGenerateExportHeader) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMQtDeclareLoggingCategory) include(ECMAddQch) include(ECMSetupQtPluginMacroNames) +set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") + 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)") diff --git a/autotests/kaboutdatatest.cpp b/autotests/kaboutdatatest.cpp --- a/autotests/kaboutdatatest.cpp +++ b/autotests/kaboutdatatest.cpp @@ -35,7 +35,9 @@ void testLongFormConstructor(); void testShortFormConstructor(); void testSetAddLicense(); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) void testSetProgramIconName(); +#endif void testSetDesktopFileName(); void testCopying(); @@ -47,7 +49,9 @@ static const char AppName[] = "app"; static const char ProgramName[] = "ProgramName"; +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) static const char ProgramIconName[] = "program-icon"; +#endif static const char Version[] = "Version"; static const char ShortDescription[] = "ShortDescription"; static const char CopyrightStatement[] = "CopyrightStatement"; @@ -68,7 +72,9 @@ QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName)); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName)); +#endif QCOMPARE(aboutData.programLogo(), QVariant()); QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org")); QCOMPARE(aboutData.version(), QString::fromLatin1(Version)); @@ -105,7 +111,9 @@ QCOMPARE(aboutData.componentName(), QLatin1String(AppName)); QCOMPARE(aboutData.productName(), QLatin1String(AppName)); QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName)); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) QCOMPARE(aboutData.programIconName(), QLatin1String(AppName)); +#endif QCOMPARE(aboutData.programLogo(), QVariant()); QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1(OrganizationDomain)); QCOMPARE(aboutData.version(), QString::fromLatin1(Version)); @@ -150,7 +158,9 @@ QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName)); QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName)); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName)); +#endif QCOMPARE(aboutData.programLogo(), QVariant()); QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org")); QCOMPARE(aboutData.version(), QString::fromLatin1(Version)); @@ -264,6 +274,7 @@ QLatin1String(LicenseFileText))); } +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) void KAboutDataTest::testSetProgramIconName() { const QString programIconName(QString::fromLatin1(ProgramIconName)); @@ -281,6 +292,7 @@ #pragma GCC diagnostic pop QCOMPARE(aboutData.programIconName(), programIconName); } +#endif void KAboutDataTest::testCopying() { diff --git a/autotests/kusertest.cpp b/autotests/kusertest.cpp --- a/autotests/kusertest.cpp +++ b/autotests/kusertest.cpp @@ -102,7 +102,9 @@ // make sure we don't crash when accessing properties of an invalid instance QCOMPARE(invalidKUser.faceIconPath(), QString()); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 0) QCOMPARE(invalidKUser.fullName(), QString()); +#endif QCOMPARE(invalidKUser.groupId(), KGroupId()); invalidKUser.groupNames(); // could be empty, or "nogroup", so no checks here invalidKUser.groups(); // same as above diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -117,8 +117,14 @@ CATEGORY_NAME org.kde.kcoreaddons) add_library(KF5CoreAddons ${libkcoreaddons_SRCS}) -generate_export_header(KF5CoreAddons BASE_NAME KCoreAddons) add_library(KF5::CoreAddons ALIAS KF5CoreAddons) +ecm_generate_export_header(KF5CoreAddons + BASE_NAME KCoreAddons + GROUP_BASE_NAME KF + VERSION ${KF5_VERSION} + DEPRECATION_VERSIONS 4.0 5.0 5.2 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) target_include_directories(KF5CoreAddons PUBLIC "$") diff --git a/src/lib/kaboutdata.h b/src/lib/kaboutdata.h --- a/src/lib/kaboutdata.h +++ b/src/lib/kaboutdata.h @@ -722,6 +722,7 @@ */ KAboutData &setDisplayName(const QString &displayName); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) /** * Obsolete method * @@ -734,8 +735,9 @@ * * @deprecated since 5.2, use QApplication::setWindowIcon(QIcon::fromTheme()) instead. */ - KCOREADDONS_DEPRECATED KAboutData &setProgramIconName(const QString &iconName); // KF6 remove this - + KCOREADDONS_DEPRECATED_VERSION(5, 2, "Use QApplication::setWindowIcon") + KAboutData &setProgramIconName(const QString &iconName); +#endif /** * Defines the program logo. * @@ -939,15 +941,18 @@ */ const char *internalProgramName() const; +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2) /** * Returns the program's icon name. * * The default value is componentName(). * @return the program's icon name. * * This is mostly for compatibility, given that setProgramIconName is deprecated. */ + KCOREADDONS_DEPRECATED_VERSION(5, 2, "Use QApplication::windowIcon") QString programIconName() const; +#endif /** * Returns the program logo image. diff --git a/src/lib/kaboutdata.cpp b/src/lib/kaboutdata.cpp --- a/src/lib/kaboutdata.cpp +++ b/src/lib/kaboutdata.cpp @@ -474,7 +474,9 @@ QList _translatorList; QList _licenseList; QString productName; +#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2) QString programIconName; +#endif QVariant programLogo; QString customAuthorPlainText, customAuthorRichText; bool customAuthorTextEnabled; @@ -611,7 +613,9 @@ KAboutData ret(plugin.pluginId(), plugin.name(), plugin.version(), plugin.description(), KAboutLicense::byKeyword(plugin.license()).key(), plugin.copyrightText(), plugin.extraInformation(), plugin.website()); +#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2) ret.d->programIconName = plugin.iconName(); +#endif ret.d->_authorList = plugin.authors(); ret.d->_translatorList = plugin.translators(); ret.d->_creditList = plugin.otherContributors(); @@ -815,6 +819,7 @@ return d->_internalProgramName.constData(); } +#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 2) QString KAboutData::programIconName() const { return d->programIconName.isEmpty() ? componentName() : d->programIconName; @@ -825,6 +830,7 @@ d->programIconName = iconName; return *this; } +#endif QVariant KAboutData::programLogo() const { diff --git a/src/lib/plugin/kexportplugin.h b/src/lib/plugin/kexportplugin.h --- a/src/lib/plugin/kexportplugin.h +++ b/src/lib/plugin/kexportplugin.h @@ -30,6 +30,7 @@ #define K_EXPORT_PLUGIN_VERSION(version) \ Q_EXTERN_C Q_DECL_EXPORT const quint32 kde_plugin_version = version; +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 0) /** * \relates KPluginLoader * This macro exports the main object of the plugin. Most times, this will be a KPluginFactory @@ -42,7 +43,6 @@ #else #define Q_STANDARD_CALL -#ifndef KCOREADDONS_NO_DEPRECATED class KCOREADDONS_DEPRECATED_EXPORT K_EXPORT_PLUGIN_is_deprecated_see_KDE5PORTING { }; diff --git a/src/lib/plugin/kpluginfactory.h b/src/lib/plugin/kpluginfactory.h --- a/src/lib/plugin/kpluginfactory.h +++ b/src/lib/plugin/kpluginfactory.h @@ -386,23 +386,22 @@ template T *create(QWidget *parentWidget, QObject *parent, const QString &keyword = QString(), const QVariantList &args = QVariantList()); +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(4, 0) /** * @deprecated since 4.0 use create(QObject *parent, const QVariantList &args) */ -#ifndef KCOREADDONS_NO_DEPRECATED template - KCOREADDONS_DEPRECATED + KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create(QObject *parent, const QVariantList &args)") T *create(QObject *parent, const QStringList &args) { return create(parent, stringListToVariantList(args)); } -#endif /** * @deprecated since 4.0 use create(QObject *parent, const QVariantList &args) */ -#ifndef KCOREADDONS_NO_DEPRECATED - KCOREADDONS_DEPRECATED QObject *create(QObject *parent = nullptr, const char *classname = "QObject", const QStringList &args = QStringList()) + KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create(QObject *parent, const QVariantList &args)") + QObject *create(QObject *parent = nullptr, const char *classname = "QObject", const QStringList &args = QStringList()) { return create(classname, nullptr, parent, stringListToVariantList(args), QString()); } @@ -491,18 +490,18 @@ KPluginFactoryPrivate *const d_ptr; +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(4, 0) /** * @deprecated since 4.0 use create(QObject *parent, const QVariantList &args) */ -#ifndef KCOREADDONS_NO_DEPRECATED - virtual KCOREADDONS_DEPRECATED QObject *createObject(QObject *parent, const char *className, const QStringList &args); -#endif + KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create(QObject *parent, const QVariantList &args)") + virtual QObject *createObject(QObject *parent, const char *className, const QStringList &args); /** * @deprecated since 4.0 use create(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args) */ -#ifndef KCOREADDONS_NO_DEPRECATED - virtual KCOREADDONS_DEPRECATED KParts::Part *createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args); + KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args)") + virtual KParts::Part *createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args); #endif /** diff --git a/src/lib/plugin/kpluginfactory.cpp b/src/lib/plugin/kpluginfactory.cpp --- a/src/lib/plugin/kpluginfactory.cpp +++ b/src/lib/plugin/kpluginfactory.cpp @@ -89,7 +89,7 @@ } } -#ifndef KCOREADDONS_NO_DEPRECATED +#if KCOREADDONS_BUILD_DEPRECATED_SINCE(4, 0) QObject *KPluginFactory::createObject(QObject *parent, const char *className, const QStringList &args) { Q_UNUSED(parent); @@ -99,7 +99,7 @@ } #endif -#ifndef KCOREADDONS_NO_DEPRECATED +#if KCOREADDONS_BUILD_DEPRECATED_SINCE(4, 0) KParts::Part *KPluginFactory::createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args) { Q_UNUSED(parent); @@ -116,7 +116,7 @@ QObject *obj = nullptr; -#ifndef KCOREADDONS_NO_DEPRECATED +#if KCOREADDONS_BUILD_DEPRECATED_SINCE(4, 0) if (keyword.isEmpty()) { const QStringList argsStringList = variantListToStringList(args); diff --git a/src/lib/util/kuser.h b/src/lib/util/kuser.h --- a/src/lib/util/kuser.h +++ b/src/lib/util/kuser.h @@ -304,13 +304,14 @@ /** @return the native user id of the user. */ KGroupId groupId() const; -#ifndef KCOREADDONS_NO_DEPRECATED +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 0) /** * Returns the group id of the user. * @return the id of the group or -1 if user is invalid * @deprecated since 5.0 use KUser::groupId() */ - KCOREADDONS_DEPRECATED K_GID gid() const + KCOREADDONS_DEPRECATED_VERSION(5, 0, "Use KUser::groupId()") + K_GID gid() const { return groupId().nativeId(); } @@ -328,22 +329,24 @@ */ QString loginName() const; +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 0) /** * The full name of the user. * @return the full name of the user or QString() if user is invalid * @deprecated use property(KUser::FullName) instead */ -#ifndef KCOREADDONS_NO_DEPRECATED - KCOREADDONS_DEPRECATED QString fullName() const + KCOREADDONS_DEPRECATED_VERSION(5, 0, "Use KUser::property(KUser::FullName).toString()") + QString fullName() const { return property(FullName).toString(); } /** * Returns the user id of the user. * @return the id of the user or -1 (UNIX)/ null(Windows) if user is invalid * @deprecated since 5.0 use KUser::userId() */ - KCOREADDONS_DEPRECATED K_UID uid() const + KCOREADDONS_DEPRECATED_VERSION(5, 0, "Use KUser::userId().nativeId()") + K_UID uid() const { return userId().nativeId(); } @@ -517,13 +520,14 @@ */ bool isValid() const; -#ifndef KCOREADDONS_NO_DEPRECATED +#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 0) /** * Returns the group id of the group. * @return the group id of the group or -1 if the group is invalid * @deprecated since 5.0 use KUserGroup::groupId() */ - KCOREADDONS_DEPRECATED K_GID gid() const + KCOREADDONS_DEPRECATED_VERSION(5, 0, "Use KUserGroup::groupId().nativeId()") + K_GID gid() const { return groupId().nativeId(); }