Bundling AppImages with Themes.

One of the projects which I have been undertaking in recent weeks has been, to teach myself GUI programming using the Qt5 GUI Library, of which I have version 5.7.1 installed on a good, tower computer, along with the IDE “Qt Creator”. What can be observed about this already is, that under Debian 9 / Stretch, which is a specific build of Linux, in addition to just a few packages, it’s really necessary to install many additional packages, before one is ready to develop Qt Applications, because of the way Debian breaks the facility into many smaller packages. Hypothetically, if a person was using the Windows, Qt SDK, then he or she would have many of the resources all in one package.

Beyond just teaching myself the basics of how to design GUIs with this, I’ve also explored what the best way is, to deploy the resulting applications, so that other people – technically, my users – may run them. This can be tricky because, with Qt especially, libraries tend to be incompatible, due to even minor version differences. So, an approach which can be taken is, to bundle the main libraries required into an AppImage, such that, when the developer has compiled everything, the resulting AppImage – a binary – is much more likely actually to run, on different versions of Linux specifically.

The tool which I’ve been using, to turn my compiled binaries into AppImage’s, is called ‘linuxdeployqt‘, and is not available in the Debian / Stretch repositories. However, it does run under …Stretch.

But a developer may have questions that go beyond just this basic capability, such as, what he or she can do, so that the application will have a predictable appearance – a “Style” or “Theme” – on the end-user’s Linux computer. And essentially, I can think of two ways to approach that question: The ‘official but slightly quirky way’, and ‘a dirty fix, that seems to get used often’…

The official, but slightly quirky way:

Within the AppImage, there will be a ‘plugins’ directory, within which there will be a ‘platformthemes’ as well as a ‘styles’ subdirectory. It’s important to note, that these subdirectories serve officially different purposes:

  • The ‘platformthemes’ subdirectory will contain plugins, that allow the application to connect with whatever theme engine the end-user’s computer has. Its plugins need to match libraries that the eventual user has, determining his desktop theme, And
  • The ‘styles’ subdirectory may contain plugins, which the end-user does not have installed, but were usually compiled by upstream developers, to make use of one specific platform-engine each.

Thus, what I had in these directories, for better or worse, was as shown:

 

dirk@Phosphene:~/Programs/build-Dirk_Roots_GUI_1-Desktop-Release/plugins/platformthemes$ ls
KDEPlasmaPlatformTheme.so  libqgtk2.so  libqgtk3.so
dirk@Phosphene:~/Programs/build-Dirk_Roots_GUI_1-Desktop-Release/plugins/platformthemes$ 


dirk@Phosphene:~/Programs/build-Dirk_Roots_GUI_1-Desktop-Release/plugins/styles$ ls
breeze.so  libqgtk2style.so
dirk@Phosphene:~/Programs/build-Dirk_Roots_GUI_1-Desktop-Release/plugins/styles$ 

 

The reader may already get, that this was a somewhat amateurish way, to satisfy themes on the end-user’s machine. But in reality, what this set of contents, of the AppImage, does rather well is, to make sure that the 3 main theme engines on an end-user’s computer are recognized:

  1. Gtk2,
  2. Gtk3,
  3. Plasma 5.

And, if the application tries to make no attempts to set its own theme or style, it will most probably run with the same theme, that the end-user has selected for his desktop. But, what the point of this posting really is, is to give a hint to the reader, as to how his AppImage could set its own theme eventually. And so, according to what I just cited above, my application could choose to select “Breeze” as the Style with which to display itself, or “Gtk2″. But, here is where the official way gets undermined, at least as the state of the art was, with v5.7.1 of Qt:

  • ‘Breeze’ can only be set (by the application), if the end-user’s machine is running Plasma 5 (:1), And
  • ‘Gtk2′ can only be set (by the application), if the end-user’s machine supports Gtk2 themes, which many Plasma 5 computers have the additional packages installed, to do.

What this means is that, even though I could try to create a predictable experience for the end-user, what the end-user will see can still vary, depending on what, exactly, his platform is. And beyond that, even though I could set the ‘Gtk2′ Style with better reliability in the outcome, I could also just think, that the classical, ‘Gtk2′ style is a boring style, not worthy of my application. Yet, in this situation, I can only select the “Breeze” theme from within my application successfully, if the end-user is based on Plasma 5. If the end-user is not, then my application’s attempt to set “Breeze” will actually cause Qt v5.7.1 to choose the “Fusion” theme, that Qt5 always supports, that might look okay, but that is not “Breeze”…

 

So, what other options does the application developer have?

(Updated 9/12/2020, 18h15… )

Continue reading Bundling AppImages with Themes.

Getting the integrated equalizer to work, from Debian Jessie, KDE 4.

I happen to have an older laptop, which I name ‘Klystron’, that is running Debian 8 / Jessie, with KDE 4 as its desktop manager. Don’t ask me why, but I tend to leave older builds of Linux running on some of my computers, just because they seem to be running without any deficiencies.

That laptop has lousy speakers. I decided a few days ago, that it would benefit, if I could get the 14-band graphical equalizer to work, that is generally available on Linux computers which, like that laptop, use the ‘PulseAudio’ sound server. However, on this old version of Linux, achieving that was a bit harder than it’s supposed to be. Yet, because I succeeded, I felt that I should share with the community, what the steps were, needed to succeed.

First of all, this is what the equalizer looks like, which I can now open on that laptop:

Equalizer_1

And it works!

 

In order to get this sort of equalizer working with PulseAudio, eventually, the following two modules need to be loaded:

module-equalizer-sink

module-dbus-protocol

And, if I gave the command ‘load-module…’ naively from the command-line, as user, because under my builds of Linux, PulseAudio runs in user mode, both these modules seem to load fine, without my having to install any additional packages.

On more recent builds of Linux, one needs to install the package ‘pulseaudio-equalizer’ to obtain this feature, or some similarly-named package. But, because these two modules just loaded fine under Debian / Jessie, I guess the functionality once came integrated with PulseAudio.

But I soon started to run in to trouble with these modules, and discovered why, then, the equalizer function was not set up to run out-of-the-box…

(Updated 6/26/2020, 10h30… )

Continue reading Getting the integrated equalizer to work, from Debian Jessie, KDE 4.

Changing the <Alt>+(LMB-Drag) behaviour of Linux, under the Plasma 5 desktop manager.

One of the realities of many graphics / editing applications is, that the action to drag either an object or one of its handles with a mouse, or with any other pointing-device, needs to be modified in several ways, depending on what, exactly, the user expects the application to do. I have recently encountered a Web-application, which therefore displays in a Web-browser, in which to hold down the Shift-Key while dragging the corner of a rectangle does one thing, holding down the Ctrl-Key while doing so does another, and holding down the Alt-Key performs yet-another action, which in this case was, to draw an ellipse instead of a rectangle. And in this Web-application, the ability to draw circles or ellipses would eventually become important.

The problem with any application that has this as one of the inputs it accepts, is that such applications were never designed with Linux in mind. The reason is the fact that, under Linux desktop-managers, to <Alt>+(LMB-Drag) gets intercepted, and has as effect to drag the entire application window. That Web-application never receives such a combination of inputs.

Fortunately, if the desktop-manager is one of the ‘Plasma 5′ sub-versions, there is a way to change that behaviour. It can be found under:

System Settings -> Application Style -> Widgets Style and Behaviour -> Applications Tab -> (Breeze Theme from Drop-Down) -> (To the right of the theme chosen from the Drop-Down) Configure… -> General Tab -> Windows’ drag mode -> (From the drop-down) ‘…Titlebar Only’.

That last drop-down is not wide enough to show its full text.

The reason this defaults to ‘Anywhere from within the window’, is a fear that might exist, that an application’s window could end up very-incorrectly positioned on the screen, and that a user might not be able to change that position, by the next time he starts the application. I.e., some applications remember their window-position from one session to the next, and it could be screwed up. If this behaviour is changed, <Alt>+(LMB-Drag) will only drag the window, and therefore be intercepted before it reaches the application, if the mouse-pointer can be positioned over the window’s title-bar.

Continue reading Changing the <Alt>+(LMB-Drag) behaviour of Linux, under the Plasma 5 desktop manager.

About the Frame-Rate of Hardware-Accelerated Animations.

One of the subjects which I’ve posted about before, is that in the case of typical hardware-accelerated animations, the frame-rate, which some people just know as ‘the FPS of the animation’, is actually lower than the refresh-rate of the monitor.

Well, if the user is running Plasma 5 as his desktop-manager – which is Linux-based – then he can open ‘System Settings -> Desktop Behaviour -> Desktop Effects’, and he will see a list of available compositing effects, that would all be hardware-accelerated, and under the section of ‘Tools’, there is an effect named ‘Show FPS’. Enabling that effect, and then clicking on ‘Apply’, will cause a piece of OSD information to display, that actually shows the frame-rate. The user will notice that it does not equal the refresh rate of his monitor.

But there is a catch to this. Often, the rendering software will place an upper limit on the frame-rate. Frame-rates actually higher than the refresh rate of the display device accomplish no useful purpose, and there used to be a simple, command-line test which Linux users could run, which was called ‘glxgears’. This would display a very simple animation, of a red, a green and a blue gear, rotating smoothly. In very early versions of this test-program, a frame-rate of something unreasonable, such as 2000 or maybe even 5000 FPS might result, which simply represents a waste of GPU power. The gears would still rotate at the same, correct apparent speed, but each frame-cycle would be fewer than 1 millisecond apart on average. Therefore, more-recent versions of this test-program will cap the frame-rate at the refresh rate of the monitor, and the gears will display as rotating at the same, smooth speed.

Dirk