Fix scrolling not possible in margins

This commit is contained in:
BasioMeusPuga
2018-02-15 02:39:16 +05:30
parent 7a78d73de8
commit 303bbc799c
2 changed files with 9 additions and 3 deletions

3
TODO
View File

@@ -41,6 +41,8 @@ TODO
✓ Selectable background color for QGraphicsView
✓ View modes for QGraphicsView
✓ View and hide toolbar actions in a list
✓ Line spacing
Search document using QTextCursor?
Use embedded fonts
Graphical themes
Comic view keyboard shortcuts
@@ -50,7 +52,6 @@ TODO
Record progress
Pagination
Set context menu for definitions and the like
Line spacing
Scrolling: Smooth / By Line
Filetypes:
✓ cbz, cbr support

View File

@@ -412,7 +412,6 @@ class Tab(QtWidgets.QWidget):
self.contentView.loadImage(chapter_content)
else:
self.contentView = PliantQTextBrowser(self.window(), self)
# print(dir(self.contentView.document())) ## TODO USE this for modifying formatting and searching
relative_path_root = os.path.join(
self.window().temp_dir.path(), self.metadata['hash'])
@@ -529,7 +528,6 @@ class Tab(QtWidgets.QWidget):
else:
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()))
@@ -542,9 +540,16 @@ class Tab(QtWidgets.QWidget):
block_format.setLineHeight(
line_spacing, QtGui.QTextBlockFormat.ProportionalHeight)
# Also for padding
# Using setViewPortMargins for this disables scrolling in the margins
block_format.setLeftMargin(padding)
block_format.setRightMargin(padding)
this_cursor = self.contentView.textCursor()
this_cursor.movePosition(QtGui.QTextCursor.Start, 0, 1)
# Iterate over the entire document block by block
# The document ends when the cursor position can no longer be incremented
while True:
old_position = this_cursor.position()
this_cursor.mergeBlockFormat(block_format)