From eaee696b6e77b8ec848fe6c49c9bc0fdfadafb3a Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 18 Oct 2023 19:23:17 +0100 Subject: [PATCH] qt: simplify style.name mappings --- modules/misc/qt.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index a968f31a..1655d437 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -3,6 +3,7 @@ let cfg = config.qt; + # Map platform names to their packages. platformPackages = with pkgs; { gnome = [ qgnomeplatform qgnomeplatform-qt6 ]; gtk = [ libsForQt5.qtstyleplugins qt6Packages.qt6gtk2 ]; @@ -11,6 +12,12 @@ let qtct = [ libsForQt5.qt5ct qt6Packages.qt6ct ]; }; + # Maps style names to their QT_QPA_PLATFORMTHEME, if necessary. + styleNames = { + gtk = "gtk2"; + qtct = "qt5ct"; + }; + # Maps known lowercase style names to style packages. Non-exhaustive. stylePackages = with pkgs; { bb10bright = libsForQt5.qtstyleplugins; @@ -152,12 +159,8 @@ in { qtVersions = with pkgs; [ qt5 qt6 ]; makeQtPath = prefix: basePath: qt: "${basePath}/${qt.qtbase.${prefix}}"; in lib.filterAttrs (n: v: v != null) { - QT_QPA_PLATFORMTHEME = if cfg.platformTheme == "gtk" then - "gtk2" - else if cfg.platformTheme == "qtct" then - "qt5ct" - else - cfg.platformTheme; + QT_QPA_PLATFORMTHEME = + styleNames.${cfg.platformTheme} or cfg.platformTheme; QT_STYLE_OVERRIDE = cfg.style.name; QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}" + (lib.concatStringsSep ":"