Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit c4738df

Browse files
committed
Merge branch 'master' into panelTest
2 parents e5b5fc2 + d0a6de0 commit c4738df

File tree

8 files changed

+106
-62
lines changed

8 files changed

+106
-62
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ If you want to save images in your clipboard, open the `CacheImages` option in s
4848
## Todo List
4949

5050
- [x] Save images manually
51+
- [ ] Word Count
5152
- [ ] Cached images format definition
5253
- [ ] Image OCR
5354

build/Build.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88
<ItemGroup>
99
<PackageReference Include="Cake.Compression" Version="0.3.0" />
10-
<PackageReference Include="Cake.Frosting" Version="3.0.0" />
11-
<PackageReference Include="SharpClipboard" Version="3.5.2" />
10+
<PackageReference Include="Cake.Frosting" Version="3.1.0" />
11+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1212
</ItemGroup>
1313
<ItemGroup>
1414
<ProjectReference Include="..\src\ClipboardR\ClipboardR.csproj" />

build/Program.cs

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using Cake.Common;
@@ -13,6 +14,7 @@
1314
using Cake.Core;
1415
using Cake.Core.IO;
1516
using Cake.Frosting;
17+
using Newtonsoft.Json;
1618

1719
namespace Build;
1820

@@ -34,7 +36,7 @@ public class BuildContext : FrostingContext
3436
public Lazy<SolutionParserResult> DefaultSln { get; set; }
3537
public const string DeployFramework = "net7.0-windows";
3638
public string PublishDir = ".dist";
37-
public string PublishVersion = "0.2.4";
39+
public string PublishVersion = "";
3840

3941
public BuildContext(ICakeContext context)
4042
: base(context)
@@ -54,7 +56,7 @@ public override void Setup(BuildContext context, ISetupContext info)
5456

5557
public override void Teardown(BuildContext context, ITeardownContext info)
5658
{
57-
59+
// ignore
5860
}
5961
}
6062

@@ -63,8 +65,7 @@ public sealed class BuildTask : FrostingTask<BuildContext>
6365
{
6466
public override void Run(BuildContext context)
6567
{
66-
var projects = context
67-
.DefaultSln.Value.Projects.Where(p => p.Name.EndsWith("ClipboardR"));
68+
var projects = context.DefaultSln.Value.Projects.Where(p => p.Name.EndsWith("ClipboardR"));
6869
var projectPath = projects.First().Path.FullPath;
6970
context.Information($"Building {projectPath}");
7071
context.DotNetBuild(
@@ -76,9 +77,8 @@ public override void Run(BuildContext context)
7677
Framework = BuildContext.DeployFramework,
7778
NoDependencies = false,
7879
NoIncremental = true,
79-
});
80-
81-
80+
}
81+
);
8282
}
8383
}
8484

@@ -88,12 +88,10 @@ public class PublishTask : FrostingTask<BuildContext>
8888
{
8989
public override void Run(BuildContext context)
9090
{
91-
var project = context
92-
.DefaultSln.Value.Projects
93-
.First(p => p.Name.EndsWith("ClipboardR"));
94-
var srcDir = project.Path.GetDirectory()
95-
.Combine(new DirectoryPath($"bin/publish"));
96-
var dstDir = $"{srcDir.GetParent().GetParent().GetParent().GetParent().FullPath}/{context.PublishDir}";
91+
var project = context.DefaultSln.Value.Projects.First(p => p.Name.EndsWith("ClipboardR"));
92+
var srcDir = project.Path.GetDirectory().Combine(new DirectoryPath($"bin/publish"));
93+
var dstDir =
94+
$"{srcDir.GetParent().GetParent().GetParent().GetParent().FullPath}/{context.PublishDir}";
9795
context.DotNetPublish(
9896
project.Path.FullPath,
9997
new DotNetPublishSettings
@@ -102,17 +100,35 @@ public override void Run(BuildContext context)
102100
Configuration = context.DotNetBuildConfig,
103101
Framework = BuildContext.DeployFramework,
104102
Verbosity = DotNetVerbosity.Minimal,
105-
});
103+
}
104+
);
106105
context.CreateDirectory(dstDir);
107-
var files = context
108-
.GetFiles(@$"{srcDir}/**/(*(c|C)lipboard*.(png|json|dll)|*.png|plugin.json|(*simulator).dll)");
106+
var files = context.GetFiles(
107+
@$"{srcDir}/**/(*(c|C)lipboard*.(png|json|dll)|*.png|plugin.json|(*simulator).dll)"
108+
);
109+
FilePath? versionFile = null;
109110
foreach (var f in files)
111+
{
110112
context.Information($"Adding: {f}");
113+
if (f.ToString().EndsWith("plugin.json"))
114+
versionFile = f;
115+
}
116+
if (versionFile != null)
117+
{
118+
VersionInfo? versionInfoObj = JsonConvert.DeserializeObject<VersionInfo>(
119+
File.ReadAllText(versionFile.ToString()!)
120+
);
121+
if (versionInfoObj != null)
122+
context.PublishVersion = versionInfoObj.Version;
123+
else
124+
Console.WriteLine("Get version info from plugin.json failed!");
125+
}
111126
context.ZipCompress(
112127
rootPath: srcDir,
113128
outputPath: $"{dstDir}/ClipboardR-v{context.PublishVersion}.zip",
114129
filePaths: files,
115-
level: 9);
130+
level: 9
131+
);
116132
}
117133
}
118134

@@ -124,14 +140,29 @@ public override void Run(BuildContext context)
124140
foreach (var project in context.DefaultSln.Value.Projects)
125141
{
126142
context.Information($"Cleaning {project.Path.GetDirectory().FullPath}...");
127-
context.CleanDirectory($"{project.Path.GetDirectory().FullPath}/bin/{context.DotNetBuildConfig}");
143+
context.CleanDirectory(
144+
$"{project.Path.GetDirectory().FullPath}/bin/{context.DotNetBuildConfig}"
145+
);
128146
}
129147
}
130148
}
131149

132150
[TaskName("Default")]
133151
[IsDependentOn(typeof(CleanTask))]
134152
[IsDependentOn(typeof(BuildTask))]
135-
public class DefaultTask : FrostingTask
153+
[IsDependentOn(typeof(PublishTask))]
154+
public class DefaultTask : FrostingTask { }
155+
156+
public class VersionInfo
136157
{
137-
}
158+
public string ID { get; set; }
159+
public string ActionKeyword { get; set; }
160+
public string Name { get; set; }
161+
public string Description { get; set; }
162+
public string Author { get; set; }
163+
public string Version { get; set; }
164+
public string Language { get; set; }
165+
public string Website { get; set; }
166+
public string IcoPath { get; set; }
167+
public string ExecuteFileName { get; set; }
168+
}

src/ClipboardR.Core/ClipboardR.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Flow.Launcher.Plugin" Version="4.0.2" />
21-
<PackageReference Include="SharpClipboard" Version="3.5.2" />
20+
<PackageReference Include="Flow.Launcher.Plugin" Version="4.1.1" />
21+
<PackageReference Include="SharpClipboard" Version="3.6.0" />
2222
</ItemGroup>
2323

2424
</Project>

src/ClipboardR.Panels/ClipboardR.Panels.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Flow.Launcher.Plugin" Version="4.0.2" />
28+
<PackageReference Include="Flow.Launcher.Plugin" Version="4.1.1" />
2929
</ItemGroup>
3030

3131
</Project>

src/ClipboardR/ClipboardR.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
</ItemGroup>
3838

3939
<ItemGroup>
40-
<PackageReference Include="Flow.Launcher.Plugin" Version="4.0.2" />
41-
<PackageReference Include="H.InputSimulator" Version="1.3.0">
40+
<PackageReference Include="Flow.Launcher.Plugin" Version="4.1.1" />
41+
<PackageReference Include="H.InputSimulator" Version="1.4.0">
4242
</PackageReference>
43-
<PackageReference Include="SharpClipboard" Version="3.5.2" />
43+
<PackageReference Include="SharpClipboard" Version="3.6.0" />
4444
</ItemGroup>
4545

4646
<ItemGroup>

src/ClipboardR/Main.cs

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,34 @@ public void Init(PluginInitContext ctx)
6262

6363
public List<Result> Query(Query query)
6464
{
65-
var displayData = query.Search.Trim().Length == 0
66-
? _dataList.ToArray()
67-
: _dataList.Where(i =>
68-
!string.IsNullOrEmpty(i.Text) && i.Text.ToLower().Contains(query.Search.Trim().ToLower())).ToArray();
65+
var displayData =
66+
query.Search.Trim().Length == 0
67+
? _dataList.ToArray()
68+
: _dataList
69+
.Where(
70+
i =>
71+
!string.IsNullOrEmpty(i.Text)
72+
&& i.Text.ToLower().Contains(query.Search.Trim().ToLower())
73+
)
74+
.ToArray();
6975

7076
var results = new List<Result>();
7177
results.AddRange(displayData.Select(ClipDataToResult));
72-
results.Add(new Result()
73-
{
74-
Title="Clear All Records",
75-
SubTitle = "Click to clear all records",
76-
IcoPath = _defaultIconPath,
77-
Score = 1,
78-
Action = _ =>
78+
results.Add(
79+
new Result()
7980
{
80-
_dataList.Clear();
81-
CurrentScore = 1;
82-
return true;
83-
},
84-
});
81+
Title = "Clear All Records",
82+
SubTitle = "Click to clear all records",
83+
IcoPath = _defaultIconPath,
84+
Score = 1,
85+
Action = _ =>
86+
{
87+
_dataList.Clear();
88+
CurrentScore = 1;
89+
return true;
90+
},
91+
}
92+
);
8593
return results;
8694
}
8795

@@ -98,31 +106,36 @@ private Result ClipDataToResult(ClipboardData o)
98106
Score = o.Score,
99107
TitleToolTip = o.Text,
100108
SubTitleToolTip = dispSubTitle,
101-
PreviewPanel = new Lazy<UserControl>(() => new PreviewPanel(
102-
o,
103-
_context!,
104-
ClipCacheDir,
105-
delAction: RemoveFromDatalist,
106-
copyAction: CopyToClipboard,
107-
pinAction: PinOneRecord
108-
)),
109+
PreviewPanel = new Lazy<UserControl>(
110+
() =>
111+
new PreviewPanel(
112+
o,
113+
_context!,
114+
ClipCacheDir,
115+
delAction: RemoveFromDatalist,
116+
copyAction: CopyToClipboard,
117+
pinAction: PinOneRecord
118+
)
119+
),
109120
AsyncAction = async _ =>
110121
{
111122
CopyToClipboard(o);
112123
_context!.API.HideMainWindow();
113124
while (_context!.API.IsMainWindowVisible())
114125
await Task.Delay(100);
115-
new InputSimulator()
116-
.Keyboard
117-
.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);
126+
new InputSimulator().Keyboard.ModifiedKeyStroke(
127+
VirtualKeyCode.CONTROL,
128+
VirtualKeyCode.VK_V
129+
);
118130
return true;
119131
},
120132
};
121133
}
122134

123135
private void _OnClipboardChange(object? sender, SharpClipboard.ClipboardChangedEventArgs e)
124136
{
125-
if (e.Content is null) return;
137+
if (e.Content is null)
138+
return;
126139
ClipboardData clipboardData = new ClipboardData
127140
{
128141
Text = "",
@@ -145,7 +158,8 @@ private void _OnClipboardChange(object? sender, SharpClipboard.ClipboardChangedE
145158
break;
146159
case SharpClipboard.ContentTypes.Image:
147160
clipboardData.Text = $"Image:{clipboardData.Time:yy-MM-dd-HH:mm:ss}";
148-
if (_settings.CacheImages) Utils.SaveImageCache(clipboardData, ClipCacheDir);
161+
if (_settings.CacheImages)
162+
Utils.SaveImageCache(clipboardData, ClipCacheDir);
149163
clipboardData.Icon = _clipboard.ClipboardImage.ToBitmapImage();
150164
break;
151165
case SharpClipboard.ContentTypes.Files:
@@ -173,9 +187,7 @@ private void _OnClipboardChange(object? sender, SharpClipboard.ClipboardChangedE
173187

174188
public Control CreateSettingPanel() => new SettingsPanel(_settings, _context!);
175189

176-
public void Dispose()
177-
{
178-
}
190+
public void Dispose() { }
179191

180192
public void CopyToClipboard(ClipboardData clipboardData)
181193
{
@@ -205,4 +217,4 @@ public void Save()
205217
{
206218
_settings?.Save();
207219
}
208-
}
220+
}

src/ClipboardR/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "ClipboardR",
55
"Description": "A clipboard plugin for Flow.Launcher, support pictures!",
66
"Author": "Rainyl",
7-
"Version": "0.2.4",
7+
"Version": "0.2.5",
88
"Language": "csharp",
99
"Website": "https://github.com/rainyl/Flow.Launcher.Plugin.ClipboardR",
1010
"IcoPath": "Images/clipboard.png",

0 commit comments

Comments
 (0)