Skip to content

Commit 2770c6a

Browse files
authored
Merge branch 'dev' into fix_result_clearing_nonquery
2 parents 7399d11 + 60de423 commit 2770c6a

File tree

85 files changed

+879
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+879
-167
lines changed

.github/workflows/release_deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
3+
name: New Release Deployments
4+
on:
5+
release:
6+
types: [published]
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy-website:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Trigger dispatch event for deploying website
14+
run: |
15+
http_status=$(curl -L -f -s -o /dev/null -w "%{http_code}" \
16+
-X POST \
17+
-H "Accept: application/vnd.github+json" \
18+
-H "Authorization: Bearer ${{ secrets.DEPLOY_FLOW_WEBSITE }}" \
19+
https://api.github.com/repos/Flow-Launcher/flow-launcher.github.io/dispatches \
20+
-d '{"event_type":"deploy"}')
21+
if [ "$http_status" -ne 204 ]; then echo "Error: Deploy website failed, HTTP status code is $http_status"; exit 1; fi
22+
23+
publish-chocolatey:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Trigger dispatch event for publishing to Chocolatey
27+
run: |
28+
http_status=$(curl -L -f -s -o /dev/null -w "%{http_code}" \
29+
-X POST \
30+
-H "Accept: application/vnd.github+json" \
31+
-H "Authorization: Bearer ${{ secrets.Publish_Chocolatey }}" \
32+
https://api.github.com/repos/Flow-Launcher/chocolatey-package/dispatches \
33+
-d '{"event_type":"publish"}')
34+
if [ "$http_status" -ne 204 ]; then echo "Error: Publish Chocolatey package failed, HTTP status code is $http_status"; exit 1; fi

.github/workflows/website_deploy.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,19 @@ public static async Task InitializePluginsAsync()
220220
catch (Exception e)
221221
{
222222
API.LogException(ClassName, $"Fail to Init plugin: {pair.Metadata.Name}", e);
223-
pair.Metadata.Disabled = true;
224-
pair.Metadata.HomeDisabled = true;
225-
failedPlugins.Enqueue(pair);
223+
if (pair.Metadata.Disabled && pair.Metadata.HomeDisabled)
224+
{
225+
// If this plugin is already disabled, do not show error message again
226+
// Or else it will be shown every time
227+
API.LogDebug(ClassName, $"Skipped init for <{pair.Metadata.Name}> due to error");
228+
}
229+
else
230+
{
231+
pair.Metadata.Disabled = true;
232+
pair.Metadata.HomeDisabled = true;
233+
failedPlugins.Enqueue(pair);
234+
API.LogDebug(ClassName, $"Disable plugin <{pair.Metadata.Name}> because init failed");
235+
}
226236
}
227237
}));
228238

Flow.Launcher.Infrastructure/Storage/JsonStorage.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ public JsonStorage(string filePath)
4545
FilesFolders.ValidateDirectory(DirectoryPath);
4646
}
4747

48+
public bool Exists()
49+
{
50+
return File.Exists(FilePath);
51+
}
52+
53+
public void Delete()
54+
{
55+
foreach (var path in new[] { FilePath, BackupFilePath, TempFilePath })
56+
{
57+
if (File.Exists(path))
58+
{
59+
File.Delete(path);
60+
}
61+
}
62+
}
63+
4864
public async Task<T> LoadAsync()
4965
{
5066
if (Data != null)

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ public SearchPrecisionScore QuerySearchPrecision
306306

307307
public double WindowLeft { get; set; }
308308
public double WindowTop { get; set; }
309+
public double PreviousScreenWidth { get; set; }
310+
public double PreviousScreenHeight { get; set; }
311+
public double PreviousDpiX { get; set; }
312+
public double PreviousDpiY { get; set; }
309313

310314
/// <summary>
311315
/// Custom left position on selected monitor

Flow.Launcher/Languages/pl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ Jeśli dodasz prefiks '@' podczas wprowadzania skrótu, będzie on pasował do d
488488
<system:String x:Key="update_flowlauncher_update_cancel">Anuluj</system:String>
489489
<system:String x:Key="update_flowlauncher_fail">Aktualizacja nie powiodła się</system:String>
490490
<system:String x:Key="update_flowlauncher_check_connection">Sprawdź połączenie i spróbuj zaktualizować ustawienia proxy do github-cloud.s3.amazonaws.com.</system:String>
491-
<system:String x:Key="update_flowlauncher_update_restart_flowlauncher_tip">Aby dokończyć proces aktualizacji Flow Launcher musi zostać zresetowany</system:String>
491+
<system:String x:Key="update_flowlauncher_update_restart_flowlauncher_tip">Aby dokończyć proces aktualizacji Flow Launcher musi zostać zrestartowany</system:String>
492492
<system:String x:Key="update_flowlauncher_update_update_files">Następujące pliki zostaną zaktualizowane</system:String>
493493
<system:String x:Key="update_flowlauncher_update_files">Aktualizuj pliki</system:String>
494494
<system:String x:Key="update_flowlauncher_update_update_description">Opis aktualizacji</system:String>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 111 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using Flow.Launcher.Infrastructure.UserSettings;
2323
using Flow.Launcher.Plugin.SharedCommands;
2424
using Flow.Launcher.ViewModel;
25+
using Microsoft.Win32;
2526
using ModernWpf.Controls;
2627
using DataObject = System.Windows.DataObject;
2728
using Key = System.Windows.Input.Key;
@@ -88,6 +89,8 @@ public MainWindow()
8889

8990
InitSoundEffects();
9091
DataObject.AddPastingHandler(QueryTextBox, QueryTextBox_OnPaste);
92+
ModernWpf.ThemeManager.Current.ActualApplicationThemeChanged += ThemeManager_ActualApplicationThemeChanged;
93+
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
9194
}
9295

9396
#endregion
@@ -96,6 +99,11 @@ public MainWindow()
9699

97100
#pragma warning disable VSTHRD100 // Avoid async void methods
98101

102+
private void ThemeManager_ActualApplicationThemeChanged(ModernWpf.ThemeManager sender, object args)
103+
{
104+
_theme.RefreshFrameAsync();
105+
}
106+
99107
private void OnSourceInitialized(object sender, EventArgs e)
100108
{
101109
var handle = Win32Helper.GetWindowHandle(this, true);
@@ -541,16 +549,29 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
541549

542550
#region Window Sound Effects
543551

552+
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
553+
{
554+
// Fix for sound not playing after sleep / hibernate
555+
// https://stackoverflow.com/questions/64805186/mediaplayer-doesnt-play-after-computer-sleeps
556+
if (e.Mode == PowerModes.Resume)
557+
{
558+
InitSoundEffects();
559+
}
560+
}
561+
544562
private void InitSoundEffects()
545563
{
546564
if (_settings.WMPInstalled)
547565
{
566+
animationSoundWMP?.Close();
548567
animationSoundWMP = new MediaPlayer();
549568
animationSoundWMP.Open(new Uri(AppContext.BaseDirectory + "Resources\\open.wav"));
550569
}
551570
else
552571
{
572+
animationSoundWPF?.Dispose();
553573
animationSoundWPF = new SoundPlayer(AppContext.BaseDirectory + "Resources\\open.wav");
574+
animationSoundWPF.Load();
554575
}
555576
}
556577

@@ -696,8 +717,26 @@ void InitializePositionInner()
696717
{
697718
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
698719
{
699-
Top = _settings.WindowTop;
720+
var previousScreenWidth = _settings.PreviousScreenWidth;
721+
var previousScreenHeight = _settings.PreviousScreenHeight;
722+
GetDpi(out var previousDpiX, out var previousDpiY);
723+
724+
_settings.PreviousScreenWidth = SystemParameters.VirtualScreenWidth;
725+
_settings.PreviousScreenHeight = SystemParameters.VirtualScreenHeight;
726+
GetDpi(out var currentDpiX, out var currentDpiY);
727+
728+
if (previousScreenWidth != 0 && previousScreenHeight != 0 &&
729+
previousDpiX != 0 && previousDpiY != 0 &&
730+
(previousScreenWidth != SystemParameters.VirtualScreenWidth ||
731+
previousScreenHeight != SystemParameters.VirtualScreenHeight ||
732+
previousDpiX != currentDpiX || previousDpiY != currentDpiY))
733+
{
734+
AdjustPositionForResolutionChange();
735+
return;
736+
}
737+
700738
Left = _settings.WindowLeft;
739+
Top = _settings.WindowTop;
701740
}
702741
else
703742
{
@@ -710,27 +749,73 @@ void InitializePositionInner()
710749
break;
711750
case SearchWindowAligns.CenterTop:
712751
Left = HorizonCenter(screen);
713-
Top = 10;
752+
Top = VerticalTop(screen);
714753
break;
715754
case SearchWindowAligns.LeftTop:
716755
Left = HorizonLeft(screen);
717-
Top = 10;
756+
Top = VerticalTop(screen);
718757
break;
719758
case SearchWindowAligns.RightTop:
720759
Left = HorizonRight(screen);
721-
Top = 10;
760+
Top = VerticalTop(screen);
722761
break;
723762
case SearchWindowAligns.Custom:
724-
Left = Win32Helper.TransformPixelsToDIP(this,
725-
screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X;
726-
Top = Win32Helper.TransformPixelsToDIP(this, 0,
727-
screen.WorkingArea.Y + _settings.CustomWindowTop).Y;
763+
var customLeft = Win32Helper.TransformPixelsToDIP(this,
764+
screen.WorkingArea.X + _settings.CustomWindowLeft, 0);
765+
var customTop = Win32Helper.TransformPixelsToDIP(this, 0,
766+
screen.WorkingArea.Y + _settings.CustomWindowTop);
767+
Left = customLeft.X;
768+
Top = customTop.Y;
728769
break;
729770
}
730771
}
731772
}
732773
}
733774

775+
private void AdjustPositionForResolutionChange()
776+
{
777+
var screenWidth = SystemParameters.VirtualScreenWidth;
778+
var screenHeight = SystemParameters.VirtualScreenHeight;
779+
GetDpi(out var currentDpiX, out var currentDpiY);
780+
781+
var previousLeft = _settings.WindowLeft;
782+
var previousTop = _settings.WindowTop;
783+
GetDpi(out var previousDpiX, out var previousDpiY);
784+
785+
var widthRatio = screenWidth / _settings.PreviousScreenWidth;
786+
var heightRatio = screenHeight / _settings.PreviousScreenHeight;
787+
var dpiXRatio = currentDpiX / previousDpiX;
788+
var dpiYRatio = currentDpiY / previousDpiY;
789+
790+
var newLeft = previousLeft * widthRatio * dpiXRatio;
791+
var newTop = previousTop * heightRatio * dpiYRatio;
792+
793+
var screenLeft = SystemParameters.VirtualScreenLeft;
794+
var screenTop = SystemParameters.VirtualScreenTop;
795+
796+
var maxX = screenLeft + screenWidth - ActualWidth;
797+
var maxY = screenTop + screenHeight - ActualHeight;
798+
799+
Left = Math.Max(screenLeft, Math.Min(newLeft, maxX));
800+
Top = Math.Max(screenTop, Math.Min(newTop, maxY));
801+
}
802+
803+
private void GetDpi(out double dpiX, out double dpiY)
804+
{
805+
var source = PresentationSource.FromVisual(this);
806+
if (source != null && source.CompositionTarget != null)
807+
{
808+
var matrix = source.CompositionTarget.TransformToDevice;
809+
dpiX = 96 * matrix.M11;
810+
dpiY = 96 * matrix.M22;
811+
}
812+
else
813+
{
814+
dpiX = 96;
815+
dpiY = 96;
816+
}
817+
}
818+
734819
private Screen SelectedScreen()
735820
{
736821
Screen screen;
@@ -791,6 +876,13 @@ private double HorizonLeft(Screen screen)
791876
return left;
792877
}
793878

879+
public double VerticalTop(Screen screen)
880+
{
881+
var dip1 = Win32Helper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
882+
var top = dip1.Y + 10;
883+
return top;
884+
}
885+
794886
#endregion
795887

796888
#region Window Animation
@@ -817,7 +909,7 @@ private void InitProgressbarAnimation()
817909
{
818910
Name = progressBarAnimationName, Storyboard = progressBarStoryBoard
819911
};
820-
912+
821913
var stopStoryboard = new StopStoryboard()
822914
{
823915
BeginStoryboardName = progressBarAnimationName
@@ -838,7 +930,7 @@ private void InitProgressbarAnimation()
838930
progressStyle.Triggers.Add(trigger);
839931

840932
ProgressBar.Style = progressStyle;
841-
933+
842934
_viewModel.ProgressBarVisibility = Visibility.Hidden;
843935
}
844936

@@ -886,7 +978,7 @@ private void WindowAnimation()
886978
Duration = TimeSpan.FromMilliseconds(animationLength),
887979
FillBehavior = FillBehavior.HoldEnd
888980
};
889-
981+
890982
var rightMargin = GetThicknessFromStyle(ClockPanel.Style, new Thickness(0, 0, DefaultRightMargin, 0)).Right;
891983

892984
var thicknessAnimation = new ThicknessAnimation
@@ -914,10 +1006,10 @@ private void WindowAnimation()
9141006
clocksb.Children.Add(ClockOpacity);
9151007
iconsb.Children.Add(IconMotion);
9161008
iconsb.Children.Add(IconOpacity);
917-
1009+
9181010
_settings.WindowLeft = Left;
9191011
_isArrowKeyPressed = false;
920-
1012+
9211013
clocksb.Begin(ClockPanel);
9221014
iconsb.Begin(SearchIcon);
9231015
}
@@ -1089,7 +1181,7 @@ private void QueryTextBox_OnPreviewDragOver(object sender, DragEventArgs e)
10891181
{
10901182
e.Handled = true;
10911183
}
1092-
1184+
10931185
#endregion
10941186

10951187
#region Placeholder
@@ -1141,7 +1233,7 @@ private void SetupResizeMode()
11411233
}
11421234

11431235
#endregion
1144-
1236+
11451237
#region Search Delay
11461238

11471239
private void QueryTextBox_TextChanged1(object sender, TextChangedEventArgs e)
@@ -1163,6 +1255,10 @@ protected virtual void Dispose(bool disposing)
11631255
{
11641256
_hwndSource?.Dispose();
11651257
_notifyIcon?.Dispose();
1258+
animationSoundWMP?.Close();
1259+
animationSoundWPF?.Dispose();
1260+
ModernWpf.ThemeManager.Current.ActualApplicationThemeChanged -= ThemeManager_ActualApplicationThemeChanged;
1261+
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
11661262
}
11671263

11681264
_disposed = true;

0 commit comments

Comments
 (0)