From 07f26c1e917b6f4758a8ec61f3fb74b551eebaf8 Mon Sep 17 00:00:00 2001 From: Rdkang <68774237+Rdkang@users.noreply.github.com> Date: Fri, 21 Jul 2023 13:38:21 +0530 Subject: [PATCH] Allow setting default screenMode (#421) --- docs/Config.md | 2 ++ pkg/config/app_config.go | 4 ++++ pkg/gui/gui.go | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/Config.md b/docs/Config.md index 786cd11..6e030db 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -36,6 +36,8 @@ gui: # When true, increases vertical space used by focused side panel, # creating an accordion effect expandFocusedSidePanel: false + # Determines which screen mode will be used on startup + screenMode: "normal" # one of 'normal' | 'half' | 'fullscreen' logs: timestamps: false since: '60m' # set to '' to show all logs diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index c3a0994..d483991 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -130,6 +130,9 @@ type GuiConfig struct { // When true, increases vertical space used by focused side panel, // creating an accordion effect ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"` + + // ScreenMode allow user to specify which screen mode will be used on startup + ScreenMode string `yaml:"screenMode,omitempty"` } // CommandTemplatesConfig determines what commands actually get called when we @@ -362,6 +365,7 @@ func GetDefaultConfig() UserConfig { SidePanelWidth: 0.3333, ShowBottomLine: true, ExpandFocusedSidePanel: false, + ScreenMode: "normal", }, ConfirmOnQuit: false, Logs: LogsConfig{ diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index cbbe541..4797fb7 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -114,6 +114,19 @@ const ( SCREEN_FULL ) +func getScreenMode(config *config.AppConfig) WindowMaximisation { + switch config.UserConfig.Gui.ScreenMode { + case "normal": + return SCREEN_NORMAL + case "half": + return SCREEN_HALF + case "fullscreen": + return SCREEN_FULL + default: + return SCREEN_NORMAL + } +} + // NewGui builds a new gui handler func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand *commands.OSCommand, tr *i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*Gui, error) { initialState := guiState{ @@ -126,6 +139,7 @@ func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand ViewStack: []string{}, ShowExitedContainers: true, + ScreenMode: getScreenMode(config), } gui := &Gui{