Skip to content

Commit a74dc70

Browse files
committed
feat: search for file name in music gallery
1 parent 21eb8fc commit a74dc70

File tree

10 files changed

+31
-19
lines changed

10 files changed

+31
-19
lines changed

BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
7070
{
7171
var settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
7272

73-
_ = new SystemTrayWindow();
73+
WindowHook.OpenOrShowWindow<SystemTrayWindow>();
7474

7575
if (settingsService.AppSettings.GeneralSettings.AutoStartLyricsWindow)
7676
{

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/TrackExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public string GetRawLyrics()
2626
}
2727
return "";
2828
}
29+
30+
public string GetFileName() => Path.GetFileName(track.Path);
2931
}
3032
}
3133
}

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Hooks/WindowHook.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public static T OpenOrShowWindow<T>(LyricsWindowStatus? status = null)
129129
{
130130
window = new LyricsWindowSwitchWindow();
131131
}
132+
else if (typeof(T) == typeof(SystemTrayWindow))
133+
{
134+
window = new SystemTrayWindow();
135+
}
132136
else
133137
{
134138
throw new ArgumentException("Unsupported window type", nameof(T));
@@ -137,8 +141,11 @@ public static T OpenOrShowWindow<T>(LyricsWindowStatus? status = null)
137141
TrackWindow(window);
138142
var castedWindow = (Window)window;
139143

140-
castedWindow.Restore();
141-
castedWindow.Activate();
144+
if (typeof(T) != typeof(SystemTrayWindow))
145+
{
146+
castedWindow.Restore();
147+
castedWindow.Activate();
148+
}
142149

143150
if (typeof(T) == typeof(NowPlayingWindow))
144151
{

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Renderer/FluidBackgroundRenderer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public void Update(TimeSpan deltaTime)
6363

6464
_timeAccumulator += (float)deltaTime.TotalSeconds;
6565

66-
_fluidEffect.Properties["iTime"] = _timeAccumulator;
66+
_fluidEffect?.Properties["iTime"] = _timeAccumulator;
6767

68-
_fluidEffect.Properties["color1"] = _c1;
69-
_fluidEffect.Properties["color2"] = _c2;
70-
_fluidEffect.Properties["color3"] = _c3;
71-
_fluidEffect.Properties["color4"] = _c4;
68+
_fluidEffect?.Properties["color1"] = _c1;
69+
_fluidEffect?.Properties["color2"] = _c2;
70+
_fluidEffect?.Properties["color3"] = _c3;
71+
_fluidEffect?.Properties["color4"] = _c4;
7272

73-
_fluidEffect.Properties["EnableLightWave"] = EnableLightWave;
73+
_fluidEffect?.Properties["EnableLightWave"] = EnableLightWave;
7474
}
7575

7676
public void Draw(ICanvasAnimatedControl control, CanvasDrawingSession ds)

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/en-US/Resources.resw

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
<value>Single loop</value>
494494
</data>
495495
<data name="MusicGalleryPageSongSearchBox.PlaceholderText" xml:space="preserve">
496-
<value>Search for song title, artist, album or folder path</value>
496+
<value>Search for the song name, artist, album, file name, or folder path where the file is located</value>
497497
</data>
498498
<data name="MusicGalleryPageSortByAlbum.Content" xml:space="preserve">
499499
<value>Album</value>
@@ -1131,6 +1131,9 @@
11311131
<data name="SettingsPageLyricsNormal.Content" xml:space="preserve">
11321132
<value>Normal</value>
11331133
</data>
1134+
<data name="SettingsPageLyricsOpacity.Header" xml:space="preserve">
1135+
<value>Font opacity</value>
1136+
</data>
11341137
<data name="SettingsPageLyricsRowFactor.Header" xml:space="preserve">
11351138
<value>Lyrics area height factor</value>
11361139
</data>
@@ -1266,9 +1269,6 @@
12661269
<data name="SettingsPageOpacity.Header" xml:space="preserve">
12671270
<value>Opacity</value>
12681271
</data>
1269-
<data name="SettingsPageLyricsOpacity.Header" xml:space="preserve">
1270-
<value>Font opacity</value>
1271-
</data>
12721272
<data name="SettingsPageOpenFolderButton.Content" xml:space="preserve">
12731273
<value>Open in file explorer</value>
12741274
</data>

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ja-JP/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
<value>シングルループ</value>
494494
</data>
495495
<data name="MusicGalleryPageSongSearchBox.PlaceholderText" xml:space="preserve">
496-
<value>曲名、アーティスト、アルバム、フォルダパスを検索してください</value>
496+
<value>ファイルが置かれている曲名、アーティスト、アルバム、ファイル名、またはフォルダパスを検索します</value>
497497
</data>
498498
<data name="MusicGalleryPageSortByAlbum.Content" xml:space="preserve">
499499
<value>アルバム</value>

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/ko-KR/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
<value>단일 루프</value>
494494
</data>
495495
<data name="MusicGalleryPageSongSearchBox.PlaceholderText" xml:space="preserve">
496-
<value>노래 제목, 아티스트, 앨범 또는 폴더 경로를 검색하세요</value>
496+
<value>파일이 있는 노래 이름, 아티스트, 앨범, 파일 이름 또는 폴더 경로를 검색하세요</value>
497497
</data>
498498
<data name="MusicGalleryPageSortByAlbum.Content" xml:space="preserve">
499499
<value>앨범</value>

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-CN/Resources.resw

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,6 @@
492492
<data name="MusicGalleryPageSingleLoop.Text" xml:space="preserve">
493493
<value>单曲循环</value>
494494
</data>
495-
<data name="MusicGalleryPageSongSearchBox.PlaceholderText" xml:space="preserve">
496-
<value>搜索歌曲名、艺术家、专辑或所在文件夹路径</value>
497-
</data>
498495
<data name="MusicGalleryPageSortByAlbum.Content" xml:space="preserve">
499496
<value>专辑</value>
500497
</data>
@@ -1623,4 +1620,7 @@
16231620
<data name="UserGuide.Content" xml:space="preserve">
16241621
<value>使用指南</value>
16251622
</data>
1623+
<data name="MusicGalleryPageSongSearchBox.PlaceholderText" xml:space="preserve">
1624+
<value>搜索歌曲名、艺术家、专辑、文件名或文件所在文件夹路径</value>
1625+
</data>
16261626
</root>

BetterLyrics.WinUI3/BetterLyrics.WinUI3/Strings/zh-TW/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494
<value>單曲循環</value>
495495
</data>
496496
<data name="MusicGalleryPageSongSearchBox.PlaceholderText" xml:space="preserve">
497-
<value>搜尋歌曲名稱、藝人、專輯或所在資料夾路徑</value>
497+
<value>搜尋歌曲名稱、藝人、專輯、檔案名稱或檔案所在資料夾路徑</value>
498498
</data>
499499
<data name="MusicGalleryPageSortByAlbum.Content" xml:space="preserve">
500500
<value>專輯</value>

BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ public void ApplySongSearchQuery()
374374
t.Title.Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) ||
375375
t.Artist.Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) ||
376376
t.Album.Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) ||
377+
// 文件名(包含后缀)
378+
t.GetFileName().Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase) ||
379+
// 文件所在文件夹的路径
377380
t.GetParentFolderPath().Contains(SongSearchQuery, StringComparison.OrdinalIgnoreCase)).ToList();
378381
}
379382

0 commit comments

Comments
 (0)