mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
New window to add/edit quick access link
This commit is contained in:
parent
59d5cd62bc
commit
179babe313
3 changed files with 251 additions and 0 deletions
|
|
@ -92,6 +92,7 @@
|
|||
<system:String x:Key="plugin_explorer_deletefile_subtitle">Permanently delete current file</system:String>
|
||||
<system:String x:Key="plugin_explorer_deletefolder_subtitle">Permanently delete current folder</system:String>
|
||||
<system:String x:Key="plugin_explorer_path">Path:</system:String>
|
||||
<system:String x:Key="plugin_explorer_name">Name:</system:String>
|
||||
<system:String x:Key="plugin_explorer_deletefilefolder_subtitle">Delete the selected</system:String>
|
||||
<system:String x:Key="plugin_explorer_runasdifferentuser">Run as different user</system:String>
|
||||
<system:String x:Key="plugin_explorer_runasdifferentuser_subtitle">Run the selected using a different user account</system:String>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
<Window x:Class="Flow.Launcher.Plugin.Explorer.Views.QuickAccessLinkSettings"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="{DynamicResource plugin_explorer_manageactionkeywords_header}"
|
||||
Width="Auto"
|
||||
Height="255"
|
||||
Background="{DynamicResource PopuBGColor}"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Width"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
|
||||
</WindowChrome.WindowChrome>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="80" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Grid.Column="4"
|
||||
Click="BtnCancel_OnClick"
|
||||
Style="{StaticResource TitleBarCloseButtonStyle}">
|
||||
<Path
|
||||
Width="46"
|
||||
Height="32"
|
||||
Data="M 18,11 27,20 M 18,20 27,11"
|
||||
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
|
||||
StrokeThickness="1">
|
||||
<Path.Style>
|
||||
<Style TargetType="Path">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
|
||||
<Setter Property="Opacity" Value="0.5" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Path.Style>
|
||||
</Path>
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="26 0 26 0">
|
||||
<StackPanel Margin="0 0 0 12">
|
||||
<TextBlock
|
||||
Margin="0 0 0 0"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource plugin_explorer_manageactionkeywords_header}"
|
||||
TextAlignment="Left" />
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
MinWidth="150"
|
||||
Margin="0 10 15 10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource plugin_explorer_actionkeyword_current}" />
|
||||
<TextBox
|
||||
Width="135"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding SelectedName, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
MinWidth="150"
|
||||
Margin="0 10 15 10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="Path:" />
|
||||
|
||||
<TextBlock
|
||||
Margin="10 0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Width="250"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{Binding SelectedPath, Mode=OneWay}" />
|
||||
|
||||
<Button
|
||||
Width="80"
|
||||
Height="25"
|
||||
Margin="10 0 0 0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Content="Adicionar"
|
||||
Click="SelectPath_OnClick" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Background="{DynamicResource PopupButtonAreaBGColor}"
|
||||
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
|
||||
BorderThickness="0 1 0 0">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Width="145"
|
||||
Height="30"
|
||||
Margin="0 0 5 0"
|
||||
Click="BtnCancel_OnClick"
|
||||
Content="{DynamicResource cancel}" />
|
||||
<Button
|
||||
Name="DownButton"
|
||||
Width="145"
|
||||
Height="30"
|
||||
Margin="5 0 0 0"
|
||||
Click="OnDoneButtonClick"
|
||||
Style="{StaticResource AccentButtonStyle}">
|
||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource plugin_explorer_actionkeyword_done}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Flow.Launcher.Plugin.Explorer.Search;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Views;
|
||||
|
||||
public partial class QuickAccessLinkSettings : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private string _selectedPath;
|
||||
public string SelectedPath
|
||||
{
|
||||
get => _selectedPath;
|
||||
set
|
||||
{
|
||||
if (_selectedPath != value)
|
||||
{
|
||||
_selectedPath = value;
|
||||
OnPropertyChanged();
|
||||
SelectedName = GetPathName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _selectedName;
|
||||
public string SelectedName
|
||||
{
|
||||
get => _selectedName;
|
||||
set
|
||||
{
|
||||
if (_selectedName != value)
|
||||
{
|
||||
_selectedName = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public QuickAccessLinkSettings()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OnDoneButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var container = Settings.QuickAccessLinks;
|
||||
|
||||
|
||||
// Lembrar de colocar uma logica pra evitar path e name vazios
|
||||
var newAccessLink = new AccessLink
|
||||
{
|
||||
Name = SelectedName,
|
||||
Path = SelectedPath
|
||||
};
|
||||
container.Add(newAccessLink);
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SelectPath_OnClick(object commandParameter, RoutedEventArgs e)
|
||||
{
|
||||
var folderBrowserDialog = new FolderBrowserDialog();
|
||||
|
||||
if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
||||
return;
|
||||
|
||||
SelectedPath = folderBrowserDialog.SelectedPath;
|
||||
}
|
||||
|
||||
private string GetPathName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(SelectedPath)) return "";
|
||||
var path = SelectedPath.EndsWith(Constants.DirectorySeparator) ? SelectedPath[0..^1] : SelectedPath;
|
||||
|
||||
if (path.EndsWith(':'))
|
||||
return path[0..^1] + " Drive";
|
||||
|
||||
return path.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
|
||||
.Last();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||
field = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue