Skip to content

Commit ad63b0e

Browse files
committed
Improve code quality for field names
1 parent 8496cfc commit ad63b0e

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public class Theme
2525

2626
private const int ShadowExtraMargin = 32;
2727

28-
private readonly IPublicAPI API;
29-
private readonly Settings Settings;
30-
private readonly List<string> _themeDirectories = new List<string>();
28+
private readonly IPublicAPI _api;
29+
private readonly Settings _settings;
30+
private readonly List<string> _themeDirectories = new();
3131
private ResourceDictionary _oldResource;
3232
private string _oldTheme;
3333
private const string Folder = Constant.Themes;
@@ -41,8 +41,8 @@ public class Theme
4141

4242
public Theme(IPublicAPI publicAPI, Settings settings)
4343
{
44-
API = publicAPI;
45-
Settings = settings;
44+
_api = publicAPI;
45+
_settings = settings;
4646

4747
_themeDirectories.Add(DirectoryPath);
4848
_themeDirectories.Add(UserDirectoryPath);
@@ -94,7 +94,7 @@ public bool ChangeTheme(string theme)
9494
// to things like fonts
9595
UpdateResourceDictionary(GetResourceDictionary(theme));
9696

97-
Settings.Theme = theme;
97+
_settings.Theme = theme;
9898

9999

100100
//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
@@ -105,7 +105,7 @@ public bool ChangeTheme(string theme)
105105

106106
BlurEnabled = Win32Helper.IsBlurTheme();
107107

108-
if (Settings.UseDropShadowEffect && !BlurEnabled)
108+
if (_settings.UseDropShadowEffect && !BlurEnabled)
109109
AddDropShadowEffectToCurrentTheme();
110110

111111
Win32Helper.SetBlurForWindow(Application.Current.MainWindow, BlurEnabled);
@@ -115,7 +115,7 @@ public bool ChangeTheme(string theme)
115115
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> path can't be found");
116116
if (theme != defaultTheme)
117117
{
118-
API.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
118+
_api.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
119119
ChangeTheme(defaultTheme);
120120
}
121121
return false;
@@ -125,7 +125,7 @@ public bool ChangeTheme(string theme)
125125
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> fail to parse");
126126
if (theme != defaultTheme)
127127
{
128-
API.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
128+
_api.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
129129
ChangeTheme(defaultTheme);
130130
}
131131
return false;
@@ -153,7 +153,7 @@ private ResourceDictionary GetThemeResourceDictionary(string theme)
153153
return dict;
154154
}
155155

156-
private ResourceDictionary CurrentThemeResourceDictionary() => GetThemeResourceDictionary(Settings.Theme);
156+
private ResourceDictionary CurrentThemeResourceDictionary() => GetThemeResourceDictionary(_settings.Theme);
157157

158158
public ResourceDictionary GetResourceDictionary(string theme)
159159
{
@@ -162,10 +162,10 @@ public ResourceDictionary GetResourceDictionary(string theme)
162162
if (dict["QueryBoxStyle"] is Style queryBoxStyle &&
163163
dict["QuerySuggestionBoxStyle"] is Style querySuggestionBoxStyle)
164164
{
165-
var fontFamily = new FontFamily(Settings.QueryBoxFont);
166-
var fontStyle = FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.QueryBoxFontStyle);
167-
var fontWeight = FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.QueryBoxFontWeight);
168-
var fontStretch = FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.QueryBoxFontStretch);
165+
var fontFamily = new FontFamily(_settings.QueryBoxFont);
166+
var fontStyle = FontHelper.GetFontStyleFromInvariantStringOrNormal(_settings.QueryBoxFontStyle);
167+
var fontWeight = FontHelper.GetFontWeightFromInvariantStringOrNormal(_settings.QueryBoxFontWeight);
168+
var fontStretch = FontHelper.GetFontStretchFromInvariantStringOrNormal(_settings.QueryBoxFontStretch);
169169

170170
queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, fontFamily));
171171
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, fontStyle));
@@ -190,10 +190,10 @@ public ResourceDictionary GetResourceDictionary(string theme)
190190
dict["ItemHotkeyStyle"] is Style resultHotkeyItemStyle &&
191191
dict["ItemHotkeySelectedStyle"] is Style resultHotkeyItemSelectedStyle)
192192
{
193-
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultFont));
194-
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.ResultFontStyle));
195-
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.ResultFontWeight));
196-
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultFontStretch));
193+
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(_settings.ResultFont));
194+
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(_settings.ResultFontStyle));
195+
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(_settings.ResultFontWeight));
196+
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(_settings.ResultFontStretch));
197197

198198
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
199199
Array.ForEach(
@@ -205,10 +205,10 @@ public ResourceDictionary GetResourceDictionary(string theme)
205205
dict["ItemSubTitleStyle"] is Style resultSubItemStyle &&
206206
dict["ItemSubTitleSelectedStyle"] is Style resultSubItemSelectedStyle)
207207
{
208-
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultSubFont));
209-
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.ResultSubFontStyle));
210-
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.ResultSubFontWeight));
211-
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultSubFontStretch));
208+
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(_settings.ResultSubFont));
209+
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(_settings.ResultSubFontStyle));
210+
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(_settings.ResultSubFontWeight));
211+
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(_settings.ResultSubFontStretch));
212212

213213
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
214214
Array.ForEach(
@@ -218,15 +218,15 @@ public ResourceDictionary GetResourceDictionary(string theme)
218218

219219
/* Ignore Theme Window Width and use setting */
220220
var windowStyle = dict["WindowStyle"] as Style;
221-
var width = Settings.WindowSize;
221+
var width = _settings.WindowSize;
222222
windowStyle.Setters.Add(new Setter(Window.WidthProperty, width));
223223
mainWindowWidth = (double)width;
224224
return dict;
225225
}
226226

227227
private ResourceDictionary GetCurrentResourceDictionary( )
228228
{
229-
return GetResourceDictionary(Settings.Theme);
229+
return GetResourceDictionary(_settings.Theme);
230230
}
231231

232232
public List<ThemeData> LoadAvailableThemes()

Flow.Launcher.Core/Updater.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ namespace Flow.Launcher.Core
2222
{
2323
public class Updater
2424
{
25-
private readonly IPublicAPI API;
26-
2725
public string GitHubRepository { get; init; }
2826

27+
private readonly IPublicAPI _api;
28+
2929
public Updater(IPublicAPI publicAPI, string gitHubRepository)
3030
{
31-
API = publicAPI;
31+
_api = publicAPI;
3232
GitHubRepository = gitHubRepository;
3333
}
3434

@@ -40,8 +40,8 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
4040
try
4141
{
4242
if (!silentUpdate)
43-
API.ShowMsg(API.GetTranslation("pleaseWait"),
44-
API.GetTranslation("update_flowlauncher_update_check"));
43+
_api.ShowMsg(_api.GetTranslation("pleaseWait"),
44+
_api.GetTranslation("update_flowlauncher_update_check"));
4545

4646
using var updateManager = await GitHubUpdateManagerAsync(GitHubRepository).ConfigureAwait(false);
4747

@@ -56,13 +56,13 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
5656
if (newReleaseVersion <= currentVersion)
5757
{
5858
if (!silentUpdate)
59-
API.ShowMsgBox(API.GetTranslation("update_flowlauncher_already_on_latest"));
59+
_api.ShowMsgBox(_api.GetTranslation("update_flowlauncher_already_on_latest"));
6060
return;
6161
}
6262

6363
if (!silentUpdate)
64-
API.ShowMsg(API.GetTranslation("update_flowlauncher_update_found"),
65-
API.GetTranslation("update_flowlauncher_updating"));
64+
_api.ShowMsg(_api.GetTranslation("update_flowlauncher_update_found"),
65+
_api.GetTranslation("update_flowlauncher_updating"));
6666

6767
await updateManager.DownloadReleases(newUpdateInfo.ReleasesToApply).ConfigureAwait(false);
6868

@@ -71,9 +71,9 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
7171
if (DataLocation.PortableDataLocationInUse())
7272
{
7373
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
74-
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, (s) => API.ShowMsgBox(s));
75-
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, (s) => API.ShowMsgBox(s)))
76-
API.ShowMsgBox(string.Format(API.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
74+
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, (s) => _api.ShowMsgBox(s));
75+
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, (s) => _api.ShowMsgBox(s)))
76+
_api.ShowMsgBox(string.Format(_api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
7777
DataLocation.PortableDataPath,
7878
targetDestination));
7979
}
@@ -86,7 +86,7 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
8686

8787
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
8888

89-
if (API.ShowMsgBox(newVersionTips, API.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
89+
if (_api.ShowMsgBox(newVersionTips, _api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
9090
{
9191
UpdateManager.RestartApp(Constant.ApplicationFileName);
9292
}
@@ -99,8 +99,8 @@ public async Task UpdateAppAsync(bool silentUpdate = true)
9999
Log.Exception($"|Updater.UpdateApp|Error Occurred", e);
100100

101101
if (!silentUpdate)
102-
API.ShowMsg(API.GetTranslation("update_flowlauncher_fail"),
103-
API.GetTranslation("update_flowlauncher_check_connection"));
102+
_api.ShowMsg(_api.GetTranslation("update_flowlauncher_fail"),
103+
_api.GetTranslation("update_flowlauncher_check_connection"));
104104
}
105105
finally
106106
{

Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public bool KeywordEnabled
3131
}
3232

3333
private string actionKeyword;
34-
private readonly IPublicAPI api;
34+
private readonly IPublicAPI _api;
3535
private bool _keywordEnabled;
3636

3737
public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword, IPublicAPI api)
3838
{
3939
CurrentActionKeyword = selectedActionKeyword;
40-
this.api = api;
40+
_api = api;
4141
ActionKeyword = selectedActionKeyword.Keyword;
4242
KeywordEnabled = selectedActionKeyword.Enabled;
4343

@@ -62,22 +62,22 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e)
6262
switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled)
6363
{
6464
case (Settings.ActionKeyword.FileContentSearchActionKeyword, true):
65-
api.ShowMsgBox(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
65+
_api.ShowMsgBox(_api.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
6666
return;
6767
case (Settings.ActionKeyword.QuickAccessActionKeyword, true):
68-
api.ShowMsgBox(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
68+
_api.ShowMsgBox(_api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
6969
return;
7070
}
7171

72-
if (!KeywordEnabled || !api.ActionKeywordAssigned(ActionKeyword))
72+
if (!KeywordEnabled || !_api.ActionKeywordAssigned(ActionKeyword))
7373
{
7474
DialogResult = true;
7575
Close();
7676
return;
7777
}
7878

7979
// The keyword is not valid, so show message
80-
api.ShowMsgBox(api.GetTranslation("newActionKeywordsHasBeenAssigned"));
80+
_api.ShowMsgBox(_api.GetTranslation("newActionKeywordsHasBeenAssigned"));
8181
}
8282

8383
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)