diff --git a/ShareX.HelpersLib/Properties/Resources.Designer.cs b/ShareX.HelpersLib/Properties/Resources.Designer.cs
index 274188cd7..95f16cb03 100644
--- a/ShareX.HelpersLib/Properties/Resources.Designer.cs
+++ b/ShareX.HelpersLib/Properties/Resources.Designer.cs
@@ -252,6 +252,15 @@ internal class Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Scan QR code.
+ ///
+ internal static string AfterCaptureTasks_ScanQRCode {
+ get {
+ return ResourceManager.GetString("AfterCaptureTasks_ScanQRCode", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Print image.
///
diff --git a/ShareX.HelpersLib/Properties/Resources.resx b/ShareX.HelpersLib/Properties/Resources.resx
index 9b5179a79..1b73defa2 100644
--- a/ShareX.HelpersLib/Properties/Resources.resx
+++ b/ShareX.HelpersLib/Properties/Resources.resx
@@ -1160,4 +1160,7 @@ Would you like to download it?
Browse for a sound file...
+
+ Scan QR code
+
\ No newline at end of file
diff --git a/ShareX/Enums.cs b/ShareX/Enums.cs
index 529b155d4..20628a54d 100644
--- a/ShareX/Enums.cs
+++ b/ShareX/Enums.cs
@@ -110,10 +110,11 @@ public enum AfterCaptureTasks // Localized
CopyFileToClipboard = 1 << 10,
CopyFilePathToClipboard = 1 << 11,
ShowInExplorer = 1 << 12,
- DoOCR = 1 << 13,
- ShowBeforeUploadWindow = 1 << 14,
- UploadImageToHost = 1 << 15,
- DeleteFile = 1 << 16
+ ScanQRCode = 1 << 13,
+ DoOCR = 1 << 14,
+ ShowBeforeUploadWindow = 1 << 15,
+ UploadImageToHost = 1 << 16,
+ DeleteFile = 1 << 17
}
[Flags]
diff --git a/ShareX/Forms/QRCodeForm.cs b/ShareX/Forms/QRCodeForm.cs
index c932e43e9..2c4304764 100644
--- a/ShareX/Forms/QRCodeForm.cs
+++ b/ShareX/Forms/QRCodeForm.cs
@@ -52,18 +52,29 @@ public QRCodeForm(string text = null)
{
txtQRCode.Text = text;
}
- else
- {
- if (Clipboard.ContainsText())
- {
- text = Clipboard.GetText();
+ }
- if (TaskHelpers.CheckQRCodeContent(text))
- {
- txtQRCode.Text = text;
- }
+ public static QRCodeForm EncodeClipboard()
+ {
+ if (Clipboard.ContainsText())
+ {
+ string text = Clipboard.GetText();
+
+ if (TaskHelpers.CheckQRCodeContent(text))
+ {
+ return new QRCodeForm(text);
}
}
+
+ return new QRCodeForm();
+ }
+
+ public static QRCodeForm DecodeFile(string filePath)
+ {
+ QRCodeForm form = new QRCodeForm();
+ form.tcMain.SelectedTab = form.tpDecode;
+ form.DecodeFromFile(filePath);
+ return form;
}
private void QRCodeForm_Shown(object sender, EventArgs e)
@@ -110,6 +121,20 @@ private void DecodeImage(Bitmap bmp)
txtDecodeResult.Text = output;
}
+ private void DecodeFromFile(string filePath)
+ {
+ if (!string.IsNullOrEmpty(filePath))
+ {
+ using (Image img = ImageHelpers.LoadImage(filePath))
+ {
+ if (img != null)
+ {
+ DecodeImage((Bitmap)img);
+ }
+ }
+ }
+ }
+
private void QRCodeForm_Resize(object sender, EventArgs e)
{
EncodeText(txtQRCode.Text);
@@ -212,16 +237,7 @@ private void btnDecodeFromFile_Click(object sender, EventArgs e)
{
string filePath = ImageHelpers.OpenImageFileDialog();
- if (!string.IsNullOrEmpty(filePath))
- {
- using (Image img = ImageHelpers.LoadImage(filePath))
- {
- if (img != null)
- {
- DecodeImage((Bitmap)img);
- }
- }
- }
+ DecodeFromFile(filePath);
}
}
}
\ No newline at end of file
diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs
index 14dd2b945..21eafb068 100644
--- a/ShareX/TaskHelpers.cs
+++ b/ShareX/TaskHelpers.cs
@@ -1010,7 +1010,7 @@ public static void RunShareXAsAdmin(string arguments)
public static void OpenQRCode()
{
- new QRCodeForm().Show();
+ QRCodeForm.EncodeClipboard().Show();
}
public static void OpenRuler(TaskSettings taskSettings = null)
@@ -1336,6 +1336,8 @@ public static Image FindMenuIcon(int index)
return Resources.clipboard_list;
case AfterCaptureTasks.ShowInExplorer:
return Resources.folder_stand;
+ case AfterCaptureTasks.ScanQRCode:
+ return Resources.barcode_2d;
case AfterCaptureTasks.DoOCR:
return Resources.edit_drop_cap;
case AfterCaptureTasks.ShowBeforeUploadWindow:
diff --git a/ShareX/WorkerTask.cs b/ShareX/WorkerTask.cs
index df2f31895..903ccbdb3 100644
--- a/ShareX/WorkerTask.cs
+++ b/ShareX/WorkerTask.cs
@@ -718,6 +718,11 @@ private void DoFileJobs()
{
Helpers.OpenFolderWithFile(Info.FilePath);
}
+
+ if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.ScanQRCode) && Info.DataType == EDataType.Image)
+ {
+ QRCodeForm.DecodeFile(Info.FilePath).ShowDialog();
+ }
}
}