mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Fixes fullScreen scrollbar range
This commit is contained in:
parent
91989269f1
commit
c504cb510e
|
@ -206,6 +206,7 @@ class fullScreenEditor(QWidget):
|
|||
# self.lblWC.setPalette(p)
|
||||
|
||||
self.update()
|
||||
self.editor.centerCursor()
|
||||
|
||||
def paintEvent(self, event):
|
||||
if self._background:
|
||||
|
@ -307,10 +308,21 @@ class myScrollBar(QScrollBar):
|
|||
self.timer.timeout.connect(lambda: self.parent().hideWidget(self))
|
||||
self.valueChanged.connect(lambda v: self.timer.start())
|
||||
self.valueChanged.connect(lambda: self.parent().showWidget(self))
|
||||
self.rangeChanged.connect(self.rangeHasChanged)
|
||||
|
||||
def setColor(self, color):
|
||||
self._color = color
|
||||
|
||||
def rangeHasChanged(self, min, max):
|
||||
"""
|
||||
Adds viewport height to scrollbar max so that we can center cursor
|
||||
on screen.
|
||||
"""
|
||||
if settings.textEditor["alwaysCenter"]:
|
||||
self.blockSignals(True)
|
||||
self.setMaximum(max + self.parent().height())
|
||||
self.blockSignals(False)
|
||||
|
||||
def paintEvent(self, event):
|
||||
opt = QStyleOptionSlider()
|
||||
self.initStyleOption(opt)
|
||||
|
|
|
@ -51,17 +51,21 @@ class MDEditView(textEditView):
|
|||
# TypeWriterScrolling
|
||||
###########################################################################
|
||||
|
||||
def setCurrentModelIndex(self, index):
|
||||
textEditView.setCurrentModelIndex(self, index)
|
||||
self.centerCursor()
|
||||
|
||||
def cursorPositionHasChanged(self):
|
||||
self.centerCursor()
|
||||
|
||||
def centerCursor(self, force=False):
|
||||
cursor = self.cursorRect()
|
||||
scrollbar = self.verticalScrollBar()
|
||||
viewport = self.viewport().rect()
|
||||
if (force or settings.textEditor["alwaysCenter"]
|
||||
or cursor.bottom() >= viewport.bottom()
|
||||
or cursor.top() <= viewport.top()):
|
||||
offset = viewport.center() - cursor.center()
|
||||
scrollbar = self.verticalScrollBar()
|
||||
scrollbar.setValue(scrollbar.value() - offset.y())
|
||||
|
||||
def scrollBarRangeChanged(self, min, max):
|
||||
|
|
Loading…
Reference in a new issue