mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
commit
49b9e97fcd
6 changed files with 82 additions and 20 deletions
|
|
@ -37,7 +37,11 @@ namespace Flow.Launcher.Plugin
|
||||||
/// user's clipboard when Ctrl + C is pressed on a result. If the text is a file/directory path
|
/// user's clipboard when Ctrl + C is pressed on a result. If the text is a file/directory path
|
||||||
/// flow will copy the actual file/folder instead of just the path text.
|
/// flow will copy the actual file/folder instead of just the path text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CopyText { get; set; } = string.Empty;
|
public string CopyText
|
||||||
|
{
|
||||||
|
get => string.IsNullOrEmpty(_copyText) ? SubTitle : _copyText;
|
||||||
|
set => _copyText = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This holds the text which can be provided by plugin to help Flow autocomplete text
|
/// This holds the text which can be provided by plugin to help Flow autocomplete text
|
||||||
|
|
@ -81,6 +85,7 @@ namespace Flow.Launcher.Plugin
|
||||||
/// Delegate to Get Image Source
|
/// Delegate to Get Image Source
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IconDelegate Icon;
|
public IconDelegate Icon;
|
||||||
|
private string _copyText = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Information for Glyph Icon (Prioritized than IcoPath/Icon if user enable Glyph Icons)
|
/// Information for Glyph Icon (Prioritized than IcoPath/Icon if user enable Glyph Icons)
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@
|
||||||
<ContentControl>
|
<ContentControl>
|
||||||
<flowlauncher:ResultListBox x:Name="ResultListBox"
|
<flowlauncher:ResultListBox x:Name="ResultListBox"
|
||||||
DataContext="{Binding Results}"
|
DataContext="{Binding Results}"
|
||||||
PreviewMouseDown="OnPreviewMouseButtonDown" />
|
PreviewMouseLeftButtonUp="OnPreviewMouseButtonDown" />
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Style="{DynamicResource WindowRadius}">
|
<Border Style="{DynamicResource WindowRadius}">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
@ -20,6 +20,11 @@ using Flow.Launcher.Infrastructure;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Flow.Launcher.Infrastructure.Hotkey;
|
using Flow.Launcher.Infrastructure.Hotkey;
|
||||||
using Flow.Launcher.Plugin.SharedCommands;
|
using Flow.Launcher.Plugin.SharedCommands;
|
||||||
|
using System.Text;
|
||||||
|
using DataObject = System.Windows.DataObject;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.IO;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,15 @@
|
||||||
VirtualizingStackPanel.IsVirtualizing="True"
|
VirtualizingStackPanel.IsVirtualizing="True"
|
||||||
VirtualizingStackPanel.VirtualizationMode="Standard"
|
VirtualizingStackPanel.VirtualizationMode="Standard"
|
||||||
Visibility="{Binding Visbility}"
|
Visibility="{Binding Visbility}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d"
|
||||||
|
PreviewMouseMove="ResultList_MouseMove"
|
||||||
|
PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown">
|
||||||
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
||||||
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Button HorizontalAlignment="Stretch">
|
<Button
|
||||||
|
HorizontalAlignment="Stretch">
|
||||||
<Button.Template>
|
<Button.Template>
|
||||||
<ControlTemplate>
|
<ControlTemplate>
|
||||||
<ContentPresenter Content="{TemplateBinding Button.Content}" />
|
<ContentPresenter Content="{TemplateBinding Button.Content}" />
|
||||||
|
|
@ -84,7 +87,7 @@
|
||||||
x:Name="ImageIcon"
|
x:Name="ImageIcon"
|
||||||
Width="{Binding IconXY}"
|
Width="{Binding IconXY}"
|
||||||
Height="{Binding IconXY}"
|
Height="{Binding IconXY}"
|
||||||
Margin="0,0,0,0"
|
Margin="0,0,0,0" IsHitTestVisible="False"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Source="{Binding Image, TargetNullValue={x:Null}}"
|
Source="{Binding Image, TargetNullValue={x:Null}}"
|
||||||
Stretch="Uniform"
|
Stretch="Uniform"
|
||||||
|
|
@ -134,6 +137,7 @@
|
||||||
x:Name="Title"
|
x:Name="Title"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
|
IsHitTestVisible="False"
|
||||||
Style="{DynamicResource ItemTitleStyle}"
|
Style="{DynamicResource ItemTitleStyle}"
|
||||||
Text="{Binding Result.Title}"
|
Text="{Binding Result.Title}"
|
||||||
ToolTip="{Binding ShowTitleToolTip}">
|
ToolTip="{Binding ShowTitleToolTip}">
|
||||||
|
|
@ -147,6 +151,7 @@
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="SubTitle"
|
x:Name="SubTitle"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
IsHitTestVisible="False"
|
||||||
Style="{DynamicResource ItemSubTitleStyle}"
|
Style="{DynamicResource ItemSubTitleStyle}"
|
||||||
Text="{Binding Result.SubTitle}"
|
Text="{Binding Result.SubTitle}"
|
||||||
ToolTip="{Binding ShowSubTitleToolTip}" />
|
ToolTip="{Binding ShowSubTitleToolTip}" />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
using System.Windows;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Flow.Launcher.ViewModel;
|
||||||
|
|
||||||
namespace Flow.Launcher
|
namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
|
|
@ -54,5 +57,51 @@ namespace Flow.Launcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Point start;
|
||||||
|
private string path;
|
||||||
|
private string query;
|
||||||
|
|
||||||
|
private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result })
|
||||||
|
return;
|
||||||
|
|
||||||
|
path = result.Result.CopyText;
|
||||||
|
query = result.Result.OriginQuery.RawQuery;
|
||||||
|
start = e.GetPosition(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResultList_MouseMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.LeftButton != MouseButtonState.Pressed)
|
||||||
|
{
|
||||||
|
start = default;
|
||||||
|
path = string.Empty;
|
||||||
|
query = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(path) && !Directory.Exists(path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Point mousePosition = e.GetPosition(null);
|
||||||
|
Vector diff = this.start - mousePosition;
|
||||||
|
|
||||||
|
if (Math.Abs(diff.X) < SystemParameters.MinimumHorizontalDragDistance
|
||||||
|
|| Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var data = new DataObject(DataFormats.FileDrop, new[]
|
||||||
|
{
|
||||||
|
path
|
||||||
|
});
|
||||||
|
DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
|
||||||
|
App.API.ChangeQuery(query, true);
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -966,28 +966,26 @@ namespace Flow.Launcher.ViewModel
|
||||||
var result = Results.SelectedItem?.Result;
|
var result = Results.SelectedItem?.Result;
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
string copyText = string.IsNullOrEmpty(result.CopyText) ? result.SubTitle : result.CopyText;
|
string copyText = result.CopyText;
|
||||||
var isFile = File.Exists(copyText);
|
var isFile = File.Exists(copyText);
|
||||||
var isFolder = Directory.Exists(copyText);
|
var isFolder = Directory.Exists(copyText);
|
||||||
if (isFile || isFolder)
|
if (isFile || isFolder)
|
||||||
{
|
{
|
||||||
var paths = new StringCollection();
|
var paths = new StringCollection
|
||||||
paths.Add(copyText);
|
{
|
||||||
|
copyText
|
||||||
|
};
|
||||||
|
|
||||||
Clipboard.SetFileDropList(paths);
|
Clipboard.SetFileDropList(paths);
|
||||||
App.API.ShowMsg(
|
App.API.ShowMsg(
|
||||||
App.API.GetTranslation("copy")
|
$"{App.API.GetTranslation("copy")} {(isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle"))}",
|
||||||
+ " "
|
|
||||||
+ (isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")),
|
|
||||||
App.API.GetTranslation("completedSuccessfully"));
|
App.API.GetTranslation("completedSuccessfully"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Clipboard.SetDataObject(copyText.ToString());
|
Clipboard.SetDataObject(copyText);
|
||||||
App.API.ShowMsg(
|
App.API.ShowMsg(
|
||||||
App.API.GetTranslation("copy")
|
$"{App.API.GetTranslation("copy")} {App.API.GetTranslation("textTitle")}",
|
||||||
+ " "
|
|
||||||
+ App.API.GetTranslation("textTitle"),
|
|
||||||
App.API.GetTranslation("completedSuccessfully"));
|
App.API.GetTranslation("completedSuccessfully"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue