Line spacing
This commit is contained in:
6
TODO
6
TODO
@@ -7,7 +7,7 @@ TODO
|
|||||||
✓ Remember files
|
✓ Remember files
|
||||||
✓ Check files (hashes) upon restart
|
✓ Check files (hashes) upon restart
|
||||||
✓ Draw shadows
|
✓ Draw shadows
|
||||||
Perform culling
|
✓ Perform culling
|
||||||
Library:
|
Library:
|
||||||
✓ sqlite3 for cover images cache
|
✓ sqlite3 for cover images cache
|
||||||
✓ sqlite3 for storing metadata
|
✓ sqlite3 for storing metadata
|
||||||
@@ -41,6 +41,7 @@ TODO
|
|||||||
✓ Selectable background color for QGraphicsView
|
✓ Selectable background color for QGraphicsView
|
||||||
✓ View modes for QGraphicsView
|
✓ View modes for QGraphicsView
|
||||||
✓ View and hide toolbar actions in a list
|
✓ View and hide toolbar actions in a list
|
||||||
|
Use embedded fonts
|
||||||
Graphical themes
|
Graphical themes
|
||||||
Comic view keyboard shortcuts
|
Comic view keyboard shortcuts
|
||||||
Comic view modes
|
Comic view modes
|
||||||
@@ -50,13 +51,14 @@ TODO
|
|||||||
Pagination
|
Pagination
|
||||||
Set context menu for definitions and the like
|
Set context menu for definitions and the like
|
||||||
Line spacing
|
Line spacing
|
||||||
|
Scrolling: Smooth / By Line
|
||||||
Filetypes:
|
Filetypes:
|
||||||
✓ cbz, cbr support
|
✓ cbz, cbr support
|
||||||
✓ Keep font settings enabled but only for background color
|
✓ Keep font settings enabled but only for background color
|
||||||
Cache next and previous images
|
Cache next and previous images
|
||||||
epub support
|
epub support
|
||||||
mobi, azw support
|
mobi, azw support
|
||||||
txt, doc, djvu, fb2 support
|
txt, doc, chm, djvu, fb2 support
|
||||||
? Plugin system for parsers
|
? Plugin system for parsers
|
||||||
? pdf support
|
? pdf support
|
||||||
Internet:
|
Internet:
|
||||||
|
11
__main__.py
11
__main__.py
@@ -696,10 +696,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
else:
|
else:
|
||||||
current_profile['font_size'] = old_size
|
current_profile['font_size'] = old_size
|
||||||
|
|
||||||
if signal_sender == 'lineSpacingUp':
|
if signal_sender == 'lineSpacingUp' and current_profile['line_spacing'] < 200:
|
||||||
current_profile['line_spacing'] += .5
|
current_profile['line_spacing'] += 10
|
||||||
if signal_sender == 'lineSpacingDown':
|
if signal_sender == 'lineSpacingDown' and current_profile['line_spacing'] > 100:
|
||||||
current_profile['line_spacing'] -= .5
|
current_profile['line_spacing'] -= 10
|
||||||
|
|
||||||
if signal_sender == 'paddingUp':
|
if signal_sender == 'paddingUp':
|
||||||
current_profile['padding'] += 5
|
current_profile['padding'] += 5
|
||||||
@@ -791,6 +791,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
background = current_profile['background']
|
background = current_profile['background']
|
||||||
padding = current_profile['padding']
|
padding = current_profile['padding']
|
||||||
font_size = current_profile['font_size']
|
font_size = current_profile['font_size']
|
||||||
|
line_spacing = current_profile['line_spacing']
|
||||||
|
|
||||||
# Change toolbar widgets to match new settings
|
# Change toolbar widgets to match new settings
|
||||||
self.bookToolBar.fontBox.blockSignals(True)
|
self.bookToolBar.fontBox.blockSignals(True)
|
||||||
@@ -808,7 +809,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
'background-color: %s' % background.name())
|
'background-color: %s' % background.name())
|
||||||
|
|
||||||
current_tab.format_view(
|
current_tab.format_view(
|
||||||
font, font_size, foreground, background, padding)
|
font, font_size, foreground, background, padding, line_spacing)
|
||||||
|
|
||||||
def reset_profile(self):
|
def reset_profile(self):
|
||||||
current_profile_index = self.bookToolBar.profileBox.currentIndex()
|
current_profile_index = self.bookToolBar.profileBox.currentIndex()
|
||||||
|
@@ -84,6 +84,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="performCulling">
|
<widget class="QCheckBox" name="performCulling">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enabling reduces startup time and memory usage</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Load covers only when needed</string>
|
<string>Load covers only when needed</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -108,14 +111,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="okButton">
|
<widget class="QPushButton" name="okButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>OK</string>
|
<string>Scan Library</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="cancelButton">
|
<widget class="QPushButton" name="cancelButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cancel</string>
|
<string>Close</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -124,6 +127,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>About</string>
|
<string>About</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@@ -71,6 +71,7 @@ class Ui_Dialog(object):
|
|||||||
self.cancelButton.setObjectName("cancelButton")
|
self.cancelButton.setObjectName("cancelButton")
|
||||||
self.horizontalLayout_2.addWidget(self.cancelButton)
|
self.horizontalLayout_2.addWidget(self.cancelButton)
|
||||||
self.aboutButton = QtWidgets.QPushButton(Dialog)
|
self.aboutButton = QtWidgets.QPushButton(Dialog)
|
||||||
|
self.aboutButton.setCheckable(True)
|
||||||
self.aboutButton.setObjectName("aboutButton")
|
self.aboutButton.setObjectName("aboutButton")
|
||||||
self.horizontalLayout_2.addWidget(self.aboutButton)
|
self.horizontalLayout_2.addWidget(self.aboutButton)
|
||||||
self.gridLayout_3.addLayout(self.horizontalLayout_2, 1, 0, 1, 1)
|
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.fileRemember.setText(_translate("Dialog", "Remember open files"))
|
||||||
self.autoTags.setText(_translate("Dialog", "Generate tags from files"))
|
self.autoTags.setText(_translate("Dialog", "Generate tags from files"))
|
||||||
self.coverShadows.setText(_translate("Dialog", "Cover shadows"))
|
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.performCulling.setText(_translate("Dialog", "Load covers only when needed"))
|
||||||
self.checkBox.setText(_translate("Dialog", "OCPD"))
|
self.checkBox.setText(_translate("Dialog", "OCPD"))
|
||||||
self.okButton.setText(_translate("Dialog", "OK"))
|
self.okButton.setText(_translate("Dialog", "Scan Library"))
|
||||||
self.cancelButton.setText(_translate("Dialog", "Cancel"))
|
self.cancelButton.setText(_translate("Dialog", "Close"))
|
||||||
self.aboutButton.setText(_translate("Dialog", "About"))
|
self.aboutButton.setText(_translate("Dialog", "About"))
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ class Settings:
|
|||||||
'background': QtGui.QColor().fromRgb(216, 216, 216),
|
'background': QtGui.QColor().fromRgb(216, 216, 216),
|
||||||
'padding': 140,
|
'padding': 140,
|
||||||
'font_size': 20,
|
'font_size': 20,
|
||||||
'line_spacing': 1.5}
|
'line_spacing': 110}
|
||||||
|
|
||||||
default_profile2 = {
|
default_profile2 = {
|
||||||
'font': 'Roboto',
|
'font': 'Roboto',
|
||||||
@@ -25,7 +25,7 @@ class Settings:
|
|||||||
'background': QtGui.QColor().fromRgb(22, 22, 22),
|
'background': QtGui.QColor().fromRgb(22, 22, 22),
|
||||||
'padding': 140,
|
'padding': 140,
|
||||||
'font_size': 20,
|
'font_size': 20,
|
||||||
'line_spacing': 1.5}
|
'line_spacing': 110}
|
||||||
|
|
||||||
default_profile3 = {
|
default_profile3 = {
|
||||||
'font': 'Clear Sans',
|
'font': 'Clear Sans',
|
||||||
@@ -33,7 +33,7 @@ class Settings:
|
|||||||
'background': QtGui.QColor().fromRgb(0, 43, 54),
|
'background': QtGui.QColor().fromRgb(0, 43, 54),
|
||||||
'padding': 140,
|
'padding': 140,
|
||||||
'font_size': 30,
|
'font_size': 30,
|
||||||
'line_spacing': 1.5}
|
'line_spacing': 110}
|
||||||
|
|
||||||
self.default_profiles = [
|
self.default_profiles = [
|
||||||
default_profile1, default_profile2, default_profile3]
|
default_profile1, default_profile2, default_profile3]
|
||||||
|
31
widgets.py
31
widgets.py
@@ -517,12 +517,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.contentView.clear()
|
self.contentView.clear()
|
||||||
self.contentView.setHtml(required_content)
|
self.contentView.setHtml(required_content)
|
||||||
|
|
||||||
# TODO
|
def format_view(self, font, font_size, foreground, background, padding, line_spacing):
|
||||||
# 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):
|
|
||||||
if self.are_we_doing_images_only:
|
if self.are_we_doing_images_only:
|
||||||
# Tab color does not need to be set separately in case
|
# Tab color does not need to be set separately in case
|
||||||
# no padding is set for the viewport of a QGraphicsView
|
# no padding is set for the viewport of a QGraphicsView
|
||||||
@@ -533,14 +528,31 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.contentView.resizeEvent()
|
self.contentView.resizeEvent()
|
||||||
|
|
||||||
else:
|
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.setViewportMargins(padding, 0, padding, 0)
|
||||||
self.contentView.setStyleSheet(
|
self.contentView.setStyleSheet(
|
||||||
"QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format(
|
"QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format(
|
||||||
font, font_size, foreground.name(), background.name()))
|
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):
|
def toggle_bookmarks(self):
|
||||||
self.dockWidget.setWindowTitle('Bookmarks')
|
self.dockWidget.setWindowTitle('Bookmarks')
|
||||||
|
|
||||||
@@ -690,7 +702,6 @@ class PliantWidgetsCommonFunctions():
|
|||||||
|
|
||||||
def wheelEvent(self, event, are_we_doing_images_only):
|
def wheelEvent(self, event, are_we_doing_images_only):
|
||||||
if self.pw.ignore_wheel_event:
|
if self.pw.ignore_wheel_event:
|
||||||
# Ignore first n wheel events after a chapter change
|
|
||||||
self.pw.ignore_wheel_event_number += 1
|
self.pw.ignore_wheel_event_number += 1
|
||||||
if self.pw.ignore_wheel_event_number > 20:
|
if self.pw.ignore_wheel_event_number > 20:
|
||||||
self.pw.ignore_wheel_event = False
|
self.pw.ignore_wheel_event = False
|
||||||
|
Reference in New Issue
Block a user