From d1662b47d98bfa94fb87294d91b8a39934eb17e3 Mon Sep 17 00:00:00 2001 From: BasioMeusPuga Date: Sat, 2 Feb 2019 00:53:09 +0530 Subject: [PATCH] Small fixes --- TODO | 2 ++ lector/contentwidgets.py | 4 ++++ lector/readers/read_fb2.py | 8 +++++--- lector/widgets.py | 12 +++++------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 8ac10c4..cff7690 100644 --- a/TODO +++ b/TODO @@ -92,8 +92,10 @@ TODO Deselecting all directories in the settings dialog also filters out manually added books Last line in QTextBrowser should never be cut off Does image alignment need to be centered? + Bookmark name for a page that's not on the TOC or has nothing before Secondary: + The cover page needs to be marked separately Graphical themes Change focus rectangle dimensions Universal Ctrl + Tab diff --git a/lector/contentwidgets.py b/lector/contentwidgets.py index 65f6a18..f88e675 100644 --- a/lector/contentwidgets.py +++ b/lector/contentwidgets.py @@ -719,6 +719,10 @@ class PliantWidgetsCommonFunctions: current_tab = self.pw.parent current_position = current_tab.metadata['position']['current_chapter'] + # Prevent scrolling below page 1 + if current_position == 1 and direction == -1: + return + # Special cases for double page view # Page limits are taken care of by the set_content method def get_modifier(): diff --git a/lector/readers/read_fb2.py b/lector/readers/read_fb2.py index a75d052..8d26cb9 100644 --- a/lector/readers/read_fb2.py +++ b/lector/readers/read_fb2.py @@ -92,16 +92,18 @@ class FB2: self.book['cover'] = None def parse_chapters(self, temp_dir): - # There's no need to parse the TOC separately because - # everything is linear for i in self.xml.find_all('section'): this_title = '' for j in i: if j.name == 'title': this_title = j.getText(separator=' ') + this_title = this_title.replace('\n', '').strip() + # This comes later because the tag is changed in place + title_xml = j.unwrap() + break self.book['book_list'].append( - [this_title, str(i)]) + [this_title, str(title_xml) + str(i)]) # Extract all images to the temp_dir for i in self.xml.find_all('binary'): diff --git a/lector/widgets.py b/lector/widgets.py index 13c63f0..b7746df 100644 --- a/lector/widgets.py +++ b/lector/widgets.py @@ -423,11 +423,6 @@ class Tab(QtWidgets.QWidget): # This function will decide how to relate # entries in the toc to the actual content - # Do not allow cycling below page 1 - # Required position goes to -1 in double page view - if required_position <= 0: - return - # Set the required page to the corresponding index # For images this is simply a page number # For text based books, this is the entire text of the chapter @@ -526,8 +521,11 @@ class Tab(QtWidgets.QWidget): 'center': QtCore.Qt.AlignCenter, 'justify': QtCore.Qt.AlignJustify} - current_index = self.main_window.bookToolBar.tocBox.currentIndex() - if current_index == 0: + # Adjusted for books without covers + current_position = self.metadata['position']['current_chapter'] + chapter_name = self.metadata['toc'][current_position - 1][1] + + if current_position == 1 and chapter_name == 'Cover': block_format.setAlignment( QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter) else: