mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: remove unnecessary memebers
This commit is contained in:
parent
ad3eeabb83
commit
f8caeceade
5 changed files with 36 additions and 44 deletions
|
@ -302,6 +302,11 @@ namespace SourceGit
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ViewModels.Launcher GetLauncer()
|
||||||
|
{
|
||||||
|
return Current is App app ? app._launcher : null;
|
||||||
|
}
|
||||||
|
|
||||||
public static ViewModels.Repository FindOpenedRepository(string repoPath)
|
public static ViewModels.Repository FindOpenedRepository(string repoPath)
|
||||||
{
|
{
|
||||||
if (Current is App app && app._launcher != null)
|
if (Current is App app && app._launcher != null)
|
||||||
|
|
|
@ -3,6 +3,8 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Avalonia.Threading;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
public class Clone : Popup
|
public class Clone : Popup
|
||||||
|
@ -51,26 +53,23 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _extraArgs, value);
|
set => SetProperty(ref _extraArgs, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Clone(Launcher launcher)
|
public Clone()
|
||||||
{
|
{
|
||||||
_launcher = launcher;
|
|
||||||
_page = launcher.ActivePage;
|
|
||||||
|
|
||||||
View = new Views.Clone() { DataContext = this };
|
View = new Views.Clone() { DataContext = this };
|
||||||
App.GetClipboardTextAsync()
|
|
||||||
.ContinueWith(t =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (t.IsFaulted)
|
try
|
||||||
{
|
{
|
||||||
t.Exception.Handle(static _ => true);
|
var text = await App.GetClipboardTextAsync();
|
||||||
|
if (Models.Remote.IsValidURL(text))
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() => Remote = text);
|
||||||
}
|
}
|
||||||
else if (t.IsCompleted)
|
|
||||||
{
|
|
||||||
var result = t.Result;
|
|
||||||
if (Models.Remote.IsValidURL(result))
|
|
||||||
{
|
|
||||||
Remote = result;
|
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -131,15 +130,24 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
var normalizedPath = path.Replace("\\", "/");
|
var normalizedPath = path.Replace("\\", "/");
|
||||||
var node = Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, null, true);
|
var node = Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, null, true);
|
||||||
_launcher.OpenRepositoryInTab(node, _page);
|
var launcher = App.GetLauncer();
|
||||||
|
var page = null as LauncherPage;
|
||||||
|
foreach (var one in launcher.Pages)
|
||||||
|
{
|
||||||
|
if (one.GetId() == HostPageId)
|
||||||
|
{
|
||||||
|
page = one;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
launcher.OpenRepositoryInTab(node, page);
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Launcher _launcher = null;
|
|
||||||
private readonly LauncherPage _page = null;
|
|
||||||
private string _remote = string.Empty;
|
private string _remote = string.Empty;
|
||||||
private bool _useSSH = false;
|
private bool _useSSH = false;
|
||||||
private string _sshKey = string.Empty;
|
private string _sshKey = string.Empty;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Collections;
|
using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
|
@ -50,24 +48,17 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PopupHost.CanCreatePopup() &&
|
if (PopupHost.CanCreatePopup())
|
||||||
Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { DataContext: Launcher launcher } })
|
PopupHost.ShowPopup(new Clone());
|
||||||
{
|
|
||||||
PopupHost.ShowPopup(new Clone(launcher));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenTerminal()
|
public void OpenTerminal()
|
||||||
{
|
{
|
||||||
if (!Preference.Instance.IsGitConfigured())
|
if (!Preference.Instance.IsGitConfigured())
|
||||||
{
|
|
||||||
App.RaiseException(PopupHost.Active.GetId(), App.Text("NotConfigured"));
|
App.RaiseException(PopupHost.Active.GetId(), App.Text("NotConfigured"));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Native.OS.OpenTerminal(null);
|
Native.OS.OpenTerminal(null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearSearchFilter()
|
public void ClearSearchFilter()
|
||||||
{
|
{
|
||||||
|
@ -96,12 +87,7 @@ namespace SourceGit.ViewModels
|
||||||
openAll.Icon = App.CreateMenuIcon("Icons.Folder.Open");
|
openAll.Icon = App.CreateMenuIcon("Icons.Folder.Open");
|
||||||
openAll.Click += (_, e) =>
|
openAll.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup() &&
|
OpenAllInNode(App.GetLauncer(), node);
|
||||||
Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { DataContext: Launcher launcher } })
|
|
||||||
{
|
|
||||||
OpenAllInNode(launcher, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
x:DataType="vm:Blame"
|
x:DataType="vm:Blame"
|
||||||
Icon="/App.ico"
|
Icon="/App.ico"
|
||||||
Title="{DynamicResource Text.Blame}"
|
Title="{DynamicResource Text.Blame}"
|
||||||
WindowStartupLocation="CenterOwner"
|
|
||||||
MinWidth="1280" MinHeight="720">
|
MinWidth="1280" MinHeight="720">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Globalization;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
@ -326,11 +325,6 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
public Blame()
|
public Blame()
|
||||||
{
|
{
|
||||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
||||||
{
|
|
||||||
Owner = desktop.MainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue