mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor<*>: rewrite all with AvaloniaUI
This commit is contained in:
parent
0136904612
commit
2a62596999
521 changed files with 19780 additions and 23244 deletions
69
src/ViewModels/RepositoryConfigure.cs
Normal file
69
src/ViewModels/RepositoryConfigure.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels {
|
||||
public class RepositoryConfigure : Popup {
|
||||
public string UserName {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string UserEmail {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool GPGSigningEnabled {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string GPGUserSigningKey {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string HttpProxy {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public RepositoryConfigure(Repository repo) {
|
||||
_repo = repo;
|
||||
|
||||
_cached = new Commands.Config(repo.FullPath).ListAll();
|
||||
if (_cached.ContainsKey("user.name")) UserName = _cached["user.name"];
|
||||
if (_cached.ContainsKey("user.email")) UserEmail = _cached["user.email"];
|
||||
if (_cached.ContainsKey("commit.gpgsign")) GPGSigningEnabled = _cached["commit.gpgsign"] == "true";
|
||||
if (_cached.ContainsKey("user.signingkey")) GPGUserSigningKey = _cached["user.signingkey"];
|
||||
if (_cached.ContainsKey("http.proxy")) HttpProxy = _cached["user.signingkey"];
|
||||
|
||||
View = new Views.RepositoryConfigure() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure() {
|
||||
SetIfChanged("user.name", UserName);
|
||||
SetIfChanged("user.email", UserEmail);
|
||||
SetIfChanged("commit.gpgsign", GPGSigningEnabled ? "true" : "false");
|
||||
SetIfChanged("user.signingkey", GPGUserSigningKey);
|
||||
SetIfChanged("http.proxy", HttpProxy);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SetIfChanged(string key, string value) {
|
||||
bool changed = false;
|
||||
if (_cached.ContainsKey(key)) {
|
||||
changed = value != _cached[key];
|
||||
} else if (!string.IsNullOrEmpty(value)) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
new Commands.Config(_repo.FullPath).Set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private Repository _repo = null;
|
||||
private Dictionary<string, string> _cached = null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue