Radu Rendec

Qt Looks in Fedora 24

OK, so I recently upgraded to Fedora 24. Not so many surprises, but one of them was that suddenly the scrollbars in all Qt applications used a different theme. Most probably not only the scrollbars, but those were strikingly different.

As a background, I'm using MATE Desktop on Fedora, with the TraditionalOk theme and Mist icon set. So normally my desktop looks pretty much like the default Gnome 2 desktop before Fedora 15 (when they decided to drop Gnome 2, because it had been discontinued upstream).

To begin with, Fedora 24 is at the transition point between Qt 4 and Qt 5. For this reason, older applications still use Qt 4, while newer have switched to Qt 5 already. And of course there are some legacy applications like Skype for Linux that are stuck on Qt 4. This is not a problem at all, but it may not be obvious to you (as it wasn't to me before I ran into this problem) that Qt 4 and Qt 5 have totally different configuration systems.

Fixing Qt 4 Appearance

  • Install the qt4-config package and then run qtconfig-qt4.
  • In the default Appearance tab, select GTK+ for GUI Style.
  • Click File - Save. That's it, you're done. Now Qt 4 applications are fixed.

Fixing Qt 5 Appearance

Quoting from the official release notes, Fedora 24 introduces QGnomePlatform, a Qt Platform Theme that aims to take as many of the GNOME settings as possible and apply them directly to Qt applications, thus enabling the Qt applications to fit more consistently into the GNOME Desktop.

So all you have to do is install the qgnomeplatform package and then suddenly all Qt 5 applications will start to look like your GTK theme. They will even use the GTK file dialogs. This is awesome.


udisks2 Mount Path

udisks2 is the package that (among many other things) is responsible for automatically mounting removable media under /media. Well, not directly under /media - it creates on-the-fly a new subdirectory with the volume label (or uuid, or serial number, depending on the mounted filesystem type) and then mounts the removable media in that subdirectory.

Starting with Fedora 17, udisks2-1.94, the mount path has changed from /media to /var/run/media/<username>, where username represents the currently logged in user. If you use the command line a lot (like I do), it's not very convenient to type all these path components (even with autocompletion). Perhaps the reason behind this change was to avoid mount point conflicts (and permission problems for filesystems that don't support UNIX permissions) between multiple logged in users. But I doubt that two (or more) different users can mount the same volume in two different places at the same time.

I created a small patch against udisks-1.94 that reverts the mount location to /media. The patch is trivial, it just disables the code block that calculates the path in /var/run. Fallback to the old /media location was already implemented.

GTK3 Legacy Behaviour

Starting with the very decision of discontinuing Gnome 2 and writing Gnome 3 from scratch, the Gnome developers have had a strange way of innovating. The early versions of Gnome 3 were barely customizable, with a lot of features that had matured and stabilized in previous versions being completely gone. Since that moment on, the developers have continued in the same manner, by radically changing or completely removing features, without any way of reverting to the old behaviour. They started making choices for their users, instead of letting the users choose by themselves. And they have been constantly insisting on this policy.

Luckily, users still have the choice of completely switching to a different desktop environment. Just like I did. As I had been using Gnome for a long time (and considered Gnome 2 a mature and robust desktop environment), the natural choice for me was MATE Desktop Environment, which I have been consistently using ever since.

However, the GTK3 library suffers from the same obtuse policy of limiting users' freedom, and recently many important desktop applications (such as Firefox and LibreOffice) have switched to GTK3. For users like me who don't want their desktop to start behaving differently over the night, perhaps one of the most annoying things in recent GTK3 versions is the default behaviour of the file chooser. This article mentions some popular GTK3 problems and the solutions to fix them.

Overlay Scroll Bars

By default, scrollbars are now hidden and appear on-demand, when you hover the mouse over the scrollable area edge. The problem is that they are rendered over the scrollable area content, hiding some of it. If you prefer traditional scrollbars, you can switch back to the old behaviour by adding this to your .bash_profile file:



Show Directories First in File Chooser

By default, the GTK3 file chooser mixes directories and files in the list. If you're looking for a particular directory in the list, this makes it harder to find it. This can be easily changed by a configuration option:

gsettings set org.gtk.Settings.FileChooser sort-directories-first true

If you prefer a GUI, there's dconf-editor, which allows you to browse to /org/gtk/Settings/FileChooser, see a list of available settings and their allowed values and change them as you like.


File Chooser Typeahead Search

In previous GTK versions, you used to be able to focus on any file/directory in the list, start typing, and this would jump to the matching file/directory in the already loaded list. In newer GTK3 versions this is no longer possible. Starting to type switches the list to recursive search results matching what you typed. If you have a large directory structure, this is not only very slow and resource consuming, but also completely useless - because you end up with a dozen of search results from not only the current directory but also subdirectories at any level, all mixed together in a flat list.

Unfortunately, at the time of writing this there is no setting for changing this behaviour and the only way to fix it is to patch GTK3 and recompile. The patch is available in a custom ArchLinux package. I also built some custom GTK 3.20.6 packages for Fedora (see below).


File Chooser Single Click Selection

In previous GTK versions, you used to have to double click on a file or directory in order to choose it. By "choose" I mean pick that file for open/save and close the file chooser. This is not to be confused with "select", which means just moving the focus on that file in the list.

In newer GTK3 versions this is no longer the case. The new behaviour is to use single click, but even that is not consistent:

  • If the file/directory is already selected, then a single click will choose it as expected (or recurse into it, if it's a directory). If you double click on it (because you're used to the old behaviour), it will not be handled as a double click event. It will be handled as two single click events. The first one will choose the file/directory. And, mostly annoying, if the first click recursed into a directory, the second click will choose whatever is there (at that mouse pointer position) in the previously chosen directory.
  • If the file/directory is not already selected, then the first click will not choose it, it will just select it. The second click will choose it. Again, if you double click, it will handle two single clicks (not a double click), but the behaviour will be similar to the old double click.

Unfortunately, at the time of writing this there is no setting for changing this behaviour and the only way to fix it is to patch GTK3 and recompile. The change was introduced by a single commit, which can be reverted. The reverse commit does not no longer apply cleanly on GTK 3.20.6, but can be easily applied manually. I also built some custom GTK 3.20.6 packages for Fedora (see below) and you can take the patch from there.


Custom Fedora Packages

Custom Fedora GTK3 packages that contain both the typeahead and the single click fix are available in my copr repository.