mirror of
https://github.com/Stone-Red-Code/Markdowser.git
synced 2026-09-04 09:06:15 +02:00
Add search engine url setting
This commit is contained in:
@@ -11,6 +11,8 @@ public class Settings
|
||||
|
||||
public bool DarkMode { get; set; }
|
||||
|
||||
public string SearchEngineUrl { get; set; } = "https://duckduckgo.com/html/?kd=-1&k1=-1&q={0}";
|
||||
|
||||
public string? HomeUrl { get; set; }
|
||||
|
||||
public static void SaveSettings()
|
||||
|
||||
@@ -220,7 +220,14 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
else
|
||||
{
|
||||
// Search with duckduckgo
|
||||
Url = $"https://duckduckgo.com/html/?kd=-1&k1=-1&q={Uri.EscapeDataString(Url)}";
|
||||
try
|
||||
{
|
||||
Url = string.Format(Settings.Current.SearchEngineUrl, Uri.EscapeDataString(Url));
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
WindowNotificationManager.Show(new Notification("Invalid Search Engine URL", $"{ex.Message}", NotificationType.Error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,12 @@ public class SettingsViewModel : ViewModelBase
|
||||
set => Settings.Current.HomeUrl = value;
|
||||
}
|
||||
|
||||
public string SearchEngineUrl
|
||||
{
|
||||
get => Settings.Current.SearchEngineUrl;
|
||||
set => Settings.Current.SearchEngineUrl = value;
|
||||
}
|
||||
|
||||
public bool DarkMode
|
||||
{
|
||||
get => Settings.Current.DarkMode;
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<Button Grid.Column="3" i:Attached.Icon="fa-solid fa-house" Command="{StaticResource HomeCommand}" />
|
||||
|
||||
<Grid Grid.Column="4">
|
||||
<TextBox IsVisible="{Binding !IsBusy}" Watermark="Search DuckDuckGo or type a URL" Text="{Binding Url}" BorderThickness="0">
|
||||
<TextBox IsVisible="{Binding !IsBusy}" Watermark="Search or type a URL" Text="{Binding Url}" BorderThickness="0">
|
||||
<TextBox.KeyBindings>
|
||||
<KeyBinding Gesture="Enter" Command="{Binding Browse}" />
|
||||
</TextBox.KeyBindings>
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<TextBlock Text="Dark Mode" />
|
||||
<ToggleSwitch IsChecked="{Binding DarkMode}" Command="{StaticResource ChangeThemeCommand}" />
|
||||
|
||||
<TextBlock Text="Search Engine URL" />
|
||||
<TextBox Text="{Binding SearchEngineUrl}" Watermark="URL with {0} as encoded search query" />
|
||||
|
||||
<TextBlock Text="Home URL" />
|
||||
<TextBox Text="{Binding HomeUrl}" Watermark="URL, or leave empty to use default" />
|
||||
</StackPanel>
|
||||
|
||||
Reference in New Issue
Block a user