Reunited after a decade

It’s been more than ten years since Dolphin, KDE’s versatile file manager, introduced its own custom QGraphicsView-based view engine. With that came more detailed view modes with grouping support, animated transitions, and a new places panel with sections. Unfortunately, it is all based on a now long-abandoned “Itemviews NG” project, and is inherently incompatible with Qt’s traditional model-view code used elsewhere in KDE.

Dolphin's (file manager) main window with sidebar of places (Home, Pictures, Documents, Downloads, Music, etc)
Looks virtually the same, doesn’t it?

A few weeks ago I sat down and over the course of a few evenings I ported Dolphin back to using the KFilePlacesView provided by KIO which is used in the Open and Save dialogs, among other places.

First of all, I had to look at what extra features were needed that either had to be replicated in KFilePlacesView or required the addition of hooks for Dolphin to provide them independently. For the longest time, the biggest roadblock has been the lack of sections, which luckily were added in late 2017. Furthermore, middle-click and control-click handling had to be added since file dialogs usually don’t have tabs.

I started by cleaning up and re-organizing the context menu, dropping redundant labels and making the order of items more consistent. Important actions, such as “Eject”, “Unmount”, and “Empty Trash” moved to the top, while entries for manipulating the view, e.g. icon size are only shown when clicking on an empty area. Dolphin was further put into position to add its own actions for “Configure Trash” or “Lock Panels” by using QWidget::addAction on the view itself. Depending on the QAction’s priority they either show up at the top or bottom of the context menu.

After that, I added additional signals: For instance, when clicking on a USB stick, we want to mount it before Dolphin opens a new tab or window. Its terminal panel also has a delicate procedure where it first changes to your home directory before trying to eject a drive it might be using, as to avoid a “bash is still accessing this device” error. Just the laborious things you have to do in order to provide an excellent user experience.

With a unified code base, we can look into adding features again

With all of that implemented, I was able to get rid of Dolphin’s custom places panel code, and deleted just over 4000 lines of code, which amounts to roughly 10 % of Dolphin’s overall code base! There are certainly some minor glitches in how the icons and free space bar is currently rendered, but sometimes perfect is the enemy of good, and with just a single implementation to worry about, we can use the upcoming months until the next KDE Gear release to thoroughly test and polish it up.

12 thoughts on “Reunited after a decade”

  1. Wow!!! What a clean up!!!
    It’s great to see this kind of improvements!
    Great job!!!

  2. I just checked dolphin code last week, and I remember that monstery kitemview still there.

    I have one question: Can porting away from it help to add the column view (or miller column) back? It was removed at dolphin2.0.

    https://bugs.kde.org/show_bug.cgi?id=387455

    I read been reading the relevant code from time to time, but still cannot get my head wrap around it.

  3. We need a hero who unifies plasma, dialogs, gwenview and dolphin codebases for showing icons, folders, etc.

  4. Wow, awesome! I had always wondered why dialogs and Dolphin views had to be different. I think it would be great if dialogs actually respected the .directory files that Dolphin sets, but that’s just me.

    Also echoing the same desire to have the column view too, I missed that, though I can’t imagine how much code it would take to put that back in.

  5. Few year ago I try to add RTL support to dolphin but it was hard because dolphin draw everything for some reason.
    Does that mean it will be easier to add RTL support?

    1. Some work has recently been done to improve RTL support in Dolphin. The view e.g. flips correctly nowadays.

      The Places panel seems to already have decent-enough RTL support. Anything else in Dolphin is untouched by this.

Leave a Reply

Your email address will not be published. Required fields are marked *