1111import warnings
1212from builtins import bytes
1313from datetime import datetime , timedelta
14+ from enum import IntEnum
1415from functools import partial
1516from pathlib import Path
1617
6162PRUNE_PATTERN = re .compile (PRUNE_PATTERN )
6263
6364
64- class WorkboxPages :
65+ class WorkboxPages ( IntEnum ) :
6566 """Nice names for the uiWorkboxSTACK indexes."""
6667
6768 Options = 0
@@ -522,7 +523,6 @@ def workbox_for_id(self, workbox_id, show=False, visible=False):
522523 to ensure that it is initialized and its text is loaded.
523524 visible (bool, optional): Make the this workbox visible if found.
524525 """
525- # pred = self.instance()
526526 workbox = None
527527 for box_info in self .uiWorkboxTAB .all_widgets ():
528528 temp_box = box_info [0 ]
@@ -850,24 +850,24 @@ def setGuiFont(self, newSize=None, newFont=None):
850850 tabbar_class = current .tabBar ().__class__
851851 menubar_class = self .menuBar ().__class__
852852 label_class = self .uiStatusLBL .__class__
853- children = self .findChildren (tabbar_class , QtCore . QRegExp ( ".*" ) )
854- children .extend (self .findChildren (menubar_class , QtCore . QRegExp ( ".*" ) ))
855- children .extend (self .findChildren (label_class , QtCore . QRegExp ( ".*" ) ))
856- children .extend (self .findChildren (QToolButton , QtCore . QRegExp ( ".*" ) ))
857- children .extend (self .findChildren (QMenu , QtCore . QRegExp ( ".*" ) ))
858- children .extend (self .findChildren (QToolTip , QtCore . QRegExp ( ".*" ) ))
853+ children = self .findChildren (tabbar_class , None )
854+ children .extend (self .findChildren (menubar_class , None ))
855+ children .extend (self .findChildren (label_class , None ))
856+ children .extend (self .findChildren (QToolButton , None ))
857+ children .extend (self .findChildren (QMenu , None ))
858+ children .extend (self .findChildren (QToolTip , None ))
859859
860860 for child in children :
861+ if not hasattr (child , "setFont" ):
862+ continue
861863 if newFont is None :
862864 newFont = child .font ()
863865 if newSize is None :
864866 newSize = newFont .pointSize ()
865867 newFont .setPointSize (newSize )
866868 child .setFont (newFont )
867- # child.resize()
868869 self .setFont (newFont )
869870 QToolTip .setFont (newFont )
870- # self.resize()
871871
872872 def setFontSize (self , newSize ):
873873 """Update the font size in the console and current workbox.
@@ -1046,8 +1046,6 @@ def setFileMonitoringEnabled(self, filename, state):
10461046 if not filename :
10471047 return
10481048
1049- filename = Path (filename ).as_posix ()
1050-
10511049 if state :
10521050 self .openFileMonitor .addPath (filename )
10531051 else :
@@ -1066,9 +1064,8 @@ def fileMonitoringEnabled(self, filename):
10661064 if not filename :
10671065 return False
10681066
1069- filename = Path (filename ).as_posix ()
1070- watched_files = self .openFileMonitor .files ()
1071- return filename in watched_files
1067+ watched_files = [Path (file ) for file in self .openFileMonitor .files ()]
1068+ return Path (filename ) in watched_files
10721069
10731070 def prefsPath (self , name = 'preditor_pref.json' ):
10741071 """Get the path to this core's prefs, for the given name
@@ -1090,10 +1087,9 @@ def linkedFileChanged(self, filename):
10901087 Args:
10911088 filename (str): The file which triggered the file changed signal
10921089 """
1093- prefs_path = Path (self .prefsPath ()).as_posix ()
10941090
10951091 # Either handle prefs or workbox
1096- if filename == prefs_path :
1092+ if Path ( filename ) == Path ( self . prefsPath ()) :
10971093 # First, save workbox prefs. Don't save preditor.prefs because that
10981094 # would just overwrite whatever changes we are responding to.
10991095 self .getBoxesChangedByInstance ()
@@ -1172,6 +1168,10 @@ def recordPrefs(self, manual=False, disableFileMonitoring=False):
11721168 if not manual and not self .autoSaveEnabled ():
11731169 return
11741170
1171+ # When applying a change to editor class, we may essentially auto-save
1172+ # prefs, in order to reload on the next class. In doing so, we may be
1173+ # changing workbox filename(s), if any, so let's remove them from file
1174+ # monitoring. They will be re-added during restorePrefs.
11751175 if disableFileMonitoring :
11761176 for editor_info in self .uiWorkboxTAB .all_widgets ():
11771177 editor = editor_info [0 ]
0 commit comments