Inspirational quote

Once upon a time,
for those who remember the old days of Plasma and Lancelot,
there was an experimental applet called Shelf.

The idea behind the Shelf was that sometimes it is useful to have a small applet
that just shows your recent files,
favourite applications,
devices,
which you can place on your panel or desktop for quick access.

Now,
this post is not about a revival of Lancelot and Shelf (sadly),
but it is closely related to them.

Namely,
I always disliked the “recent documents” section
that is available in almost all launchers in Plasma.
The reason is that only one in ten of those documents
has a chance to ever be opened again.

The first code that had the aim to fix this
landed in Lancelot a long time ago
–
Lancelot was tracking how you use it so that it could eventually
start predicting your behaviour.

This idea was recognized as a good one,
and we decided that Plasma as a whole could benefit from this.

This is how the activities manager (KAMD) was born.
The aim was to allow the user to separate the workspace
based on the project she was working on;
and to have the activity manager track
which applications, documents etc. the user uses in each of the activities.

The first part – having different widget sets for different activities was baked in Plasma 4 from the start.
The second one (which I consider to be much more important) came much later in the form of KAMD.

KAMD, apart from being tasked to manage activities and switch from one to another,
also tracks which files you access,
which applications you use
so that the menus like Kicker and Kickoff
can show recent documents and recent applications.
And have those recent documents and applications tied to the activity you are currently in.

For example,
if you have two activities –
one for KDE development,
and another for working on your photo collection,
Digikam will be shown in the recent applications section of Kicker only for the second activity,
since you haven’t used Digikam for KDE development.

Now,
this is still only showing the “recent documents”.
It does show a list of documents and applications
that are relevant to the task you are currently working on,
but still, it can be improved.

Since we know how often you open a document or start an application,
we do not need to focus only on the last time you did so.
We can detect which applications and documents you use often
and show them instead.
Both Kicker and Kickoff allow you to replace the “recently used” with “often used” in the current version of Plasma.

Documents shelf

While working on the KAMD service,
I often need to perform tests whether it
keeps enough data for it to be able to deduce which are the important applications and documents,
and whether the deduction logic performs well.

Most of these tests are small GUI applications
that show me the data in a convenient way.

For one of these,
I realized it is not only useful for testing and debugging,
but that it might be useful for the day-to-day work.

In the screenshot above,
you can see an applet,
that looks quite similar to Shelf from Plasma 4 days
which shows the files I use most often in the dummy “test” activity.

One thing that Shelf did not have,
and neither Kicker nor Kickoff have it now
is that this applet allows you to pin
the documents that are really important to you
so that they never disappear from the list
because the service thinks some other file is more important.

You can think of it as a combination of “often used” and “favourite” documents.
It shows your favourite documents – the documents you pinned,
and then adds the items that it considers worthy enough
to be alongside them.

This applet is not going to be released with the next Plasma,
it needs to evolve a bit more before that happens.
But all the backend stuff it uses is released and available now
if you want to use it in your project.

The keywords are kde:kactivities, kde:kactivities-stats and kde:kactivitymanagerd.

For people unaware of this conference,
it is the annual conference of KDE contributors.

We tend to have a few dozen of high quality talks
on various topics ranging from art and community building,
to hard-core Qt and C++ talks.

This year,
I’m going to have two talks.
One on (obviously :) ) functional programming in C++,
and one on C++17 and 20.
The later one will be a bit self-serving because I’d like
us to raise the compiler requirements for our software
so that we could enjoy working in KDE even more.

The only thing more important
than talks is the period after
where the different teams within KDE
meet-up to discuss the future plans.
While we do it all the time on IRC
and on the mailing lists,
having face-to-face meetings is irreplaceable.

If you are near Almeria,
join us
–
the conference is free for attendance!

This will require some serious mental and physical preparation.
I’ve never had a talk two hours long. :)

If you are in area,
and you speak Russian
(My keynote will be in English since, despite having a Russian-sounding name, I don’t speak Russian),
come and join us –
the tickets are available at the conference website.

Sometimes, we need to create wrapper types.
For example,
types like unique_ptr, shared_ptr, optional and similar.

Usually,
these types have an accessor member function called .get
but they also provide the operator-> to support
direct access to the contained value
similarly to what ordinary pointers do.

The problem is that sometimes we have a few of these types
nested into each other.
This means that we need to call .get multiple times,
or to have a lot of dereference operators
until we reach the value.

Something like this:

wrap<wrap<std::string>>wp;wp.get().get().length();wp.get()->length();

This can be a bit ugly.
If we can replace one .get() with an arrow,
it would be nice if we could replace the second .get() as well.
For this, the C++98 introduced a long arrow operator.

wrap<wrap<std::string>>wp;wp--->length();

What if we have another layer of wrapping?
Just make a longer arrow.

wrap<wrap<wrap<std::string>>>wp;wp----->length();

With a special implementation of wrap,
this compiles and works without many problems.

Disclaimer

Now, before we continue,
you should realize that this post is not a serious one.
And that this should never be used in a serious project,
just like the left arrow operator <--[1]
and the WTF operator ??!??![2] (which no longer works in C++17 BTW).