diff --git a/usdmanager/__init__.py b/usdmanager/__init__.py index 84e7d2a..9627b9d 100755 --- a/usdmanager/__init__.py +++ b/usdmanager/__init__.py @@ -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. @@ -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 @@ -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"))) @@ -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 @@ -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: @@ -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() @@ -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): @@ -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. @@ -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']: @@ -4650,6 +4650,7 @@ def onExit(self): """ App._eventLoopStarted = False self.cleanup() + logging.shutdown() class Settings(QtCore.QSettings): diff --git a/usdmanager/file_status.py b/usdmanager/file_status.py index 22ab33b..b3a7111 100644 --- a/usdmanager/file_status.py +++ b/usdmanager/file_status.py @@ -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. @@ -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(): diff --git a/usdmanager/utils.py b/usdmanager/utils.py index b09188d..db03830 100644 --- a/usdmanager/utils.py +++ b/usdmanager/utils.py @@ -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: diff --git a/usdmanager/version.py b/usdmanager/version.py index a0f658f..8ccdc0a 100644 --- a/usdmanager/version.py +++ b/usdmanager/version.py @@ -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'