Skip to content

Commit aafbdeb

Browse files
committed
Allow adjustment of offset in settings file
1 parent aa850ff commit aafbdeb

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class Settings : BaseModel
1515
private string language = "en";
1616
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
1717
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
18+
public int SuggestionTextOffset { get; set; } = 40;
1819
public string ColorScheme { get; set; } = "System";
1920
public bool ShowOpenResultHotkey { get; set; } = true;
2021
public double WindowSize { get; set; } = 580;

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class QuerySuggestionBoxConverter : IMultiValueConverter
1212
{
1313
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
1414
{
15-
if (values.Length != 3)
15+
16+
if (values.Length != 4)
1617
{
1718
return string.Empty;
1819
}
@@ -53,7 +54,10 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
5354
// Check if Text will be larger then our QueryTextBox
5455
System.Windows.Media.Typeface typeface = new Typeface(QueryTextBox.FontFamily, QueryTextBox.FontStyle, QueryTextBox.FontWeight, QueryTextBox.FontStretch);
5556
System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black);
56-
if ((ft.Width + 40) > QueryTextBox.ActualWidth || QueryTextBox.HorizontalOffset != 0)
57+
58+
var FormatOffset = (int)values[3];
59+
60+
if ((ft.Width + FormatOffset) > QueryTextBox.ActualWidth || QueryTextBox.HorizontalOffset != 0)
5761
{
5862
return string.Empty;
5963
};

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
<Binding ElementName="QueryTextBox" Mode="OneTime" />
165165
<Binding ElementName="ResultListBox" Path="SelectedItem" />
166166
<Binding ElementName="QueryTextBox" Path="Text" />
167+
<Binding Path="SuggestionTextOffset" />
167168
</MultiBinding>
168169
</TextBox.Text>
169170
</TextBox>

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public MainViewModel(Settings settings)
8484
InitializeKeyCommands();
8585
RegisterViewUpdate();
8686
RegisterResultsUpdatedEvent();
87+
SetSuggestionTextOffset();
8788

8889
SetOpenResultModifiers();
8990
}
@@ -395,6 +396,8 @@ private ResultsViewModel SelectedResults
395396

396397
public double MainWindowWidth => _settings.WindowSize;
397398

399+
public int SuggestionTextOffset { get; set; }
400+
398401
public ICommand EscCommand { get; set; }
399402
public ICommand SelectNextItemCommand { get; set; }
400403
public ICommand SelectPrevItemCommand { get; set; }
@@ -720,6 +723,11 @@ private void SetOpenResultModifiers()
720723
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
721724
}
722725

726+
private void SetSuggestionTextOffset()
727+
{
728+
SuggestionTextOffset = _settings.SuggestionTextOffset;
729+
}
730+
723731
public void ToggleFlowLauncher()
724732
{
725733
if (!MainWindowVisibilityStatus)

0 commit comments

Comments
 (0)