Cover shadows

This commit is contained in:
BasioMeusPuga
2017-11-25 04:02:53 +05:30
parent 5fc5f98636
commit 70549e8c53
6 changed files with 42 additions and 13 deletions

View File

@@ -216,7 +216,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
return return
# The hackiness of this hack is just... # The hackiness of this hack is just...
default_size = 175 # This is size of the QIcon (160 by default) + default_size = 170 # This is size of the QIcon (160 by default) +
# minimum margin is needed between thumbnails # minimum margin is needed between thumbnails
# for n icons, the n + 1th icon will appear at > n +1.11875 # for n icons, the n + 1th icon will appear at > n +1.11875

View File

@@ -104,7 +104,7 @@ class Library:
img_pixmap.loadFromData(cover) img_pixmap.loadFromData(cover)
else: else:
img_pixmap.load(':/images/NotFound.png') img_pixmap.load(':/images/NotFound.png')
img_pixmap = img_pixmap.scaled(420, 600, QtCore.Qt.IgnoreAspectRatio) img_pixmap = img_pixmap.scaled(420, 600, QtCore.Qt.IgnoreAspectRatio)
item = QtGui.QStandardItem() item = QtGui.QStandardItem()
item.setToolTip(tooltip_string) item.setToolTip(tooltip_string)
# The following order is needed to keep sorting working # The following order is needed to keep sorting working

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -1,5 +1,6 @@
<RCC> <RCC>
<qresource prefix="images"> <qresource prefix="images">
<file>gray-shadow.png</file>
<file>NotFound.png</file> <file>NotFound.png</file>
<file>checkmark.svg</file> <file>checkmark.svg</file>
<file>error.svg</file> <file>error.svg</file>

View File

@@ -1117,6 +1117,19 @@ qt_resource_data = b"\
\x00\x00\xd2\x04\x2f\x00\x00\x69\x82\x17\x00\x80\xb4\x2f\xb6\xe1\ \x00\x00\xd2\x04\x2f\x00\x00\x69\x82\x17\x00\x80\xb4\x2f\xb6\xe1\
\xd6\x4d\xdd\x20\x9a\xae\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\ \xd6\x4d\xdd\x20\x9a\xae\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\
\x60\x82\ \x60\x82\
\x00\x00\x00\xa3\
\x00\
\x00\x09\x38\x78\x9c\xeb\x0c\xf0\x73\xe7\xe5\x92\xe2\x62\x60\x60\
\xe0\xf5\xf4\x70\x09\x62\x60\x60\x5c\xc2\xc0\xc0\x14\xc1\xc1\x06\
\x14\xd1\xfd\x32\xe9\x14\x90\xe2\x2c\xf0\x88\x2c\x66\x60\x10\x2a\
\x01\x61\xc6\x7b\x69\xf2\x15\x0c\x0c\x1c\xaf\x3c\x5d\x1c\x43\x2a\
\xe6\xbc\xbd\x6a\xc8\x78\xc0\x80\xe7\xc0\x86\x35\x12\x87\xe7\x9f\
\xe2\x5a\x6c\xa7\xc2\xf2\xef\xcf\xdb\x77\xf6\x0c\x1f\x6e\x54\xca\
\x32\x30\x18\xb7\xb1\x38\xb4\x28\x32\x4e\x48\xf0\x60\x50\x91\x10\
\x62\xe0\x04\x72\x9b\x46\xb9\xa3\xdc\x51\xee\x28\x77\x94\x3b\xca\
\x1d\xe5\x8e\x72\x07\x39\xb7\x80\x91\xc5\x87\x6d\xf5\xcd\x67\x8b\
\x6a\x80\x4d\x21\x06\x4f\x57\x3f\x97\x75\x4e\x09\x4d\x00\xf2\xfe\
\xe3\x9e\
\x00\x00\x01\x55\ \x00\x00\x01\x55\
\x3c\ \x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\ \x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
@@ -1182,6 +1195,10 @@ qt_resource_name = b"\
\x02\xea\x4d\x87\ \x02\xea\x4d\x87\
\x00\x4e\ \x00\x4e\
\x00\x6f\x00\x74\x00\x46\x00\x6f\x00\x75\x00\x6e\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\ \x00\x6f\x00\x74\x00\x46\x00\x6f\x00\x75\x00\x6e\x00\x64\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x0a\xe2\xd1\x87\
\x00\x67\
\x00\x72\x00\x61\x00\x79\x00\x2d\x00\x73\x00\x68\x00\x61\x00\x64\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0d\ \x00\x0d\
\x0b\x5d\x1f\x07\ \x0b\x5d\x1f\x07\
\x00\x63\ \x00\x63\
@@ -1194,22 +1211,25 @@ qt_resource_name = b"\
qt_resource_struct_v1 = b"\ qt_resource_struct_v1 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x02\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ \x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x00\x50\x00\x00\x00\x00\x00\x01\x00\x00\x46\x70\ \x00\x00\x00\x74\x00\x00\x00\x00\x00\x01\x00\x00\x47\x17\
\x00\x00\x00\x30\x00\x00\x00\x00\x00\x01\x00\x00\x45\x17\ \x00\x00\x00\x30\x00\x01\x00\x00\x00\x01\x00\x00\x45\x17\
\x00\x00\x00\x54\x00\x00\x00\x00\x00\x01\x00\x00\x45\xbe\
" "
qt_resource_struct_v2 = b"\ qt_resource_struct_v2 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x02\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ \x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x5f\xb9\x9f\xcd\x26\ \x00\x00\x01\x5f\xb9\x9f\xcd\x26\
\x00\x00\x00\x50\x00\x00\x00\x00\x00\x01\x00\x00\x46\x70\ \x00\x00\x00\x74\x00\x00\x00\x00\x00\x01\x00\x00\x47\x17\
\x00\x00\x01\x5f\x7e\xcc\x7f\x20\ \x00\x00\x01\x5f\x7e\xcc\x7f\x20\
\x00\x00\x00\x30\x00\x00\x00\x00\x00\x01\x00\x00\x45\x17\ \x00\x00\x00\x30\x00\x01\x00\x00\x00\x01\x00\x00\x45\x17\
\x00\x00\x01\x5f\xf0\x1d\xc5\xb3\
\x00\x00\x00\x54\x00\x00\x00\x00\x00\x01\x00\x00\x45\xbe\
\x00\x00\x01\x5f\x7e\xcc\x7f\x20\ \x00\x00\x01\x5f\x7e\xcc\x7f\x20\
" "

View File

@@ -668,16 +668,28 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
# TODO # TODO
# Calculate progress on the basis of lines # Calculate progress on the basis of lines
# The shadow pixmap currently is set to 420 x 600
shadow_pixmap = QtGui.QPixmap()
shadow_pixmap.load(':/images/gray-shadow.png')
shadow_pixmap = shadow_pixmap.scaled(160, 230, QtCore.Qt.IgnoreAspectRatio)
shadow_x = option.rect.topLeft().x() + 10
shadow_y = option.rect.topLeft().y() - 5
if not file_exists: if not file_exists:
read_icon = QtGui.QIcon(':/images/error.svg').pixmap(36)
painter.setOpacity(.7) painter.setOpacity(.7)
painter.drawPixmap(shadow_x, shadow_y, shadow_pixmap)
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
painter.setOpacity(1) painter.setOpacity(1)
read_icon = QtGui.QIcon(':/images/error.svg').pixmap(36)
x_draw = option.rect.bottomRight().x() - 30 x_draw = option.rect.bottomRight().x() - 30
y_draw = option.rect.bottomRight().y() - 35 y_draw = option.rect.bottomRight().y() - 35
painter.drawPixmap(x_draw, y_draw, read_icon) painter.drawPixmap(x_draw, y_draw, read_icon)
return return
painter.setOpacity(.8)
painter.drawPixmap(shadow_x, shadow_y, shadow_pixmap)
painter.setOpacity(1)
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
if position: if position:
current_chapter = position['current_chapter'] current_chapter = position['current_chapter']
@@ -685,14 +697,10 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
progress_percent = int(current_chapter * 100 / total_chapters) progress_percent = int(current_chapter * 100 / total_chapters)
if current_chapter == total_chapters: if current_chapter == total_chapters:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
read_icon = QtGui.QIcon(':/images/checkmark.svg').pixmap(36) read_icon = QtGui.QIcon(':/images/checkmark.svg').pixmap(36)
elif current_chapter == 1:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
else: else:
# TODO # TODO
# See if saving the svg to disk can be avoided # See if saving the svg to disk can be avoided
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
pie_chart.GeneratePie(progress_percent, self.temp_dir).generate() pie_chart.GeneratePie(progress_percent, self.temp_dir).generate()
svg_path = os.path.join(self.temp_dir, 'lector_progress.svg') svg_path = os.path.join(self.temp_dir, 'lector_progress.svg')
read_icon = QtGui.QIcon(svg_path).pixmap(32) read_icon = QtGui.QIcon(svg_path).pixmap(32)