Implement save as for comic/pdf view

Account for malformed container.xml for epubs
This commit is contained in:
BasioMeusPuga
2018-03-19 01:11:55 +05:30
parent d4aaa4dc74
commit aca08827fb
3 changed files with 25 additions and 14 deletions

3
TODO
View File

@@ -55,7 +55,8 @@ TODO
✓ Set context menu for definitions and the like
✓ Paragraph indentation
✓ Comic view keyboard shortcuts
Comic view context menu
Comic view context menu
Adjust key navigation according to viewport dimensions
Search document using QTextCursor?
Filetypes:
✓ pdf support

View File

@@ -38,7 +38,7 @@ class EPUB:
None, True)
if not contents_path:
return False # No opf was found so processing cannot continue
return False # No (valid) opf was found so processing cannot continue
self.generate_book_metadata(contents_path)
self.parse_toc()
@@ -76,13 +76,17 @@ class EPUB:
if xml:
root_item = xml.find('rootfile')
return root_item.get('full-path')
else:
possible_filenames = ('content.opf', 'package.opf')
for i in possible_filenames:
presumptive_location = self.get_file_path(i)
if presumptive_location:
return presumptive_location
try:
return root_item.get('full-path')
except AttributeError:
print(f'ePub module: {self.filename} has a malformed container.xml')
return None
possible_filenames = ('content.opf', 'package.opf')
for i in possible_filenames:
presumptive_location = self.get_file_path(i)
if presumptive_location:
return presumptive_location
for i in self.zip_file.filelist:
if os.path.basename(i.filename) == os.path.basename(filename):

View File

@@ -656,8 +656,8 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
next_val = 0
self.verticalScrollBar().setValue(next_val)
small_increment = maximum // 5
big_increment = maximum // 3
small_increment = maximum // 4
big_increment = maximum // 2
if event.key() == QtCore.Qt.Key_Up:
scroller(small_increment, False)
@@ -711,9 +711,15 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
action = contextMenu.exec_(self.sender().mapToGlobal(position))
if action == saveAction:
# TODO
# Save this page as an image
pass
dialog_prompt = self._translate('Main_UI', 'Save page as...')
extension_string = self._translate('Main_UI', 'Images')
save_file = QtWidgets.QFileDialog.getSaveFileName(
self, dialog_prompt, self.main_window.settings['last_open_path'],
f'{extension_string} (*.png *.jpg *.bmp)')
if save_file:
self.image_pixmap.save(save_file[0])
if action == toggleAction:
self.main_window.toggle_distraction_free()