diff --git a/src/photini/__init__.py b/src/photini/__init__.py index a812d96e..8a99449c 100644 --- a/src/photini/__init__.py +++ b/src/photini/__init__.py @@ -2,6 +2,6 @@ from __future__ import unicode_literals -__version__ = '15.10.0' -_dev_no = '364' -_commit = 'c0decf3' +__version__ = '15.10.0.dev365' +_dev_no = '365' +_commit = '8d74a6b' diff --git a/src/photini/imagelist.py b/src/photini/imagelist.py index 41c9f053..41f1275c 100644 --- a/src/photini/imagelist.py +++ b/src/photini/imagelist.py @@ -37,7 +37,7 @@ class Image(QtWidgets.QFrame): def __init__(self, path, image_list, thumb_size=80, parent=None): - QtWidgets.QFrame.__init__(self, parent) + super(Image, self).__init__(parent) self.path = path self.image_list = image_list self.name = os.path.splitext(os.path.basename(self.path))[0] @@ -193,7 +193,7 @@ def get_selected(self): class ScrollArea(QtWidgets.QScrollArea): dropped_images = QtCore.pyqtSignal(list) def __init__(self, parent=None): - QtWidgets.QScrollArea.__init__(self, parent) + super(ScrollArea, self).__init__(parent) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setWidgetResizable(True) self.setAcceptDrops(True) @@ -209,14 +209,17 @@ def dragEnterEvent(self, event): if event.mimeData().hasFormat('text/uri-list'): event.acceptProposedAction() + class ImageList(QtWidgets.QWidget): image_list_changed = QtCore.pyqtSignal() new_metadata = QtCore.pyqtSignal(bool) selection_changed = QtCore.pyqtSignal(list) sort_order_changed = QtCore.pyqtSignal() + def __init__(self, config_store, parent=None): - QtWidgets.QWidget.__init__(self, parent) + super(ImageList, self).__init__(parent) self.config_store = config_store + self.image_types = ['*.' + x for x in image_types()] self.app = QtWidgets.QApplication.instance() self.drag_icon = None self.path_list = list() @@ -301,10 +304,10 @@ def mousePressEvent(self, event): @QtCore.pyqtSlot() def open_files(self): - types = ['*.' + x for x in image_types] path_list = QtWidgets.QFileDialog.getOpenFileNames( self, "Open files", self.config_store.get('paths', 'images', ''), - self.tr("Images ({0});;All files (*)").format(' '.join(types))) + self.tr("Images ({0});;All files (*)").format( + ' '.join(self.image_types))) if QtCore.QT_VERSION_STR.split('.')[0] == '5': path_list = path_list[0] if not path_list: diff --git a/src/photini/importer.py b/src/photini/importer.py index df1e835b..d97b337c 100644 --- a/src/photini/importer.py +++ b/src/photini/importer.py @@ -39,7 +39,7 @@ class FolderSource(object): def __init__(self, root): self.root = root - self.image_types = ['.' + x for x in image_types] + self.image_types = ['.' + x for x in image_types()] def list_files(self): result = [] diff --git a/src/photini/utils.py b/src/photini/utils.py index 6a9e203b..3b8539c7 100644 --- a/src/photini/utils.py +++ b/src/photini/utils.py @@ -28,18 +28,26 @@ multiple = QtWidgets.QApplication.translate('utils', '') multiple_values = QtWidgets.QApplication.translate('utils', '') -image_types = [ - 'jpeg', 'jpg', 'exv', 'cr2', 'crw', 'mrw', 'tiff', 'tif', 'dng', - 'nef', 'pef', 'arw', 'rw2', 'sr2', 'srw', 'orf', 'png', 'pgf', - 'raf', 'eps', 'gif', 'psd', 'tga', 'bmp', 'jp2', 'pnm' - ] -for _fmt in QtGui.QImageReader.supportedImageFormats(): - _ext = _fmt.data().decode('utf_8').lower() - if _ext not in image_types: - image_types.append(_ext) -for _ext in ('ico', 'xcf'): - if _ext in image_types: - image_types.remove(_ext) +_image_types = None + +def image_types(): + global _image_types + if _image_types: + return _image_types + _image_types = [ + 'jpeg', 'jpg', 'exv', 'cr2', 'crw', 'mrw', 'tiff', 'tif', 'dng', + 'nef', 'pef', 'arw', 'rw2', 'sr2', 'srw', 'orf', 'png', 'pgf', + 'raf', 'eps', 'gif', 'psd', 'tga', 'bmp', 'jp2', 'pnm' + ] + for fmt in QtGui.QImageReader.supportedImageFormats(): + ext = fmt.data().decode('utf_8').lower() + if ext not in _image_types: + _image_types.append(ext) + for ext in ('ico', 'xcf'): + if ext in _image_types: + _image_types.remove(ext) + return _image_types + class Busy(object): def __enter__(self):