diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index ff1a53de96..5011227a73 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -531,3 +531,18 @@ numeric_collation = False # number here. The default is ten libraries. many_libraries = 10 +#: Use rectangular (non-square) images for icons for columns +# When using column icons, the images are normally displayed as square icons in +# a small box. If necessary, the images are scaled to fit into that box to +# ensure that all the images are the same size. In some cases you might not want +# this behavior, instead wanting the image to be shown as rectangles with their +# orignal aspect ratio. Enter the lookup names of columns where you want this +# behavior. Note that calibre will scale the image so that it is maximum 128 +# pixels wide and that it fits within the height of the displaying row. For this +# reason you should be sure that the images are oriented in landscape, not +# portrait. +# Examples: +# use_rectangular_images_for_icons_for_columns = ['#enum2', '#myrating'] +# use_rectangular_images_for_icons_for_columns = [] +use_rectangular_images_for_icons_for_columns = [''] + diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 3fed536603..b348b724b9 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -9,7 +9,7 @@ import functools, re, os, traceback, errno, time from collections import defaultdict from PyQt4.Qt import (QAbstractTableModel, Qt, pyqtSignal, QIcon, QImage, - QModelIndex, QVariant, QDateTime, QColor) + QModelIndex, QVariant, QDateTime, QColor, QPixmap) from calibre.gui2 import NONE, UNDEFINED_QDATETIME, error_dialog from calibre.utils.pyparsing import ParseException @@ -94,7 +94,10 @@ class ColumnIcon(object): return icon_bitmap d = os.path.join(config_dir, 'cc_icons', icon) if (os.path.exists(d)): - icon_bitmap = QIcon(d) + if key in tweaks['use_rectangular_images_for_icons_for_columns']: + icon_bitmap = QPixmap(d) + else: + icon_bitmap = QIcon(d) icon_cache[id_][dex] = icon_bitmap icon_bitmap_cache[icon] = icon_bitmap self.mi = None