Skip to content

Commit

Permalink
Add a "hidden" command line switch.
Browse files Browse the repository at this point in the history
The goal is to set some settings so regardless of your existing settings, if you start the program with that switch, it will prevent the splash screen from loading and always start in the tray.

This is usefull for starting ComicRack automatically with windows.

#121
  • Loading branch information
maforget committed Oct 30, 2024
1 parent 902e4d2 commit 17f7b63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
11 changes: 10 additions & 1 deletion ComicRack/Config/ExtendedSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,15 @@ public bool UseLocalSettings
set;
}

public ExtendedSettings()
[DefaultValue(false)]
[CommandLineSwitch(ShortName = "hidden")]
public bool StartHidden
{
get;
set;
}

public ExtendedSettings()
{
AnamorphicScalingTolerance = 0.25f;
KeyboardZoomStepping = 0.5f;
Expand All @@ -458,6 +466,7 @@ public ExtendedSettings()
QueryCacheMode = QueryCacheMode.InstantUpdate;
MacCompatibleScanning = true;
SortNetworkFolders = true;
StartHidden = false;
}
}
}
17 changes: 11 additions & 6 deletions ComicRack/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ public BookmarkEditorWrapper(IEditBookmark editor)

private bool quickListDirty;

private FormWindowState oldState;

[DefaultValue(null)]
public ComicDisplay ComicDisplay
{
Expand Down Expand Up @@ -2557,10 +2559,12 @@ private void SetWorkspace(DisplayWorkspace workspace, bool remember)
}
if (workspace.IsWindowLayout)
{
base.WindowState = workspace.FormState;
oldState = workspace.FormState;
base.WindowState = Program.ExtendedSettings.StartHidden ? FormWindowState.Minimized : workspace.FormState;
ComicDisplay.FullScreen = workspace.FullScreen;
MinimalGui = workspace.MinimalGui;
ComicBookDialog.PagesConfig = workspace.ComicBookDialogPagesConfig;
Program.ExtendedSettings.StartHidden = false; //Sets it false so it respects normal setting after the first load
}
SetWorkspaceDisplayOptions(workspace);
}
Expand Down Expand Up @@ -3913,14 +3917,15 @@ protected override void OnResize(EventArgs e)
maximized = true;
break;
case FormWindowState.Minimized:
if (Program.Settings.MinimizeToTray)
{
if (Program.ExtendedSettings.StartHidden)
maximized = oldState == FormWindowState.Maximized ? true : false;

if (Program.ExtendedSettings.StartHidden || Program.Settings.MinimizeToTray)
MinimizeToTray();
}

else
{
maximized = false;
}

Program.Collect();
break;
case FormWindowState.Normal:
Expand Down
2 changes: 1 addition & 1 deletion ComicRack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ private static void StartNew(string[] args)
InitializeDatabase(0, null);
});
}
if (Settings.ShowSplash)
if (!ExtendedSettings.StartHidden && Settings.ShowSplash)
{
ManualResetEvent mre = new ManualResetEvent(initialState: false);
ThreadUtility.RunInBackground("Splash Thread", delegate
Expand Down

0 comments on commit 17f7b63

Please sign in to comment.