Decouple KBookmarksMenu from KActionCollection
ClosedPublic

Authored by nicolasfella on Dec 1 2019, 4:56 PM.

Details

Summary

The usage of KActionCollection makes KBookmarks depend on KXMLGui. To allow to get rid of this rather heavy dependency for KF6 a new constructor is introduced that does not take a KActionCollection. Instead apps that use KBookmarksMenu and KXMLGui are encouraged to manually add the relevant actions to their action collection. It's not pretty, but better than depending on KXMLGui, especially given that KIO depends on KBookmarks and thus on KXMLGui.

Test Plan

Tested with patched Dolphin (new constructor is used) and unpatched Konsole.

Diff Detail

Repository
R294 KBookmarks
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nicolasfella created this revision.Dec 1 2019, 4:56 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 1 2019, 4:56 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
nicolasfella requested review of this revision.Dec 1 2019, 4:56 PM
apol added a subscriber: apol.Dec 1 2019, 5:21 PM

Maybe this is too of an intermediate step? this patch doesn't really do anything.

nicolasfella planned changes to this revision.Dec 1 2019, 5:35 PM

I can do it with the rest of the patch

  • Decouple from KActionCollection
nicolasfella retitled this revision from Add member for editbookmarks action to Decouple KBookmarksMenu from KActionCollection.Dec 1 2019, 8:48 PM
nicolasfella edited the summary of this revision. (Show Details)
nicolasfella edited the test plan for this revision. (Show Details)
dfaure requested changes to this revision.Jan 12 2020, 11:56 AM
dfaure added a subscriber: dfaure.

Thanks for the patch.

Please call setObjectName() on the actions so that their object name is fixed (no matter which ctor is used). (this is because KActionCollection::addAction calls setObjectName on the actions)

This can even help apps to just get all 3 actions and put them into an action collection without having to copy the standard names from the documentation.

QAction *addAction = menu->addBookmarkAction();
actionCollection()->addAction(addAction->objectName(), addAction);

Maybe you can use the C++11 feature of one ctor calling another to avoid the setup() method which will look even more strange once the deprecated ctor is removed.

The @since value needs to be updated obviously.

src/kbookmarkmenu.cpp
338

The m_bIsRoot check disappeared in the refactoring!

Actions in submenus should not be named.

Same thing for the action named add_bookmarks_list above.

This revision now requires changes to proceed.Jan 12 2020, 11:56 AM

Some API (docs) nitpicks :)

src/kbookmarkmenu.cpp
89

Why the QLatin1String("") instead of QString()? Is there a need for a non-null empty string? It#s copied from the other constructor, but should get a comment while at it if that is the case, or just get to be QString()

src/kbookmarkmenu.h
94

The visibility guard for deprecated methods should start before the API dox , if only for consistency, so please move to front.

See https://community.kde.org/Policies/Library_Code_Policy#Deprecation_of_API

103
105

Note: -> @note

108

No such parameter "collec"?

111

"mgr" -> "manager" while at it, please

147

Official casing is "KXmlGui" :) Also below.

147

This being a method, not a property "Action which is" is not the perfect text, please describe what the method does (getting access to the action owned by the menu).

152

Please add a @return ... here and to the other methods, so e.g. IDEs can have better metadata avaialble.

154

Can be const methods, no?

nicolasfella marked 11 inline comments as done.
  • Decouple from KActionCollection
  • Set action name
  • Restore root check
  • Use constructor delegation
  • Update since
  • fix docs
  • Docs fixes
  • Use QString()
  • Make methods const
  • Rename parameter
dfaure accepted this revision.Mar 22 2020, 10:18 PM

Oops I forgot to review this again after your last changes.

Looks fine to me now, but meanwhile it needs s/5.67/5.69/ everywhere (docu and deprecation macros).
Feel free to land if you check that there's no 67 anywhere in the diff.

This revision is now accepted and ready to land.Mar 22 2020, 10:18 PM
This revision was automatically updated to reflect the committed changes.

As usual, it's the too strong "no deprecated API usage" define in the apps.

Fixed.

Thanks. That macro really does cause quite a bit of trouble...

Thanks. That macro really does cause quite a bit of trouble...

It is not the macro, but using it with a future version of 0x060000.

See https://marc.info/?l=kde-devel&m=157190321318565&w=2 for details.

@mlaurent AFAICS you removed the deprecation macro completely in master, and left it (with 0x060000) in release/20.04?

I thought we wanted

  • to remove it in release/20.04 (or set it to a tested value like 0x053A00)
  • to set it to a tested value in master so we can increase it regularly (after verifying compilation)

If you don't have a release/20.04 checkout I can look into making the changes there.

Just as reminder:
When keeping the use of the macro flags, make sure to

  • also set the *_DEPRECATED_WARNINGS_SINCE flags to 0x060000, otherwise deprecation warnings for newer API will no longer be shown, due to default set by *_DISABLE_DEPRECATED_BEFORE*
  • remove the if (EXISTS "${CMAKE_SOURCE_DIR}/.git") wrapper, to ensure released builds see the same API as developer builds (chance of running otherwise into method overloads/implicit conversions)

This would be the recommended use to control limit of deprecated API not visible to compiler and limit of until which version use of deprecated API will be warned about:

add_definitions(
    # hide deprecated API of Qt <= 5.9
    -DQT_DISABLE_DEPRECATED_BEFORE=0x050900 
    # enable warnings for API up to Qt 6.0
    -DQT_DEPRECATED_WARNINGS_SINCE=0x060000
    # hide deprecated API of KF <= 5.48
    -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x053000
    # enable warnings for API up to KF 6.0
    -DKF_DEPRECATED_WARNINGS_SINCE=0x060000
)

@mlaurent AFAICS you removed the deprecation macro completely in master, and left it (with 0x060000) in release/20.04?

nope or I missed to forward port in 20.04. So it's an error.
but by default There is not some 0x060000 in 20.04