Skip to content

Commit 8b6dcd0

Browse files
authored
Merge branch 'dev' into dev4
2 parents 23f6342 + 1a54eed commit 8b6dcd0

File tree

11 files changed

+149
-62
lines changed

11 files changed

+149
-62
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Windows.Markup;
99
using System.Windows.Media;
1010
using System.Windows.Media.Effects;
11+
using System.Windows.Shell;
1112
using Flow.Launcher.Infrastructure;
1213
using Flow.Launcher.Infrastructure.Logger;
1314
using Flow.Launcher.Infrastructure.UserSettings;
@@ -309,12 +310,15 @@ public void AddDropShadowEffectToCurrentTheme()
309310
var marginSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) as Setter;
310311
if (marginSetter == null)
311312
{
313+
var margin = new Thickness(ShadowExtraMargin, 12, ShadowExtraMargin, ShadowExtraMargin);
312314
marginSetter = new Setter()
313315
{
314316
Property = Border.MarginProperty,
315-
Value = new Thickness(ShadowExtraMargin, 12, ShadowExtraMargin, ShadowExtraMargin),
317+
Value = margin,
316318
};
317319
windowBorderStyle.Setters.Add(marginSetter);
320+
321+
SetResizeBoarderThickness(margin);
318322
}
319323
else
320324
{
@@ -325,6 +329,8 @@ public void AddDropShadowEffectToCurrentTheme()
325329
baseMargin.Right + ShadowExtraMargin,
326330
baseMargin.Bottom + ShadowExtraMargin);
327331
marginSetter.Value = newMargin;
332+
333+
SetResizeBoarderThickness(newMargin);
328334
}
329335

330336
windowBorderStyle.Setters.Add(effectSetter);
@@ -355,9 +361,36 @@ public void RemoveDropShadowEffectFromCurrentTheme()
355361
marginSetter.Value = newMargin;
356362
}
357363

364+
SetResizeBoarderThickness(null);
365+
358366
UpdateResourceDictionary(dict);
359367
}
360368

369+
// because adding drop shadow effect will change the margin of the window,
370+
// we need to update the window chrome thickness to correct set the resize border
371+
private static void SetResizeBoarderThickness(Thickness? effectMargin)
372+
{
373+
var window = Application.Current.MainWindow;
374+
if (WindowChrome.GetWindowChrome(window) is WindowChrome windowChrome)
375+
{
376+
Thickness thickness;
377+
if (effectMargin == null)
378+
{
379+
thickness = SystemParameters.WindowResizeBorderThickness;
380+
}
381+
else
382+
{
383+
thickness = new Thickness(
384+
effectMargin.Value.Left + SystemParameters.WindowResizeBorderThickness.Left,
385+
effectMargin.Value.Top + SystemParameters.WindowResizeBorderThickness.Top,
386+
effectMargin.Value.Right + SystemParameters.WindowResizeBorderThickness.Right,
387+
effectMargin.Value.Bottom + SystemParameters.WindowResizeBorderThickness.Bottom);
388+
}
389+
390+
windowChrome.ResizeBorderThickness = thickness;
391+
}
392+
}
393+
361394
public record ThemeData(string FileNameWithoutExtension, string Name, bool? IsDark = null, bool? HasBlur = null);
362395
}
363396
}

Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ private static unsafe HBITMAP GetHBitmap(string fileName, int width, int height,
8484
// Fallback to IconOnly if ThumbnailOnly fails
8585
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
8686
}
87+
catch (FileNotFoundException) when (options == ThumbnailOptions.ThumbnailOnly)
88+
{
89+
// Fallback to IconOnly if files cannot be found
90+
imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);
91+
}
8792
}
8893
finally
8994
{

Flow.Launcher.Plugin/Query.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text.Json.Serialization;
1+
using System.Text.Json.Serialization;
52

63
namespace Flow.Launcher.Plugin
74
{
85
public class Query
96
{
107
public Query() { }
118

12-
[Obsolete("Use the default Query constructor.")]
13-
public Query(string rawQuery, string search, string[] terms, string[] searchTerms, string actionKeyword = "")
14-
{
15-
Search = search;
16-
RawQuery = rawQuery;
17-
SearchTerms = searchTerms;
18-
ActionKeyword = actionKeyword;
19-
}
20-
219
/// <summary>
2210
/// Raw query, this includes action keyword if it has
2311
/// We didn't recommend use this property directly. You should always use Search property.

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
mc:Ignorable="d">
3939
<!-- WindowChrome -->
4040
<WindowChrome.WindowChrome>
41-
<WindowChrome CaptionHeight="9" ResizeBorderThickness="32 4 32 32" />
41+
<WindowChrome CaptionHeight="9" />
4242
</WindowChrome.WindowChrome>
4343
<Window.Resources>
4444
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />

Flow.Launcher/Storage/TopMostRecord.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class TopMostRecord
1212

1313
internal bool IsTopMost(Result result)
1414
{
15+
// origin query is null when user select the context menu item directly of one item from query list
16+
// in this case, we do not need to check if the result is top most
1517
if (records.IsEmpty || result.OriginQuery == null ||
1618
!records.TryGetValue(result.OriginQuery.RawQuery, out var value))
1719
{
@@ -24,11 +26,25 @@ internal bool IsTopMost(Result result)
2426

2527
internal void Remove(Result result)
2628
{
29+
// origin query is null when user select the context menu item directly of one item from query list
30+
// in this case, we do not need to remove the record
31+
if (result.OriginQuery == null)
32+
{
33+
return;
34+
}
35+
2736
records.Remove(result.OriginQuery.RawQuery, out _);
2837
}
2938

3039
internal void AddOrUpdate(Result result)
3140
{
41+
// origin query is null when user select the context menu item directly of one item from query list
42+
// in this case, we do not need to add or update the record
43+
if (result.OriginQuery == null)
44+
{
45+
return;
46+
}
47+
3248
var record = new Record
3349
{
3450
PluginID = result.PluginID,
@@ -38,11 +54,6 @@ internal void AddOrUpdate(Result result)
3854
};
3955
records.AddOrUpdate(result.OriginQuery.RawQuery, record, (key, oldValue) => record);
4056
}
41-
42-
public void Load(Dictionary<string, Record> dictionary)
43-
{
44-
records = new ConcurrentDictionary<string, Record>(dictionary);
45-
}
4657
}
4758

4859
public class Record

Flow.Launcher/Storage/UserSelectedRecord.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ private static int GenerateResultHashCode(Result result)
5757

5858
private static int GenerateQueryAndResultHashCode(Query query, Result result)
5959
{
60+
// query is null when user select the context menu item directly of one item from query list
61+
// so we only need to consider the result
6062
if (query == null)
6163
{
6264
return GenerateResultHashCode(result);

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public partial class MainViewModel : BaseModel, ISavable
3535

3636
private bool _isQueryRunning;
3737
private Query _lastQuery;
38-
private Result lastContextMenuResult = new Result();
39-
private List<Result> lastContextMenuResults = new List<Result>();
4038
private string _queryTextBeforeLeaveResults;
4139

4240
private readonly FlowLauncherJsonStorage<History> _historyItemsStorage;
@@ -399,11 +397,15 @@ private async Task OpenResultAsync(string index)
399397
})
400398
.ConfigureAwait(false);
401399

402-
403400
if (SelectedIsFromQueryResults())
404401
{
405402
_userSelectedRecord.Add(result);
406-
_history.Add(result.OriginQuery.RawQuery);
403+
// origin query is null when user select the context menu item directly of one item from query list
404+
// so we don't want to add it to history
405+
if (result.OriginQuery != null)
406+
{
407+
_history.Add(result.OriginQuery.RawQuery);
408+
}
407409
lastHistoryIndex = 1;
408410
}
409411

@@ -987,19 +989,10 @@ private void QueryContextMenu()
987989
if (selected != null) // SelectedItem returns null if selection is empty.
988990
{
989991
List<Result> results;
990-
if (selected == lastContextMenuResult)
991-
{
992-
results = lastContextMenuResults;
993-
}
994-
else
995-
{
996-
results = PluginManager.GetContextMenusForPlugin(selected);
997-
lastContextMenuResults = results;
998-
lastContextMenuResult = selected;
999-
results.Add(ContextMenuTopMost(selected));
1000-
results.Add(ContextMenuPluginInfo(selected.PluginID));
1001-
}
1002992

993+
results = PluginManager.GetContextMenusForPlugin(selected);
994+
results.Add(ContextMenuTopMost(selected));
995+
results.Add(ContextMenuPluginInfo(selected.PluginID));
1003996

1004997
if (!string.IsNullOrEmpty(query))
1005998
{
@@ -1274,6 +1267,8 @@ private Result ContextMenuTopMost(Result result)
12741267
{
12751268
_topMostRecord.Remove(result);
12761269
App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success"));
1270+
App.API.BackToQueryResults();
1271+
App.API.ReQuery();
12771272
return false;
12781273
}
12791274
};
@@ -1290,6 +1285,8 @@ private Result ContextMenuTopMost(Result result)
12901285
{
12911286
_topMostRecord.AddOrUpdate(result);
12921287
App.API.ShowMsg(InternationalizationManager.Instance.GetTranslation("success"));
1288+
App.API.BackToQueryResults();
1289+
App.API.ReQuery();
12931290
return false;
12941291
}
12951292
};
@@ -1378,8 +1375,6 @@ public async void Hide()
13781375
lastHistoryIndex = 1;
13791376
// Trick for no delay
13801377
MainWindowOpacity = 0;
1381-
lastContextMenuResult = new Result();
1382-
lastContextMenuResults = new List<Result>();
13831378

13841379
if (ExternalPreviewVisible)
13851380
CloseExternalPreview();

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
242242
var name = "Plugin: Folder";
243243
var message = $"File not found: {e.Message}";
244244
Context.API.ShowMsgError(name, message);
245+
return false;
245246
}
246247

247248
return true;

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
264264
Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
265265
Context.API.GetTranslation(
266266
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
267+
Context.API.BackToQueryResults();
268+
Context.API.ReQuery();
267269
return false;
268270
},
269271
IcoPath = "Images/disable.png",

0 commit comments

Comments
 (0)