mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
Merge pull request #189 from workgroupengineering/feature/Clone_Populate_URL
feature: Allow populating the repository URL from the clipboard
This commit is contained in:
commit
0a35d8a22d
2 changed files with 28 additions and 0 deletions
|
@ -317,6 +317,18 @@ namespace SourceGit
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<string> GetClipboardTextAsync()
|
||||||
|
{
|
||||||
|
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
if (desktop.MainWindow.Clipboard is { } clipboard)
|
||||||
|
{
|
||||||
|
return await clipboard.GetTextAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
private ResourceDictionary _activeLocale = null;
|
private ResourceDictionary _activeLocale = null;
|
||||||
private ResourceDictionary _colorOverrides = null;
|
private ResourceDictionary _colorOverrides = null;
|
||||||
private Models.INotificationReceiver _notificationReceiver = null;
|
private Models.INotificationReceiver _notificationReceiver = null;
|
||||||
|
|
|
@ -56,6 +56,22 @@ namespace SourceGit.ViewModels
|
||||||
_page = launcher.ActivePage;
|
_page = launcher.ActivePage;
|
||||||
|
|
||||||
View = new Views.Clone() { DataContext = this };
|
View = new Views.Clone() { DataContext = this };
|
||||||
|
App.GetClipboardTextAsync()
|
||||||
|
.ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (t.IsFaulted)
|
||||||
|
{
|
||||||
|
t.Exception.Handle(static _ => true);
|
||||||
|
}
|
||||||
|
else if (t.IsCompleted)
|
||||||
|
{
|
||||||
|
var result = t.Result;
|
||||||
|
if (Models.Remote.IsValidURL(result))
|
||||||
|
{
|
||||||
|
Remote = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult ValidateRemote(string remote, ValidationContext _)
|
public static ValidationResult ValidateRemote(string remote, ValidationContext _)
|
||||||
|
|
Loading…
Reference in a new issue