Skip to content

Commit

Permalink
Add HideSidebar to appsettings.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Oct 5, 2024
1 parent da9e3aa commit 741ed9f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions NAPS2.Lib/Config/ConfigSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private ToolbarButtons GetHiddenButtonFlags(AppConfigV0 c)
if (c.HidePrintButton) flags |= ToolbarButtons.Print;
if (c.HideSettingsButton) flags |= ToolbarButtons.Settings;
if (c.HideDonateButton) flags |= ToolbarButtons.Donate;
if (c.HideSidebar) flags |= ToolbarButtons.Sidebar;
return flags;
}

Expand Down
2 changes: 2 additions & 0 deletions NAPS2.Lib/Config/ObsoleteTypes/AppConfigV0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class AppConfigV0

public bool HideDonateButton { get; set; }

public bool HideSidebar { get; set; }

public bool DisableAutoSave { get; set; }

public bool LockSystemProfiles { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion NAPS2.Lib/Config/ToolbarButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public enum ToolbarButtons
Language = 1 << 15,
Settings = 1 << 16,
About = 1 << 17,
Donate = 1 << 18
Donate = 1 << 18,
Sidebar = 1 << 19
}
2 changes: 1 addition & 1 deletion NAPS2.Lib/EtoForms/Layout/SkipLayoutElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public class SkipLayoutElement : LayoutElement
{
public override void Materialize(LayoutContext context) => throw new NotSupportedException();
public override void DoLayout(LayoutContext context, RectangleF bounds) => throw new NotSupportedException();
protected override SizeF GetPreferredSizeCore(LayoutContext context, RectangleF parentBounds) => throw new NotSupportedException();
protected override SizeF GetPreferredSizeCore(LayoutContext context, RectangleF parentBounds) => SizeF.Empty;
}
8 changes: 7 additions & 1 deletion NAPS2.Lib/EtoForms/Ui/DesktopForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ protected override void BuildLayout()

LayoutController.RootPadding = 0;
LayoutController.Content = L.LeftPanel(
_sidebar.CreateView(this),
Config.Get(c => c.HiddenButtons).HasFlag(ToolbarButtons.Sidebar)
? C.None()
: _sidebar.CreateView(this),
L.Overlay(
// For WinForms, we add 1px of top padding to give us room to draw a border above the listview
_listView.Control.Padding(top: EtoPlatform.Current.IsWinForms ? 1 : 0),
Expand Down Expand Up @@ -435,6 +437,10 @@ protected virtual LayoutElement GetControlButtons()

protected LayoutElement GetSidebarButton()
{
if (Config.Get(c => c.HiddenButtons).HasFlag(ToolbarButtons.Sidebar))
{
return C.None();
}
var toggleSidebar = C.ImageButton(Commands.ToggleSidebar);
EtoPlatform.Current.ConfigureZoomButton(toggleSidebar, "application_side_list_small");
return toggleSidebar.AlignTrailing();
Expand Down
1 change: 1 addition & 0 deletions NAPS2.Setup/appsettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<HidePrintButton>false</HidePrintButton>
<HideSettingsButton>false</HideSettingsButton>
<HideDonateButton>false</HideDonateButton>
<HideSidebar>true</HideSidebar>
<DisableAutoSave>false</DisableAutoSave>
<LockSystemProfiles>false</LockSystemProfiles>
<LockUnspecifiedDevices>false</LockUnspecifiedDevices>
Expand Down

0 comments on commit 741ed9f

Please sign in to comment.