Skip to content

Code Quality: Improved app startup routine #12861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Task ExecuteAsync()

private static SelectorItem? GetFocusedElement()
{
return FocusManager.GetFocusedElement(App.Window.Content.XamlRoot) as SelectorItem;
return FocusManager.GetFocusedElement(MainWindow.Instance.Content.XamlRoot) as SelectorItem;
}
}
}
11 changes: 3 additions & 8 deletions src/Files.App/Actions/Global/EnterCompactOverlayAction.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.Extensions;
using Microsoft.UI.Windowing;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.Graphics;

namespace Files.App.Actions
Expand All @@ -34,9 +29,9 @@ public EnterCompactOverlayAction()

public Task ExecuteAsync()
{
var window = App.GetAppWindow(App.Window);
window.SetPresenter(AppWindowPresenterKind.CompactOverlay);
window.Resize(new SizeInt32(400, 350));
var appWindow = MainWindow.Instance.AppWindow;
appWindow.SetPresenter(AppWindowPresenterKind.CompactOverlay);
appWindow.Resize(new SizeInt32(400, 350));

return Task.CompletedTask;
}
Expand Down
9 changes: 2 additions & 7 deletions src/Files.App/Actions/Global/ExitCompactOverlayAction.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.Extensions;
using Microsoft.UI.Windowing;
using System.ComponentModel;
using System.Threading.Tasks;

namespace Files.App.Actions
{
Expand All @@ -33,8 +28,8 @@ public ExitCompactOverlayAction()

public Task ExecuteAsync()
{
var window = App.GetAppWindow(App.Window);
window.SetPresenter(AppWindowPresenterKind.Overlapped);
var appWindow = MainWindow.Instance.AppWindow;
appWindow.SetPresenter(AppWindowPresenterKind.Overlapped);

return Task.CompletedTask;
}
Expand Down
13 changes: 4 additions & 9 deletions src/Files.App/Actions/Global/ToggleCompactOverlayAction.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Commands;
using Files.App.Contexts;
using Files.App.Extensions;
using Microsoft.UI.Windowing;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.Graphics;

namespace Files.App.Actions
Expand All @@ -32,16 +27,16 @@ public ToggleCompactOverlayAction()

public Task ExecuteAsync()
{
var window = App.GetAppWindow(App.Window);
var appWindow = MainWindow.Instance.AppWindow;

if (windowContext.IsCompactOverlay)
{
window.SetPresenter(AppWindowPresenterKind.Overlapped);
appWindow.SetPresenter(AppWindowPresenterKind.Overlapped);
}
else
{
window.SetPresenter(AppWindowPresenterKind.CompactOverlay);
window.Resize(new SizeInt32(400, 350));
appWindow.SetPresenter(AppWindowPresenterKind.CompactOverlay);
appWindow.Resize(new SizeInt32(400, 350));
}

return Task.CompletedTask;
Expand Down
14 changes: 5 additions & 9 deletions src/Files.App/Actions/Global/ToggleFullScreenAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.Commands;
using Files.App.Extensions;
using Microsoft.UI.Windowing;
using System.Threading.Tasks;

namespace Files.App.Actions
{
Expand All @@ -20,21 +18,19 @@ public bool IsOn
{
get
{
var window = App.GetAppWindow(App.Window);
return window.Presenter.Kind is AppWindowPresenterKind.FullScreen;
var appWindow = MainWindow.Instance.AppWindow;
return appWindow.Presenter.Kind is AppWindowPresenterKind.FullScreen;
}
}

public Task ExecuteAsync()
{
var window = App.GetAppWindow(App.Window);

var newKind = window.Presenter.Kind is AppWindowPresenterKind.FullScreen
var appWindow = MainWindow.Instance.AppWindow;
var newKind = appWindow.Presenter.Kind is AppWindowPresenterKind.FullScreen
? AppWindowPresenterKind.Overlapped
: AppWindowPresenterKind.FullScreen;

window.SetPresenter(newKind);

appWindow.SetPresenter(newKind);
return Task.CompletedTask;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Open/OpenTerminalAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Task ExecuteAsync()
var terminalStartInfo = GetProcessStartInfo();
if (terminalStartInfo is not null)
{
App.Window.DispatcherQueue.TryEnqueue(() =>
MainWindow.Instance.DispatcherQueue.TryEnqueue(() =>
{
try
{
Expand Down
Loading