Преглед на файлове

wxGUI: add single window to settings (#1810)

* add note it's experimental
* fix saving settings, fix for Python 3.10
Anna Petrasova преди 3 години
родител
ревизия
55079f3bdb
променени са 4 файла, в които са добавени 30 реда и са изтрити 4 реда
  1. 1 0
      gui/wxpython/core/settings.py
  2. 19 1
      gui/wxpython/gui_core/preferences.py
  3. 2 2
      gui/wxpython/main_window/frame.py
  4. 8 1
      gui/wxpython/wxgui.py

+ 1 - 0
gui/wxpython/core/settings.py

@@ -153,6 +153,7 @@ class Settings:
                 "region": {
                     "resAlign": {"enabled": False},
                 },
+                "singleWindow": {"enabled": False},
             },
             #
             # datacatalog

+ 19 - 1
gui/wxpython/gui_core/preferences.py

@@ -405,6 +405,19 @@ class PreferencesDialog(PreferencesBaseDialog):
         gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
 
         row = 0
+        singleWindow = wx.CheckBox(
+            parent=panel,
+            id=wx.ID_ANY,
+            label=_("Use single-window mode (experimental, requires GUI restart)"),
+            name="IsChecked",
+        )
+        singleWindow.SetValue(
+            self.settings.Get(group="general", key="singleWindow", subkey="enabled")
+        )
+        self.winId["general:singleWindow:enabled"] = singleWindow.GetId()
+        gridSizer.Add(singleWindow, pos=(row, 0), span=(1, 2))
+
+        row += 1
         posDisplay = wx.CheckBox(
             parent=panel,
             id=wx.ID_ANY,
@@ -1822,7 +1835,12 @@ class PreferencesDialog(PreferencesBaseDialog):
                 size = mapdisp.GetSize()
 
                 # window size must be larger than zero, not minimized
-                if not mapdisp.IsIconized() and (size[0] > 0 and size[1] > 0):
+                # when mapdisp is inside single window (panel has no IsIconized), don't save dim
+                if (
+                    hasattr(mapdisp, "IsIconized")
+                    and not mapdisp.IsIconized()
+                    and (size[0] > 0 and size[1] > 0)
+                ):
                     dim += ",%d,%d,%d,%d" % (pos[0], pos[1], size[0], size[1])
 
             self.settings.Set(

+ 2 - 2
gui/wxpython/main_window/frame.py

@@ -155,8 +155,8 @@ class GMFrame(wx.Frame):
 
         # set pane sizes according to the full screen size of the primary monitor
         size = wx.Display().GetGeometry().GetSize()
-        self.PANE_BEST_SIZE = tuple(t / 3 for t in size)
-        self.PANE_MIN_SIZE = tuple(t / 5 for t in size)
+        self.PANE_BEST_SIZE = tuple(t // 3 for t in size)
+        self.PANE_MIN_SIZE = tuple(t // 5 for t in size)
 
         # create widgets and build panes
         self.CreateMenuBar()

+ 8 - 1
gui/wxpython/wxgui.py

@@ -30,6 +30,7 @@ from grass.script.core import set_raise_on_error
 
 from core import globalvar
 from core.utils import registerPid, unregisterPid
+from core.settings import UserSettings
 
 import wx
 
@@ -83,7 +84,13 @@ class GMApp(wx.App):
 
         def show_main_gui():
             # create and show main frame
-            from lmgr.frame import GMFrame
+            single = UserSettings.Get(
+                group="general", key="singleWindow", subkey="enabled"
+            )
+            if single:
+                from main_window.frame import GMFrame
+            else:
+                from lmgr.frame import GMFrame
 
             mainframe = GMFrame(parent=None, id=wx.ID_ANY, workspace=self.workspaceFile)
             mainframe.Show()