Skip to content
Open
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
33 changes: 16 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# serve to show the default.

import os
from recommonmark.parser import CommonMarkParser
import sys

# If extensions (or modules to document with autodoc) are in another directory,
Expand All @@ -33,6 +32,7 @@
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinxcontrib.apidoc',
'recommonmark',
]

autodoc_mock_imports = [
Expand All @@ -42,28 +42,27 @@
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

source_parsers = {
'.md': CommonMarkParser,
}

# The suffix of source filenames.
source_suffix = ['.rst', '.md']
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
root_doc = 'index'

# General information about the project.
project = u'USD Manager'
copyright = u'2019, DreamWorks Animation'
project = 'USD Manager'
copyright = '2019, DreamWorks Animation'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
execfile("../usdmanager/version.py")
from usdmanager.version import __version__
# The short X.Y version.
version = __version__
# The full version, including alpha/beta/rc tags.
Expand Down Expand Up @@ -118,7 +117,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -216,8 +215,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'USDManager.tex', u'USD Manager Documentation',
u'DreamWorks Animation', 'manual'),
('index', 'USDManager.tex', 'USD Manager Documentation',
'DreamWorks Animation', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -246,8 +245,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'usdmanager', u'USD Manager Documentation',
[u'DreamWorks Animation'], 1)
('index', 'usdmanager', 'USD Manager Documentation',
['DreamWorks Animation'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -260,8 +259,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'USDManager', u'USD Manager Documentation',
u'DreamWorks Animation', 'USDManager', 'One line description of project.',
('index', 'USDManager', 'USD Manager Documentation',
'DreamWorks Animation', 'USDManager', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
2 changes: 2 additions & 0 deletions docs/keyboardShortcuts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ For ease of use, there are some extra shortcuts not shown in the menus themselve
- Ctrl+Tab
* - Previous Tab
- Ctrl+Shift+Tab
* - Raw View
- Ctrl+Shift+V
* - Reload
- F5
* - Indent (if text is selected)
Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
recommonmark>=0.5.0
Sphinx>=1.8.5
sphinxcontrib-apidoc>=0.3.0
sphinxcontrib-apidoc>=0.3.0
sphinx-rtd-theme
7 changes: 7 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ usdmanager shot.usd

- [Browse Mode](#browse-mode)
* [Browsing Standard Features](#browsing-standard-features)
* [Raw View Mode](#raw-view-mode)
- [Edit Mode](#edit-mode)
* [Editing Standard Features](#editing-standard-features)
- [USD Crate](#usd-crate)
Expand Down Expand Up @@ -48,6 +49,12 @@ The browser boasts many standard features, including tabbed browsing with rearra
per tab, a recent files list (File > Open Recent), and the ability to restore closed Tabs (History > Recently Closed
Tabs).

### Raw View Mode
For improved performance with large files, you can enable Raw View mode by clicking the "Raw View" button or using
Ctrl+Shift+V. Raw View disables syntax highlighting and link parsing, making file loading and scrolling significantly
faster. To exit Raw View, click "Disable Raw View" or use Ctrl+Shift+V again. You can set Raw View as the default for
new tabs in the Advanced preferences.

## Edit Mode

The program can switch back and forth between browsing (the default) and editing. Before switching to the editor, the
Expand Down
123 changes: 111 additions & 12 deletions usdmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def setupUi(self):
textEdit = icon("accessories-text-editor")
self.actionEdit.setIcon(textEdit)
self.actionTextEditor.setIcon(textEdit)
self.actionRawView.setIcon(textEdit)
self.buttonGo.setIcon(icon("media-playback-start"))
self.actionFullScreen.setIcon(icon("view-fullscreen"))
self.browserReloadIcon = icon("view-refresh")
Expand Down Expand Up @@ -537,6 +538,8 @@ def setupUi(self):
# Add one of our special tabs.
self.currTab = self.newTab()
self.setNavigationMenus()

self.updateEditButtons()

# Adjust tab order.
self.setTabOrder(self.addressBar, self.includeWidget.listView)
Expand Down Expand Up @@ -599,6 +602,9 @@ def setHighlighter(self, ext=None, tab=None):
logger.debug("Setting highlighter to %s", ext)
tab.highlighter.deleteLater()
tab.highlighter = highlighter.Highlighter(tab.getCurrentTextWidget().document(), master)

enableHighlighting = self.preferences['syntaxHighlighting'] and not tab.inRawView
tab.highlighter.master.setSyntaxHighlighting(enableHighlighting)

@Slot(QtCore.QPoint)
def customTextBrowserContextMenu(self, pos):
Expand Down Expand Up @@ -727,6 +733,7 @@ def readSettings(self):
default = self.app.DEFAULTS
self.preferences = {
'parseLinks': self.config.boolValue("parseLinks", default['parseLinks']),
'rawViewDefault': self.config.boolValue("rawViewDefault", default['rawViewDefault']),
'newTab': self.config.boolValue("newTab", default['newTab']),
'syntaxHighlighting': self.config.boolValue("syntaxHighlighting", default['syntaxHighlighting']),
'teletype': self.config.boolValue("teletype", default['teletype']),
Expand Down Expand Up @@ -809,6 +816,7 @@ def writeSettings(self):
"""
logger.debug("Writing user settings to %s", self.config.fileName())
self.config.setValue("parseLinks", self.preferences['parseLinks'])
self.config.setValue("rawViewDefault", self.preferences['rawViewDefault'])
self.config.setValue("newTab", self.preferences['newTab'])
self.config.setValue("syntaxHighlighting", self.preferences['syntaxHighlighting'])
self.config.setValue("teletype", self.preferences['teletype'])
Expand Down Expand Up @@ -907,6 +915,7 @@ def connectSignals(self):
# Edit Menu
self.actionEdit.triggered.connect(self.toggleEdit)
self.actionBrowse.triggered.connect(self.toggleEdit)
self.actionRawView.triggered.connect(self.toggleRawView)
self.actionUndo.triggered.connect(self.undo)
self.actionRedo.triggered.connect(self.redo)
self.actionCut.triggered.connect(self.cut)
Expand Down Expand Up @@ -1681,6 +1690,8 @@ def toggleEdit(self, checked=False, tab=None):
vScrollPos = tab.textBrowser.verticalScrollBar().value()
tab.textBrowser.setVisible(False)
tab.textEditor.setVisible(True)
tab.textEditor.setReadOnly(False)

tab.textEditor.setFocus()
tab.textEditor.horizontalScrollBar().setValue(hScrollPos)
tab.textEditor.verticalScrollBar().setValue(vScrollPos)
Expand All @@ -1694,11 +1705,20 @@ def toggleEdit(self, checked=False, tab=None):
# be safe, but this can be slow.
refreshed = self.refreshTab(tab=tab)

tab.textEditor.setVisible(False)
tab.textBrowser.setVisible(True)
tab.textBrowser.setFocus()
tab.textBrowser.horizontalScrollBar().setValue(hScrollPos)
tab.textBrowser.verticalScrollBar().setValue(vScrollPos)
if tab.inRawView:
tab.textEditor.setVisible(True)
tab.textBrowser.setVisible(False)
tab.textEditor.setReadOnly(True)
tab.textEditor.setFocus()
tab.textEditor.horizontalScrollBar().setValue(hScrollPos)
tab.textEditor.verticalScrollBar().setValue(vScrollPos)
else:
tab.textEditor.setVisible(False)
tab.textBrowser.setVisible(True)

tab.textBrowser.setFocus()
tab.textBrowser.horizontalScrollBar().setValue(hScrollPos)
tab.textBrowser.verticalScrollBar().setValue(vScrollPos)

# Don't double-up the below commands if we already refreshed the tab.
if not refreshed:
Expand All @@ -1712,6 +1732,51 @@ def toggleEdit(self, checked=False, tab=None):
self.editModeChanged.emit(tab.inEditMode)
return True

@Slot()
def toggleRawView(self, checked=False, tab=None):
""" Switch between normal Browse mode and Raw View mode.

:Parameters:
checked : `bool`
Unused. For signal/slot only
tab : `BrowserTab`
Tab to toggle raw view mode on
:Returns:
True if we switched modes; otherwise, False.
:Rtype:
`bool`
"""
tab = tab or self.currTab
if not tab:
return False

if tab.inEditMode:
return False

tab.inRawView = not tab.inRawView

enableHighlighting = self.preferences['syntaxHighlighting'] and not tab.inRawView
if tab.highlighter:
tab.highlighter.master.setSyntaxHighlighting(enableHighlighting)

self.refreshTab(tab=tab)

if not tab.inEditMode:
if tab.inRawView:
tab.textBrowser.setVisible(False)
tab.textEditor.setVisible(True)
tab.textEditor.setReadOnly(True)
tab.textEditor.setFocus()
else:
tab.textEditor.setVisible(False)
tab.textBrowser.setVisible(True)
tab.textBrowser.setFocus()

if tab == self.currTab:
self.updateEditButtons()

return True

@Slot()
def undo(self):
""" Undo last change in the current text editor.
Expand Down Expand Up @@ -2196,6 +2261,7 @@ def editPreferences(self):
self.preferences['newTab'] = dlg.getPrefNewTab()
self.preferences['lineNumbers'] = dlg.getPrefLineNumbers()
self.preferences['showAllMessages'] = dlg.getPrefShowAllMessages()
self.preferences['rawViewDefault'] = dlg.getPrefRawViewDefault()
self.preferences['showHiddenFiles'] = dlg.getPrefShowHiddenFiles()
self.preferences['autoCompleteAddressBar'] = dlg.getPrefAutoCompleteAddressBar()
self.preferences['textEditor'] = dlg.getPrefTextEditor()
Expand Down Expand Up @@ -3054,17 +3120,33 @@ def setSource(self, link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos
# Stop Loading Tab stops the expensive parsing of the file
# for links, checking if the links actually exist, etc.
# Setting it to this bypasses link parsing if the tab is in edit mode.
parser.stop(tab.inEditMode or not self.preferences['parseLinks'])
shouldStop = tab.inEditMode or tab.inRawView or not self.preferences['parseLinks']
parser.stop(shouldStop)
self.actionStop.setEnabled(True)

parser.parse(nativeAbsPath, fileInfo, link)
tab.fileFormat = parser.fileFormat
self.tabWidget.setTabIcon(idx, parser.icon)
self.setHighlighter(ext, tab=tab)
logger.debug("Setting HTML")
tab.textBrowser.setHtml(parser.html)
logger.debug("Setting plain text")
tab.textEditor.setPlainText("".join(parser.text))

if tab.inEditMode:
# Edit mode: textEditor visible, textBrowser hidden
logger.debug("Setting plain text (Edit Mode)")
tab.textEditor.setPlainText("".join(parser.text))
tab.textEditor.setReadOnly(False) # Enable editing
elif tab.inRawView:
# Raw View mode: Use textEditor for fast plain text display
logger.debug("Setting plain text (Raw View Mode)")
tab.textEditor.setVisible(True)
tab.textBrowser.setVisible(False)
tab.textEditor.setPlainText("".join(parser.text))
tab.textEditor.setReadOnly(True)
else:
# Normal View mode: textBrowser visible for HTML display
logger.debug("Setting HTML (Normal View Mode)")
tab.textBrowser.setVisible(True)
tab.textEditor.setVisible(False)
tab.textBrowser.setHtml(parser.html)
truncated = parser.truncated
warning = parser.warning
parser.cleanup()
Expand All @@ -3085,8 +3167,19 @@ def setSource(self, link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos
else:
# Load an empty tab pointing to the nonexistent file.
self.setHighlighter(ext, tab=tab)
tab.textBrowser.setHtml("")
tab.textEditor.setPlainText("")

if tab.inEditMode:
tab.textEditor.setPlainText("")
tab.textEditor.setReadOnly(False)
elif tab.inRawView:
tab.textEditor.setVisible(True)
tab.textBrowser.setVisible(False)
tab.textEditor.setPlainText("")
tab.textEditor.setReadOnly(True)
else:
tab.textBrowser.setVisible(True)
tab.textEditor.setVisible(False)
tab.textBrowser.setHtml("")
truncated = False
warning = None

Expand Down Expand Up @@ -3408,6 +3501,8 @@ def updateEditButtons(self):
self.actionUncomment.setEnabled(True)
self.actionIndent.setEnabled(True)
self.actionUnindent.setEnabled(True)
self.actionRawView.setEnabled(False)
self.actionRawView.setText("Raw View")
else:
self.actionEdit.setVisible(True)
self.actionBrowse.setVisible(False)
Expand All @@ -3422,6 +3517,8 @@ def updateEditButtons(self):
self.actionUncomment.setEnabled(False)
self.actionIndent.setEnabled(False)
self.actionUnindent.setEnabled(False)
self.actionRawView.setEnabled(True)
self.actionRawView.setText("Raw View" if not self.currTab.inRawView else "Disable Raw View")

@Slot(str)
def validateAddressBar(self, address):
Expand Down Expand Up @@ -4343,6 +4440,7 @@ def __init__(self, parent=None):
color = self.style().standardPalette().base().color().darker(105).name()
self.setStyleSheet("QTextBrowser{{background-color:{}}}".format(color))
self.inEditMode = False
self.inRawView = parent.window().preferences.get('rawViewDefault', False) if parent else False
self.isActive = True # Track if this tab is open or has been closed.
self.isNewTab = True # Track if this tab has been used for any files yet.
self.setAcceptDrops(True)
Expand Down Expand Up @@ -4857,6 +4955,7 @@ def run(self):
'lineNumbers': True,
'newTab': False,
'parseLinks': True,
'rawViewDefault': False,
'showAllMessages': True,
'showHiddenFiles': False,
'syntaxHighlighting': True,
Expand Down
Loading