mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix General
This commit is contained in:
parent
dc26792e85
commit
7e4a37c1a3
3 changed files with 220 additions and 102 deletions
|
|
@ -29,6 +29,8 @@ using Flow.Launcher.Core.Resource;
|
|||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
|
||||
|
||||
namespace Flow.Launcher.SettingPages.ViewModels
|
||||
{
|
||||
|
|
@ -49,6 +51,30 @@ namespace Flow.Launcher.SettingPages.ViewModels
|
|||
public SearchWindowScreens Value { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public bool StartFlowLauncherOnSystemStartup
|
||||
{
|
||||
get => Settings.StartFlowLauncherOnSystemStartup;
|
||||
set
|
||||
{
|
||||
Settings.StartFlowLauncherOnSystemStartup = value;
|
||||
|
||||
try
|
||||
{
|
||||
if (value)
|
||||
AutoStartup.Enable();
|
||||
else
|
||||
AutoStartup.Disable();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"),
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Internationalization _translater => InternationalizationManager.Instance;
|
||||
public List<SearchWindowScreen> SearchWindowScreens
|
||||
{
|
||||
|
|
@ -69,5 +95,161 @@ namespace Flow.Launcher.SettingPages.ViewModels
|
|||
|
||||
|
||||
}
|
||||
|
||||
public List<SearchWindowAlign> SearchWindowAligns
|
||||
{
|
||||
get
|
||||
{
|
||||
List<SearchWindowAlign> modes = new List<SearchWindowAlign>();
|
||||
var enums = (SearchWindowAligns[])Enum.GetValues(typeof(SearchWindowAligns));
|
||||
foreach (var e in enums)
|
||||
{
|
||||
var key = $"SearchWindowAlign{e}";
|
||||
var display = _translater.GetTranslation(key);
|
||||
var m = new SearchWindowAlign { Display = display, Value = e, };
|
||||
modes.Add(m);
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
}
|
||||
|
||||
public List<int> ScreenNumbers
|
||||
{
|
||||
get
|
||||
{
|
||||
var screens = System.Windows.Forms.Screen.AllScreens;
|
||||
var screenNumbers = new List<int>();
|
||||
for (int i = 1; i <= screens.Length; i++)
|
||||
{
|
||||
screenNumbers.Add(i);
|
||||
}
|
||||
|
||||
return screenNumbers;
|
||||
}
|
||||
}
|
||||
|
||||
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
|
||||
private bool _portableMode = DataLocation.PortableDataLocationInUse();
|
||||
|
||||
public bool PortableMode
|
||||
{
|
||||
get => _portableMode;
|
||||
set
|
||||
{
|
||||
if (!_portable.CanUpdatePortability())
|
||||
return;
|
||||
|
||||
if (DataLocation.PortableDataLocationInUse())
|
||||
{
|
||||
_portable.DisablePortableMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
_portable.EnablePortableMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// todo a better name?
|
||||
public class LastQueryMode : BaseModel
|
||||
{
|
||||
public string Display { get; set; }
|
||||
public Infrastructure.UserSettings.LastQueryMode Value { get; set; }
|
||||
}
|
||||
|
||||
private List<LastQueryMode> _lastQueryModes = new List<LastQueryMode>();
|
||||
|
||||
public List<LastQueryMode> LastQueryModes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lastQueryModes.Count == 0)
|
||||
{
|
||||
_lastQueryModes = InitLastQueryModes();
|
||||
}
|
||||
|
||||
return _lastQueryModes;
|
||||
}
|
||||
}
|
||||
|
||||
private List<LastQueryMode> InitLastQueryModes()
|
||||
{
|
||||
var modes = new List<LastQueryMode>();
|
||||
var enums = (Infrastructure.UserSettings.LastQueryMode[])Enum.GetValues(
|
||||
typeof(Infrastructure.UserSettings.LastQueryMode));
|
||||
foreach (var e in enums)
|
||||
{
|
||||
var key = $"LastQuery{e}";
|
||||
var display = _translater.GetTranslation(key);
|
||||
var m = new LastQueryMode { Display = display, Value = e, };
|
||||
modes.Add(m);
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
private void UpdateLastQueryModeDisplay()
|
||||
{
|
||||
foreach (var item in LastQueryModes)
|
||||
{
|
||||
item.Display = _translater.GetTranslation($"LastQuery{item.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
public string Language
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Language;
|
||||
}
|
||||
set
|
||||
{
|
||||
InternationalizationManager.Instance.ChangeLanguage(value);
|
||||
|
||||
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
|
||||
ShouldUsePinyin = true;
|
||||
|
||||
UpdateLastQueryModeDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldUsePinyin
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.ShouldUsePinyin;
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings.ShouldUsePinyin = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> QuerySearchPrecisionStrings
|
||||
{
|
||||
get
|
||||
{
|
||||
var precisionStrings = new List<string>();
|
||||
|
||||
var enumList = Enum.GetValues(typeof(SearchPrecisionScore)).Cast<SearchPrecisionScore>().ToList();
|
||||
|
||||
enumList.ForEach(x => precisionStrings.Add(x.ToString()));
|
||||
|
||||
return precisionStrings;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> OpenResultModifiersList => new List<string>
|
||||
{
|
||||
KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}"
|
||||
};
|
||||
|
||||
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
||||
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
||||
|
||||
public string AlwaysPreviewToolTip =>
|
||||
string.Format(_translater.GetTranslation("AlwaysPreviewToolTip"), Settings.PreviewHotkey);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
x:Class="Flow.Launcher.SettingPages.Views.Theme"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:cc="clr-namespace:Flow.Launcher.Resources.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.SettingPages.Views"
|
||||
|
|
@ -13,14 +14,6 @@
|
|||
d:DesignWidth="800"
|
||||
Style="{DynamicResource SettingPageBasic}"
|
||||
mc:Ignorable="d">
|
||||
<ui:Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Resources/SettingWindowStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<CollectionViewSource x:Key="SortedFonts" Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}" />
|
||||
</ResourceDictionary>
|
||||
</ui:Page.Resources>
|
||||
<ScrollViewer
|
||||
Margin="0,0,0,0"
|
||||
Padding="6,0,24,0"
|
||||
|
|
@ -128,55 +121,41 @@
|
|||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="2" VerticalAlignment="Top">
|
||||
<Border Margin="0,12,0,0" Style="{DynamicResource SettingGroupBox}">
|
||||
<ItemsControl Style="{StaticResource SettingGrid}">
|
||||
<StackPanel Style="{StaticResource TextPanel}">
|
||||
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource queryWindowShadowEffect}" />
|
||||
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource shadowEffectCPUUsage}" />
|
||||
</StackPanel>
|
||||
<ui:ToggleSwitch
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
IsOn="{Binding DropShadowEffect, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
Style="{DynamicResource SideToggleSwitch}" />
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
<Border Margin="0,8,0,0" Style="{DynamicResource SettingGroupBox}">
|
||||
<ItemsControl Style="{StaticResource SettingGrid}">
|
||||
<StackPanel Style="{StaticResource TextPanel}">
|
||||
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource windowWidthSize}" />
|
||||
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource windowWidthSizeToolTip}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Width="Auto"
|
||||
Margin="0,0,8,2"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource Color05B}"
|
||||
Text="{Binding ElementName=WindowWidthValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Right" />
|
||||
<Slider
|
||||
Name="WindowWidthValue"
|
||||
Width="250"
|
||||
Margin="0,0,18,0"
|
||||
VerticalAlignment="Center"
|
||||
IsMoveToPointEnabled="True"
|
||||
IsSnapToTickEnabled="True"
|
||||
Maximum="1920"
|
||||
Minimum="400"
|
||||
TickFrequency="10"
|
||||
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
|
||||
<cc:Card
|
||||
Title="{DynamicResource queryWindowShadowEffect}"
|
||||
Margin="0,4,0,0"
|
||||
Icon=""
|
||||
Sub="{DynamicResource shadowEffectCPUUsage}">
|
||||
<ui:ToggleSwitch
|
||||
IsOn="{Binding DropShadowEffect, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}" />
|
||||
</cc:Card>
|
||||
|
||||
<cc:Card
|
||||
Title="{DynamicResource windowWidthSize}"
|
||||
Icon=""
|
||||
Sub="{DynamicResource windowWidthSizeToolTip}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Width="Auto"
|
||||
Margin="0,0,8,2"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource Color05B}"
|
||||
Text="{Binding WindowWidthSize, Mode=TwoWay}"
|
||||
TextAlignment="Right" />
|
||||
<Slider
|
||||
Width="250"
|
||||
VerticalAlignment="Center"
|
||||
IsMoveToPointEnabled="True"
|
||||
IsSnapToTickEnabled="True"
|
||||
Maximum="1920"
|
||||
Minimum="400"
|
||||
TickFrequency="10"
|
||||
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</cc:Card>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="3">
|
||||
|
|
@ -324,8 +303,8 @@
|
|||
<ui:ToggleSwitch
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
IsOn="{Binding UseGlyphIcons, Mode=TwoWay}"
|
||||
Style="{DynamicResource SideToggleSwitch}" />
|
||||
Margin="0,0,18,0"
|
||||
IsOn="{Binding UseGlyphIcons, Mode=TwoWay}" />
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
</TextBlock>
|
||||
|
|
|
|||
|
|
@ -112,49 +112,6 @@ namespace Flow.Launcher.ViewModel
|
|||
string.Format(_translater.GetTranslation("AlwaysPreviewToolTip"), Settings.PreviewHotkey);
|
||||
|
||||
|
||||
public bool StartFlowLauncherOnSystemStartup
|
||||
{
|
||||
get => Settings.StartFlowLauncherOnSystemStartup;
|
||||
set
|
||||
{
|
||||
Settings.StartFlowLauncherOnSystemStartup = value;
|
||||
|
||||
try
|
||||
{
|
||||
if (value)
|
||||
AutoStartup.Enable();
|
||||
else
|
||||
AutoStartup.Disable();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"),
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
|
||||
private bool _portableMode = DataLocation.PortableDataLocationInUse();
|
||||
|
||||
public bool PortableMode
|
||||
{
|
||||
get => _portableMode;
|
||||
set
|
||||
{
|
||||
if (!_portable.CanUpdatePortability())
|
||||
return;
|
||||
|
||||
if (DataLocation.PortableDataLocationInUse())
|
||||
{
|
||||
_portable.DisablePortableMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
_portable.EnablePortableMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save Flow settings. Plugins settings are not included.
|
||||
|
|
|
|||
Loading…
Reference in a new issue