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
@@ -521,7 +522,6 @@ def workbox_for_id(self, workbox_id, show=False, visible=False):
521522 to ensure that it is initialized and its text is loaded.
522523 visible (bool, optional): Make the this workbox visible if found.
523524 """
524- # pred = self.instance()
525525 workbox = None
526526 for box_info in self .uiWorkboxTAB .all_widgets ():
527527 temp_box = box_info [0 ]
@@ -849,24 +849,24 @@ def setGuiFont(self, newSize=None, newFont=None):
849849 tabbar_class = current .tabBar ().__class__
850850 menubar_class = self .menuBar ().__class__
851851 label_class = self .uiStatusLBL .__class__
852- children = self .findChildren (tabbar_class , QtCore . QRegExp ( ".*" ) )
853- children .extend (self .findChildren (menubar_class , QtCore . QRegExp ( ".*" ) ))
854- children .extend (self .findChildren (label_class , QtCore . QRegExp ( ".*" ) ))
855- children .extend (self .findChildren (QToolButton , QtCore . QRegExp ( ".*" ) ))
856- children .extend (self .findChildren (QMenu , QtCore . QRegExp ( ".*" ) ))
857- children .extend (self .findChildren (QToolTip , QtCore . QRegExp ( ".*" ) ))
852+ children = self .findChildren (tabbar_class , None )
853+ children .extend (self .findChildren (menubar_class , None ))
854+ children .extend (self .findChildren (label_class , None ))
855+ children .extend (self .findChildren (QToolButton , None ))
856+ children .extend (self .findChildren (QMenu , None ))
857+ children .extend (self .findChildren (QToolTip , None ))
858858
859859 for child in children :
860+ if not hasattr (child , "setFont" ):
861+ continue
860862 if newFont is None :
861863 newFont = child .font ()
862864 if newSize is None :
863865 newSize = newFont .pointSize ()
864866 newFont .setPointSize (newSize )
865867 child .setFont (newFont )
866- # child.resize()
867868 self .setFont (newFont )
868869 QToolTip .setFont (newFont )
869- # self.resize()
870870
871871 def setFontSize (self , newSize ):
872872 """Update the font size in the console and current workbox.
@@ -1045,8 +1045,6 @@ def setFileMonitoringEnabled(self, filename, state):
10451045 if not filename :
10461046 return
10471047
1048- filename = Path (filename ).as_posix ()
1049-
10501048 if state :
10511049 self .openFileMonitor .addPath (filename )
10521050 else :
@@ -1065,9 +1063,8 @@ def fileMonitoringEnabled(self, filename):
10651063 if not filename :
10661064 return False
10671065
1068- filename = Path (filename ).as_posix ()
1069- watched_files = self .openFileMonitor .files ()
1070- return filename in watched_files
1066+ watched_files = [Path (file ) for file in self .openFileMonitor .files ()]
1067+ return Path (filename ) in watched_files
10711068
10721069 def prefsPath (self , name = 'preditor_pref.json' ):
10731070 """Get the path to this core's prefs, for the given name
@@ -1089,10 +1086,9 @@ def linkedFileChanged(self, filename):
10891086 Args:
10901087 filename (str): The file which triggered the file changed signal
10911088 """
1092- prefs_path = Path (self .prefsPath ()).as_posix ()
10931089
10941090 # Either handle prefs or workbox
1095- if filename == prefs_path :
1091+ if Path ( filename ) == Path ( self . prefsPath ()) :
10961092 # First, save workbox prefs. Don't save preditor.prefs because that
10971093 # would just overwrite whatever changes we are responding to.
10981094 self .getBoxesChangedByInstance ()
@@ -1171,6 +1167,10 @@ def recordPrefs(self, manual=False, disableFileMonitoring=False):
11711167 if not manual and not self .autoSaveEnabled ():
11721168 return
11731169
1170+ # When applying a change to editor class, we may essentially auto-save
1171+ # prefs, in order to reload on the next class. In doing so, we may be
1172+ # changing workbox filename(s), if any, so let's remove them from file
1173+ # monitoring. They will be re-added during restorePrefs.
11741174 if disableFileMonitoring :
11751175 for editor_info in self .uiWorkboxTAB .all_widgets ():
11761176 editor = editor_info [0 ]
0 commit comments