diff --git a/TODO b/TODO index 5816ea9..b09c64f 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/ePub/read_epub.py b/ePub/read_epub.py index f55fa11..7b7399e 100644 --- a/ePub/read_epub.py +++ b/ePub/read_epub.py @@ -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): diff --git a/lector/widgets.py b/lector/widgets.py index 90c2c46..83452c2 100644 --- a/lector/widgets.py +++ b/lector/widgets.py @@ -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()