#!/usr/bin/env bash # SPDX-FileCopyrightText: 2026 Marco Allegretti # SPDX-License-Identifier: EUPL-1.2 set -euo pipefail repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_dir" fail() { printf '%s\n' "$1" >&2 exit 1 } require_line() { local file="$1" local pattern="$2" local message="$3" grep -Eq -- "$pattern" "$file" || fail "$message" } settings_header=components/shellsettingsplugin/mobileshellsettings.h settings_cpp=components/shellsettingsplugin/mobileshellsettings.cpp settings_cmake=components/shellsettingsplugin/CMakeLists.txt kcm_main=kcms/mobileshell/ui/main.qml kcm_appearance=kcms/mobileshell/ui/AppearanceForm.qml desktop_view=shell/contents/views/Desktop.qml kcm_metadata=kcms/mobileshell/kcm_mobileshell.json panel_background=components/mobileshell/qml/components/PanelBackground.qml motion_state_layer=components/mobileshell/qml/components/MotionStateLayer.qml surface_colors=components/mobileshell/qml/components/SurfaceColors.qml folio_main=containments/homescreens/folio/qml/main.qml favourites_bar=containments/homescreens/folio/qml/FavouritesBar.qml landscape_drawer=components/mobileshell/qml/actiondrawer/private/LandscapeContentContainer.qml require_line "$settings_header" 'Q_PROPERTY\(QString colorScheme READ colorScheme NOTIFY colorSchemeChanged\)' \ "mobile shell settings must expose the active KDE color scheme" require_line "$settings_header" 'Q_PROPERTY\(bool darkThemeEnabled READ darkThemeEnabled WRITE setDarkThemeEnabled NOTIFY darkThemeEnabledChanged\)' \ "mobile shell settings must expose Shift dark/light switching" require_line "$settings_header" 'Q_PROPERTY\(bool wallpaperThemeEnabled READ wallpaperThemeEnabled WRITE setWallpaperThemeEnabled NOTIFY wallpaperThemeEnabledChanged\)' \ "mobile shell settings must expose wallpaper-driven theme mode" require_line "$settings_header" 'Q_PROPERTY\(QColor wallpaperThemeColor READ wallpaperThemeColor NOTIFY wallpaperThemeColorChanged\)' \ "mobile shell settings must expose the extracted wallpaper theme color for UI inspection" require_line "$settings_header" 'Q_PROPERTY\(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged\)' \ "mobile shell settings must expose manual accent color selection" require_line "$settings_header" 'Q_PROPERTY\(bool wallpaperAccentEnabled READ wallpaperAccentEnabled WRITE setWallpaperAccentEnabled NOTIFY wallpaperAccentEnabledChanged\)' \ "mobile shell settings must expose wallpaper-derived accent colors" require_line "$settings_cpp" 'KSharedConfig::openConfig\(\)' \ "dynamic theming must use kdeglobals, not a parallel Shift-only config file" require_line "$settings_cpp" 'readEntry\("ColorScheme", SHIFT_DARK_COLOR_SCHEME\)' \ "dark/light mode must be backed by kdeglobals ColorScheme" require_line "$settings_cpp" 'readEntry\("wallpaperThemeEnabled", false\)' \ "wallpaper theme mode must be an explicit Shift setting" require_line "$settings_cpp" 'writeEntry\("wallpaperThemeEnabled", enabled, KConfigGroup::Notify\)' \ "wallpaper theme mode must persist changes with config notifications" require_line "$settings_cpp" 'WALLPAPER_THEME_MANUAL_DARK_KEY' \ "wallpaper theme mode must remember the previous manual dark/light choice" require_line "$settings_cpp" 'readEntry\(WALLPAPER_THEME_MANUAL_DARK_KEY, darkThemeEnabled\(\)\)' \ "disabling wallpaper theme mode must restore the previous manual dark/light choice" require_line "$settings_cpp" 'm_wallpaperThemeTimer\.stop\(\)' \ "disabling wallpaper theme mode must cancel pending automatic theme changes" require_line "$settings_cpp" 'applyWallpaperThemeColor' \ "wallpaper theme mode must expose a shell hook for extracted wallpaper colors" require_line "$settings_cpp" 'Q_EMIT wallpaperThemeColorChanged\(\)' \ "wallpaper theme mode must notify the UI when the extracted wallpaper theme color changes" require_line "$settings_cpp" 'm_wallpaperThemeTimer\.setInterval\(450\)' \ "wallpaper theme mode must debounce wallpaper color changes" require_line "$settings_cpp" 'm_wallpaperThemeTimer\.start\(\)' \ "wallpaper theme mode must apply extracted wallpaper colors through the debounce timer" require_line "$settings_cpp" '0\.2126 \* color\.redF\(\) \+ 0\.7152 \* color\.greenF\(\) \+ 0\.0722 \* color\.blueF\(\)' \ "wallpaper theme mode must use relative luminance to choose light or dark Shift schemes" require_line "$settings_cpp" 'writeEntry\("accentColorFromWallpaper", enabled, KConfigGroup::Notify\)' \ "wallpaper accent mode must persist KDE's accentColorFromWallpaper key" require_line "$settings_cpp" 'm_lastWallpaperThemeColor\.name\(QColor::HexRgb\)' \ "wallpaper accent mode must apply the extracted wallpaper color directly as accent override" require_line "$settings_cpp" 'writeEntry\("LastUsedCustomAccentColor", opaqueColor, KConfigGroup::Notify\)' \ "manual accent mode must preserve KDE's LastUsedCustomAccentColor key" require_line "$settings_cpp" 'deleteEntry\("AccentColor", KConfigGroup::Notify\)' \ "resetting the accent must clear KDE's AccentColor key" require_line "$settings_cpp" 'plasma-apply-colorscheme' \ "color-scheme changes must go through KDE's color applicator" require_line "$settings_cpp" '--accent-color' \ "manual accent selection must use KDE's accent-color applicator path" require_line "$settings_cpp" 'plasma-apply-desktoptheme' \ "dark/light switching must update the Shift Plasma desktop theme" require_line "$settings_cpp" 'ShiftDark' \ "dynamic theming must keep ShiftDark as the dark scheme" require_line "$settings_cpp" 'ShiftLight' \ "dynamic theming must keep ShiftLight as the light scheme" require_line "$settings_cpp" 'ShiftWallpaperDark' \ "wallpaper theme mode must provide a generated dark Shift wallpaper scheme" require_line "$settings_cpp" 'ShiftWallpaperLight' \ "wallpaper theme mode must provide a generated light Shift wallpaper scheme" require_line "$settings_cpp" 'QStandardPaths::locate\(QStandardPaths::GenericDataLocation,' \ "wallpaper theme mode must derive generated schemes from the installed Shift base schemes" require_line "$settings_cpp" 'QStandardPaths::writableLocation\(QStandardPaths::GenericDataLocation\)' \ "wallpaper theme mode must write generated schemes into the session data location" require_line "$settings_cpp" 'QFile::copy\(sourcePath, outputPath\)' \ "wallpaper theme mode must generate a concrete .colors file before applying it" require_line "$settings_cpp" 'tintBackgroundEntries\(' \ "wallpaper theme mode must generate tinted background roles in the derived color scheme" require_line "$settings_cpp" 'tuneForegroundEntries\(' \ "wallpaper theme mode must generate contrast-aware foreground hierarchy entries" require_line "$settings_cpp" 'contrastRatio\(' \ "wallpaper theme mode must use contrast-aware text color selection" require_line "$settings_cpp" 'ensureContrast\(' \ "wallpaper theme mode must clamp generated foreground roles to a minimum contrast threshold" require_line "$settings_cpp" 'MIN_NORMAL_CONTRAST' \ "wallpaper theme mode must define explicit minimum contrast targets for readability" require_line "$settings_cpp" 'writeEntry\("BackgroundNormal"' \ "wallpaper theme mode must update BackgroundNormal in generated scheme groups" require_line "$settings_cpp" 'writeEntry\("inactiveBackground"' \ "wallpaper theme mode must generate an inactive window background role" require_line "$settings_cpp" 'shift-dark' \ "dynamic theming must keep shift-dark as the dark Plasma theme" require_line "$settings_cpp" 'shift-light' \ "dynamic theming must keep shift-light as the light Plasma theme" require_line "$settings_cmake" 'KF6::ConfigCore' \ "shell settings plugin must link explicitly to KConfigCore for kdeglobals access" require_line "$kcm_main" 'kcm\.push\("AppearanceForm\.qml"\)' \ "mobile shell settings must expose the dynamic theming controls" if grep -Eq -- 'dialog\.parent[[:space:]]*=' "$kcm_main"; then fail "mobile shell KCM must not assign dialog.parent on FormComboBoxDelegate (invalid in current runtime)" fi require_line "$kcm_metadata" '"FormFactors"[[:space:]]*:[[:space:]]*\[' \ "shell settings module metadata must declare form factors" require_line "$kcm_metadata" '"desktop"' \ "shell settings module must be visible in desktop System Settings form factor" require_line "$kcm_metadata" '"X-KDE-Keywords"[[:space:]]*:[[:space:]]*"[^"]*appearance[^"]*theme[^"]*wallpaper[^"]*accent' \ "shell settings module search keywords must include appearance/theme/wallpaper/accent terms" require_line "$kcm_appearance" 'ShellSettings\.Settings\.darkThemeEnabled' \ "appearance settings must control Shift dark/light mode" require_line "$kcm_appearance" 'ShellSettings\.Settings\.wallpaperThemeEnabled' \ "appearance settings must control wallpaper-driven theme mode" require_line "$kcm_appearance" 'ShellSettings\.Settings\.colorScheme' \ "appearance settings must show the active generated wallpaper color scheme" require_line "$kcm_appearance" 'ShellSettings\.Settings\.wallpaperThemeColor' \ "appearance settings must show the extracted wallpaper theme color" require_line "$kcm_appearance" 'ShellSettings\.Settings\.wallpaperAccentEnabled' \ "appearance settings must control wallpaper-derived accent colors" require_line "$kcm_appearance" 'Dialogs\.ColorDialog' \ "appearance settings must provide manual accent color selection" require_line "$kcm_appearance" 'ShellSettings\.Settings\.accentColor = selectedColor' \ "appearance settings must apply the selected manual accent color" require_line "$kcm_appearance" 'ShellSettings\.Settings\.resetAccentColor\(\)' \ "appearance settings must allow returning to the scheme accent" require_line "$desktop_view" 'usedInAccentColor' \ "wallpaper accent mode depends on the Plasma desktop accent extraction hook" require_line "$desktop_view" 'ShellSettings\.Settings\.wallpaperThemeEnabled' \ "wallpaper theme mode must reuse the Plasma desktop wallpaper color extraction hook" require_line "$desktop_view" 'ShellSettings\.Settings\.applyWallpaperThemeColor\(imageColors\.wallpaperColor\)' \ "desktop wallpaper color extraction must feed Shift's wallpaper theme mode" require_line "$desktop_view" 'onWallpaperThemeEnabledChanged' \ "desktop wallpaper color extraction must react when wallpaper theme mode is toggled" require_line "$surface_colors" '!ShellSettings\.Settings\.wallpaperThemeEnabled && !ShellSettings\.Settings\.wallpaperAccentEnabled' \ "shared shell surface color helper must react to wallpaper/accent theming" require_line "$surface_colors" 'ShellSettings\.Settings\.accentColor' \ "shared shell surface color helper must prefer the applied KDE accent color" require_line "$surface_colors" 'ShellSettings\.Settings\.wallpaperThemeColor' \ "shared shell surface color helper must fall back to the extracted wallpaper color" require_line "$panel_background" 'SurfaceColors\.accentSurface\(baseColor, accentTintDark, accentTintLight\)' \ "shared shell panel backgrounds must react to wallpaper/accent theming" require_line "$surface_colors" 'mix\(base, accent\(\), darkSurface \? darkRatio : lightRatio\)' \ "shared shell panel backgrounds must tint surfaces from the active accent color" require_line "$motion_state_layer" 'property color activeColor: SurfaceColors\.accent\(\)' \ "shared active state layers must use the same accent source as shell surfaces" require_line "$folio_main" 'readonly property color chromeColor: MobileShell\.SurfaceColors\.accentSurface\(Kirigami\.Theme\.backgroundColor, 0\.32, 0\.18\)' \ "convergence top bar, frame, and dock chrome must tint from the active accent color" require_line "$surface_colors" '!ShellSettings\.Settings\.wallpaperThemeEnabled && !ShellSettings\.Settings\.wallpaperAccentEnabled' \ "convergence chrome must react to wallpaper/accent theming mode" require_line "$folio_main" 'fillColor: MobileShell\.SurfaceColors\.accentSurface\(Kirigami\.Theme\.backgroundColor, 0\.32, 0\.18\)' \ "convergence app drawer surface must tint from the active accent color" require_line "$landscape_drawer" 'fillColor: MobileShell\.SurfaceColors\.accentSurface\(Kirigami\.Theme\.backgroundColor, 0\.32, 0\.18\)' \ "convergence action drawer surface must tint from the active accent color" require_line "$favourites_bar" 'color: MobileShell\.SurfaceColors\.accentSurface\(Kirigami\.Theme\.backgroundColor, 0\.24, 0\.12\)' \ "dock thumbnail popup surfaces must tint from the active accent color" require_line "$favourites_bar" 'color: leftDesktopBtn\.isCurrent \? MobileShell\.SurfaceColors\.accent\(\) : Kirigami\.Theme\.textColor' \ "dock workspace pager labels must use the same accent source as shell surfaces" if grep -Eq -- 'Kirigami\.Theme\.highlightColor' "$favourites_bar"; then fail "convergence dock must not use Kirigami.Theme.highlightColor directly; use MobileShell.SurfaceColors.accent()" fi require_line tests/CMakeLists.txt 'NAME shift-dynamic-theming' \ "dynamic theming regression test must be registered with CTest" printf '%s\n' 'shift-dynamic-theming-ok'