From ed5bc0b2b9b92a506d4eb2144e349075caf3a8c0 Mon Sep 17 00:00:00 2001 From: BasioMeusPuga Date: Fri, 6 Jul 2018 09:01:40 -0400 Subject: [PATCH] Shift to tree view for bookmarks Cleanup --- TODO | 8 ++- lector/delegates.py | 28 --------- lector/readers/read_fb2.py | 11 ++-- lector/sorter.py | 2 +- lector/widgets.py | 122 +++++++++++++++++++++++-------------- 5 files changed, 89 insertions(+), 82 deletions(-) diff --git a/TODO b/TODO index 9dfd4cb..b196220 100644 --- a/TODO +++ b/TODO @@ -78,7 +78,8 @@ TODO Limit the extra files produced by KindleUnpack Have them save to memory ✓ fb2 support - Images need to show up in their placeholders + ✓ Images need to show up in their placeholders + djvu support Other: ✓ Define every widget in code Bugs: @@ -86,6 +87,9 @@ TODO Clean up 'switch' page layout Colors aren't loaded properly for annotation previews Cover page shouldn't be scolled midway + Docks + Fullscreening should keep dock visible + Closing a book keeps dock show button clicked Secondary: Graphical themes @@ -99,7 +103,7 @@ TODO Use embedded fonts + CSS Scrolling: Smooth / By Line Shift to logging instead of print statements - txt, doc, chm, djvu support + txt, doc, chm support Include icons for filetype emblems Comic view modes Continuous paging diff --git a/lector/delegates.py b/lector/delegates.py index b649aeb..c2dc7d6 100644 --- a/lector/delegates.py +++ b/lector/delegates.py @@ -66,31 +66,3 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate): x_draw = option.rect.bottomRight().x() - 30 y_draw = option.rect.bottomRight().y() - 35 painter.drawPixmap(x_draw, y_draw, read_icon) - - -class BookmarkDelegate(QtWidgets.QStyledItemDelegate): - def __init__(self, main_window, parent=None): - super(BookmarkDelegate, self).__init__() - self.main_window = main_window - self.parent = parent - - def sizeHint(self, *args): - dockwidget_width = self.parent.width() - 20 - return QtCore.QSize(dockwidget_width, 50) - - def paint(self, painter, option, index): - # TODO - # Alignment of the painted item - - option = option.__class__(option) - - chapter_index = index.data(QtCore.Qt.UserRole) - chapter_name = self.main_window.bookToolBar.tocBox.itemText(chapter_index - 1) - if len(chapter_name) > 25: - chapter_name = chapter_name[:25] + '...' - - QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) - painter.drawText( - option.rect, - QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight | QtCore.Qt.TextWordWrap, - ' ' + chapter_name) diff --git a/lector/readers/read_fb2.py b/lector/readers/read_fb2.py index aa6d1a8..b08868a 100644 --- a/lector/readers/read_fb2.py +++ b/lector/readers/read_fb2.py @@ -31,7 +31,8 @@ class FB2: def read_fb2(self): try: if self.filename.endswith('.fb2.zip'): - this_book = zipfile.ZipFile(self.filename, mode='r', allowZip64=True) + this_book = zipfile.ZipFile( + self.filename, mode='r', allowZip64=True) for i in this_book.filelist: if os.path.splitext(i.filename)[1] == '.fb2': book_text = this_book.read(i.filename) @@ -42,7 +43,7 @@ class FB2: self.xml = BeautifulSoup(book_text, 'lxml') self.generate_book_metadata() - except ValueError: # Not specifying an exception type here may be justified + except: # Not specifying an exception type here may be justified return False return True @@ -60,7 +61,8 @@ class FB2: self.book['title'] = os.path.splitext( os.path.basename(self.filename))[0] - self.book['author'] = all_tags.find('author').getText(separator=' ').replace('\n', ' ') + self.book['author'] = all_tags.find( + 'author').getText(separator=' ').replace('\n', ' ') if self.book['author'] == '' or self.book['author'] is None: self.book['author'] = 'Unknown' @@ -104,7 +106,8 @@ class FB2: replacement_string = f'