Skip to content
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

Add Setting for Default Startup Page #2953

Merged
merged 5 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions src/UniGetUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,12 @@ private void LoadTrayMenu()
TrayIcon = new TaskbarIcon();
ContentRoot.Children.Add(TrayIcon);
Closed += (_, _) => TrayIcon.Dispose();
TrayIcon.ContextMenuMode = H.NotifyIcon.ContextMenuMode.PopupMenu;
TrayIcon.ContextMenuMode = ContextMenuMode.PopupMenu;

XamlUICommand ShowHideCommand = new();
ShowHideCommand.ExecuteRequested += (_, _) =>
{
if (MainApp.Instance.TooltipStatus.AvailableUpdates > 0)
{
MainApp.Instance?.MainWindow?.NavigationPage?.UpdatesNavButton?.ForceClick();
}

NavigationPage?.LoadDefaultPage();
Activate();
};

Expand Down
65 changes: 38 additions & 27 deletions src/UniGetUI/Pages/MainView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public MainView()
PageButtonReference.Add(SettingsPage, SettingsNavButton);
PageButtonReference.Add(BundlesPage, BundlesNavButton);

DiscoverNavButton.ForceClick();
LoadDefaultPage();

if (CoreTools.IsAdministrator() && !Settings.Get("AlreadyWarnedAboutAdmin"))
{
Expand Down Expand Up @@ -137,25 +137,45 @@ public MainView()
};
}

private void DiscoverNavButton_Click(object sender, EventArgs e)
public void LoadDefaultPage()
{
NavigateToPage(DiscoverPage);
switch (Settings.GetValue("StartupPage"))
{
case "discover":
NavigateToPage(DiscoverPage);
break;
case "updates":
NavigateToPage(UpdatesPage);
break;
case "installed":
NavigateToPage(InstalledPage);
break;
case "bundles":
NavigateToPage(BundlesPage);
break;
case "settings":
NavigateToPage(SettingsPage);
break;
default:
if (MainApp.Instance.TooltipStatus.AvailableUpdates > 0)
NavigateToPage(UpdatesPage);
else
NavigateToPage(DiscoverPage);
break;
}
}

private void DiscoverNavButton_Click(object sender, EventArgs e)
=> NavigateToPage(DiscoverPage);

private void InstalledNavButton_Click(object sender, EventArgs e)
{
NavigateToPage(InstalledPage);
}
=> NavigateToPage(InstalledPage);

private void UpdatesNavButton_Click(object sender, EventArgs e)
{
NavigateToPage(UpdatesPage);
}
=> NavigateToPage(UpdatesPage);

private void BundlesNavButton_Click(object sender, EventArgs e)
{
NavigateToPage(BundlesPage);
}
=> NavigateToPage(BundlesPage);

private void MoreNavButton_Click(object sender, EventArgs e)
{
Expand All @@ -180,9 +200,7 @@ private void MoreNavButton_Click(object sender, EventArgs e)
}

private void SettingsNavButton_Click(object sender, EventArgs e)
{
NavigateToPage(SettingsPage);
}
=> NavigateToPage(SettingsPage);

private async void AboutNavButton_Click(object sender, EventArgs e)
{
Expand All @@ -202,6 +220,8 @@ private async void AboutNavButton_Click(object sender, EventArgs e)

private void NavigateToPage(Page TargetPage)
{
if (CurrentPage == TargetPage) return;

if (!PageButtonReference.TryGetValue(TargetPage, out var pageButton))
{
PageButtonReference.Add(TargetPage, MoreNavButton);
Expand All @@ -211,7 +231,6 @@ private void NavigateToPage(Page TargetPage)
}
foreach (NavButton button in MainApp.Instance.MainWindow.NavButtonList)
{

button.ToggleButton.IsChecked = button == pageButton;
}

Expand All @@ -229,9 +248,7 @@ private void NavigateToPage(Page TargetPage)
}

private void ReleaseNotesMenu_Click(object sender, RoutedEventArgs e)
{
DialogHelper.ShowReleaseNotes();
}
=> DialogHelper.ShowReleaseNotes();

private void OperationHistoryMenu_Click(object sender, RoutedEventArgs e)
{
Expand All @@ -252,15 +269,9 @@ private void HelpMenu_Click(object sender, RoutedEventArgs e)
{
ShowHelp();
}
public void ShowHelp()
{
if (HelpPage is null)
{
HelpPage = new HelpDialog();
}

NavigateToPage(HelpPage);
}
public void ShowHelp()
=> NavigateToPage(HelpPage ??= new HelpDialog());

private void QuitUniGetUI_Click(object sender, RoutedEventArgs e)
{
Expand Down
11 changes: 8 additions & 3 deletions src/UniGetUI/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@
SettingName="PreferredTheme"
ValueChanged="ThemeSelector_ValueChanged"
/>
<widgets:CheckboxCard
Text="Do not remove successful operations from the list automatically"
SettingName="MaintainSuccessfulInstalls"
<widgets:ComboboxCard
x:Name="StartupPageSelector"
Text="UniGetUI startup page:"
SettingName="StartupPage"
/>
<widgets:CheckboxCard
Text="Show UniGetUI on the system tray"
Expand All @@ -132,6 +133,10 @@
x:Name="ResetIconCache"
Click="ResetIconCache_OnClick"
/>
<widgets:CheckboxCard
Text="Do not remove successful operations from the list automatically"
SettingName="MaintainSuccessfulInstalls"
/>
</Toolkit:SettingsExpander.Items>
</widgets:SettingsEntry>

Expand Down
14 changes: 9 additions & 5 deletions src/UniGetUI/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed partial class SettingsInterface : Page
private readonly HyperlinkButton ResetBackupDirectory;
private readonly HyperlinkButton OpenBackupDirectory;
private readonly TextBlock BackupDirectoryLabel;
private bool InterfaceLoaded = false;
private bool InterfaceLoaded;

public SettingsInterface()
{
Expand All @@ -51,7 +51,7 @@ public SettingsInterface()
bool isFirst = true;
foreach (KeyValuePair<string, string> entry in lang_dict)
{
LanguageSelector.AddItem(entry.Value, entry.Key.ToString(), isFirst);
LanguageSelector.AddItem(entry.Value, entry.Key, isFirst);
isFirst = false;
}
LanguageSelector.ShowAddedItems();
Expand Down Expand Up @@ -89,9 +89,13 @@ public SettingsInterface()
ThemeSelector.AddItem(CoreTools.AutoTranslated("Follow system color scheme"), "auto");
ThemeSelector.ShowAddedItems();

// UI Section
// DisableIconsOnPackageLists.Text = "[EXPERIMENTAL] " + CoreTools.Translate("Show package icons on package lists");

StartupPageSelector.AddItem(CoreTools.AutoTranslated("Default"), "default");
StartupPageSelector.AddItem(CoreTools.AutoTranslated("Discover Packages"), "discover");
StartupPageSelector.AddItem(CoreTools.AutoTranslated("Software Updates"), "updates");
StartupPageSelector.AddItem(CoreTools.AutoTranslated("Installed Packages"), "installed");
StartupPageSelector.AddItem(CoreTools.AutoTranslated("Package Bundles"), "bundles");
StartupPageSelector.AddItem(CoreTools.AutoTranslated("Settings"), "settings");
StartupPageSelector.ShowAddedItems();

// Backup Section
BackupDirectoryLabel = (TextBlock)((StackPanel)ChangeBackupDirectory.Description).Children.ElementAt(0);
Expand Down
Loading