Skip to content

Commit c74a2db

Browse files
committed
- Add clock in query bar (sublime theme only)
1 parent 1149ff5 commit c74a2db

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
</ContextMenu>
9797
</TextBox.ContextMenu>
9898
</TextBox>
99+
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
100+
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}"></TextBlock>
101+
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}"></TextBlock>
102+
</StackPanel>
99103
<Canvas Style="{DynamicResource SearchIconPosition}">
100104
<Path Data="{DynamicResource SearchIconImg}" Style="{DynamicResource SearchIconStyle}" Margin="0" Stretch="Fill"/>
101105
</Canvas>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using Flow.Launcher.Helper;
1212
using Flow.Launcher.Infrastructure.UserSettings;
1313
using Flow.Launcher.ViewModel;
14+
using System.Windows.Threading;
15+
using System.Globalization;
1416
using Application = System.Windows.Application;
1517
using Screen = System.Windows.Forms.Screen;
1618
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
@@ -31,22 +33,37 @@ public partial class MainWindow
3133
private Settings _settings;
3234
private NotifyIcon _notifyIcon;
3335
private MainViewModel _viewModel;
34-
3536
#endregion
3637

3738
public MainWindow(Settings settings, MainViewModel mainVM)
3839
{
3940
DataContext = mainVM;
4041
_viewModel = mainVM;
4142
_settings = settings;
43+
44+
DispatcherTimer timer = new DispatcherTimer();
45+
timer.Interval = new TimeSpan(0, 0, 1);
46+
timer.Tick += Timer_Tick;
47+
timer.Start();
4248
InitializeComponent();
4349
}
4450

4551
public MainWindow()
4652
{
53+
4754
InitializeComponent();
55+
56+
57+
}
58+
59+
private void Timer_Tick(object sender, EventArgs e)
60+
{
61+
ClockBox.Text = System.DateTime.Now.ToString("tt hh:mm");
62+
DateBox.Text = System.DateTime.Now.ToString("ddd MM/dd", CultureInfo.InvariantCulture);
63+
4864
}
4965

66+
5067
private async void OnClosing(object sender, CancelEventArgs e)
5168
{
5269
_notifyIcon.Visible = false;

Flow.Launcher/SettingWindow.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@
586586
<Canvas Style="{DynamicResource SearchIconPosition}">
587587
<Path Data="{DynamicResource SearchIconImg}" Style="{DynamicResource SearchIconStyle}" Margin="0" Stretch="Fill"/>
588588
</Canvas>
589-
589+
<StackPanel x:Name="ClockPanel" Style="{DynamicResource ClockPanel}">
590+
<TextBlock x:Name="ClockBox" Style="{DynamicResource ClockBox}"></TextBlock>
591+
<TextBlock x:Name="DateBox" Style="{DynamicResource DateBox}"></TextBlock>
592+
</StackPanel>
590593
<Border Margin="0 0 0 0" Grid.Row="1">
591594
<Rectangle Width="Auto" HorizontalAlignment="Stretch" Style="{DynamicResource SeparatorStyle}" Visibility="visible"/>
592595
</Border>

Flow.Launcher/Themes/Base.xaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,28 @@
270270
<Setter Property="HorizontalAlignment" Value="Right" />
271271
</Style>
272272

273+
<Style x:Key="BaseClockPanel" TargetType="{x:Type StackPanel}">
274+
<Setter Property="HorizontalAlignment" Value="Right" />
275+
<Setter Property="VerticalAlignment" Value="Center" />
276+
<Setter Property="Height" Value="Auto" />
277+
<Setter Property="Margin" Value="0 0 14 0" />
278+
<Setter Property="Visibility" Value="Collapsed" />
279+
</Style>
280+
<Style x:Key="BaseClockBox" TargetType="{x:Type TextBlock}">
281+
<Setter Property="FontSize" Value="20" />
282+
<Setter Property="Foreground" Value="#8f8f8f" />
283+
<Setter Property="VerticalAlignment" Value="Bottom" />
284+
<Setter Property="HorizontalAlignment" Value="Right" />
285+
<Setter Property="Margin" Value="0 0 0 -5" />
286+
</Style>
287+
<Style x:Key="BaseDateBox" TargetType="{x:Type TextBlock}">
288+
<Setter Property="FontSize" Value="14" />
289+
<Setter Property="Foreground" Value="#8f8f8f" />
290+
<Setter Property="VerticalAlignment" Value="Top" />
291+
<Setter Property="HorizontalAlignment" Value="Right" />
292+
<Setter Property="Margin" Value="0 0 0 0" />
293+
</Style>
294+
273295
<!--for classic themes-->
274296
<Style x:Key="SearchIconStyle" TargetType="{x:Type Path}">
275297
<Setter Property="Fill" Value="#555555" />
@@ -293,5 +315,12 @@
293315
<Setter Property="Foreground" Value="#8f8f8f" />
294316
<Setter Property="Opacity" Value="0.5" />
295317
</Style>
318+
319+
<Style x:Key="ClockBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseClockBox}">
320+
</Style>
321+
<Style x:Key="DateBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseDateBox}">
322+
</Style>
323+
<Style x:Key="ClockPanel" TargetType="{x:Type StackPanel}" BasedOn="{StaticResource BaseClockPanel}">
324+
</Style>
296325
</ResourceDictionary>
297326

Flow.Launcher/Themes/Sublime.xaml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Setter Property="Cursor" Value="Arrow" />
6060
<Setter Property="Foreground" Value="#cc8ec8" />
6161
</Style>
62-
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#3c454e</SolidColorBrush>
62+
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#3C454E</SolidColorBrush>
6363
<Style x:Key="ItemImageSelectedStyle" BasedOn="{StaticResource BaseItemImageSelectedStyle}" TargetType="{x:Type Image}" >
6464
<Setter Property="Cursor" Value="Arrow" />
6565
</Style>
@@ -100,5 +100,44 @@
100100
<Setter Property="Fill" Value="#3c454e" />
101101
<Setter Property="Width" Value="32" />
102102
<Setter Property="Height" Value="32" />
103+
<Setter Property="Visibility" Value="Collapsed" />
104+
</Style>
105+
106+
<Style x:Key="ClockBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseClockBox}">
107+
<Setter Property="Foreground" Value="#cc8ec8" />
108+
</Style>
109+
<Style x:Key="DateBox" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseDateBox}">
110+
<Setter Property="Foreground" Value="#cc8ec8" />
111+
</Style>
112+
<Style x:Key="ClockPanel" TargetType="{x:Type StackPanel}" BasedOn="{StaticResource BaseClockPanel}">
113+
<Setter Property="Visibility" Value="Visible" />
114+
<Style.Triggers>
115+
<DataTrigger Binding="{Binding ElementName=QueryTextBox, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
116+
117+
<DataTrigger.EnterActions>
118+
<BeginStoryboard>
119+
<Storyboard>
120+
<DoubleAnimation
121+
Storyboard.TargetProperty="Opacity"
122+
From="0.0" To="1.0" Duration="0:0:0.2"
123+
/>
124+
</Storyboard>
125+
</BeginStoryboard>
126+
</DataTrigger.EnterActions>
127+
<DataTrigger.ExitActions>
128+
<BeginStoryboard>
129+
<Storyboard>
130+
<DoubleAnimation
131+
Storyboard.TargetProperty="Opacity"
132+
From="1.0" To="0.0" Duration="0:0:0.2"
133+
/>
134+
</Storyboard>
135+
</BeginStoryboard>
136+
</DataTrigger.ExitActions>
137+
138+
</DataTrigger>
139+
140+
</Style.Triggers>
141+
103142
</Style>
104143
</ResourceDictionary>

0 commit comments

Comments
 (0)