Dolphin got the ability to send the events when the user opens a directory to the activity manager. It is quite a small patch that I decided to share in order to demonstrate how easy it is to use KActivities API.
Find the widget that displays your document (in this case, a folder). Declare one KActivities::ResourceInstance object inside it
When you create the container, just create a new ResourceInstance and pass the window id (of the top-level window that your container resides in) and the url you just opened:
This is it if you have a SDI (single-document interface) - interface where one main window can contain only one document (okular, kwrite etc.)
If you have a possibility to have multiple documents inside one window (dolphin, konqueror, kate etc.), you’ll need to do some additional things:
If your component lost the user’s focus (switched to another document), call:
When it receives the focus, call:
And when the url of the document that is shown changes (user opens another file, navigates to another web page), just call:
This is all.
This info is used for the share-like-connect applet and to rank the locations users visit. This can be, in turn, used to sort applications, documents etc. in krunner based on the ranking; to show most recent documents for pinned applications in the task bar etc.
Although every system tracks the user’s behaviour in some way, it might not be something the user desires. This will be configurable - see this for more info
For the whole ResourceInstance API, see: api.kde.org/KActivities::ResourceInstance