Skip to content

Commit

Permalink
Use a single list of image file types
Browse files Browse the repository at this point in the history
This ensures consistency between the importer and normal image loading.
See issue #15.
  • Loading branch information
jim-easterbrook committed Sep 22, 2015
1 parent 4ecc775 commit 2f69ef7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/photini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from __future__ import unicode_literals

__version__ = '15.09.1.dev340'
_dev_no = '340'
_commit = 'b0a4571'
__version__ = '15.09.1.dev341'
_dev_no = '341'
_commit = '4ecc775'
13 changes: 2 additions & 11 deletions src/photini/imagelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .flowlayout import FlowLayout
from .metadata import Metadata, MetadataHandler
from .pyqt import Qt, QtCore, QtGui, QtWidgets
from .utils import Busy
from .utils import Busy, image_types

DRAG_MIMETYPE = 'application/x-photini-image'

Expand Down Expand Up @@ -301,16 +301,7 @@ def mousePressEvent(self, event):

@QtCore.pyqtSlot()
def open_files(self):
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 types:
types.append(ext)
types = map(lambda x: '*.' + x, types)
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)))
Expand Down
11 changes: 3 additions & 8 deletions src/photini/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@

from .configstore import ConfigStore
from .metadata import Metadata
from .pyqt import Qt, QtCore, QtGui, QtWidgets
from .utils import Busy
from .pyqt import Qt, QtCore, QtWidgets
from .utils import Busy, image_types

class FolderSource(object):
def __init__(self, root):
self.root = root
self.image_types = QtGui.QImageReader.supportedImageFormats()
self.image_types = [x.data().decode('utf-8') for x in self.image_types]
self.image_types = ['.' + x.lower() for x in self.image_types]
for ext in ('.ico', '.xcf'):
while ext in self.image_types:
self.image_types.remove(ext)
self.image_types = ['.' + x for x in image_types]

def list_files(self):
result = []
Expand Down
15 changes: 14 additions & 1 deletion src/photini/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,26 @@

import os

from .pyqt import Qt, QtWidgets
from .pyqt import Qt, QtGui, QtWidgets

data_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', '')

multiple = QtWidgets.QApplication.translate('utils', '<multiple>')
multiple_values = QtWidgets.QApplication.translate('utils', '<multiple values>')

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)

class Busy(object):
def __enter__(self):
QtWidgets.QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down

0 comments on commit 2f69ef7

Please sign in to comment.