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

wxGUI/preferences: allow the user save/load single-window mode panes layout #3312

Merged
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
4 changes: 4 additions & 0 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def _defaultSettings(self):
"region": {
"resAlign": {"enabled": False},
},
"singleWinPanesLayoutPos": {
"enabled": False,
"pos": "",
},
},
#
# datacatalog
Expand Down
166 changes: 115 additions & 51 deletions gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
havePwd = False

import wx
import wx.lib.agw.aui as aui
import wx.lib.colourselect as csel
import wx.lib.mixins.listctrl as listmix
import wx.lib.scrolledpanel as SP
Expand Down Expand Up @@ -312,11 +313,103 @@ def _createGeneralPage(self, notebook):

gridSizer.Add(askOnQuit, pos=(row, 0), span=(1, 2))

#
# Selected text is copied to clipboard
#
row += 1
copySelectedTextToClipboard = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_(
"Automatically copy selected text to clipboard (in the Console tab)"
),
name="IsChecked",
)
copySelectedTextToClipboard.SetValue(
self.settings.Get(
group="manager", key="copySelectedTextToClipboard", subkey="enabled"
)
)
self.winId["manager:copySelectedTextToClipboard:enabled"] = (
copySelectedTextToClipboard.GetId()
)

gridSizer.Add(copySelectedTextToClipboard, pos=(row, 0), span=(1, 2))

gridSizer.AddGrowableCol(0)
sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)

#
# Layout settings
#
box = StaticBox(
parent=panel, id=wx.ID_ANY, label=" {} ".format(_("Layout settings"))
)
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

row = 0
defaultPos = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Save current window layout as default"),
name="IsChecked",
)
defaultPos.SetValue(
self.settings.Get(group="general", key="defWindowPos", subkey="enabled")
)
defaultPos.SetToolTip(
wx.ToolTip(
_(
"Save current position and size of Layer Manager window and opened "
"Map Display window(s) and use as default for next sessions."
)
)
)
self.winId["general:defWindowPos:enabled"] = defaultPos.GetId()

gridSizer.Add(defaultPos, pos=(row, 0), span=(1, 2))

row += 1
singleWinPanesLayoutPos = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Save current single window panes layout as default"),
name="SingleWinPanesLayoutPos",
)
singleWinPanesLayoutPos.SetValue(
self.settings.Get(
group="general",
key="singleWinPanesLayoutPos",
subkey="enabled",
)
)
singleWinPanesLayoutPos.SetToolTip(
wx.ToolTip(
_(
"Save current position and size of single-window mode panes"
" and use as default for next sessions."
)
)
)
if not self.settings.Get(
group="appearance",
key="singleWindow",
subkey="enabled",
):
singleWinPanesLayoutPos.Disable()
self.winId["general:singleWinPanesLayoutPos:enabled"] = (
singleWinPanesLayoutPos.GetId()
)

gridSizer.Add(singleWinPanesLayoutPos, pos=(row, 0), span=(1, 2))

row += 1
hideSearch = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Hide '%s' tab (requires GUI restart)") % _("Tools"),
label=_("Hide '{}' tab (requires GUI restart)").format(_("Tools")),
name="IsChecked",
)
hideSearch.SetValue(
Expand All @@ -330,7 +423,7 @@ def _createGeneralPage(self, notebook):
hideHistory = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Hide '%s' tab (requires GUI restart)") % _("History"),
label=_("Hide '{}' tab (requires GUI restart)").format(_("History")),
name="IsChecked",
)
hideHistory.SetValue(
Expand All @@ -344,7 +437,7 @@ def _createGeneralPage(self, notebook):
hidePyShell = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Hide '%s' tab (requires GUI restart)") % _("Python"),
label=_("Hide '{}' tab (requires GUI restart)").format(_("Python")),
name="IsChecked",
)
hidePyShell.SetValue(
Expand All @@ -353,33 +446,9 @@ def _createGeneralPage(self, notebook):
self.winId["manager:hideTabs:pyshell"] = hidePyShell.GetId()

gridSizer.Add(hidePyShell, pos=(row, 0), span=(1, 2))

#
# Selected text is copied to clipboard
#
row += 1
copySelectedTextToClipboard = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_(
"Automatically copy selected text to clipboard (in the Console tab)"
),
name="IsChecked",
)
copySelectedTextToClipboard.SetValue(
self.settings.Get(
group="manager", key="copySelectedTextToClipboard", subkey="enabled"
)
)
self.winId["manager:copySelectedTextToClipboard:enabled"] = (
copySelectedTextToClipboard.GetId()
)

gridSizer.Add(copySelectedTextToClipboard, pos=(row, 0), span=(1, 2))

gridSizer.AddGrowableCol(0)
sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)

#
# Data catalog settings
#
Expand Down Expand Up @@ -427,7 +496,6 @@ def _createGeneralPage(self, notebook):
gridSizer.Add(posDisplay, pos=(row, 0), span=(1, 2))

row += 1

posManager = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
Expand All @@ -443,28 +511,6 @@ def _createGeneralPage(self, notebook):

gridSizer.Add(posManager, pos=(row, 0), span=(1, 2))

row += 1
defaultPos = wx.CheckBox(
parent=panel,
id=wx.ID_ANY,
label=_("Save current window layout as default"),
name="IsChecked",
)
defaultPos.SetValue(
self.settings.Get(group="general", key="defWindowPos", subkey="enabled")
)
defaultPos.SetToolTip(
wx.ToolTip(
_(
"Save current position and size of Layer Manager window and opened "
"Map Display window(s) and use as default for next sessions."
)
)
)
self.winId["general:defWindowPos:enabled"] = defaultPos.GetId()

gridSizer.Add(defaultPos, pos=(row, 0), span=(1, 2))

gridSizer.AddGrowableCol(0)
sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
Expand Down Expand Up @@ -1944,6 +1990,24 @@ def _updateSettings(self):
group="general", key="defWindowPos", subkey="dim", value=dim
)

#
# update single window panes layout
#
single_win_panes_layout_pos = self.settings.Get(
group="general",
key="singleWinPanesLayoutPos",
subkey="enabled",
)
if single_window and single_win_panes_layout_pos:
aui_manager = aui.GetManager(self.parent)
if aui_manager:
self.settings.Set(
group="general",
key="singleWinPanesLayoutPos",
subkey="pos",
value=aui_manager.SavePerspective(),
)

return True

def OnCheckColorTable(self, event):
Expand Down
14 changes: 14 additions & 0 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,20 @@ def BuildPanes(self):

wx.CallAfter(self.datacatalog.LoadItems)

single_win_panes_layout_pos_enabled = UserSettings.Get(
group="general",
key="singleWinPanesLayoutPos",
subkey="enabled",
)

single_win_panes_layout_pos = UserSettings.Get(
group="general",
key="singleWinPanesLayoutPos",
subkey="pos",
)
if single_win_panes_layout_pos_enabled and single_win_panes_layout_pos:
self._auimgr.LoadPerspective(single_win_panes_layout_pos)

self._auimgr.Update()

def BindEvents(self):
Expand Down
Loading