@@ -163,7 +163,6 @@ class UsdMngrWindow(QtWidgets.QMainWindow):
163
163
- AddressBar file completer has problems occasionally.
164
164
- Figure out why network printers aren't showing up. Linux or DWA
165
165
issue? macOS and Windows are fine.
166
- - When reading in a USDZ file, the progress bar gets stuck.
167
166
- Qt.py problems:
168
167
169
168
- PyQt5
@@ -208,7 +207,7 @@ def __init__(self, parent=None, **kwargs):
208
207
# externally. The user's preferred programs are stored in
209
208
# self.programs.
210
209
self .defaultPrograms = {x : "" for x in USD_EXTS }
211
- self .defaultPrograms .update (self .app .appConfig . get ( " defaultPrograms" , {}) )
210
+ self .defaultPrograms .update (self .app .DEFAULTS [ ' defaultPrograms' ] )
212
211
self .programs = self .defaultPrograms
213
212
self .masterHighlighters = {}
214
213
@@ -247,12 +246,14 @@ def setupUi(self):
247
246
self .baseInstance = utils .loadUiWidget ('main_window.ui' , self )
248
247
249
248
# You now have access to the widgets defined in the ui file.
250
- self .defaultDocFont = QtGui .QFont ()
251
- self .defaultDocFont .setStyleHint (QtGui .QFont .Courier )
252
- self .defaultDocFont .setFamily ("Monospace" )
253
- self .defaultDocFont .setPointSize (9 )
254
- self .defaultDocFont .setBold (False )
255
- self .defaultDocFont .setItalic (False )
249
+ # Update some app defaults that required the GUI to be created first.
250
+ defaultDocFont = QtGui .QFont ()
251
+ defaultDocFont .setStyleHint (QtGui .QFont .Courier )
252
+ defaultDocFont .setFamily ("Monospace" )
253
+ defaultDocFont .setPointSize (9 )
254
+ defaultDocFont .setBold (False )
255
+ defaultDocFont .setItalic (False )
256
+ self .app .DEFAULTS ['font' ] = defaultDocFont
256
257
257
258
self .readSettings ()
258
259
self .compileLinkRegEx ()
@@ -288,13 +289,13 @@ def setupUi(self):
288
289
</style></head><body style="white-space:pre">{}</body></html>"""
289
290
290
291
searchPaths = QtGui .QIcon .themeSearchPaths ()
291
- extraSearchPaths = [x for x in self .app .appConfig . get ( "themeSearchPaths" , []) if x not in searchPaths ]
292
+ extraSearchPaths = [x for x in self .app .DEFAULTS [ 'themeSearchPaths' ] if x not in searchPaths ]
292
293
if extraSearchPaths :
293
294
searchPaths = extraSearchPaths + searchPaths
294
295
QtGui .QIcon .setThemeSearchPaths (searchPaths )
295
296
296
297
# Set the preferred theme name for some non-standard icons.
297
- QtGui .QIcon .setThemeName (self .app .appConfig . get ( " iconTheme" , "crystal_project" ) )
298
+ QtGui .QIcon .setThemeName (self .app .DEFAULTS [ ' iconTheme' ] )
298
299
299
300
# Try to adhere to the freedesktop icon standards (https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html).
300
301
# Some icons are preferred from the crystal_project set, which sadly follows different naming standards.
@@ -633,27 +634,27 @@ def readSettings(self):
633
634
""" Read in user config settings.
634
635
"""
635
636
logger .debug ("Reading user settings from {}" .format (self .config .fileName ()))
636
- # Get basic preferences.
637
- # TODO: Read some of these from the same places as the preferences dialog so we don't have to maintain defaults in 2 places.
637
+ default = self .app .DEFAULTS
638
638
self .preferences = {
639
- 'parseLinks' : self .config .boolValue ("parseLinks" , True ),
640
- 'newTab' : self .config .boolValue ("newTab" , False ),
641
- 'syntaxHighlighting' : self .config .boolValue ("syntaxHighlighting" , True ),
642
- 'teletype' : self .config .boolValue ("teletype" , True ),
643
- 'lineNumbers' : self .config .boolValue ("lineNumbers" , True ),
644
- 'showAllMessages' : self .config .boolValue ("showAllMessages" , True ),
645
- 'showHiddenFiles' : self .config .boolValue ("showHiddenFiles" , False ),
646
- 'font' : self .config .value ("font" , self .defaultDocFont ),
647
- 'fontSizeAdjust' : int (self .config .value ("fontSizeAdjust" , 0 )),
648
- 'findMatchCase' : self .config .boolValue ("findMatchCase" , self .checkBoxMatchCase .isChecked ()),
649
- 'includeVisible' : self .config .boolValue ("includeVisible" , self .actionIncludePanel .isChecked ()),
650
- 'lastOpenWithStr' : self .config .value ("lastOpenWithStr" , "" ),
651
- 'textEditor' : self .config .value ("textEditor" , os .getenv ("EDITOR" , self .app .appConfig .get ("textEditor" , "nedit" ))),
652
- 'diffTool' : self .config .value ("diffTool" , self .app .appConfig .get ("diffTool" , "xdiff" )),
653
- 'autoCompleteAddressBar' : self .config .boolValue ("autoCompleteAddressBar" , True ),
654
- 'useSpaces' : self .config .boolValue ("useSpaces" , True ),
655
- 'tabSpaces' : int (self .config .value ("tabSpaces" , 4 )),
656
- 'theme' : self .config .value ("theme" , None ),
639
+ 'parseLinks' : self .config .boolValue ("parseLinks" , default ['parseLinks' ]),
640
+ 'newTab' : self .config .boolValue ("newTab" , default ['newTab' ]),
641
+ 'syntaxHighlighting' : self .config .boolValue ("syntaxHighlighting" , default ['syntaxHighlighting' ]),
642
+ 'teletype' : self .config .boolValue ("teletype" , default ['teletype' ]),
643
+ 'lineNumbers' : self .config .boolValue ("lineNumbers" , default ['lineNumbers' ]),
644
+ 'showAllMessages' : self .config .boolValue ("showAllMessages" , default ['showAllMessages' ]),
645
+ 'showHiddenFiles' : self .config .boolValue ("showHiddenFiles" , default ['showHiddenFiles' ]),
646
+ 'font' : self .config .value ("font" , default ['font' ]),
647
+ 'fontSizeAdjust' : int (self .config .value ("fontSizeAdjust" , default ['fontSizeAdjust' ])),
648
+ 'findMatchCase' : self .config .boolValue ("findMatchCase" , default ['findMatchCase' ]),
649
+ 'includeVisible' : self .config .boolValue ("includeVisible" , default ['includeVisible' ]),
650
+ 'lastOpenWithStr' : self .config .value ("lastOpenWithStr" , default ['lastOpenWithStr' ]),
651
+ 'textEditor' : self .config .value ("textEditor" , default ['textEditor' ]),
652
+ 'diffTool' : self .config .value ("diffTool" , default ['diffTool' ]),
653
+ 'autoCompleteAddressBar' : self .config .boolValue ("autoCompleteAddressBar" , default ['autoCompleteAddressBar' ]),
654
+ 'useSpaces' : self .config .boolValue ("useSpaces" , default ['useSpaces' ]),
655
+ 'tabSpaces' : int (self .config .value ("tabSpaces" , default ['tabSpaces' ])),
656
+ 'theme' : self .config .value ("theme" , default ['theme' ]),
657
+ 'lineLimit' : int (self .config .value ("lineLimit" , default ['lineLimit' ])),
657
658
}
658
659
659
660
# Read 'programs' settings object into self.programs.
@@ -736,6 +737,7 @@ def writeSettings(self):
736
737
self .config .setValue ("useSpaces" , self .preferences ['useSpaces' ])
737
738
self .config .setValue ("tabSpaces" , self .preferences ['tabSpaces' ])
738
739
self .config .setValue ("theme" , self .preferences ['theme' ])
740
+ self .config .setValue ("lineLimit" , self .preferences ['lineLimit' ])
739
741
740
742
# Write self.programs to settings object
741
743
exts = self .programs .keys ()
@@ -1918,11 +1920,14 @@ def editPreferences(self):
1918
1920
dlg = PreferencesDialog (self )
1919
1921
# Open dialog.
1920
1922
if dlg .exec_ () == dlg .Accepted :
1921
- # Save new preferences .
1923
+ # Users currently have to refresh to see these changes .
1922
1924
self .preferences ['parseLinks' ] = dlg .getPrefParseLinks ()
1923
- self .preferences ['newTab' ] = dlg .getPrefNewTab ()
1924
1925
self .preferences ['syntaxHighlighting' ] = dlg .getPrefSyntaxHighlighting ()
1925
1926
self .preferences ['teletype' ] = dlg .getPrefTeletypeConversion ()
1927
+ self .preferences ['theme' ] = dlg .getPrefTheme ()
1928
+
1929
+ # These changes do not require the user to refresh any tabs to see the change.
1930
+ self .preferences ['newTab' ] = dlg .getPrefNewTab ()
1926
1931
self .preferences ['lineNumbers' ] = dlg .getPrefLineNumbers ()
1927
1932
self .preferences ['showAllMessages' ] = dlg .getPrefShowAllMessages ()
1928
1933
self .preferences ['showHiddenFiles' ] = dlg .getPrefShowHiddenFiles ()
@@ -1932,7 +1937,7 @@ def editPreferences(self):
1932
1937
self .preferences ['font' ] = dlg .getPrefFont ()
1933
1938
self .preferences ['useSpaces' ] = dlg .getPrefUseSpaces ()
1934
1939
self .preferences ['tabSpaces' ] = dlg .getPrefTabSpaces ()
1935
- self .preferences ['theme ' ] = dlg .getPrefTheme ()
1940
+ self .preferences ['lineLimit ' ] = dlg .getPrefLineLimit ()
1936
1941
1937
1942
# Update font and line number visibility in all tabs.
1938
1943
self .tabWidget .setFont (self .preferences ['font' ])
@@ -1964,9 +1969,6 @@ def editPreferences(self):
1964
1969
else :
1965
1970
self .addressBar .setCompleter (QtWidgets .QCompleter ())
1966
1971
1967
- if not self .currTab .isDirty ():
1968
- self .refreshTab ()
1969
-
1970
1972
self .writeSettings ()
1971
1973
1972
1974
@Slot (int )
@@ -1977,7 +1979,7 @@ def updatePreference_findMatchCase(self, checked):
1977
1979
checked : `int`
1978
1980
State of checkbox.
1979
1981
"""
1980
- checked = checked & QtCore .Qt .Checked
1982
+ checked = checked == QtCore .Qt .Checked
1981
1983
if checked != self .preferences ['findMatchCase' ]:
1982
1984
self .preferences ['findMatchCase' ] = checked
1983
1985
for lang , h in self .masterHighlighters .iteritems ():
@@ -2185,7 +2187,7 @@ def restoreTab(self, tab):
2185
2187
self .menuRecentlyClosedTabs .setEnabled (False )
2186
2188
2187
2189
# Update settings in the recently re-opened tab that may have changed.
2188
- if self .preferences ['font' ] != self .defaultDocFont :
2190
+ if self .preferences ['font' ] != self .app . DEFAULTS [ 'font' ] :
2189
2191
tab .textBrowser .setFont (self .preferences ['font' ])
2190
2192
tab .textEditor .setFont (self .preferences ['font' ])
2191
2193
tab .lineNumbers .setVisible (self .preferences ['lineNumbers' ])
@@ -2348,7 +2350,7 @@ def launchTextEditor(self):
2348
2350
def launchUsdView (self ):
2349
2351
""" Launch the current file in usdview.
2350
2352
"""
2351
- app = self .app .appConfig . get ( " usdview" , "usdview" )
2353
+ app = self .app .DEFAULTS [ ' usdview' ]
2352
2354
path = self .currTab .getCurrentPath ()
2353
2355
# Files with spaces have to be double-quoted on Windows for usdview.
2354
2356
if os .name == "nt" :
@@ -2557,9 +2559,9 @@ def setSource(self, link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos
2557
2559
vScrollPos : `int`
2558
2560
Vertical scroll bar position.
2559
2561
"""
2560
- # Check if the current tab is dirty before doing anything.
2562
+ # If we're staying in the current tab, check if the tab is dirty before doing anything.
2561
2563
# Perform save operations if necessary.
2562
- if not self .dirtySave ():
2564
+ if not newTab and not self .dirtySave ():
2563
2565
return True
2564
2566
2565
2567
# Re-cast the QUrl so any query strings are evaluated properly.
@@ -2681,6 +2683,8 @@ def setSource(self, link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos
2681
2683
layer = utils .queryItemValue (link , "layer" )
2682
2684
dest = utils .unzip (fileStr , layer , self .app .tmpDir )
2683
2685
self .restoreOverrideCursor ()
2686
+ self .statusbar .removeWidget (loadingProgressBar )
2687
+ self .statusbar .removeWidget (loadingProgressLabel )
2684
2688
return self .setSource (QtCore .QUrl (dest ))
2685
2689
else :
2686
2690
if ext == "usda" :
@@ -2709,11 +2713,13 @@ def setSource(self, link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos
2709
2713
2710
2714
# TODO: Figure out a better way to handle streaming text for large files like Crate geometry.
2711
2715
# Large chunks of text (e.g. 2.2 billion characters) will cause Qt to segfault when creating a QString.
2712
- if length > LINE_LIMIT :
2713
- length = LINE_LIMIT
2716
+ lineLimit = self .preferences ['lineLimit' ]
2717
+ if length > lineLimit :
2718
+ length = lineLimit
2714
2719
truncated = True
2715
2720
fileText = fileText [:length ]
2716
- warning = "Extremely large file! Capping display at {:,d} lines." .format (LINE_LIMIT )
2721
+ warning = "Extremely large file! Capping display at {:,d} lines. You can edit this cap in the " \
2722
+ "Advanced tab of Preferences." .format (lineLimit )
2717
2723
2718
2724
loadingProgressBar .setMaximum (length - 1 )
2719
2725
if self .stopLoadingTab :
@@ -4274,13 +4280,40 @@ def run(self):
4274
4280
try :
4275
4281
logger .info ("Loading app config from {}" .format (appConfigPath ))
4276
4282
with open (appConfigPath ) as f :
4277
- self . appConfig = json .load (f )
4283
+ appConfig = json .load (f )
4278
4284
except Exception as e :
4279
4285
logger .error ("Failed to load app config from {}: {}" .format (appConfigPath , e ))
4280
- self .appConfig = {}
4286
+ appConfig = {}
4287
+
4288
+ # Define app defaults that we use when the user preference doesn't exist and when resetting preferences in the
4289
+ # Preferences dialog.
4290
+ self .DEFAULTS = {
4291
+ 'autoCompleteAddressBar' : True ,
4292
+ 'defaultPrograms' : appConfig .get ("defaultPrograms" , {}),
4293
+ 'diffTool' : appConfig .get ("diffTool" , "xdiff" ),
4294
+ 'findMatchCase' : False ,
4295
+ 'fontSizeAdjust' : 0 ,
4296
+ 'iconTheme' : appConfig .get ("iconTheme" , "crystal_project" ),
4297
+ 'includeVisible' : True ,
4298
+ 'lastOpenWithStr' : "" ,
4299
+ 'lineLimit' : LINE_LIMIT ,
4300
+ 'lineNumbers' : True ,
4301
+ 'newTab' : False ,
4302
+ 'parseLinks' : True ,
4303
+ 'showAllMessages' : True ,
4304
+ 'showHiddenFiles' : False ,
4305
+ 'syntaxHighlighting' : True ,
4306
+ 'tabSpaces' : 4 ,
4307
+ 'teletype' : True ,
4308
+ 'textEditor' : os .getenv ("EDITOR" , appConfig .get ("textEditor" , "nedit" )),
4309
+ 'theme' : None ,
4310
+ 'themeSearchPaths' : appConfig .get ("themeSearchPaths" , []),
4311
+ 'usdview' : appConfig .get ("usdview" , "usdview" ),
4312
+ 'useSpaces' : True ,
4313
+ }
4281
4314
4282
4315
# Documentation URL.
4283
- self .appURL = self . appConfig .get ("appURL" , "https://github.com/dreamworksanimation/usdmanager" )
4316
+ self .appURL = appConfig .get ("appURL" , "https://github.com/dreamworksanimation/usdmanager" )
4284
4317
4285
4318
# Create a main window.
4286
4319
window = self .newWindow ()
0 commit comments