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.
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 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.