Show title of selected tab in windows task bar

This commit is contained in:
FelixSe
2018-07-06 23:56:24 +02:00
parent 55995bd7a9
commit cee34dfb63
4 changed files with 11 additions and 33 deletions
+1
View File
@@ -2,6 +2,7 @@
FluentTerminal.App/Win32
FluentTerminal.App/Client/
FluentTerminal.Client/dist
/.sonarqube
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
@@ -22,7 +22,6 @@ namespace FluentTerminal.App.ViewModels
private double _backgroundOpacity;
private int _nextTerminalId;
private TerminalViewModel _selectedTerminal;
private string _title;
private readonly IApplicationView _applicationView;
private readonly IDispatcherTimer _dispatcherTimer;
private readonly IClipboardService _clipboardService;
@@ -61,10 +60,6 @@ namespace FluentTerminal.App.ViewModels
AddTerminalCommand = new RelayCommand(() => AddTerminal(null, false));
ShowSettingsCommand = new RelayCommand(ShowSettings);
Terminals.CollectionChanged += OnTerminalsCollectionChanged;
Title = "Fluent Terminal";
_applicationView.CloseRequested += OnCloseRequest;
}
@@ -114,12 +109,6 @@ namespace FluentTerminal.App.ViewModels
public ObservableCollection<TerminalViewModel> Terminals { get; } = new ObservableCollection<TerminalViewModel>();
public string Title
{
get => _title;
set => Set(ref _title, value);
}
public Task AddTerminal(string startupDirectory, bool showProfileSelection)
{
return _applicationView.RunOnDispatcherThread(async () =>
@@ -142,7 +131,6 @@ namespace FluentTerminal.App.ViewModels
var terminal = new TerminalViewModel(GetNextTerminalId(), _settingsService, _trayProcessCommunicationService, _dialogService, _keyboardCommandService,
_applicationSettings, startupDirectory, profile, _applicationView, _dispatcherTimer, _clipboardService);
terminal.CloseRequested += OnTerminalCloseRequested;
terminal.TitleChanged += OnTitleChanged;
Terminals.Add(terminal);
SelectedTerminal = terminal;
@@ -228,22 +216,6 @@ namespace FluentTerminal.App.ViewModels
}
}
private void OnTerminalsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (Terminals.Any())
{
Title = Terminals.First().Title;
}
}
private void OnTitleChanged(object sender, string e)
{
if (sender is TerminalViewModel terminal && Terminals.First() == terminal)
{
Title = e;
}
}
private void SelectNextTab()
{
var currentIndex = Terminals.IndexOf(SelectedTerminal);
@@ -73,8 +73,6 @@ namespace FluentTerminal.App.ViewModels
public event EventHandler CloseRequested;
public event EventHandler<string> TitleChanged;
public RelayCommand CloseCommand { get; }
public RelayCommand FindPreviousCommand { get; }
@@ -88,6 +86,10 @@ namespace FluentTerminal.App.ViewModels
{
if (Set(ref _isSelected, value))
{
if (IsSelected)
{
_applicationView.Title = Title;
}
RaisePropertyChanged(nameof(IsUnderlined));
}
}
@@ -99,7 +101,7 @@ namespace FluentTerminal.App.ViewModels
public bool Initialized { get; private set; }
public string DefaultTitle { get; private set; } = "Fluent Terminal";
public string DefaultTitle { get; private set; } = string.Empty;
public string SearchText
{
@@ -145,7 +147,10 @@ namespace FluentTerminal.App.ViewModels
if (Set(ref _title, value))
{
TitleChanged?.Invoke(this, Title);
if (IsSelected)
{
_applicationView.Title = Title;
}
}
}
}
+1 -1
View File
@@ -41,7 +41,7 @@
Grid.Column="0"
IsHitTestVisible="False"
Style="{StaticResource WindowTitleTextBlockStyle}"
Text="{x:Bind ViewModel.Title, Mode=OneWay}"
Text="{x:Bind ViewModel.SelectedTerminal.Title, Mode=OneWay}"
Visibility="{x:Bind ViewModel.Terminals.Count, Mode=OneWay, Converter={StaticResource OneToVisibleConverter}}" />
<ListView
x:Name="Tabs"