Add [img] BBCode tag to the link on the clipboard

Add [img] BBCode tag to the link on the clipboard
This commit is contained in:
Jan 2018-11-30 16:03:39 +01:00
commit 560f4cbfa3
4 changed files with 14 additions and 1 deletions

View file

@ -55,6 +55,10 @@ namespace Greenshot.Addon.Imgur
[DefaultValue(false)] [DefaultValue(false)]
bool UsePageLink { get; set; } bool UsePageLink { get; set; }
[Description("Add [img] BBCode tag to the link on the clipboard")]
[DefaultValue(false)]
bool addImgBBCode { get; set; }
[Description("Use anonymous access to Imgur")] [Description("Use anonymous access to Imgur")]
[DefaultValue(true)] [DefaultValue(true)]
bool AnonymousAccess { get; set; } bool AnonymousAccess { get; set; }

View file

@ -61,6 +61,8 @@ namespace Greenshot.Addon.Imgur
string UsePageLink { get; } string UsePageLink { get; }
string addImgBBCode { get; }
string AnonymousAccess { get; } string AnonymousAccess { get; }
string ResetCredentialsButton { get; } string ResetCredentialsButton { get; }

View file

@ -171,9 +171,15 @@ namespace Greenshot.Addon.Imgur
using (var clipboardAccessToken = ClipboardNative.Access()) using (var clipboardAccessToken = ClipboardNative.Access())
{ {
clipboardAccessToken.ClearContents(); clipboardAccessToken.ClearContents();
// EDIT
if (_imgurConfiguration.addImgBBCode && !_imgurConfiguration.UsePageLink) {
clipboardAccessToken.SetAsUnicodeString("[img]" + uploadUrl.AbsoluteUri + "[/img]");
} else {
clipboardAccessToken.SetAsUrl(uploadUrl.AbsoluteUri); clipboardAccessToken.SetAsUrl(uploadUrl.AbsoluteUri);
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Log.Error().WriteLine(ex, "Can't write to clipboard: "); Log.Error().WriteLine(ex, "Can't write to clipboard: ");

View file

@ -14,6 +14,7 @@
<ContentControl x:Name="FileConfigPartViewModel"/> <ContentControl x:Name="FileConfigPartViewModel"/>
<CheckBox IsChecked="{Binding ImgurConfiguration.AnonymousAccess}" Content="{Binding ImgurLanguage.AnonymousAccess}"/> <CheckBox IsChecked="{Binding ImgurConfiguration.AnonymousAccess}" Content="{Binding ImgurLanguage.AnonymousAccess}"/>
<CheckBox IsChecked="{Binding ImgurConfiguration.UsePageLink}" Content="{Binding ImgurLanguage.UsePageLink}"/> <CheckBox IsChecked="{Binding ImgurConfiguration.UsePageLink}" Content="{Binding ImgurLanguage.UsePageLink}"/>
<CheckBox IsChecked="{Binding ImgurConfiguration.addImgBBCode}" Content="{Binding ImgurLanguage.addImgBBCode}"/>
<Button x:Name="ShowHistory" Content="{Binding ImgurLanguage.History}"/> <Button x:Name="ShowHistory" Content="{Binding ImgurLanguage.History}"/>
<Button Content="{Binding ImgurLanguage.ResetCredentialsButton}" x:Name="ResetCredentials" /> <Button Content="{Binding ImgurLanguage.ResetCredentialsButton}" x:Name="ResetCredentials" />
</StackPanel> </StackPanel>