diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-01-03 18:32:15 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-01-03 18:32:15 +0100 |
commit | b71beaf0d22f182ab0b95b1b35da7e786585c4e7 (patch) | |
tree | 1e95d573c09bee1dec63d909cc59ef57222a7710 /raphodo/thumbnaildisplay.py | |
parent | deb736d38beac3863c04d4c0f285c28557fe07c6 (diff) | |
parent | 8351a36cbcbe8529ec1c0bb60d77bf65fb59fe12 (diff) |
Update upstream source from tag 'upstream/0.9.7'
Update to upstream version '0.9.7'
with Debian dir 9c39d3b734403d3ae14a7bfdb1f76e371acb4e78
Diffstat (limited to 'raphodo/thumbnaildisplay.py')
-rw-r--r-- | raphodo/thumbnaildisplay.py | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/raphodo/thumbnaildisplay.py b/raphodo/thumbnaildisplay.py index cde71f8..e7a3f9b 100644 --- a/raphodo/thumbnaildisplay.py +++ b/raphodo/thumbnaildisplay.py @@ -59,7 +59,9 @@ from raphodo.constants import ( Desktop, DeviceState, extensionColor, FadeSteps, FadeMilliseconds, PaleGray, DarkGray, DoubleDarkGray, Plural, manually_marked_previously_downloaded, thumbnail_margin ) -from raphodo.storage import get_program_cache_directory, get_desktop, validate_download_folder +from raphodo.storage import ( + get_program_cache_directory, get_desktop, validate_download_folder, open_in_file_manager +) from raphodo.utilities import ( CacheDirs, make_internationalized_list, format_size_for_user, runs, arrow_locale ) @@ -1715,9 +1717,13 @@ class ThumbnailView(QListView): return else: uid = uids[0] - row = model.uid_to_row[uid] - index = model.index(row, 0) - self.scrollTo(index, QAbstractItemView.PositionAtTop) + try: + row = model.uid_to_row[uid] + except KeyError: + logging.debug("Ignoring scroll request to unknown thumbnail") + else: + index = model.index(row, 0) + self.scrollTo(index, QAbstractItemView.PositionAtTop) class ThumbnailDelegate(QStyledItemDelegate): @@ -1766,7 +1772,7 @@ class ThumbnailDelegate(QStyledItemDelegate): self.contextMenu = QMenu() self.openInFileBrowserAct = self.contextMenu.addAction(_('Open in File Browser...')) - self.openInFileBrowserAct.triggered.connect(self.doOpenInFileBrowserAct) + self.openInFileBrowserAct.triggered.connect(self.doOpenInFileManagerAct) self.copyPathAct = self.contextMenu.addAction(_('Copy Path')) self.copyPathAct.triggered.connect(self.doCopyPathAction) # Translators: 'File' here applies to a single file. The command allows users to instruct @@ -1844,14 +1850,15 @@ class ThumbnailDelegate(QStyledItemDelegate): QApplication.clipboard().setText(path) @pyqtSlot() - def doOpenInFileBrowserAct(self) -> None: + def doOpenInFileManagerAct(self) -> None: index = self.clickedIndex if index: uri = index.model().data(index, Roles.uri) - cmd = '{} "{}"'.format(self.rapidApp.file_manager, uri) - logging.debug("Launching: %s", cmd) - args = shlex.split(cmd) - subprocess.Popen(args) + open_in_file_manager( + file_manager=self.rapidApp.file_manager, + file_manager_type=self.rapidApp.file_manager_type, + uri=uri + ) @pyqtSlot() def doMarkFileDownloadedAct(self) -> None: @@ -2072,12 +2079,15 @@ class ThumbnailDelegate(QStyledItemDelegate): def oneOrMoreNotDownloaded(self) -> Tuple[int, Plural]: i = 0 selectedIndexes = self.selectedIndexes() - noSelected = len(selectedIndexes) - for index in selectedIndexes: - if not index.data(Roles.previously_downloaded): - i += 1 - if i == 2: - break + if selectedIndexes is None: + noSelected = 0 + else: + noSelected = len(selectedIndexes) + for index in selectedIndexes: + if not index.data(Roles.previously_downloaded): + i += 1 + if i == 2: + break if i == 0: return noSelected, Plural.zero @@ -2208,7 +2218,7 @@ class ThumbnailDelegate(QStyledItemDelegate): else: logging.debug("Not applying job code because no files selected") - def selectedIndexes(self): + def selectedIndexes(self) -> Optional[List[QModelIndex]]: selection = self.rapidApp.thumbnailView.selectionModel() # type: QItemSelectionModel if selection.hasSelection(): selected = selection.selection() # type: QItemSelection |