prefer https over http setting

This commit is contained in:
AWAS666 2025-10-09 10:36:42 +02:00
parent 5ae159de5b
commit 1a373e1c40
7 changed files with 76 additions and 4 deletions

View file

@ -14,4 +14,7 @@
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Bitte legen Sie Ihren Browser-Pfad fest:</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Wählen</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Anwendung (*.exe)|*.exe|Alle Dateien|*.*</system:String>
<system:String x:Key="flowlauncher_plugin_url_usehttps">https über http bevorzugen</system:String>
</ResourceDictionary>

View file

@ -15,4 +15,6 @@
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Please set your browser path:</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Choose</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>
<system:String x:Key="flowlauncher_plugin_url_usehttps">Prefer https over http</system:String>
</ResourceDictionary>

View file

@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Url
{
public class Main : IPlugin, IPluginI18n
public class Main : IPlugin, IPluginI18n, ISettingProvider
{
//based on https://gist.github.com/dperini/729294
private const string urlPattern = "^" +
@ -58,13 +59,13 @@ namespace Flow.Launcher.Plugin.Url
Score = 8,
Action = _ =>
{
if (!raw.ToLower().StartsWith("http"))
if (!raw.ToLower().StartsWith(GetHttpPreference()))
{
raw = "http://" + raw;
raw = GetHttpPreference() + "://" + raw;
}
try
{
Context.API.OpenUrl(raw);
Context.API.OpenUrl(raw);
return true;
}
@ -80,6 +81,11 @@ namespace Flow.Launcher.Plugin.Url
return new List<Result>(0);
}
private string GetHttpPreference()
{
return _settings.AlwaysOpenWithHttps ? "https": "http";
}
public bool IsURL(string raw)
{
raw = raw.ToLower();
@ -113,5 +119,10 @@ namespace Flow.Launcher.Plugin.Url
{
return Localize.flowlauncher_plugin_url_plugin_description();
}
public Control CreateSettingPanel()
{
return new URLSettings(_settings);
}
}
}

View file

@ -5,5 +5,6 @@
public string BrowserPath { get; set; }
public bool OpenInNewBrowserWindow { get; set; } = true;
public bool AlwaysOpenWithHttps { get; set; } = false;
}
}

View file

@ -0,0 +1,9 @@
using System.Collections.Generic;
using System.Linq;
namespace Flow.Launcher.Plugin.Url;
public class SettingsViewModel(Settings settings) : BaseModel
{
public Settings Settings { get; } = settings;
}

View file

@ -0,0 +1,31 @@
<UserControl
x:Class="Flow.Launcher.Plugin.Url.URLSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:url="clr-namespace:Flow.Launcher.Plugin.Url"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Url"
d:DataContext="{d:DesignInstance Type=viewModels:SettingsViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid Margin="{StaticResource SettingPanelMargin}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource flowlauncher_plugin_url_usehttps}"
IsChecked="{Binding Settings.AlwaysOpenWithHttps, Mode=TwoWay}" />
</Grid>
</UserControl>

View file

@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Url;
public partial class URLSettings : UserControl
{
private readonly SettingsViewModel _viewModel;
public URLSettings(Settings settings)
{
_viewModel = new SettingsViewModel(settings);
DataContext = _viewModel;
InitializeComponent();
}
}