diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 7524d6c1a79..b9f638957db 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -165,6 +165,7 @@ public string SettingWindowFont public bool UseClock { get; set; } = true; public bool UseDate { get; set; } = false; + public bool UseBattery { get; set; } = false; public string TimeFormat { get; set; } = "hh:mm tt"; public string DateFormat { get; set; } = "MM'/'dd ddd"; public bool FirstLaunch { get; set; } = true; diff --git a/Flow.Launcher/Flow.Launcher.csproj b/Flow.Launcher/Flow.Launcher.csproj index 576bf6f2f13..849b9adb116 100644 --- a/Flow.Launcher/Flow.Launcher.csproj +++ b/Flow.Launcher/Flow.Launcher.csproj @@ -147,6 +147,7 @@ + all diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 1b2b01ef892..e4a8d4fe734 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -328,6 +328,7 @@ Custom Clock Date + Battery Backdrop Type The backdrop effect is not applied in the preview. Backdrop supported starting from Windows 11 build 22000 and above diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 747975b2a62..93e884b15cc 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -299,18 +299,29 @@ x:Name="ClockPanel" IsHitTestVisible="False" Opacity="{Binding ClockPanelOpacity}" + Orientation="Horizontal" Style="{DynamicResource ClockPanel}" Visibility="{Binding ClockPanelVisibility}"> - - + + + + + + + diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index f69774e8e20..0a7e65e70c8 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -296,6 +296,14 @@ public bool UseDate set => Settings.UseDate = value; } + public bool UseBattery + { + get => Settings.UseBattery; + set => Settings.UseBattery = value; + } + + public string BatteryText => "75%"; + public FontFamily ClockPanelFont { get; } public Brush PreviewBackground diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 20b8dfb9ca2..c6453c807bd 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -333,21 +333,33 @@ - - + + + + + + + + + + + + + + + - + - @@ -144,11 +143,10 @@ - + - diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 333ac3652f4..e744d18ce99 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -27,6 +27,7 @@ using Flow.Launcher.Storage; using iNKORE.UI.WPF.Modern; using Microsoft.VisualStudio.Threading; +using PowerStatus; namespace Flow.Launcher.ViewModel { @@ -67,6 +68,8 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable, IResultUp private bool _taskbarShownByFlow = false; + private readonly PowerStatusProvider _powerStatusProvider = new(); + #endregion #region Constructor @@ -336,6 +339,13 @@ private async Task RegisterClockAndDateUpdateAsync() ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); if (Settings.UseDate) DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); + if (Settings.UseBattery) + { + var status = _powerStatusProvider.GetStatus(); + BatteryText = status.BatteryLifeProportion.HasValue + ? $"{(int)(status.BatteryLifeProportion.Value * 100)}%" + : string.Empty; + } } } @@ -692,6 +702,7 @@ public void CopyAlternative() public Settings Settings { get; } public string ClockText { get; private set; } public string DateText { get; private set; } + public string BatteryText { get; private set; } public ResultsViewModel Results { get; private set; } diff --git a/Flow.Launcher/packages.lock.json b/Flow.Launcher/packages.lock.json index b4b929d1965..6802629e451 100644 --- a/Flow.Launcher/packages.lock.json +++ b/Flow.Launcher/packages.lock.json @@ -135,6 +135,12 @@ "System.ValueTuple": "4.5.0" } }, + "PowerStatus": { + "type": "Direct", + "requested": "[1.0.3, )", + "resolved": "1.0.3", + "contentHash": "kDqm6puX7icNM9wX6OdmruBXZAM9bX2XwNNBB9KmQf9/D8wqyixYYVnZF6U3WGs+qtyNIpPIflRaQ4wwzoRfJQ==" + }, "PropertyChanged.Fody": { "type": "Direct", "requested": "[4.1.0, )", @@ -1619,7 +1625,7 @@ "FSharp.Core": "[9.0.303, )", "Flow.Launcher.Infrastructure": "[1.0.0, )", "Flow.Launcher.Localization": "[0.0.6, )", - "Flow.Launcher.Plugin": "[5.0.0, )", + "Flow.Launcher.Plugin": "[5.2.0, )", "Meziantou.Framework.Win32.Jobs": "[3.4.5, )", "Microsoft.IO.RecyclableMemoryStream": "[3.0.1, )", "SemanticVersioning": "[3.0.0, )", @@ -1634,7 +1640,7 @@ "BitFaster.Caching": "[2.5.4, )", "CommunityToolkit.Mvvm": "[8.4.0, )", "Flow.Launcher.Localization": "[0.0.6, )", - "Flow.Launcher.Plugin": "[5.0.0, )", + "Flow.Launcher.Plugin": "[5.2.0, )", "InputSimulator": "[1.0.4, )", "MemoryPack": "[1.21.4, )", "Microsoft.VisualStudio.Threading": "[17.14.15, )",