diff --git a/assets/translations/en.json b/assets/translations/en.json index ad2daa813f..ab57ac53f7 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -4092,6 +4092,12 @@ "color-title": "Wallpaper color", "filter-placeholder": "Filter…", "flatten": "Flatten", + "favorite-current": "Add current wallpaper to favorites", + "unfavorite-current": "Remove current wallpaper from favorites", + "choose-color": "Choose wallpaper color", + "close": "Close wallpaper panel", + "navigate-up": "Go to parent folder", + "refresh": "Refresh wallpapers", "loading": "Loading wallpapers…", "sort-date-asc": "Sort by date (oldest first)", "sort-date-desc": "Sort by date (newest first)", diff --git a/src/shell/wallpaper/panel/wallpaper_panel.cpp b/src/shell/wallpaper/panel/wallpaper_panel.cpp index 4355190855..dd1c5e9631 100644 --- a/src/shell/wallpaper/panel/wallpaper_panel.cpp +++ b/src/shell/wallpaper/panel/wallpaper_panel.cpp @@ -455,6 +455,7 @@ void WallpaperPanel::create() { .glyph = "arrow-big-up", .glyphSize = Style::fontSizeBody * scale, .variant = ButtonVariant::Secondary, + .tooltip = i18n::tr("wallpaper.panel.navigate-up"), .minWidth = Style::controlHeightSm * scale, .minHeight = Style::controlHeightSm * scale, .padding = Style::spaceXs * scale, @@ -521,6 +522,7 @@ void WallpaperPanel::create() { .glyph = "color-picker", .glyphSize = Style::fontSizeBody * scale, .variant = ButtonVariant::Default, + .tooltip = i18n::tr("wallpaper.panel.choose-color"), .minWidth = Style::controlHeightSm * scale, .minHeight = Style::controlHeightSm * scale, .padding = Style::spaceXs * scale, @@ -535,6 +537,7 @@ void WallpaperPanel::create() { .glyph = std::string(sortModeGlyph(m_sortMode)), .glyphSize = Style::fontSizeBody * scale, .variant = ButtonVariant::Default, + .tooltip = i18n::tr(sortModeTooltipKey(m_sortMode)), .minWidth = Style::controlHeightSm * scale, .minHeight = Style::controlHeightSm * scale, .padding = Style::spaceXs * scale, @@ -549,6 +552,7 @@ void WallpaperPanel::create() { .glyph = "refresh", .glyphSize = Style::fontSizeBody * scale, .variant = ButtonVariant::Default, + .tooltip = i18n::tr("wallpaper.panel.refresh"), .minWidth = Style::controlHeightSm * scale, .minHeight = Style::controlHeightSm * scale, .padding = Style::spaceXs * scale, @@ -572,6 +576,7 @@ void WallpaperPanel::create() { .out = &m_closeButton, .glyph = "close", .glyphSize = Style::fontSizeBody * scale, + .tooltip = i18n::tr("wallpaper.panel.close"), .minWidth = Style::controlHeightSm * scale, .minHeight = Style::controlHeightSm * scale, .padding = Style::spaceXs * scale, @@ -664,6 +669,21 @@ void WallpaperPanel::create() { }) ); + favoritesOptions->addChild( + ui::button({ + .out = &m_favoriteCurrentButton, + .glyph = "star", + .glyphSize = Style::fontSizeBody * scale, + .variant = ButtonVariant::Default, + .tooltip = i18n::tr("wallpaper.panel.favorite-current"), + .minWidth = Style::controlHeightSm * scale, + .minHeight = Style::controlHeightSm * scale, + .padding = Style::spaceXs * scale, + .radius = Style::scaledRadiusMd(scale), + .onClick = [this]() { toggleFavoriteForPath(currentWallpaperPathForSelection()); }, + }) + ); + favoritesOptions->addChild(ui::spacer()); favoritesOptions->addChild( @@ -901,6 +921,7 @@ void WallpaperPanel::onClose() { m_title = nullptr; m_backButton = nullptr; m_monitorSelect = nullptr; + m_favoriteCurrentButton = nullptr; m_filterInput = nullptr; m_flattenToggle = nullptr; m_flattenLabel = nullptr; @@ -1087,6 +1108,15 @@ void WallpaperPanel::syncBrowseChrome() { if (m_backButton != nullptr) { m_backButton->setVisible(!m_navStack.empty()); } + if (m_favoriteCurrentButton != nullptr && m_config != nullptr) { + const std::string current = currentWallpaperPathForSelection(); + const bool favorite = !current.empty() && m_config->isWallpaperFavorite(current); + m_favoriteCurrentButton->setEnabled(!current.empty()); + m_favoriteCurrentButton->setGlyph(favorite ? "star-filled" : "star"); + m_favoriteCurrentButton->setTooltip( + i18n::tr(favorite ? "wallpaper.panel.unfavorite-current" : "wallpaper.panel.favorite-current") + ); + } syncThemeControls(); } @@ -1409,6 +1439,7 @@ void WallpaperPanel::applyWallpaperPath(const std::string& path, const Wallpaper choice.connector.empty() ? std::optional{} : std::optional{choice.connector}; m_config->applyWallpaperSelection(connector, path, applyTheme, allMonitorConnectors()); rebindGrid(); + syncBrowseChrome(); } const WallpaperFavorite* WallpaperPanel::favoriteThemeToApply(std::string_view path) const { diff --git a/src/shell/wallpaper/panel/wallpaper_panel.h b/src/shell/wallpaper/panel/wallpaper_panel.h index b8c56ff180..b17f199d03 100644 --- a/src/shell/wallpaper/panel/wallpaper_panel.h +++ b/src/shell/wallpaper/panel/wallpaper_panel.h @@ -136,6 +136,7 @@ class WallpaperPanel : public Panel { Select* m_favoritePaletteDetailSelect = nullptr; Select* m_monitorSelect = nullptr; Input* m_filterInput = nullptr; + Button* m_favoriteCurrentButton = nullptr; Toggle* m_flattenToggle = nullptr; Label* m_flattenLabel = nullptr; Button* m_sortButton = nullptr;