From 32376992f7ef4d7ae76dda690de5b23725fd8300 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 14 Jun 2023 19:16:20 +0000 Subject: [PATCH] qt: add "kde" to qt.platformTheme (#4085) This allow you to configure Qt integration using KDE instead of qgnomeplatform or qtstyleplugins. Useful if your theme supports both GTK and KDE, for example Nordic. To use this properly you will need to do some manual configuration for now. You can set the theme settings using `~/.config/kdeglobals`. Example: ```nix { ... }: { qt = { enable = true; platformTheme = "kde"; }; xdg = { configFile.kdeglobals.text = lib.generators.toINI { } { General = { ColorScheme = "nordicbluish"; Name = "nordic-bluish"; shadeSortColumn = true; }; Icons = { Theme = "Nordic-bluish"; }; KDE = { LookAndFeelPackage = "Nordic-bluish"; contrast = 4; }; }; dataFile = { # For General.ColorScheme color-schemes = { source = "${pkgs.nordic}/share/color-schemes"; recursive = true; }; # For KDE.LookAndFeelPackage plasma = { source = "${pkgs.nordic}/share/plasma"; recursive = true; }; }; }; } ``` --- modules/misc/qt.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index 4c289522f..cdc0283d6 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -38,7 +38,7 @@ in { enable = mkEnableOption "Qt 4 and 5 configuration"; platformTheme = mkOption { - type = types.nullOr (types.enum [ "gtk" "gnome" ]); + type = types.nullOr (types.enum [ "gtk" "gnome" "kde" ]); default = null; example = "gnome"; relatedPackages = @@ -59,6 +59,10 @@ in { qgnomeplatform + + kde + Use Qt settings from Plasma + ''; }; @@ -134,14 +138,17 @@ in { # Necessary because home.sessionVariables doesn't support mkIf home.sessionVariables = filterAttrs (n: v: v != null) { QT_QPA_PLATFORMTHEME = - if cfg.platformTheme == "gnome" then "gnome" else "gtk2"; + if cfg.platformTheme == "gtk" then "gtk2" else cfg.platformTheme; QT_STYLE_OVERRIDE = cfg.style.name; }; home.packages = if cfg.platformTheme == "gnome" then [ pkgs.qgnomeplatform ] ++ lib.optionals (cfg.style.package != null) [ cfg.style.package ] - else + else if cfg.platformTheme == "kde" then [ + pkgs.libsForQt5.plasma-integration + pkgs.libsForQt5.systemsettings + ] else [ pkgs.libsForQt5.qtstyleplugins ]; xsession.importedVariables = [ "QT_QPA_PLATFORMTHEME" ]