Skip to content

Commit

Permalink
Snap: fix theming (#3057)
Browse files Browse the repository at this point in the history
Use gtk3 file chooser dialogs, mouse coursor theme if available and force fallback icon theme, fixes issue #2966
  • Loading branch information
joshirio authored and droidmonkey committed Apr 25, 2019
1 parent d3a53a7 commit a2caa31
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
11 changes: 11 additions & 0 deletions snap/local/launchers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# /snap/local/launchers
Here are the launchers, or wrapper programs to deal with some runtime-fixable problems for the snapped applications, like setting proper environmental variables in snap.

In convention launchers are named _something_-launch, for dealing certain problem with _something_, and usually can be called in a stacked manner to consolidate their modifications.

```yaml
apps:
_app_name_:
command: foo-launch bar-launch _app_command_
```
14 changes: 14 additions & 0 deletions snap/local/launchers/gtk3-env-launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# This is the maintainence launcher for the snap, make necessary runtime environment changes to make the snap work here. You may also insert security confinement/deprecation/obsoletion notice of the snap here.

set \
-o errexit \
-o errtrace \
-o nounset \
-o pipefail

# gtk-common-themes support
export QT_QPA_PLATFORMTHEME=gtk3

# Finally run the next part of the command chain
exec "${@}"
30 changes: 25 additions & 5 deletions snapcraft.yaml → snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ description: |
confinement: strict
base: core18

plugs:
icon-themes: # fix mouse cursor theme
plugs: # plugs for theming, font settings, cursor and to use gtk3 file chooser
gtk-3-themes:
interface: content
target: $SNAP/data-dir/themes
default-provider: gtk-common-themes:gtk-3-themes
icon-themes:
interface: content
target: $SNAP/data-dir/icons
default-provider: gtk-common-themes
default-provider: gtk-common-themes:icon-themes
sound-themes:
interface: content
target: $SNAP/data-dir/sounds
default-provider: gtk-common-themes:sounds-themes

apps:
keepassxc:
command: desktop-launch keepassxc
adapter: full
command: usr/bin/keepassxc -style fusion
command-chain:
- bin/desktop-launch
- bin/gtk3-env-launch
plugs: [unity7, x11, opengl, gsettings, home, network, network-bind, removable-media, raw-usb, wayland, desktop-legacy, desktop]
desktop: usr/share/applications/org.keepassxc.KeePassXC.desktop
environment:
Expand Down Expand Up @@ -73,7 +85,7 @@ parts:
- libquazip5-1
- libusb-1.0-0
- qtwayland5
- qt5-style-plugins # for mouse cursor theme fix
- qt5-gtk-platformtheme # for theming, font settings, cursor and to use gtk3 file chooser
override-build: |
snapcraftctl build
sed -i 's|Icon=keepassxc|Icon=${SNAP}/usr/share/icons/hicolor/256x256/apps/keepassxc.png|g' $SNAPCRAFT_PART_INSTALL/usr/share/applications/org.keepassxc.KeePassXC.desktop
Expand All @@ -83,6 +95,14 @@ parts:
- -opt
after: [desktop-qt5]

launchers: # custom launcher to set QT_QPA_PLATFORMTHEME=gtk3 correctly
source: snap/local/launchers
plugin: dump
organize:
'*': bin/
stage:
- -bin/README.*

desktop-qt5:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: qt
Expand Down
6 changes: 6 additions & 0 deletions src/core/Bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ namespace Bootstrap
bootstrap();
MessageBox::initializeButtonDefs();

#ifdef KEEPASSXC_DIST_SNAP
// snap: force fallback theme to avoid using system theme (gtk integration)
// with missing actions just like on Windows and macOS
QIcon::setThemeSearchPaths(QStringList() << ":/icons");
#endif

#ifdef Q_OS_MACOS
// Don't show menu icons on OSX
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
Expand Down

0 comments on commit a2caa31

Please sign in to comment.