From 54e35e0e1c1b6b4888c34423335a448ab3ec78d5 Mon Sep 17 00:00:00 2001 From: tschai-yim <89387771+tschai-yim@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:52:14 +0100 Subject: [PATCH] qt: use warnings API --- modules/misc/qt.nix | 21 ++++++++++--------- .../misc/qt/qt-platform-theme-gnome.nix | 4 ++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index 2dbb3139..51fbac46 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -187,22 +187,17 @@ in { }; config = let - warnGnomeDeprecation = option: name: - lib.warnIf (name == "gnome") - "The value `gnome` for option `${option}` is deprecated. Use `adwaita` instead." - name; - platformTheme = if (builtins.isString cfg.platformTheme) then { - name = lib.warn - "The option `qt.platformTheme` has been renamed to `qt.platformTheme.name`." - (warnGnomeDeprecation "qt.platformTheme" cfg.platformTheme); + option = "qt.platformTheme"; + name = cfg.platformTheme; package = null; } else if cfg.platformTheme == null then { + option = null; name = null; package = null; } else { - name = - warnGnomeDeprecation "cfg.platformTheme.name" cfg.platformTheme.name; + option = "qt.platformTheme.name"; + name = cfg.platformTheme.name; package = cfg.platformTheme.package; }; @@ -238,6 +233,12 @@ in { ''; }]; + warnings = (lib.lists.optional (platformTheme.option == "qt.platformTheme") + "The option `qt.platformTheme` has been renamed to `qt.platformTheme.name`.") + ++ (lib.lists.optional + (platformTheme.name == "gnome" && platformTheme.package == null) + "The value `gnome` for option `${platformTheme.option}` is deprecated. Use `adwaita` instead."); + qt.style.package = lib.mkIf (cfg.style.name != null) (lib.mkDefault (stylePackages.${lib.toLower cfg.style.name} or null)); diff --git a/tests/modules/misc/qt/qt-platform-theme-gnome.nix b/tests/modules/misc/qt/qt-platform-theme-gnome.nix index 617d99b0..ab65f146 100644 --- a/tests/modules/misc/qt/qt-platform-theme-gnome.nix +++ b/tests/modules/misc/qt/qt-platform-theme-gnome.nix @@ -19,5 +19,9 @@ assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ 'QML2_IMPORT_PATH' ''; + test.asserts.warnings.expected = [ + "The option `qt.platformTheme` has been renamed to `qt.platformTheme.name`." + "The value `gnome` for option `qt.platformTheme` is deprecated. Use `adwaita` instead." + ]; }; }