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 ✓ Set context menu for definitions and the like
✓ Paragraph indentation ✓ Paragraph indentation
✓ Comic view keyboard shortcuts ✓ Comic view keyboard shortcuts
Comic view context menu Comic view context menu
Adjust key navigation according to viewport dimensions
Search document using QTextCursor? Search document using QTextCursor?
Filetypes: Filetypes:
✓ pdf support ✓ pdf support

View File

@@ -38,7 +38,7 @@ class EPUB:
None, True) None, True)
if not contents_path: 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.generate_book_metadata(contents_path)
self.parse_toc() self.parse_toc()
@@ -76,8 +76,12 @@ class EPUB:
if xml: if xml:
root_item = xml.find('rootfile') root_item = xml.find('rootfile')
try:
return root_item.get('full-path') return root_item.get('full-path')
else: except AttributeError:
print(f'ePub module: {self.filename} has a malformed container.xml')
return None
possible_filenames = ('content.opf', 'package.opf') possible_filenames = ('content.opf', 'package.opf')
for i in possible_filenames: for i in possible_filenames:
presumptive_location = self.get_file_path(i) presumptive_location = self.get_file_path(i)

View File

@@ -656,8 +656,8 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
next_val = 0 next_val = 0
self.verticalScrollBar().setValue(next_val) self.verticalScrollBar().setValue(next_val)
small_increment = maximum // 5 small_increment = maximum // 4
big_increment = maximum // 3 big_increment = maximum // 2
if event.key() == QtCore.Qt.Key_Up: if event.key() == QtCore.Qt.Key_Up:
scroller(small_increment, False) scroller(small_increment, False)
@@ -711,9 +711,15 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
action = contextMenu.exec_(self.sender().mapToGlobal(position)) action = contextMenu.exec_(self.sender().mapToGlobal(position))
if action == saveAction: if action == saveAction:
# TODO dialog_prompt = self._translate('Main_UI', 'Save page as...')
# Save this page as an image extension_string = self._translate('Main_UI', 'Images')
pass 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: if action == toggleAction:
self.main_window.toggle_distraction_free() self.main_window.toggle_distraction_free()