Skip to content

Commit 179babe

Browse files
committed
New window to add/edit quick access link
1 parent 59d5cd6 commit 179babe

File tree

3 files changed

+251
-0
lines changed

3 files changed

+251
-0
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
<system:String x:Key="plugin_explorer_deletefile_subtitle">Permanently delete current file</system:String>
9393
<system:String x:Key="plugin_explorer_deletefolder_subtitle">Permanently delete current folder</system:String>
9494
<system:String x:Key="plugin_explorer_path">Path:</system:String>
95+
<system:String x:Key="plugin_explorer_name">Name:</system:String>
9596
<system:String x:Key="plugin_explorer_deletefilefolder_subtitle">Delete the selected</system:String>
9697
<system:String x:Key="plugin_explorer_runasdifferentuser">Run as different user</system:String>
9798
<system:String x:Key="plugin_explorer_runasdifferentuser_subtitle">Run the selected using a different user account</system:String>
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<Window x:Class="Flow.Launcher.Plugin.Explorer.Views.QuickAccessLinkSettings"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
Title="{DynamicResource plugin_explorer_manageactionkeywords_header}"
8+
Width="Auto"
9+
Height="255"
10+
Background="{DynamicResource PopuBGColor}"
11+
DataContext="{Binding RelativeSource={RelativeSource Self}}"
12+
Foreground="{DynamicResource PopupTextColor}"
13+
ResizeMode="NoResize"
14+
SizeToContent="Width"
15+
WindowStartupLocation="CenterScreen"
16+
mc:Ignorable="d">
17+
<WindowChrome.WindowChrome>
18+
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
19+
</WindowChrome.WindowChrome>
20+
<Grid>
21+
<Grid.RowDefinitions>
22+
<RowDefinition />
23+
<RowDefinition Height="80" />
24+
</Grid.RowDefinitions>
25+
<StackPanel Grid.Row="0">
26+
<StackPanel>
27+
<Grid>
28+
<Grid.ColumnDefinitions>
29+
<ColumnDefinition Width="Auto" />
30+
<ColumnDefinition Width="*" />
31+
<ColumnDefinition Width="Auto" />
32+
<ColumnDefinition Width="Auto" />
33+
<ColumnDefinition Width="Auto" />
34+
</Grid.ColumnDefinitions>
35+
<Button
36+
Grid.Column="4"
37+
Click="BtnCancel_OnClick"
38+
Style="{StaticResource TitleBarCloseButtonStyle}">
39+
<Path
40+
Width="46"
41+
Height="32"
42+
Data="M 18,11 27,20 M 18,20 27,11"
43+
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
44+
StrokeThickness="1">
45+
<Path.Style>
46+
<Style TargetType="Path">
47+
<Style.Triggers>
48+
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
49+
<Setter Property="Opacity" Value="0.5" />
50+
</DataTrigger>
51+
</Style.Triggers>
52+
</Style>
53+
</Path.Style>
54+
</Path>
55+
</Button>
56+
</Grid>
57+
</StackPanel>
58+
<StackPanel Margin="26 0 26 0">
59+
<StackPanel Margin="0 0 0 12">
60+
<TextBlock
61+
Margin="0 0 0 0"
62+
FontSize="20"
63+
FontWeight="SemiBold"
64+
Text="{DynamicResource plugin_explorer_manageactionkeywords_header}"
65+
TextAlignment="Left" />
66+
</StackPanel>
67+
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
68+
<TextBlock
69+
MinWidth="150"
70+
Margin="0 10 15 10"
71+
HorizontalAlignment="Left"
72+
VerticalAlignment="Center"
73+
FontSize="14"
74+
Text="{DynamicResource plugin_explorer_actionkeyword_current}" />
75+
<TextBox
76+
Width="135"
77+
HorizontalAlignment="Left"
78+
VerticalAlignment="Center"
79+
Text="{Binding SelectedName, Mode=TwoWay}" />
80+
</StackPanel>
81+
82+
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
83+
<TextBlock
84+
MinWidth="150"
85+
Margin="0 10 15 10"
86+
HorizontalAlignment="Left"
87+
VerticalAlignment="Center"
88+
FontSize="14"
89+
Text="Path:" />
90+
91+
<TextBlock
92+
Margin="10 0 0 0"
93+
VerticalAlignment="Center"
94+
FontSize="12"
95+
Width="250"
96+
TextTrimming="CharacterEllipsis"
97+
Text="{Binding SelectedPath, Mode=OneWay}" />
98+
99+
<Button
100+
Width="80"
101+
Height="25"
102+
Margin="10 0 0 0"
103+
HorizontalAlignment="Left"
104+
VerticalAlignment="Center"
105+
Content="Adicionar"
106+
Click="SelectPath_OnClick" />
107+
</StackPanel>
108+
109+
</StackPanel>
110+
</StackPanel>
111+
<Border
112+
Grid.Row="1"
113+
Background="{DynamicResource PopupButtonAreaBGColor}"
114+
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
115+
BorderThickness="0 1 0 0">
116+
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
117+
<Button
118+
x:Name="btnCancel"
119+
Width="145"
120+
Height="30"
121+
Margin="0 0 5 0"
122+
Click="BtnCancel_OnClick"
123+
Content="{DynamicResource cancel}" />
124+
<Button
125+
Name="DownButton"
126+
Width="145"
127+
Height="30"
128+
Margin="5 0 0 0"
129+
Click="OnDoneButtonClick"
130+
Style="{StaticResource AccentButtonStyle}">
131+
<TextBlock x:Name="lblAdd" Text="{DynamicResource plugin_explorer_actionkeyword_done}" />
132+
</Button>
133+
</StackPanel>
134+
</Border>
135+
</Grid>
136+
</Window>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Runtime.CompilerServices;
7+
using System.Windows;
8+
using System.Windows.Forms;
9+
using Flow.Launcher.Plugin.Explorer.Search;
10+
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
11+
12+
namespace Flow.Launcher.Plugin.Explorer.Views;
13+
14+
public partial class QuickAccessLinkSettings : INotifyPropertyChanged
15+
{
16+
17+
private string _selectedPath;
18+
public string SelectedPath
19+
{
20+
get => _selectedPath;
21+
set
22+
{
23+
if (_selectedPath != value)
24+
{
25+
_selectedPath = value;
26+
OnPropertyChanged();
27+
SelectedName = GetPathName();
28+
}
29+
}
30+
}
31+
32+
33+
private string _selectedName;
34+
public string SelectedName
35+
{
36+
get => _selectedName;
37+
set
38+
{
39+
if (_selectedName != value)
40+
{
41+
_selectedName = value;
42+
OnPropertyChanged();
43+
}
44+
}
45+
}
46+
47+
48+
public QuickAccessLinkSettings()
49+
{
50+
InitializeComponent();
51+
}
52+
53+
54+
55+
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
56+
{
57+
DialogResult = false;
58+
Close();
59+
}
60+
61+
private void OnDoneButtonClick(object sender, RoutedEventArgs e)
62+
{
63+
var container = Settings.QuickAccessLinks;
64+
65+
66+
// Lembrar de colocar uma logica pra evitar path e name vazios
67+
var newAccessLink = new AccessLink
68+
{
69+
Name = SelectedName,
70+
Path = SelectedPath
71+
};
72+
container.Add(newAccessLink);
73+
DialogResult = false;
74+
Close();
75+
}
76+
77+
private void SelectPath_OnClick(object commandParameter, RoutedEventArgs e)
78+
{
79+
var folderBrowserDialog = new FolderBrowserDialog();
80+
81+
if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
82+
return;
83+
84+
SelectedPath = folderBrowserDialog.SelectedPath;
85+
}
86+
87+
private string GetPathName()
88+
{
89+
if (string.IsNullOrEmpty(SelectedPath)) return "";
90+
var path = SelectedPath.EndsWith(Constants.DirectorySeparator) ? SelectedPath[0..^1] : SelectedPath;
91+
92+
if (path.EndsWith(':'))
93+
return path[0..^1] + " Drive";
94+
95+
return path.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
96+
.Last();
97+
}
98+
99+
public event PropertyChangedEventHandler PropertyChanged;
100+
101+
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
102+
{
103+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
104+
}
105+
106+
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
107+
{
108+
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
109+
field = value;
110+
OnPropertyChanged(propertyName);
111+
return true;
112+
}
113+
}
114+

0 commit comments

Comments
 (0)