Allow adjustment of offset in settings file

This commit is contained in:
Garulf 2021-12-20 02:20:26 -05:00
parent aa850ff0e8
commit aafbdebb9b
4 changed files with 16 additions and 2 deletions

View file

@ -15,6 +15,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
private string language = "en"; private string language = "en";
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}"; public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
public string OpenResultModifiers { get; set; } = KeyConstant.Alt; public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
public int SuggestionTextOffset { get; set; } = 40;
public string ColorScheme { get; set; } = "System"; public string ColorScheme { get; set; } = "System";
public bool ShowOpenResultHotkey { get; set; } = true; public bool ShowOpenResultHotkey { get; set; } = true;
public double WindowSize { get; set; } = 580; public double WindowSize { get; set; } = 580;

View file

@ -12,7 +12,8 @@ namespace Flow.Launcher.Converters
{ {
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{ {
if (values.Length != 3)
if (values.Length != 4)
{ {
return string.Empty; return string.Empty;
} }
@ -53,7 +54,10 @@ namespace Flow.Launcher.Converters
// Check if Text will be larger then our QueryTextBox // Check if Text will be larger then our QueryTextBox
System.Windows.Media.Typeface typeface = new Typeface(QueryTextBox.FontFamily, QueryTextBox.FontStyle, QueryTextBox.FontWeight, QueryTextBox.FontStretch); System.Windows.Media.Typeface typeface = new Typeface(QueryTextBox.FontFamily, QueryTextBox.FontStyle, QueryTextBox.FontWeight, QueryTextBox.FontStretch);
System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black); System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black);
if ((ft.Width + 40) > QueryTextBox.ActualWidth || QueryTextBox.HorizontalOffset != 0)
var FormatOffset = (int)values[3];
if ((ft.Width + FormatOffset) > QueryTextBox.ActualWidth || QueryTextBox.HorizontalOffset != 0)
{ {
return string.Empty; return string.Empty;
}; };

View file

@ -164,6 +164,7 @@
<Binding ElementName="QueryTextBox" Mode="OneTime" /> <Binding ElementName="QueryTextBox" Mode="OneTime" />
<Binding ElementName="ResultListBox" Path="SelectedItem" /> <Binding ElementName="ResultListBox" Path="SelectedItem" />
<Binding ElementName="QueryTextBox" Path="Text" /> <Binding ElementName="QueryTextBox" Path="Text" />
<Binding Path="SuggestionTextOffset" />
</MultiBinding> </MultiBinding>
</TextBox.Text> </TextBox.Text>
</TextBox> </TextBox>

View file

@ -84,6 +84,7 @@ namespace Flow.Launcher.ViewModel
InitializeKeyCommands(); InitializeKeyCommands();
RegisterViewUpdate(); RegisterViewUpdate();
RegisterResultsUpdatedEvent(); RegisterResultsUpdatedEvent();
SetSuggestionTextOffset();
SetOpenResultModifiers(); SetOpenResultModifiers();
} }
@ -395,6 +396,8 @@ namespace Flow.Launcher.ViewModel
public double MainWindowWidth => _settings.WindowSize; public double MainWindowWidth => _settings.WindowSize;
public int SuggestionTextOffset { get; set; }
public ICommand EscCommand { get; set; } public ICommand EscCommand { get; set; }
public ICommand SelectNextItemCommand { get; set; } public ICommand SelectNextItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; } public ICommand SelectPrevItemCommand { get; set; }
@ -720,6 +723,11 @@ namespace Flow.Launcher.ViewModel
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers; OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
} }
private void SetSuggestionTextOffset()
{
SuggestionTextOffset = _settings.SuggestionTextOffset;
}
public void ToggleFlowLauncher() public void ToggleFlowLauncher()
{ {
if (!MainWindowVisibilityStatus) if (!MainWindowVisibilityStatus)