diff --git a/TODO b/TODO index f1cedb5..19f2572 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,7 @@ TODO ✓ Remember files ✓ Check files (hashes) upon restart ✓ Draw shadows - Perform culling + ✓ Perform culling Library: ✓ sqlite3 for cover images cache ✓ sqlite3 for storing metadata @@ -41,6 +41,7 @@ TODO ✓ Selectable background color for QGraphicsView ✓ View modes for QGraphicsView ✓ View and hide toolbar actions in a list + Use embedded fonts Graphical themes Comic view keyboard shortcuts Comic view modes @@ -50,13 +51,14 @@ TODO Pagination Set context menu for definitions and the like Line spacing + Scrolling: Smooth / By Line Filetypes: ✓ cbz, cbr support ✓ Keep font settings enabled but only for background color Cache next and previous images epub support mobi, azw support - txt, doc, djvu, fb2 support + txt, doc, chm, djvu, fb2 support ? Plugin system for parsers ? pdf support Internet: diff --git a/__main__.py b/__main__.py index 9ef2fd7..988982c 100755 --- a/__main__.py +++ b/__main__.py @@ -696,10 +696,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): else: current_profile['font_size'] = old_size - if signal_sender == 'lineSpacingUp': - current_profile['line_spacing'] += .5 - if signal_sender == 'lineSpacingDown': - current_profile['line_spacing'] -= .5 + if signal_sender == 'lineSpacingUp' and current_profile['line_spacing'] < 200: + current_profile['line_spacing'] += 10 + if signal_sender == 'lineSpacingDown' and current_profile['line_spacing'] > 100: + current_profile['line_spacing'] -= 10 if signal_sender == 'paddingUp': current_profile['padding'] += 5 @@ -791,6 +791,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): background = current_profile['background'] padding = current_profile['padding'] font_size = current_profile['font_size'] + line_spacing = current_profile['line_spacing'] # Change toolbar widgets to match new settings self.bookToolBar.fontBox.blockSignals(True) @@ -808,7 +809,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): 'background-color: %s' % background.name()) current_tab.format_view( - font, font_size, foreground, background, padding) + font, font_size, foreground, background, padding, line_spacing) def reset_profile(self): current_profile_index = self.bookToolBar.profileBox.currentIndex() diff --git a/resources/raw/settings.ui b/resources/raw/settings.ui index a97617d..592d72a 100644 --- a/resources/raw/settings.ui +++ b/resources/raw/settings.ui @@ -84,6 +84,9 @@ + + Enabling reduces startup time and memory usage + Load covers only when needed @@ -108,14 +111,14 @@ - OK + Scan Library - Cancel + Close @@ -124,6 +127,9 @@ About + + true + diff --git a/resources/settingswindow.py b/resources/settingswindow.py index a10cd23..c718e85 100644 --- a/resources/settingswindow.py +++ b/resources/settingswindow.py @@ -71,6 +71,7 @@ class Ui_Dialog(object): self.cancelButton.setObjectName("cancelButton") self.horizontalLayout_2.addWidget(self.cancelButton) self.aboutButton = QtWidgets.QPushButton(Dialog) + self.aboutButton.setCheckable(True) self.aboutButton.setObjectName("aboutButton") self.horizontalLayout_2.addWidget(self.aboutButton) self.gridLayout_3.addLayout(self.horizontalLayout_2, 1, 0, 1, 1) @@ -87,9 +88,10 @@ class Ui_Dialog(object): self.fileRemember.setText(_translate("Dialog", "Remember open files")) self.autoTags.setText(_translate("Dialog", "Generate tags from files")) self.coverShadows.setText(_translate("Dialog", "Cover shadows")) + self.performCulling.setToolTip(_translate("Dialog", "Enabling reduces startup time and memory usage")) self.performCulling.setText(_translate("Dialog", "Load covers only when needed")) self.checkBox.setText(_translate("Dialog", "OCPD")) - self.okButton.setText(_translate("Dialog", "OK")) - self.cancelButton.setText(_translate("Dialog", "Cancel")) + self.okButton.setText(_translate("Dialog", "Scan Library")) + self.cancelButton.setText(_translate("Dialog", "Close")) self.aboutButton.setText(_translate("Dialog", "About")) diff --git a/settings.py b/settings.py index 30ff2c9..5059670 100644 --- a/settings.py +++ b/settings.py @@ -17,7 +17,7 @@ class Settings: 'background': QtGui.QColor().fromRgb(216, 216, 216), 'padding': 140, 'font_size': 20, - 'line_spacing': 1.5} + 'line_spacing': 110} default_profile2 = { 'font': 'Roboto', @@ -25,7 +25,7 @@ class Settings: 'background': QtGui.QColor().fromRgb(22, 22, 22), 'padding': 140, 'font_size': 20, - 'line_spacing': 1.5} + 'line_spacing': 110} default_profile3 = { 'font': 'Clear Sans', @@ -33,7 +33,7 @@ class Settings: 'background': QtGui.QColor().fromRgb(0, 43, 54), 'padding': 140, 'font_size': 30, - 'line_spacing': 1.5} + 'line_spacing': 110} self.default_profiles = [ default_profile1, default_profile2, default_profile3] diff --git a/widgets.py b/widgets.py index dd5896a..d5cafce 100644 --- a/widgets.py +++ b/widgets.py @@ -517,12 +517,7 @@ class Tab(QtWidgets.QWidget): self.contentView.clear() self.contentView.setHtml(required_content) - # TODO - # This here. Use it for stuff. - # self.contentView.document().begin().blockFormat().setLineHeight(1000, QtGui.QTextBlockFormat.FixedHeight) - # self.contentView.document().end().blockFormat().setLineHeight(1000, QtGui.QTextBlockFormat.FixedHeight) - - def format_view(self, font, font_size, foreground, background, padding): + def format_view(self, font, font_size, foreground, background, padding, line_spacing): if self.are_we_doing_images_only: # Tab color does not need to be set separately in case # no padding is set for the viewport of a QGraphicsView @@ -533,14 +528,31 @@ class Tab(QtWidgets.QWidget): self.contentView.resizeEvent() else: - # print(dir(self.contentView.document().begin().blockFormat())) ## TODO Line Height here - # self.contentView.document().begin().blockFormat().setLineHeight(1000, QtGui.QTextBlockFormat.FixedHeight) - # self.contentView.document().end().blockFormat().setLineHeight(1000, QtGui.QTextBlockFormat.FixedHeight) + self.contentView.setViewportMargins(padding, 0, padding, 0) self.contentView.setStyleSheet( "QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format( font, font_size, foreground.name(), background.name())) + # Line spacing + # Iterate over each block using the QTextCursor + # Set line spacing per a block format + # This is proportional line spacing so assume a divisor of 100 + block_format = QtGui.QTextBlockFormat() + block_format.setLineHeight( + line_spacing, QtGui.QTextBlockFormat.ProportionalHeight) + + this_cursor = self.contentView.textCursor() + this_cursor.movePosition(QtGui.QTextCursor.Start, 0, 1) + + while True: + old_position = this_cursor.position() + this_cursor.mergeBlockFormat(block_format) + this_cursor.movePosition(QtGui.QTextCursor.NextBlock, 0, 1) + new_position = this_cursor.position() + if old_position == new_position: + break + def toggle_bookmarks(self): self.dockWidget.setWindowTitle('Bookmarks') @@ -690,7 +702,6 @@ class PliantWidgetsCommonFunctions(): def wheelEvent(self, event, are_we_doing_images_only): if self.pw.ignore_wheel_event: - # Ignore first n wheel events after a chapter change self.pw.ignore_wheel_event_number += 1 if self.pw.ignore_wheel_event_number > 20: self.pw.ignore_wheel_event = False