Small fixes

This commit is contained in:
BasioMeusPuga
2019-02-02 00:53:09 +05:30
parent dfe0fceea9
commit d1662b47d9
4 changed files with 16 additions and 10 deletions

View File

@@ -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():

View File

@@ -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 = '<No 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'):

View File

@@ -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: