Improve mouse pointer hiding

Improve search result formatting
This commit is contained in:
BasioMeusPuga
2019-01-16 12:58:40 +05:30
parent c6d24fd970
commit 5d35319164
4 changed files with 26 additions and 14 deletions

View File

@@ -276,7 +276,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
self.viewport().setCursor(QtCore.Qt.OpenHandCursor)
else:
self.viewport().setCursor(QtCore.Qt.ClosedHandCursor)
self.parent.mouse_hide_timer.start(3000)
self.parent.mouse_hide_timer.start(2000)
QtWidgets.QGraphicsView.mouseMoveEvent(self, event)
def generate_graphicsview_context_menu(self, position):
@@ -669,7 +669,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
self.viewport().setCursor(QtCore.Qt.IBeamCursor)
else:
self.viewport().setCursor(QtCore.Qt.ArrowCursor)
self.parent.mouse_hide_timer.start(3000)
self.parent.mouse_hide_timer.start(2000)
QtWidgets.QTextBrowser.mouseMoveEvent(self, event)

View File

@@ -195,6 +195,18 @@ class BackGroundTextSearch(QtCore.QThread):
if not self.search_text or len(self.search_text) < 3:
return
def get_surrounding_text(textCursor, words_before):
textCursor.movePosition(
QtGui.QTextCursor.WordLeft,
QtGui.QTextCursor.MoveAnchor,
words_before)
textCursor.movePosition(
QtGui.QTextCursor.NextWord,
QtGui.QTextCursor.KeepAnchor,
words_before * 2)
cursor_selection = textCursor.selection().toPlainText()
return cursor_selection.replace('\n', '')
self.search_results = {}
# Create a new QTextDocument of each chapter and iterate
@@ -215,16 +227,16 @@ class BackGroundTextSearch(QtCore.QThread):
while not findResultCursor.isNull():
result_position = findResultCursor.position()
surroundingTextCursor = QtGui.QTextCursor(chapterDocument)
surroundingTextCursor.setPosition(
result_position, QtGui.QTextCursor.MoveAnchor)
# Get words before and after
surroundingTextCursor.movePosition(
QtGui.QTextCursor.WordLeft, QtGui.QTextCursor.MoveAnchor, 3)
surroundingTextCursor.movePosition(
QtGui.QTextCursor.NextWord, QtGui.QTextCursor.KeepAnchor, 6)
surrounding_text = surroundingTextCursor.selection().toPlainText()
surrounding_text = surrounding_text.replace('\n', ' ')
words_before = 3
while True:
surroundingTextCursor = QtGui.QTextCursor(chapterDocument)
surroundingTextCursor.setPosition(
result_position, QtGui.QTextCursor.MoveAnchor)
surrounding_text = get_surrounding_text(
surroundingTextCursor, words_before)
words_before += 1
if surrounding_text[:2] not in ('. ', ', '):
break
# Case insensitive replace for find results
replace_pattern = re.compile(re.escape(self.search_text), re.IGNORECASE)

View File

@@ -426,6 +426,7 @@ class Tab(QtWidgets.QWidget):
if not self.are_we_doing_images_only:
self.hiddenButton.animateClick(100)
self.mouse_hide_timer.start(2000)
self.is_fullscreen = True
def exit_fullscreen(self):
@@ -458,6 +459,7 @@ class Tab(QtWidgets.QWidget):
if not self.main_window.settings['show_bars']:
self.main_window.toggle_distraction_free()
self.mouse_hide_timer.start(2000)
self.contentView.setFocus()
def change_chapter_tocBox(self):