mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-08 05:17:03 +01:00
Compare commits
5 Commits
dev/mjolle
...
copilot/ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
210b53a8dc | ||
|
|
39011da721 | ||
|
|
803ab070a6 | ||
|
|
281a32e21d | ||
|
|
a8c7d30c3c |
@@ -49,6 +49,8 @@ namespace Awake.Core
|
||||
|
||||
private static DateTimeOffset ExpireAt { get; set; }
|
||||
|
||||
private static bool ShowTrayIcon { get; set; } = true;
|
||||
|
||||
private static readonly CompositeFormat AwakeMinute = CompositeFormat.Parse(Resources.AWAKE_MINUTE);
|
||||
private static readonly CompositeFormat AwakeMinutes = CompositeFormat.Parse(Resources.AWAKE_MINUTES);
|
||||
private static readonly CompositeFormat AwakeHour = CompositeFormat.Parse(Resources.AWAKE_HOUR);
|
||||
@@ -145,8 +147,42 @@ namespace Awake.Core
|
||||
Logger.LogInfo("New token source and thread token instantiated.");
|
||||
}
|
||||
|
||||
internal static void SetShowTrayIcon(bool showTrayIcon)
|
||||
{
|
||||
ShowTrayIcon = showTrayIcon;
|
||||
SetModeShellIcon();
|
||||
}
|
||||
|
||||
private static void UpdateTrayIconText(string iconText, Icon? icon, TrayIconAction action = TrayIconAction.Update)
|
||||
{
|
||||
if (!ShowTrayIcon && action != TrayIconAction.Delete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrayHelper.SetShellIcon(TrayHelper.WindowHandle, iconText, icon, action);
|
||||
}
|
||||
|
||||
internal static void SetModeShellIcon(bool forceAdd = false)
|
||||
{
|
||||
if (!ShowTrayIcon && !forceAdd)
|
||||
{
|
||||
// If the tray icon should be hidden and this is not a forced add (e.g., taskbar recreated),
|
||||
// delete the icon if it exists
|
||||
TrayHelper.SetShellIcon(
|
||||
TrayHelper.WindowHandle,
|
||||
string.Empty,
|
||||
null,
|
||||
TrayIconAction.Delete);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ShowTrayIcon && forceAdd)
|
||||
{
|
||||
// If the tray icon should be hidden but taskbar was recreated, still hide it
|
||||
return;
|
||||
}
|
||||
|
||||
string iconText = string.Empty;
|
||||
Icon? icon = null;
|
||||
|
||||
@@ -344,11 +380,8 @@ namespace Awake.Core
|
||||
{
|
||||
TimeRemaining = (uint)remainingTimeSpan.TotalSeconds;
|
||||
|
||||
TrayHelper.SetShellIcon(
|
||||
TrayHelper.WindowHandle,
|
||||
$"{Constants.FullAppName} [{Resources.AWAKE_TRAY_TEXT_TIMED}][{ScreenStateString}][{remainingTimeSpan.ToHumanReadableString()}]",
|
||||
TrayHelper.TimedIcon,
|
||||
TrayIconAction.Update);
|
||||
string iconText = $"{Constants.FullAppName} [{Resources.AWAKE_TRAY_TEXT_TIMED}][{ScreenStateString}][{remainingTimeSpan.ToHumanReadableString()}]";
|
||||
UpdateTrayIconText(iconText, TrayHelper.TimedIcon, TrayIconAction.Update);
|
||||
},
|
||||
_ => HandleTimerCompletion("timed"),
|
||||
_tokenSource.Token);
|
||||
|
||||
@@ -506,6 +506,8 @@ namespace Awake
|
||||
|
||||
Logger.LogInfo($"Identified custom time shortcuts for the tray: {settings.Properties.CustomTrayTimes.Count}");
|
||||
|
||||
Manager.SetShowTrayIcon(settings.Properties.ShowTrayIcon);
|
||||
|
||||
switch (settings.Properties.Mode)
|
||||
{
|
||||
case AwakeMode.PASSIVE:
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
IntervalMinutes = 1;
|
||||
ExpirationDateTime = DateTimeOffset.Now;
|
||||
CustomTrayTimes = [];
|
||||
ShowTrayIcon = true;
|
||||
}
|
||||
|
||||
[JsonPropertyName("keepDisplayOn")]
|
||||
@@ -40,5 +41,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
[JsonPropertyName("customTrayTimes")]
|
||||
[CmdConfigureIgnore]
|
||||
public Dictionary<string, uint> CustomTrayTimes { get; set; }
|
||||
|
||||
[JsonPropertyName("showTrayIcon")]
|
||||
public bool ShowTrayIcon { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
|
||||
// Fix old buggy default value that might be saved in Settings. Some components don't deal well with negative time zones and minimum time offsets.
|
||||
ExpirationDateTime = Properties.ExpirationDateTime.Year < 2 ? DateTimeOffset.Now : Properties.ExpirationDateTime,
|
||||
ShowTrayIcon = Properties.ShowTrayIcon,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
</controls:GPOInfoControl>
|
||||
|
||||
<controls:SettingsGroup x:Uid="Awake_BehaviorSettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
|
||||
<tkcontrols:SettingsCard
|
||||
Name="AwakeShowTrayIconSettingsCard"
|
||||
x:Uid="Awake_ShowTrayIconSettingsCard"
|
||||
HeaderIcon="{ui:FontIcon Glyph=}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.ShowTrayIcon, Mode=TwoWay}" />
|
||||
</tkcontrols:SettingsCard>
|
||||
|
||||
<tkcontrols:SettingsCard
|
||||
Name="AwakeModeSettingsCard"
|
||||
x:Uid="Awake_ModeSettingsCard"
|
||||
|
||||
@@ -2356,6 +2356,9 @@ From there, simply click on one of the supported files in the File Explorer and
|
||||
<data name="Awake_BehaviorSettingsGroup.Header" xml:space="preserve">
|
||||
<value>Behavior</value>
|
||||
</data>
|
||||
<data name="Awake_ShowTrayIconSettingsCard.Header" xml:space="preserve">
|
||||
<value>Show tray icon</value>
|
||||
</data>
|
||||
<data name="Awake_IntervalHoursInput.Header" xml:space="preserve">
|
||||
<value>Hours</value>
|
||||
</data>
|
||||
|
||||
@@ -198,6 +198,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowTrayIcon
|
||||
{
|
||||
get => ModuleSettings.Properties.ShowTrayIcon;
|
||||
set
|
||||
{
|
||||
if (ModuleSettings.Properties.ShowTrayIcon != value)
|
||||
{
|
||||
ModuleSettings.Properties.ShowTrayIcon = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
Logger.LogInfo($"Changed the property {propertyName}");
|
||||
@@ -219,6 +232,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
OnPropertyChanged(nameof(IntervalHours));
|
||||
OnPropertyChanged(nameof(IntervalMinutes));
|
||||
OnPropertyChanged(nameof(ExpirationDateTime));
|
||||
OnPropertyChanged(nameof(ShowTrayIcon));
|
||||
}
|
||||
|
||||
private bool _enabledStateIsGPOConfigured;
|
||||
|
||||
Reference in New Issue
Block a user