-
Notifications
You must be signed in to change notification settings - Fork 148
feat: desktop background context menu #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: desktop background context menu #55
Conversation
Add a new context menu option that allows users to set any image file as their desktop background directly from the file explorer. Changes: - Add isImageFile() helper function to detect image files by extension - Add set_as_desktop_background i18n translation string - Add context menu item that appears only for image files (not folders, non-images, or trashed items) - Implement background change with image preloading to prevent gray flash - Add smooth fade transition (0.4s) for polished UX - Persist background preference to server via /set-desktop-bg endpoint - Update window.user object with new background settings The implementation follows the same pattern as UIWindowDesktopBGSettings and uses signed URLs from the /sign endpoint to ensure proper authentication for CSS background-image requests. Files modified: - src/gui/src/UI/UIItem.js - src/gui/src/i18n/translations/en.js
Add the set_as_desktop_background translation key to all 37 translation files to support the new 'Set as Desktop Background' context menu feature.
| const read_url = sign_res.signatures[0].read_url; | ||
|
|
||
| // Preload image before setting as background to avoid gray flash | ||
| await new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary? why do we need to wrap the logic below into a promise? — img operation seem to be sync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The promise wrapper is necessary because we need to wait for the asynchronous image download to complete before setting the background. Here's why:
- new Image() and img.src = read_url are synchronous operations (they just create the object and set the property)
- The actual image download happens asynchronously in the browser
- The onload callback fires when that async download completes
- The Promise wrapper lets us await that async event
Without this, we'd set the background before the image finishes downloading, causing a gray flash while the browser loads it. By preloading, the image is cached and ready, so the background change is instant.
israx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job raising PRs so far
Add 'Set as Desktop Background' Context Menu Item for Images
Summary
This PR adds a "Set as Desktop Background" option to the context menu when right-clicking on image files in the file system. This feature allows users to quickly personalize their desktop by setting any image as their background directly from the file explorer, without navigating through settings menus.
Motivation
Users currently have no quick way to set an image as their desktop background directly from the file system. They must navigate through settings or other indirect methods to change their wallpaper. Adding a context menu option when right-clicking on image files provides a convenient, intuitive way for users to personalize their desktop environment.
This feature enhances the user experience by reducing friction in a common personalization task. It follows familiar desktop environment patterns where users expect to be able to right-click images and set them as backgrounds, making the interface more intuitive and user-friendly.
Changes Made
Core Implementation
Added
isImageFile()helper function (src/gui/src/UI/UIItem.js)Added context menu item (
src/gui/src/UI/UIItem.js)/signendpoint for proper authenticationImplemented background change with UX improvements
/set-desktop-bgendpointwindow.userobject with new background settingsInternationalization
set_as_desktop_backgroundtranslation key to all 37 language filesTechnical Details
Implementation Approach
UIWindowDesktopBGSettingsfor consistency/signendpoint to generate authenticated URLs that work in CSSbackground-image/set-desktop-bgAPI endpoint)window.set_desktop_background()function)Files Modified
src/gui/src/UI/UIItem.js- Main implementation (helper function + context menu item)src/gui/src/i18n/translations/*.js- Translation strings (37 files)Files NOT Modified
Testing
Manual Testing Performed
✅ Context Menu Visibility
✅ Functionality
✅ Internationalization
Test Cases Covered
Acceptance Criteria
UX Improvements
Related Issues
Link to related GitHub issues or feature requests here
Checklist
Notes
/signendpoint to ensure proper authentication for CSSbackground-imagerequests