Skip to content

Commit

Permalink
Logging improvements to address one note in issue #17
Browse files Browse the repository at this point in the history
Add missing icon for closing the find search bar on Mac and Windows
General maintenance

Signed-off-by: mds-dwa <[email protected]>
  • Loading branch information
mds-dwa committed Apr 6, 2020
1 parent 1e5d5bc commit 6d3e2ca
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
35 changes: 18 additions & 17 deletions usdmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
# Set up logging.
logger = logging.getLogger(__name__)
logging.basicConfig()
logger.setLevel(logging.WARNING)


# Qt.py compatibility: HACK for missing QUrl.path in PySide2 build.
Expand Down Expand Up @@ -141,11 +142,14 @@ class UsdMngrWindow(QtWidgets.QMainWindow):
- Mac could use more testing and work with icons and theme.
- Remember scroll position per file so going back in history jumps you to approximately where you were before.
- Add Browse... buttons to select default applications.
- Set consistent cross-platform read/write/execute permissions when saving new files
Known issues:
- AddressBar file completer has problems occasionally.
- Figure out why network printers aren't showing up. Linux or DWA issue? macOS and Windows are fine.
- Save As... doesn't add file to recent files or history menus.
- Qt.py problems:
- PyQt5
Expand Down Expand Up @@ -291,7 +295,11 @@ def setupUi(self):
self.exitAction.setIcon(ft("application-exit"))
self.documentationAction.setIcon(ft("help-browser"))
self.aboutAction.setIcon(ft("help-about"))
self.buttonCloseFind.setIcon(ft("window-close")) # TODO: Need mac icon
icon = ft("window-close")
if icon.isNull():
self.buttonCloseFind.setText("x")
else:
self.buttonCloseFind.setIcon(ft("window-close"))

# Try for standard name, then fall back to crystal_project name.
self.actionBrowse.setIcon(ft("applications-internet", ft("Globe")))
Expand Down Expand Up @@ -2769,7 +2777,7 @@ def setSource(self, link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos
# Read in the file.
usd = False
try:
if self.validateFileSize(fileStr):
if self.validateFileSize(fileInfo):
if utils.queryItemBoolValue(link, "binary") or ext == "usdc":
# Treat this file as a binary USD crate file. Don't bother
# checking the first line. If this is a valid ASCII USD
Expand Down Expand Up @@ -3043,18 +3051,18 @@ def setSources(self, files):
for path in files:
self.setSource(utils.expandUrl(path, prevPath), newTab=True)

def validateFileSize(self, path):
def validateFileSize(self, info):
""" If a file's size is above a certain threshold, confirm the user still wants to open the file.
:Parameters:
path : `str`
File path
info : `QtCore.QFileInfo`
File info object
:Returns:
If we should open the file or not
:Rtype:
`bool`
"""
size = QtCore.QFileInfo(path).size()
size = info.size()
if size >= 104857600: # 100 MB
self.restoreOverrideCursor()
try:
Expand Down Expand Up @@ -3126,9 +3134,9 @@ def goPressed(self, *args):
""" Handle loading the current path in the address bar.
"""
# Check if text has changed.
text = utils.expandUrl(self.addressBar.text().strip())
if text != self.currTab.getCurrentUrl():
self.setSource(text)
url = utils.expandUrl(self.addressBar.text().strip())
if url != self.currTab.getCurrentUrl():
self.setSource(url)
else:
self.refreshTab()

Expand Down Expand Up @@ -3786,7 +3794,6 @@ def __init__(self, parent=None):
self.tabBar = TabBar(self)
self.tabBar.tabMoveRequested.connect(self.moveTab)
self.setTabBar(self.tabBar)
QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Tab"), self, self.nextTab)

@Slot(int, int)
def moveTab(self, fromIndex, toIndex):
Expand All @@ -3805,12 +3812,6 @@ def moveTab(self, fromIndex, toIndex):
self.insertTab(toIndex, widget, icon, text)
self.setCurrentIndex(toIndex)

def nextTab(self):
""" Switch to the next tab. If on the last tab, go back to the first.
"""
i = self.currentIndex() + 1
self.setCurrentIndex(0 if i == self.count() else i)

def setTabIcon(self, index, icon):
""" Override the default method to set the same icon on our custom action that focuses on or re-opens the
widget at the given index.
Expand Down Expand Up @@ -4585,7 +4586,6 @@ def _set_log_level(self):
Call this after each component in the case of misbehaving libraries.
"""
logger.setLevel(logging.WARNING)
if self.opts['info']:
logger.setLevel(logging.INFO)
if self.opts['debug']:
Expand Down Expand Up @@ -4650,6 +4650,7 @@ def onExit(self):
"""
App._eventLoopStarted = False
self.cleanup()
logging.shutdown()


class Settings(QtCore.QSettings):
Expand Down
9 changes: 5 additions & 4 deletions usdmanager/file_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ def __init__(self, url=None, update=True, truncated=False):
If the file was truncated on read, and therefore should never be edited.
"""
self.url = url if url else QUrl()
self.path = url.path() if url else ""
self.path = "" if self.url.isEmpty() else self.url.path()
self.status = self.FILE_NEW
self.fileInfo = None
if update:
self.updateFileStatus(truncated)
else:
self.fileInfo = None

def updateFileStatus(self, truncated=False):
""" Cache the status of a file.
Expand All @@ -60,7 +59,9 @@ def updateFileStatus(self, truncated=False):
If the file was truncated on read, and therefore should never be edited.
"""
if self.path:
self.fileInfo = QFileInfo(self.path)
if self.fileInfo is None:
self.fileInfo = QFileInfo(self.path)
self.fileInfo.setCaching(False)
if truncated:
self.status = self.FILE_TRUNCATED
elif self.fileInfo.isWritable():
Expand Down
2 changes: 1 addition & 1 deletion usdmanager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def unzip(path, tmpDir=None):
tmpDir : `str` | None
Temp directory to create the new unzipped directory within
:Returns:
Destination directory for unzipped usdz
Absolute path to destination directory for unzipped usdz
:Rtype:
`str`
:Raises zipfile.BadZipfile:
Expand Down
2 changes: 1 addition & 1 deletion usdmanager/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = '0.9.0'
__version__ = '0.10.0'

0 comments on commit 6d3e2ca

Please sign in to comment.