Skip to content

Commit 98bbfa1

Browse files
committed
v3.0.3 RC 2
1 parent a245c10 commit 98bbfa1

File tree

5 files changed

+36
-43
lines changed

5 files changed

+36
-43
lines changed

SmartImage 3/Mode/Shell/ShellMode.Handlers.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,17 @@ private async void Input_TextChanging(TextChangingEventArgs tc)
7171
var sourceType = SearchQuery.IsValidSourceType(text);
7272

7373
if (sourceType) {
74+
// m_upload.WaitOne();
75+
/*if (_inputVerifying) {
76+
return;
77+
}*/
78+
7479
var ok = await TrySetQueryAsync(text);
7580

7681
Btn_Run.Enabled = ok;
7782
Debug.WriteLine($"{nameof(Input_TextChanging)} :: ok");
7883

84+
// m_upload.Release();
7985
if (ok && Config.AutoSearch && !Client.IsRunning) {
8086
Run_Clicked();
8187
}

SmartImage 3/Mode/Shell/ShellMode.cs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,20 @@ public ShellMode(string[] args)
429429
Btn_Cancel.Clicked += Cancel_Clicked;
430430
Btn_Browse.Clicked += Browse_Clicked;
431431
Lbl_InputInfo.Clicked += InputInfo_Clicked;
432-
Tf_Input.TextChanging += Input_TextChanging;
433-
Btn_Delete.Clicked += Delete_Clicked;
434-
Cb_Queue.Toggled += Queue_Checked;
435-
Btn_Queue.Clicked += Queue_Dialog;
436-
Btn_Next.Clicked += Next_Clicked;
432+
433+
Tf_Input.TextChanging += delegate(TextChangingEventArgs eventArgs)
434+
{
435+
if (_inputVerifying) {
436+
return;
437+
}
438+
439+
Input_TextChanging(eventArgs);
440+
};
441+
442+
Btn_Delete.Clicked += Delete_Clicked;
443+
Cb_Queue.Toggled += Queue_Checked;
444+
Btn_Queue.Clicked += Queue_Dialog;
445+
Btn_Next.Clicked += Next_Clicked;
437446
// Btn_Reload.Clicked += Reload_Clicked;
438447

439448
Lbl_QueryUpload.Clicked += () =>
@@ -631,8 +640,11 @@ internal void SetInputText(ustring s)
631640

632641
}
633642

643+
private Semaphore m_upload = new Semaphore(0, 1);
644+
634645
private async Task<bool> TrySetQueryAsync(ustring text)
635646
{
647+
636648
// TODO: IMPROVE
637649

638650
// Btn_Run.Enabled = false;
@@ -657,7 +669,7 @@ private async Task<bool> TrySetQueryAsync(ustring text)
657669
Lbl_Status2.Text = ustring.Empty;
658670
Btn_Delete.Enabled = false;
659671
Btn_Reload.Enabled = false;
660-
_inputVerifying = false;
672+
_inputVerifying = false;
661673
return false;
662674
}
663675

@@ -679,7 +691,7 @@ private async Task<bool> TrySetQueryAsync(ustring text)
679691
Tf_Input.ReadOnly = true;
680692
Btn_Delete.Enabled = true;
681693
Btn_Reload.Enabled = true;
682-
_inputVerifying = false;
694+
_inputVerifying = false;
683695

684696
return true;
685697
}
@@ -764,6 +776,8 @@ private async Task<bool> TryUploadQueryAsync(SearchQuery sq)
764776

765777
#endregion
766778

779+
internal static bool _clipboardFile;
780+
767781
private bool ClipboardCallback(MainLoop c)
768782
{
769783
// Debug.WriteLine($"executing timeout {nameof(ClipboardCallback)} {c} {UseClipboard} {Clipboard.SequenceNumber}");
@@ -810,8 +824,11 @@ private bool ClipboardCallback(MainLoop c)
810824
}
811825
812826
Debug.WriteLine($"{str}");*/
827+
_clipboardFile = true;
813828

814829
SetInputText(str);
830+
_clipboardFile = false;
831+
815832
// Lbl_InputOk.Text = UI.Clp;
816833
Lbl_InputInfo.Text = R2.Inf_Clipboard;
817834

@@ -827,6 +844,7 @@ private bool ClipboardCallback(MainLoop c)
827844
r1:
828845
c.RemoveTimeout(m_cbCallbackTok);
829846
m_cbCallbackTok = c.AddTimeout(TimeoutTimeSpan, ClipboardCallback);
847+
_clipboardFile = false;
830848
return false;
831849
}
832850
catch (Exception e) {
@@ -836,6 +854,7 @@ private bool ClipboardCallback(MainLoop c)
836854
finally { }
837855

838856
r2:
857+
_clipboardFile = false;
839858
// Debug.WriteLine($"{UseClipboard}");
840859
return true;
841860
// return UseClipboard;
@@ -867,6 +886,7 @@ private async Task RunMainAsync()
867886

868887
private void Clear()
869888
{
889+
_inputVerifying = false;
870890
Tf_Input.ReadOnly = false;
871891

872892
Tf_Input.DeleteAll();
@@ -903,7 +923,7 @@ private void Clear()
903923
m_results.Clear();
904924

905925
_keyPressHandling = false;
906-
_inputVerifying = false;
926+
_inputVerifying = false;
907927
}
908928

909929
public void Close()

SmartImage.Lib 3/Engines/Impl/Upload/BaseUploadEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected void Verify(string file)
5757
public static readonly BaseUploadEngine[] All =
5858
ReflectionHelper.CreateAllInAssembly<BaseUploadEngine>(TypeProperties.Subclass).ToArray();
5959

60-
public static BaseUploadEngine Default { get; set; } = new CatboxEngine();
60+
public static BaseUploadEngine Default { get; set; } = new LitterboxEngine();
6161
}
6262

6363
public abstract class BaseCatboxEngine : BaseUploadEngine

SmartImage.Lib 3/Engines/Impl/Upload/CatboxEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public sealed class CatboxEngine : BaseCatboxEngine
1111

1212
public CatboxEngine() : base("https://catbox.moe/user/api.php")
1313
{
14-
Paranoid = true;
14+
// Paranoid = true;
1515
}
1616

1717
}

SmartImage.Lib 3/SearchQuery.cs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ public static async Task<SearchQuery> TryCreateAsync(string value)
4343
{
4444
var uf = await UniSource.TryGetAsync(value, whitelist: FileType.Image);
4545

46-
if (uf != null) {
47-
if (uf.IsFile) {
48-
var f = uf.Value.ToString();
49-
var f2 = await test(f);
50-
Debug.WriteLine($"replacing {f} with {f2}");
51-
if (f!=f2) {
52-
uf.Dispose();
53-
uf = await UniSource.TryGetAsync(f2, whitelist: FileType.Image);
54-
}
55-
}
56-
}
57-
5846
var sq = new SearchQuery(uf)
5947
{ };
6048

@@ -213,25 +201,4 @@ public override int GetHashCode()
213201

214202
return (t, b);
215203
}
216-
217-
public static async Task<string> test(string fi)
218-
{
219-
using var im = await SixLabors.ImageSharp.Image.LoadAsync(fi);
220-
var m = im.Metadata;
221-
222-
string fn = fi;
223-
224-
if (m.XmpProfile is { } || m.ExifProfile is { }) {
225-
Debug.WriteLine($"metadata found");
226-
m.XmpProfile = null;
227-
m.ExifProfile = null;
228-
fn = Path.GetFileNameWithoutExtension(fi) + "_1" + Path.GetExtension(fi);
229-
230-
await im.SaveAsync(fn);
231-
}
232-
else { }
233-
234-
return fn;
235-
}
236-
237204
}

0 commit comments

Comments
 (0)