-
Notifications
You must be signed in to change notification settings - Fork 309
Add support for reordering notification icons via drag-and-drop #1227
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: master
Are you sure you want to change the base?
Conversation
|
Download the artifacts for this pull request: |
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.
Pull Request Overview
This PR adds support for reordering notification icons via drag-and-drop functionality and saves/restores the layout order. The implementation uses the GongSolutions.Wpf.DragDrop library to enable interactive reordering of notification icons in the system tray.
Key changes:
- Added
NotifyIconOrderproperty to Settings class to persist icon order - Created
NotifyIconDropHandlerclass to handle drag-and-drop operations - Modified
NotifyIconListto use ObservableCollections instead of CollectionViewSources and implement order persistence
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| RetroBar/Utilities/Settings.cs | Adds NotifyIconOrder property to store icon ordering |
| RetroBar/Utilities/NotifyIconDropHandler.cs | Implements IDropTarget interface for drag-and-drop handling |
| RetroBar/Controls/NotifyIconList.xaml.cs | Refactors collection management and adds order persistence logic |
| RetroBar/Controls/NotifyIconList.xaml | Enables drag-and-drop on NotifyIcons ItemsControl |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| .ToList(); | ||
|
|
||
| // Sort icons according to saved order | ||
| var sortedIcons = icons.OrderBy(i => Settings.Instance.NotifyIconOrder.IndexOf(i.GetInvertIdentifier())).ToList(); |
Copilot
AI
Aug 21, 2025
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.
Using IndexOf for ordering will fail when icons are not in the saved order list. IndexOf returns -1 for missing items, which will cause all unknown icons to be sorted to the beginning with the same priority. Use a custom ordering logic that handles missing items by assigning them a default order value.
| var sortedIcons = icons.OrderBy(i => Settings.Instance.NotifyIconOrder.IndexOf(i.GetInvertIdentifier())).ToList(); | |
| var sortedIcons = icons.OrderBy(i => | |
| { | |
| int idx = Settings.Instance.NotifyIconOrder.IndexOf(i.GetInvertIdentifier()); | |
| return idx == -1 ? Settings.Instance.NotifyIconOrder.Count : idx; | |
| }).ToList(); |
| } | ||
| foreach (var icon in NotificationArea.PinnedIcons.Cast<ManagedShell.WindowsTray.NotifyIcon>().OrderBy(i => Settings.Instance.NotifyIconOrder.IndexOf(i.GetInvertIdentifier()))) | ||
| { | ||
| pinnedNotifyIcons.Add(icon); |
Copilot
AI
Aug 21, 2025
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.
Same IndexOf issue as line 218. Missing icons from the saved order will all receive -1 and be grouped together at the beginning, losing their relative order.
| pinnedNotifyIcons.Add(icon); | |
| foreach (var tuple in NotificationArea.PinnedIcons.Cast<ManagedShell.WindowsTray.NotifyIcon>() | |
| .Select((icon, idx) => new { icon, idx, orderIndex = Settings.Instance.NotifyIconOrder.IndexOf(icon.GetInvertIdentifier()) }) | |
| .OrderBy(t => t.orderIndex == -1 ? int.MaxValue : t.orderIndex) | |
| .ThenBy(t => t.idx)) | |
| { | |
| pinnedNotifyIcons.Add(tuple.icon); |
|
|
||
| public void SaveIconOrder() | ||
| { | ||
| var visibleIcons = new System.Collections.Generic.List<ManagedShell.WindowsTray.NotifyIcon>(); |
Copilot
AI
Aug 21, 2025
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.
Using the fully qualified type name 'System.Collections.Generic.List' is unnecessary since 'using System.Collections.Generic;' is already present. Use 'List<ManagedShell.WindowsTray.NotifyIcon>' instead.
| var visibleIcons = new System.Collections.Generic.List<ManagedShell.WindowsTray.NotifyIcon>(); | |
| var visibleIcons = new List<ManagedShell.WindowsTray.NotifyIcon>(); |
|
Hi, will be this (drag-dropp icon ordering) finished soon and added to official release? |
It should also save and restore the layout order.
Further testing is required. Since the code has not been reviewed, it may not adhere to best practices.