Closed probonopd closed 1 year ago
If this means my Qt application will look more native on a GTK sytem - yes, definitely.
Which of the platformthemes are the "standard" ones and should be copied in? Can you send a PR?
I don't see such a folder in my Qt installation. I can't send a pr in, sorry.
libqgtk2.so to have a gtk look on qt5
You would need all plugins I would say. Plus QT_PLUGIN_PATH}/styles
Now there is a bit of a chicken and egg situation here. If you just add the ones which are installed on the machine the appimage gets packed, you will miss out some which are installed on the target system. You cannot guess which style/theme is used on the target systems. So if you do not ship with all, the appimage will look like an alien in some target systems.
So I guess its the best to have a list of all possible qt5 styles' and themes' .so files beforehand (the most common, I count 8 at archlinux wiki), and compare these with the ones installed in the qt5 installation of the machine the appimage gets packed, and then inform/warn the user of the fact that if he does not have all the platformthemes and styles installed in his plugins folder, that his app will not look right in different target systems.
If applicable, it would be wise to host these plugins here on github, (for each qt version I guess - or maybe one set of .so's work across more than one version/qtbase-abi...?), and insert them automatically.
Or provide a quick apt-get install or yum install list suggestion depending on the distro linuxdeployqt is run on, or maybe ask the user if linuxdeployqt itself should install these themes/styles via package system before building the appimage.
Can't Qt be made look for platform themes in one place and the rest in another? How do they solve it on Windows/macOS?
It is super important never to mix Qt versions. So if we bundle Qt (which we do) we must make sure that Qt themes are never loaded from the system or else we will crash. Check out the Krita AppImage, it ships with a dark Qt theme.
never loaded from the system or else we will crash.
I suspected that.
The way to solve it, from my point of view, is to ship the themes and styles, with ALL their dependencies, that is, you also will need to package GTK it you plan to also support libqgtk2.so (and related) themes.
That is for sure overkill for the average user, but some definitely strive to have a consistent desktop experience for their Apps, and a Dark theme does not necessarily help there.
What would be nice from a user perspective would be to have a possibility to ship the themes with all the dependencies if demanded, e.g. through an extra flag, and that the User is being hinted/warned that when generating the Appimage as it happens now, theme inconsistencies are gonna happen.
you also will need to package GTK
No, since we consider Gtk+2 to be ABI stable and part of each target system.
So we would "only" have to bundle all Qt-GTK parts (libraries, plugins, themes, whatever is needed), if a certain extra flag was specified.
PR welcome!
libgtk2.0 is part of a kde-based distro?
ok, here are the dependecies of the platformthemes and styles:
libqgtk2.so libqgtk2style.so NEEDED libgtk-x11-2.0.so.0 NEEDED libgdk-x11-2.0.so.0 NEEDED libgdk_pixbuf-2.0.so.0 NEEDED libpango-1.0.so.0 NEEDED libgobject-2.0.so.0 NEEDED libglib-2.0.so.0 NEEDED libX11.so.6 NEEDED libQt5Widgets.so.5 NEEDED libQt5Gui.so.5 NEEDED libQt5Core.so.5 NEEDED libstdc++.so.6 NEEDED libm.so.6 NEEDED libc.so.6
libqcleanlooksstyle.so libqmotifstyle.so libqplastiquestyle.so NEEDED libQt5Widgets.so.5 NEEDED libQt5Gui.so.5 NEEDED libQt5Core.so.5 NEEDED libstdc++.so.6 NEEDED libm.so.6 NEEDED libc.so.6
breeze.so qtcurve.so NEEDED libqtcurve-utils.so.2 NEEDED libKF5KDELibs4Support.so.5 NEEDED libKF5XmlGui.so.5 NEEDED libQt5PrintSupport.so.5 NEEDED libKF5IconThemes.so.5 NEEDED libQt5Svg.so.5 NEEDED libKF5ConfigWidgets.so.5 NEEDED libKF5GuiAddons.so.5 NEEDED libKF5WidgetsAddons.so.5 NEEDED libKF5WindowSystem.so.5 NEEDED libKF5ConfigCore.so.5 NEEDED libQt5DBus.so.5 NEEDED libQt5X11Extras.so.5 NEEDED libQt5Widgets.so.5 NEEDED libQt5Gui.so.5 NEEDED libQt5Core.so.5
oxygen.so NEEDED libKF5Style.so.5 NEEDED libKF5WindowSystem.so.5 NEEDED liboxygenstyle5.so.5 NEEDED libxcb.so.1 NEEDED libKF5WaylandClient.so.5 NEEDED libKF5ConfigWidgets.so.5 NEEDED libKF5GuiAddons.so.5 NEEDED libQt5X11Extras.so.5 NEEDED libKF5ConfigGui.so.5 NEEDED libKF5ConfigCore.so.5 NEEDED libQt5Widgets.so.5 NEEDED libQt5DBus.so.5 NEEDED libQt5Gui.so.5 NEEDED libQt5Core.so.5 NEEDED libstdc++.so.6 NEEDED libm.so.6 NEEDED libc.so.6
so for breeze, qtcurve, oxygen as default, one would have to ship parts of kde libs...
I now query the QT_QPA_PLATFORMTHEME variable of the system and then set the theme accordingly. But doing so, on a system where QT_QPA_PLATFORMTHEME is set to gtk2, and with the gtk2 platformtheme and style installed, results in this error (vanilla xubuntu 17.10 daily image)
QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.
QCommonStyle::drawComplexControl: Control 1 not handled
as well as this appearance:
instead of
If I try to install the qt5-gtk-platformtheme plugin via debian package in xubuntu 17.10, it shows these dependencies
libdouble-conversion1 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5
libqt5widgets5 libxcb-icccm4 libxcb-image0 libxcb-keysyms1
libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1
libxkbcommon-x11-0 qt5-gtk-platformtheme
Try running with LD_DEBUG=libs your.AppImage
to see what is being loaded and what fails to load.
https://pastebin.com/8bUR910v
notably, I have a
/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0: error: symbol lookup error: undefined symbol: hb_font_funcs_set_variation_glyph_func (fatal)
and it tries to find all the libs I get when installing libgnomeui-0, that is
libbonobo2-0 libbonobo2-common libbonoboui2-0 libbonoboui2-common libglade2-0 libgnome-2-0 libgnome-keyring-common libgnome-keyring0 libgnome2-common libgnomecanvas2-0 libgnomecanvas2-common libgnomeui-0 libgnomeui-common libgnomevfs2-0 libgnomevfs2-common liborbit-2-0
I found elsewhere this answer to install libgnomeui-0 when searching for a solution to "could not resolve GTK". So note: while xfce is a GTK-based desktop, it did NOT have the necessary libs shipped!
Obviously, when I try to install these on the target system via package-manager, the app tries to link against them, which results in a segfault. So I am not entirely shure about ABI stability helps here. So you will have to ship all these libs in the appimage for proper theming. You will have to rethink that anyways if you get kde-based themes into play, as well as qt5.8+ switching the theme /style plugins to gtk3... Does not seem to be a trivial task, also given the fact that the machine where the appimage gets created would need to have all these installed..
I'm asking myself whether it's a good idea to depend on GNOME when all we (probably) really want is to render in Gtk+ 2.
What exactly pulls in libgnomeui-0?
nothing I guess - but the style does not work when its not bundled. Even if the style now works, the theme (the color which is set in the system theme, that is, does not...
Some Qt expert is needed here. Maybe ask on the Qt mailing list how this needs to be deployed so that it works.
Interesting: The AppImages from https://download.opensuse.org/repositories/home:/rncbc/AppImage/ look correctly themed on XFCE:
See https://github.com/AppImage/AppImageKit/issues/125 for further analysis. Turns out that this could be achieved whithout the need to bundle platformthemes or anything else.
Seems to be fixable when using Qt 5.9.3 and copying the platform themes to the AppDir.
See e.g., https://github.com/probonopd/quassel/commit/b75a57c1212948d713fff576d293e93ff22dd4ba.
With the platformtheme, the font now looks like in XFCE but the colors still don't...
Probably due to the lack of a pretty GTK(3?) theme for XFCE (uses GTK2). Some Qt apps lack a "native" look on my xubuntu 16.04. Might not even be the platform themes' fault.
Another idea: we might bundle the wrong one. On my system, the only available platform theme is /usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/KDEPlatformTheme.so
.
If true, then I want the gtk2 platformtheme back. And we need a KDEPlatformTheme.so as well. If I remember correctly someone had made a special version with few dependencies for use with AppImage.
Is just using Qt 5.9.3 and the latest linuxdeployqt
enough to get this change, or is some coding per https://github.com/probonopd/quassel/commit/b75a57c1212948d713fff576d293e93ff22dd4ba needed?
We upgraded to 5.9.3 but I don't see a change in theming - it's still using Fusion.
@vadi2 check whether your AppImage contains a directory usr/plugins/platformthemes/
, and describe its contents please.
/tmp/.mount_Mudlet5HkMB5/plugins$ tree
.
├── audio
│ ├── libqtaudio_alsa.so
│ └── libqtmedia_pulse.so
├── bearer
│ ├── libqconnmanbearer.so
│ ├── libqgenericbearer.so
│ └── libqnmbearer.so
├── imageformats
│ ├── libqgif.so
│ ├── libqico.so
│ └── libqjpeg.so
├── mediaservice
│ ├── libgstaudiodecoder.so
│ ├── libgstcamerabin.so
│ ├── libgstmediacapture.so
│ └── libgstmediaplayer.so
├── platforminputcontexts
│ ├── libcomposeplatforminputcontextplugin.so
│ └── libibusplatforminputcontextplugin.so
├── platforms
│ └── libqxcb.so
├── platformthemes
│ └── libqgtk3.so
└── xcbglintegrations
└── libqxcb-glx-integration.so
The AppImage is available at https://transfer.sh/WNlqb/Mudlet-3.5.0-testing-963e49b.AppImage and I'm running Ubuntu 17.04.
The platform themes are bundled properly here. It's actually all about libqgtk3.so
. Maybe you need some other platform themes file as well, like I do with my XFCE/xubuntu desktop?
Please list the contents of /usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/
.
Not much more to it:
$ tree /usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/
/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/
├── libqgtk3.so
└── libubuntuappmenu.so
0 directories, 2 files
Just wanted to comment that so far the AppImages probonopd linked above and the AppImage for Cantata are the only Qt based AppImages that I've used so far that will actually follow my GTK or Qt color theme.
I've tried quite a few Qt based AppImages on both Xfce and LXQt, and none other than the ones linked above and Cantata follow my system color theme. The color themes for all of the apps I've tested (at least ones available in my repos) work fine when using the versions of these programs installed through my package manager.
Quassel, keepassxc, notepadqq, and simplescreenrecorder are just a few that come to mind that I've tested that do not follow my system theme when using the AppImage release.
@simoniz0r you need to take into account that the feature is very recent, and Quassel for instance doesn't even publish official AppImages, there's only the ones @probonopd builds in his fork. The feature requires build recipes to use the latest Qt 5.9.3, but many recipes still use 5.9/5.9.2.
Please provide more information on where you got the AppImages from, and what versions you use.
Yes, it's not working properly yet. But the ones from https://download.opensuse.org/repositories/home:/rncbc/AppImage/ are working properly. We still need to find out why these work and others don't. It has to do with the fact that the ones from OBS have a lot of gtk_ symbols in libQt5Widgets:
me@host:~$ strings squashfs-root/usr/lib/libQt5Widgets.so.5 | grep gtk_ | wc -l
89
Whereas libQt5Widgets in our AppImages from Travis don't have this. Why?
@TheAssassin I used the latest release of Quassel that probonopd has built, and the version of simplescreenrecorder that I've tried is one that probonopd has hosted on his bintray. The rest of the Qt AppImages that I've tried that will not follow my system theme colors are being built by the application's developers themselves.
@simoniz0r does my Quassel at least follow the system fonts (not colors)?
@simoniz0r you can safely consider the stuff on Bintray outdated at any time. You shouldn't use them for productive work anyway. The keepassxc and notepadqq builds seem outdated, too. They might not be the best candidates for verifying this behavior. But you can use https://github.com/TheAssassin/mumble as another test object.
No, it does not @probonopd
Installed through my package manager:
AppImage:
@TheAssassin Your AppImage build of Mumble does not follow my system colors or fonts either.
For reference, can you also post a screenshot of an AppImage from https://download.opensuse.org/repositories/home:/rncbc/AppImage/ and describe your system (which OS, version, desktop environment, etc.), please. This will help us a lot.
After doing some more testing, it seems that only qxgedit and qtractor from the link above use my system theme. I'm thinking this may be because I'm using LXQt's option to use a GTK theme to theme Qt applications. Both qxgedit and qtractor have an option that lets me use the GTK theme for the app, and they use the GTK theme that I have set using lxappearance. Cantata also has an option to use the GTK theme, and it works the same way.
Any Qt apps that are packaged in AppImages that do not have the option built in to use the system's GTK theme do not follow the GTK theme that my system is using. They seem to just fall back to a default Qt theme and font. When I install these applications through my system's package manager using the same theme settings, they follow my system's theme as expected.
It would seem to me like the AppImages that are working with my system theme are applications that have been built with GTK theme support regardless of what package they're being delivered in.
As you can see below, both qxgedit and Cantata have the option for me to use the system's GTK theme. I know that for Cantata, this is something that is in all of the package releases. It's also worth noting that the AppImage release of Cantata will only use my system theme when I go into Cantata's settings and tell it to use the GTK theme. When I install it through my package manager, it uses my system theme when I have the option set to system default.
My info:
edb-qt56-continuous-git.6fcbf13-x86_64.AppImage on XFCE is using the system's theme, looks almost like a native XFCE application:
.
It ships with the libqgtk2.so
platform theme which unfortunately seems no longer present in newer versions of Qt. Strangely, it continues to look the same when one removes that platform theme.
@probonopd how sure are you it won't load the system theme file when removing it from the bundle...? strace might help here.
The same AppImage does not follow my system theme at all on LXQt.
https://transfer.sh/gjO1r/edb-qt56-continuous-git.6fcbf13-x86_64.AppImage
Strange. We still don't know why it is behaving so differently with different system/Qt combinations.
Like I said before, the only Qt AppImages that follow my system theme are applications that have been built with GTK support and have an option to switch to GTK based theming. No other Qt AppImages follow my system theme.
applications that have been built with GTK support
How does one do that?
Sorry, no idea on that one; I'm not a Qt dev... You might try asking someone like CDrummond who works on Cantata or the qxgedit developer.
What do people think of https://github.com/CrimsonAS/gtkplatform?
gtkplatform is a Qt Platform Abstraction plugin providing Qt applications with the capability to use gtk+ as a host toolkit, primarily intended for use on Linux desktops.
That is: it lets Qt applications render with native gtk+ menus, and use gtk+ for input (mouse, keyboard, touch), and getting window content on screen, the same as it uses e.g. cocoa on macOS for instance.
Unfortunately it seems to be using the more complex and "moving target" Gtk+ 3 rather than the mature Gtk+ 2.
Tried it out and it didn't work: https://github.com/CrimsonAS/gtkplatform/issues/23
GTK+ 2 isn't mature btw, it's deprecated - the last release was 8 years ago. An application using GTK+ 2 now would look out of place in a modern desktop.
According to https://askubuntu.com/a/910143,
The problem has occurred since Qt5.7. In this release, the GTK2 platform theme and style was removed and replaced with the GTK3 platform theme. I've recently been in discussion with the Qt developers and it appears there isn't a GTK3 style to complement the platform theme and there are currently no plans to implement this in the future.
So, bundle the GTK2 platform theme and style?
Yes, that does the trick:
########################################################################
# https://askubuntu.com/a/910143
# https://askubuntu.com/a/748186
# At runtime, export QT_QPA_PLATFORMTHEME=gtk2 (Xfce does it automatically)
########################################################################
apt-get update
apt-get -y install libgtk2.0-dev
git clone http://code.qt.io/qt/qtstyleplugins.git
cd qtstyleplugins
qmake
make -j$(nproc)
make install
cd -
(...)
linuxdeployqt (...) -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
As the AppImageKit issue closed, what's the status on this one?
Can platformthemes be bundled and how to make sure the version is compatible with the host version? Specifically QGnome
The issue is that if you bundle QGnome, then you need to bundle all of its dependencies, too - since you can't assume Gnome to be present on all systems. And in practice, this can lead to all kinds of difficulties.
So over the years the contributors in this project have come to the conclusion that it's not worth the effort, but ymmv. You'd have to use another tool for that, though.
@probonopd I think you're confusing Qt platform themes with desktop environments. QGnomePlatform theme is quite lightweight and doesn't require any GNOME dependencies.
As you can see, there's nothing whatsoever that involves any of GNOME libraries other than Gtk3. And if Gtk3 is not present on target system, the platform plugin would just not load, so noop.
What difficulties you're talking about?
And if Gtk3 is not present on target system, the platform plugin would just not load, so noop.
if that is how it works, then it's good. But I remember that back in the time when we bundled Gtk Qt platform themes, we eventually ran into issues that made us decide it was not worth keeping them.
If you are interested in the details: https://github.com/AppImageCommunity/AppImageUpdate/issues/150
Should we do `cp -a "${QT_PLUGIN_PATH}/platformthemes"?