-
-
Notifications
You must be signed in to change notification settings - Fork 374
Add preview background in welcome page 2 #3277
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
Add preview background in welcome page 2 #3277
Conversation
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
📝 WalkthroughWalkthroughThis change adds a new public property, Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client/UI
participant WP2 as WelcomePage2
participant Retrieval as WallpaperPathRetrieval
UI->>WP2: Access PreviewBackground property
WP2->>Retrieval: GetWallpaperPath()
alt Wallpaper exists and file is valid
Retrieval-->>WP2: Return wallpaper path
WP2->>WP2: Check file existence
WP2->>WP2: Read file into MemoryStream
WP2->>WP2: Initialize BitmapImage (800x600)
WP2-->>UI: Return ImageBrush (stretched)
else Wallpaper not available
Retrieval-->>WP2: No valid wallpaper
WP2->>Retrieval: GetWallpaperColor()
Retrieval-->>WP2: Return fallback color
WP2-->>UI: Return SolidColorBrush
end
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs (2)
34-54
: Exception handling needed for image loading.The current implementation doesn't handle exceptions that could occur during image loading. If the wallpaper file exists but is corrupted or not a valid image, this could throw an unhandled exception.
Consider adding try-catch blocks:
public Brush PreviewBackground { get { var wallpaper = WallpaperPathRetrieval.GetWallpaperPath(); if (wallpaper is not null && File.Exists(wallpaper)) { + try + { var memStream = new MemoryStream(File.ReadAllBytes(wallpaper)); var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = memStream; bitmap.DecodePixelWidth = 800; bitmap.DecodePixelHeight = 600; bitmap.EndInit(); return new ImageBrush(bitmap) { Stretch = Stretch.UniformToFill }; + } + catch (Exception ex) + { + // Log the exception + System.Diagnostics.Debug.WriteLine($"Error loading wallpaper: {ex.Message}"); + // Fall through to the fallback color + } } var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor(); return new SolidColorBrush(wallpaperColor); } }
45-46
: Consider preserving image aspect ratio.The current implementation uses fixed dimensions (800x600) which might distort some wallpapers. While the
UniformToFill
stretch mode helps, it would be better to maintain the aspect ratio during decoding.Consider setting only one dimension (e.g., width) and letting the height scale proportionally:
- bitmap.DecodePixelWidth = 800; - bitmap.DecodePixelHeight = 600; + bitmap.DecodePixelWidth = 800; // Set only the width
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
🔇 Additional comments (1)
Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs (1)
8-10
: Appropriate using directives added.The additional using directives for System.IO, System.Windows.Media.Imaging, and System.Windows.Media are correctly included to support the new property implementation.
🥷 Code experts: taooceros Jack251970 has most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
Add preview background in welcome page 2
There is
Background="{Binding PreviewBackground}"
inWelcomePage2.xaml
, but I cannot find this inWelcomePage2.xaml.cs
, so I believe this brush seems to have been left out.Test