diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,8 @@ include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) +include(ECMGenerateExportHeader) -include(GenerateExportHeader) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) @@ -30,6 +30,8 @@ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfigVersion.cmake" SOVERSION 5) +set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") + option(FORCE_DISABLE_KGLOBALACCEL "Force building KXmlGui without KGlobalAccel. Doing this will break global shortcut support. [default=OFF]" OFF) 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/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,7 +73,15 @@ ki18n_wrap_ui(kxmlgui_SRCS ${kxmlgui_UI} ) add_library(KF5XmlGui ${kxmlgui_SRCS}) -generate_export_header(KF5XmlGui BASE_NAME KXmlGui) +ecm_generate_export_header(KF5XmlGui + BASE_NAME KXmlGui + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 4.1 5.0 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) + add_library(KF5::XmlGui ALIAS KF5XmlGui) target_include_directories(KF5XmlGui INTERFACE "$") diff --git a/src/kactioncollection.h b/src/kactioncollection.h --- a/src/kactioncollection.h +++ b/src/kactioncollection.h @@ -270,17 +270,23 @@ */ void inserted(QAction *action); +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * Indicates that @p action was removed from this action collection. - * @deprecated + * @deprecated Since 5.0 */ + KXMLGUI_DEPRECATED_VERSION(5, 0, "Do not rely on") QT_MOC_COMPAT void removed(QAction *action); +#endif +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * Indicates that @p action was highlighted (hovered over). - * @deprecated Replaced by actionHovered(QAction* action); + * @deprecated Since 5.0. Replaced by actionHovered(QAction* action); */ + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KActionCollection::actionHovered(QAction* action)") QT_MOC_COMPAT void actionHighlighted(QAction *action); +#endif /** * Indicates that @p action was hovered. @@ -299,11 +305,14 @@ protected Q_SLOTS: virtual void slotActionTriggered(); +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * @internal - * @deprecated Replaced by slotActionHovered(); + * @deprecated Since 5.0. Replaced by slotActionHovered(); */ + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KActionCollection::slotActionHovered()") QT_MOC_COMPAT virtual void slotActionHighlighted(); +#endif private Q_SLOTS: void slotActionHovered(); diff --git a/src/kactioncollection.cpp b/src/kactioncollection.cpp --- a/src/kactioncollection.cpp +++ b/src/kactioncollection.cpp @@ -370,7 +370,9 @@ action->disconnect(this); +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) emit removed(action); //deprecated +#endif return action; } @@ -729,16 +731,20 @@ } } +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KActionCollection::slotActionHighlighted() { slotActionHovered(); } +#endif void KActionCollection::slotActionHovered() { QAction *action = qobject_cast(sender()); if (action) { +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) emit actionHighlighted(action); +#endif emit actionHovered(action); } } @@ -754,16 +760,21 @@ } //HACK the object we emit is partly destroyed +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) emit q->removed(action); //deprecated. remove in KDE5 +#endif } void KActionCollection::connectNotify(const QMetaMethod &signal) { if (d->connectHovered && d->connectTriggered) { return; } - if (signal.methodSignature() == "actionHighlighted(QAction*)" || + if ( +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) + signal.methodSignature() == "actionHighlighted(QAction*)" || +#endif signal.methodSignature() == "actionHovered(QAction*)") { if (!d->connectHovered) { d->connectHovered = true; diff --git a/src/kkeysequencewidget.h b/src/kkeysequencewidget.h --- a/src/kkeysequencewidget.h +++ b/src/kkeysequencewidget.h @@ -222,14 +222,15 @@ */ void setCheckActionCollections(const QList &actionCollections); +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(4, 1) /** * @deprecated since 4.1 * use setCheckActionCollections so that KKeySequenceWidget knows * in which action collection to call the writeSettings method after stealing * a shortcut from an action. */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void setCheckActionList(const QList &checkList); + KXMLGUI_DEPRECATED_VERSION(4, 1, "Use KKeySequenceWidget::setCheckActionCollections(const QList &)") + void setCheckActionList(const QList &checkList); #endif /** diff --git a/src/kkeysequencewidget.cpp b/src/kkeysequencewidget.cpp --- a/src/kkeysequencewidget.cpp +++ b/src/kkeysequencewidget.cpp @@ -340,7 +340,7 @@ d->clearButton->setVisible(show); } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(4, 1) void KKeySequenceWidget::setCheckActionList(const QList &checkList) // deprecated { d->checkList = checkList; diff --git a/src/kmainwindow.h b/src/kmainwindow.h --- a/src/kmainwindow.h +++ b/src/kmainwindow.h @@ -161,6 +161,7 @@ */ ~KMainWindow() override; +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * Retrieve the standard help menu. * @@ -184,13 +185,14 @@ * the "What's This" menu entry. * * @return A standard help menu. - * @deprecated use KHelpMenu directly + * @deprecated Since 5.0, use KHelpMenu directly */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED QMenu *helpMenu(const QString &aboutAppText = QString(), - bool showWhatsThis = true); + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KHelpMenu directly") + QMenu *helpMenu(const QString &aboutAppText = QString(), + bool showWhatsThis = true); #endif +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * Returns the help menu. Creates a standard help menu if none exists yet. * @@ -212,10 +214,10 @@ * the "What's This" menu entry. * * @return A standard help menu. - * @deprecated use XMLGUI instead, or KHelpMenu directly + * @deprecated Since 5.0, use XMLGUI instead, or KHelpMenu directly */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED QMenu *customHelpMenu(bool showWhatsThis = true); + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use XMLGUI or KHelpMenu") + QMenu *customHelpMenu(bool showWhatsThis = true); #endif /** @@ -398,12 +400,13 @@ */ QString dbusName() const; +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * @returns Always @c false * @deprecated since 5.0, the functionality got removed **/ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED bool initialGeometrySet() const { return false; } + KXMLGUI_DEPRECATED_VERSION(5, 0, "Remove usage, is a no-op now") + bool initialGeometrySet() const { return false; } #endif public Q_SLOTS: @@ -567,23 +570,26 @@ * For inherited classes */ bool settingsDirty() const; +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * For inherited classes - * @deprecated use KWindowConfig::saveWindowSize + * @deprecated Since 5.0, use KWindowConfig::saveWindowSize */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void saveWindowSize(KConfigGroup &config) const; + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KWindowConfig::saveWindowSize(...)") + void saveWindowSize(KConfigGroup &config) const; #endif +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * For inherited classes - * @deprecated use KWindowConfig::restoreWindowSize + * @deprecated Since 5.0, use KWindowConfig::restoreWindowSize */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void restoreWindowSize(const KConfigGroup &config); + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KWindowConfig::restoreWindowSize(...)") + void restoreWindowSize(const KConfigGroup &config); #endif protected Q_SLOTS: +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) /** * This slot does nothing. * @@ -607,10 +613,10 @@ * * } * \endcode - * @deprecated use KHelpMenu + * @deprecated Since 5.0, use KHelpMenu */ -#ifndef KXMLGUI_NO_DEPRECATED - virtual KXMLGUI_DEPRECATED void showAboutApplication() {} + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KHelpMenu") + virtual void showAboutApplication() {} #endif /** @@ -652,7 +658,7 @@ * @{ */ -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * @def RESTORE * Restores the last session. diff --git a/src/kmainwindow.cpp b/src/kmainwindow.cpp --- a/src/kmainwindow.cpp +++ b/src/kmainwindow.cpp @@ -405,7 +405,7 @@ delete k_ptr; } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) QMenu *KMainWindow::helpMenu(const QString &aboutAppText, bool showWhatsThis) { K_D(KMainWindow); @@ -729,14 +729,14 @@ d->letDirtySettings = oldLetDirtySettings; } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KMainWindow::restoreWindowSize(const KConfigGroup &cg) { KWindowConfig::restoreWindowSize(windowHandle(), cg); } #endif -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KMainWindow::saveWindowSize(KConfigGroup &cg) const { KWindowConfig::saveWindowSize(windowHandle(), cg); diff --git a/src/kshortcutseditor.h b/src/kshortcutseditor.h --- a/src/kshortcutseditor.h +++ b/src/kshortcutseditor.h @@ -188,10 +188,11 @@ * * @param config Config object */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void exportConfiguration(KConfig *config) const; -#endif void exportConfiguration(KConfigBase *config) const; +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KShortcutsEditor::exportConfiguration(KConfigBase *config)") + void exportConfiguration(KConfig *config) const; +#endif /** * Import the settings from configuration @p config. @@ -201,10 +202,11 @@ * * @param config Config object */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void importConfiguration(KConfig *config); -#endif void importConfiguration(KConfigBase *config); +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KShortcutsEditor::importConfiguration(KConfigBase *config)") + void importConfiguration(KConfig *config); +#endif /** * Sets the types of actions to display in this widget. diff --git a/src/kshortcutseditor.cpp b/src/kshortcutseditor.cpp --- a/src/kshortcutseditor.cpp +++ b/src/kshortcutseditor.cpp @@ -166,7 +166,7 @@ d->clearConfiguration(); } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KShortcutsEditor::importConfiguration(KConfig *config) { d->importConfiguration(config); @@ -178,7 +178,7 @@ d->importConfiguration(config); } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KShortcutsEditor::exportConfiguration(KConfig *config) const { exportConfiguration(static_cast(config)); diff --git a/src/kshortcutwidget.h b/src/kshortcutwidget.h --- a/src/kshortcutwidget.h +++ b/src/kshortcutwidget.h @@ -63,14 +63,15 @@ */ void setCheckActionCollections(const QList &actionCollections); +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(4, 1) /** * @deprecated since 4.1 * Use setCheckActionCollections so that KShortcutWidget knows * in which action collection to call the writeSettings method after stealing * a shortcut from an action. */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void setCheckActionList(const QList &checkList); + KXMLGUI_DEPRECATED_VERSION(4, 1, "Use KShortcutWidget::setCheckActionCollections(const QList &)") + void setCheckActionList(const QList &checkList); #endif Q_SIGNALS: diff --git a/src/kshortcutwidget.cpp b/src/kshortcutwidget.cpp --- a/src/kshortcutwidget.cpp +++ b/src/kshortcutwidget.cpp @@ -78,7 +78,7 @@ return ret; } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(4, 1) void KShortcutWidget::setCheckActionList(const QList &checkList) { d->ui.priEditor->setCheckActionList(checkList); diff --git a/src/ktoolbar.h b/src/ktoolbar.h --- a/src/ktoolbar.h +++ b/src/ktoolbar.h @@ -144,23 +144,25 @@ */ int iconSizeDefault() const; // KDE5: hide from public API. Doesn't make sense to export this, and it isn't used. +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * This allows you to enable or disable the context menu. * * @param enable If false, then the context menu will be disabled - * @deprecated use setContextMenuPolicy() + * @deprecated Since 5.0, use setContextMenuPolicy() */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void setContextMenuEnabled(bool enable = true); + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy)") + void setContextMenuEnabled(bool enable = true); #endif +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * Returns the context menu enabled flag * @return true if the context menu is disabled - * @deprecated use contextMenuPolicy() + * @deprecated Since 5.0, use contextMenuPolicy() */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED bool contextMenuEnabled() const; + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use QWidget::contextMenuPolicy()") + bool contextMenuEnabled() const; #endif /** @@ -174,12 +176,13 @@ */ void applySettings(const KConfigGroup &cg); +#if KXMLGUI_ENABLE_DEPRECATED_SINCE(5, 0) /** * Sets the XML gui client. - * @deprecated use addXMLGUIClient() + * @deprecated Since 5.0, use addXMLGUIClient() */ -#ifndef KXMLGUI_NO_DEPRECATED - KXMLGUI_DEPRECATED void setXMLGUIClient(KXMLGUIClient *client); + KXMLGUI_DEPRECATED_VERSION(5, 0, "Use KToolBar::addXMLGUIClient(KXMLGUIClient *)") + void setXMLGUIClient(KXMLGUIClient *client); #endif /** diff --git a/src/ktoolbar.cpp b/src/ktoolbar.cpp --- a/src/ktoolbar.cpp +++ b/src/ktoolbar.cpp @@ -95,7 +95,7 @@ Private(KToolBar *qq) : q(qq), isMainToolBar(false), -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) enableContext(true), #endif unlockedMovable(true), @@ -152,7 +152,7 @@ KToolBar *q; bool isMainToolBar : 1; -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) bool enableContext : 1; #endif bool unlockedMovable : 1; @@ -847,14 +847,14 @@ delete d; } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KToolBar::setContextMenuEnabled(bool enable) { d->enableContext = enable; } #endif -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) bool KToolBar::contextMenuEnabled() const { return d->enableContext; @@ -885,7 +885,7 @@ } } -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KToolBar::setXMLGUIClient(KXMLGUIClient *client) { d->xmlguiClients.clear(); @@ -905,7 +905,7 @@ void KToolBar::contextMenuEvent(QContextMenuEvent *event) { -#ifndef KXMLGUI_NO_DEPRECATED +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) if (mainWindow() && d->enableContext) { QPointer guard(this); const QPoint globalPos = event->globalPos(); diff --git a/src/kxmlguibuilder.h b/src/kxmlguibuilder.h --- a/src/kxmlguibuilder.h +++ b/src/kxmlguibuilder.h @@ -82,9 +82,13 @@ virtual QAction *createCustomElement(QWidget *parent, int index, const QDomElement &element); +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) // KF6 TODO: REMOVE - /// @internal, @deprecated, do not use - virtual KXMLGUI_DEPRECATED void removeCustomElement(QWidget *parent, QAction *action); + /// @internal + /// @deprecated Since 5.0, do not use + KXMLGUI_DEPRECATED_VERSION(5, 0, "Do not use") + virtual void removeCustomElement(QWidget *parent, QAction *action); +#endif virtual void finalizeGUI(KXMLGUIClient *client); diff --git a/src/kxmlguibuilder.cpp b/src/kxmlguibuilder.cpp --- a/src/kxmlguibuilder.cpp +++ b/src/kxmlguibuilder.cpp @@ -393,10 +393,12 @@ return blank; } +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) void KXMLGUIBuilder::removeCustomElement(QWidget *parent, QAction *action) { parent->removeAction(action); } +#endif KXMLGUIClient *KXMLGUIBuilder::builderClient() const { diff --git a/tests/kmainwindowrestoretest.cpp b/tests/kmainwindowrestoretest.cpp --- a/tests/kmainwindowrestoretest.cpp +++ b/tests/kmainwindowrestoretest.cpp @@ -20,8 +20,11 @@ if (qApp->isSessionRestored()) { kRestoreMainWindows< MainWin1, MainWin2, MainWin3 >(); kRestoreMainWindows< MainWin4, MainWin5 >(); +#if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0) RESTORE(MainWin6); - //kRestoreMainWindows< MainWin6 >(); // should be equivalent to RESTORE() +#else + kRestoreMainWindows< MainWin6 >(); // should be equivalent to RESTORE() +#endif } else { MAKE_WINDOW(1, QStringLiteral("First 1")); MAKE_WINDOW(1, QStringLiteral("Second 1"));