mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[Workspaces] Change workspaces icon store position (#39677)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Before, workspaces ico are stored in temp folder, which is easily cleaned up by user. After clean, user has to explicitly save icon once again. With this change, icons are stored at the same position with workspaces settings <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] **Closes:** #35004 - [ ] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed  --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -193,27 +193,29 @@ namespace WorkspacesEditor.ViewModels
|
|||||||
ApplyShortcut(editedProject);
|
ApplyShortcut(editedProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetDesktopShortcutAddress(Project project) => Path.Combine(FolderUtils.Desktop(), project.Name + ".lnk");
|
||||||
|
|
||||||
|
private string GetShortcutStoreAddress(Project project)
|
||||||
|
{
|
||||||
|
var dataFolder = FolderUtils.DataFolder();
|
||||||
|
Directory.CreateDirectory(dataFolder);
|
||||||
|
var shortcutStoreFolder = Path.Combine(dataFolder, "WorkspacesIcons");
|
||||||
|
Directory.CreateDirectory(shortcutStoreFolder);
|
||||||
|
return Path.Combine(shortcutStoreFolder, project.Id + ".ico");
|
||||||
|
}
|
||||||
|
|
||||||
private void ApplyShortcut(Project project)
|
private void ApplyShortcut(Project project)
|
||||||
{
|
{
|
||||||
string basePath = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
string shortcutAddress = Path.Combine(FolderUtils.Desktop(), project.Name + ".lnk");
|
|
||||||
string shortcutIconFilename = Path.Combine(FolderUtils.Temp(), project.Id + ".ico");
|
|
||||||
|
|
||||||
if (!project.IsShortcutNeeded)
|
if (!project.IsShortcutNeeded)
|
||||||
{
|
{
|
||||||
if (File.Exists(shortcutIconFilename))
|
RemoveShortcut(project);
|
||||||
{
|
|
||||||
File.Delete(shortcutIconFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists(shortcutAddress))
|
|
||||||
{
|
|
||||||
File.Delete(shortcutAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
var shortcutAddress = GetDesktopShortcutAddress(project);
|
||||||
|
var shortcutIconFilename = GetShortcutStoreAddress(project);
|
||||||
|
|
||||||
Bitmap icon = WorkspacesIcon.DrawIcon(WorkspacesIcon.IconTextFromProjectName(project.Name), App.ThemeManager.GetCurrentTheme());
|
Bitmap icon = WorkspacesIcon.DrawIcon(WorkspacesIcon.IconTextFromProjectName(project.Name), App.ThemeManager.GetCurrentTheme());
|
||||||
WorkspacesIcon.SaveIcon(icon, shortcutIconFilename);
|
WorkspacesIcon.SaveIcon(icon, shortcutIconFilename);
|
||||||
|
|
||||||
@@ -360,8 +362,8 @@ namespace WorkspacesEditor.ViewModels
|
|||||||
|
|
||||||
private void RemoveShortcut(Project selectedProject)
|
private void RemoveShortcut(Project selectedProject)
|
||||||
{
|
{
|
||||||
string shortcutAddress = Path.Combine(FolderUtils.Desktop(), selectedProject.Name + ".lnk");
|
string shortcutAddress = GetDesktopShortcutAddress(selectedProject);
|
||||||
string shortcutIconFilename = Path.Combine(FolderUtils.Temp(), selectedProject.Id + ".ico");
|
string shortcutIconFilename = GetShortcutStoreAddress(selectedProject);
|
||||||
|
|
||||||
if (File.Exists(shortcutIconFilename))
|
if (File.Exists(shortcutIconFilename))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user