BUG-1852: Added CopyLinkToClipboard property for Imgur [skip ci]

This commit is contained in:
Robin 2015-10-29 12:21:51 +01:00
commit f92dd4122c
2 changed files with 21 additions and 9 deletions

View file

@ -41,6 +41,8 @@ namespace GreenshotImgurPlugin {
public int UploadJpegQuality; public int UploadJpegQuality;
[IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")] [IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
public bool UploadReduceColors; public bool UploadReduceColors;
[IniProperty("CopyLinkToClipboard", Description = "Copy the link, which one is controlled by the UsePageLink, on the clipboard", DefaultValue = "True")]
public bool CopyLinkToClipboard;
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")] [IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
public bool UsePageLink; public bool UsePageLink;
[IniProperty("AnonymousAccess", Description = "Use anonymous access to Imgur", DefaultValue="true")] [IniProperty("AnonymousAccess", Description = "Use anonymous access to Imgur", DefaultValue="true")]

View file

@ -194,18 +194,28 @@ namespace GreenshotImgurPlugin {
imgurInfo.Image = ImageHelper.CreateThumbnail(tmpImage, 90, 90); imgurInfo.Image = ImageHelper.CreateThumbnail(tmpImage, 90, 90);
} }
IniConfig.Save(); IniConfig.Save();
try {
if (config.UsePageLink) { if (config.UsePageLink)
{
uploadURL = imgurInfo.Page; uploadURL = imgurInfo.Page;
ClipboardHelper.SetClipboardData(imgurInfo.Page);
} else {
uploadURL = imgurInfo.Original;
ClipboardHelper.SetClipboardData(imgurInfo.Original);
} }
} catch (Exception ex) { else
{
uploadURL = imgurInfo.Original;
}
if (string.IsNullOrEmpty(uploadURL) && config.CopyLinkToClipboard)
{
try
{
ClipboardHelper.SetClipboardData(imgurInfo.Original);
}
catch (Exception ex)
{
LOG.Error("Can't write to clipboard: ", ex); LOG.Error("Can't write to clipboard: ", ex);
uploadURL = null; uploadURL = null;
} }
}
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {