From 4e09c83255c5b23d58714d56672d3946faf1bcef Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 15 Jun 2023 18:09:30 +0000 Subject: [PATCH] qt: bunch of fixes and updates (#4095) * qt: always apply qt.style.package Before this commit this was only being applied if `qt.platformName` was set to "gnome". With this change we will always apply the package. * qt: only set ~/config/Trolltech.conf in GTK or GNOME * qt: add qtstyleplugin-kvantum-qt4 and qt6Packages.qtstyleplugin-kvantum qt: add qtstyleplugin-kvantum-qt4 * news: add news entry about the qt module refactors * qt: add thiagokokada as maintainer --- modules/misc/news.nix | 16 ++++++++++++++++ modules/misc/qt.nix | 37 +++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 06a4fbcc1..857fc54db 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1111,6 +1111,22 @@ in - 'services.comodoro' ''; } + + { + time = "2023-06-15T16:30:00+00:00"; + condition = config.qt.enable; + message = '' + Qt module now supports new platform themes and styles, and has partial + support for Qt6. For example, you can now use: + + - `qt.platformTheme = "kde"`: set a theme using Plasma. You can + configure it by setting `~/.config/kdeglobals` file; + - `qt.platformTheme = "qtct"`: set a theme using qt5ct/qt6ct. You + can control it by using the `qt5ct` and `qt6ct` applications; + - `qt.style.name = "kvantum"`: override the style by using themes + written in SVG. Supports many popular themes. + ''; + } ]; }; } diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index d3f370d3c..281b2870c 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -23,11 +23,15 @@ let breeze = libsForQt5.breeze-qt5; - kvantum = libsForQt5.qtstyleplugin-kvantum; + kvantum = [ + qtstyleplugin-kvantum-qt4 + libsForQt5.qtstyleplugin-kvantum + qt6Packages.qtstyleplugin-kvantum + ]; }; in { - meta.maintainers = [ maintainers.rycee ]; + meta.maintainers = with maintainers; [ rycee thiagokokada ]; imports = [ (mkChangedOptionModule [ "qt" "useGtkTheme" ] [ "qt" "platformTheme" ] @@ -37,7 +41,7 @@ in { options = { qt = { - enable = mkEnableOption "Qt 4 and 5 configuration"; + enable = mkEnableOption "Qt 4, 5 and 6 configuration"; platformTheme = mkOption { type = types.nullOr (types.enum [ "gtk" "gnome" "qtct" "kde" ]); @@ -92,10 +96,12 @@ in { "adwaita-qt" "breeze-qt5" [ "libsForQt5" "qtstyleplugins" ] + "qtstyleplugin-kvantum-qt4" [ "libsForQt5" "qtstyleplugin-kvantum" ] + [ "qt6Packages" "qtstyleplugin-kvantum" ] ]; description = '' - Style to use for Qt5 applications. Case-insensitive. + Style to use for Qt5/Qt6 applications. Case-insensitive. Some examples are @@ -137,11 +143,11 @@ in { }; package = mkOption { - type = types.nullOr types.package; + type = with types; nullOr (either package (listOf package)); default = null; example = literalExpression "pkgs.adwaita-qt"; description = '' - Theme package to be used in Qt5 applications. + Theme package to be used in Qt5/Qt6 applications. Auto-detected from if possible. ''; }; @@ -173,9 +179,8 @@ in { QT_STYLE_OVERRIDE = cfg.style.name; }; - home.packages = if cfg.platformTheme == "gnome" then + home.packages = (if cfg.platformTheme == "gnome" then [ pkgs.qgnomeplatform ] - ++ lib.optionals (cfg.style.package != null) [ cfg.style.package ] else if cfg.platformTheme == "qtct" then [ pkgs.libsForQt5.qt5ct pkgs.qt6Packages.qt6ct @@ -183,16 +188,20 @@ in { pkgs.libsForQt5.plasma-integration pkgs.libsForQt5.systemsettings ] else - [ pkgs.libsForQt5.qtstyleplugins ]; + [ pkgs.libsForQt5.qtstyleplugins ]) + ++ lib.optionals (cfg.style.package != null) + (lib.toList cfg.style.package); xsession.importedVariables = [ "QT_QPA_PLATFORMTHEME" ] ++ lib.optionals (cfg.style.name != null) [ "QT_STYLE_OVERRIDE" ]; - # Enable GTK+ style for Qt4 in either case. + # Enable GTK+ style for Qt4 in Gtk/GNOME. # It doesn’t support the platform theme packages. - home.activation.useGtkThemeInQt4 = hm.dag.entryAfter [ "writeBoundary" ] '' - $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG \ - --set "${config.xdg.configHome}/Trolltech.conf" Qt style GTK+ - ''; + home.activation.useGtkThemeInQt4 = + mkIf (cfg.platformTheme == "gtk" || cfg.platformTheme == "gnome") + (hm.dag.entryAfter [ "writeBoundary" ] '' + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG \ + --set "${config.xdg.configHome}/Trolltech.conf" Qt style GTK+ + ''); }; }