summaryrefslogtreecommitdiff
path: root/qutebrowser/browser/webkit/webkittab.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/browser/webkit/webkittab.py')
-rw-r--r--qutebrowser/browser/webkit/webkittab.py152
1 files changed, 76 insertions, 76 deletions
diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py
index 6c2710fb4..f7ba641fa 100644
--- a/qutebrowser/browser/webkit/webkittab.py
+++ b/qutebrowser/browser/webkit/webkittab.py
@@ -64,9 +64,9 @@ class WebKitAction(browsertab.AbstractAction):
"""
new_actions = {
# https://github.com/qtwebkit/qtwebkit/commit/a96d9ef5d24b02d996ad14ff050d0e485c9ddc97
- 'RequestClose': QWebPage.ToggleVideoFullscreen + 1,
+ 'RequestClose': QWebPage.WebAction.ToggleVideoFullscreen + 1,
# https://github.com/qtwebkit/qtwebkit/commit/96b9ba6269a5be44343635a7aaca4a153ea0366b
- 'Unselect': QWebPage.ToggleVideoFullscreen + 2,
+ 'Unselect': QWebPage.WebAction.ToggleVideoFullscreen + 2,
}
if name in new_actions:
self._widget.triggerPageAction(new_actions[name])
@@ -124,7 +124,7 @@ class WebKitSearch(browsertab.AbstractSearch):
# Removing FindWrapsAroundDocument to get the same logging as with
# QtWebEngine
debug_flags = debug.qflags_key(
- QWebPage, flags & ~QWebPage.FindWrapsAroundDocument,
+ QWebPage, flags & ~QWebPage.FindFlag.FindWrapsAroundDocument,
klass=QWebPage.FindFlag)
if debug_flags != '0x0000':
flag_text = 'with flags {}'.format(debug_flags)
@@ -143,7 +143,7 @@ class WebKitSearch(browsertab.AbstractSearch):
self.search_displayed = False
# We first clear the marked text, then the highlights
self._widget.findText('')
- self._widget.findText('', QWebPage.HighlightAllOccurrences)
+ self._widget.findText('', QWebPage.FindFlag.HighlightAllOccurrences)
def search(self, text, *, ignore_case=usertypes.IgnoreCase.never,
reverse=False, wrap=True, result_cb=None):
@@ -160,16 +160,16 @@ class WebKitSearch(browsertab.AbstractSearch):
self.search_displayed = True
self._flags = self._empty_flags()
if self._is_case_sensitive(ignore_case):
- self._flags |= QWebPage.FindCaseSensitively
+ self._flags |= QWebPage.FindFlag.FindCaseSensitively
if reverse:
- self._flags |= QWebPage.FindBackward
+ self._flags |= QWebPage.FindFlag.FindBackward
if wrap:
- self._flags |= QWebPage.FindWrapsAroundDocument
+ self._flags |= QWebPage.FindFlag.FindWrapsAroundDocument
# We actually search *twice* - once to highlight everything, then again
# to get a mark so we can navigate.
found = self._widget.findText(text, self._flags)
self._widget.findText(text,
- self._flags | QWebPage.HighlightAllOccurrences)
+ self._flags | QWebPage.FindFlag.HighlightAllOccurrences)
self._call_cb(result_cb, found, text, self._flags, 'search')
def next_result(self, *, result_cb=None):
@@ -182,10 +182,10 @@ class WebKitSearch(browsertab.AbstractSearch):
# The int() here makes sure we get a copy of the flags.
flags = QWebPage.FindFlags(
int(self._flags)) # type: ignore[call-overload]
- if flags & QWebPage.FindBackward:
- flags &= ~QWebPage.FindBackward
+ if flags & QWebPage.FindFlag.FindBackward:
+ flags &= ~QWebPage.FindFlag.FindBackward
else:
- flags |= QWebPage.FindBackward
+ flags |= QWebPage.FindFlag.FindBackward
found = self._widget.findText(self.text, flags)
self._call_cb(result_cb, found, self.text, flags, 'prev_result')
@@ -212,13 +212,13 @@ class WebKitCaret(browsertab.AbstractCaret):
self._selection_state = browsertab.SelectionState.none
self.selection_toggled.emit(self._selection_state)
settings = self._widget.settings()
- settings.setAttribute(QWebSettings.CaretBrowsingEnabled, True)
+ settings.setAttribute(QWebSettings.WebAttribute.CaretBrowsingEnabled, True)
if self._widget.isVisible():
# Sometimes the caret isn't immediately visible, but unfocusing
# and refocusing it fixes that.
self._widget.clearFocus()
- self._widget.setFocus(Qt.OtherFocusReason)
+ self._widget.setFocus(Qt.FocusReason.OtherFocusReason)
# Move the caret to the first element in the viewport if there
# isn't any text which is already selected.
@@ -232,19 +232,19 @@ class WebKitCaret(browsertab.AbstractCaret):
@pyqtSlot(usertypes.KeyMode)
def _on_mode_left(self, _mode):
settings = self._widget.settings()
- if settings.testAttribute(QWebSettings.CaretBrowsingEnabled):
+ if settings.testAttribute(QWebSettings.WebAttribute.CaretBrowsingEnabled):
if (self._selection_state is not browsertab.SelectionState.none and
self._widget.hasSelection()):
# Remove selection if it exists
- self._widget.triggerPageAction(QWebPage.MoveToNextChar)
- settings.setAttribute(QWebSettings.CaretBrowsingEnabled, False)
+ self._widget.triggerPageAction(QWebPage.WebAction.MoveToNextChar)
+ settings.setAttribute(QWebSettings.WebAttribute.CaretBrowsingEnabled, False)
self._selection_state = browsertab.SelectionState.none
def move_to_next_line(self, count=1):
if self._selection_state is not browsertab.SelectionState.none:
- act = QWebPage.SelectNextLine
+ act = QWebPage.WebAction.SelectNextLine
else:
- act = QWebPage.MoveToNextLine
+ act = QWebPage.WebAction.MoveToNextLine
for _ in range(count):
self._widget.triggerPageAction(act)
if self._selection_state is browsertab.SelectionState.line:
@@ -252,9 +252,9 @@ class WebKitCaret(browsertab.AbstractCaret):
def move_to_prev_line(self, count=1):
if self._selection_state is not browsertab.SelectionState.none:
- act = QWebPage.SelectPreviousLine
+ act = QWebPage.WebAction.SelectPreviousLine
else:
- act = QWebPage.MoveToPreviousLine
+ act = QWebPage.WebAction.MoveToPreviousLine
for _ in range(count):
self._widget.triggerPageAction(act)
if self._selection_state is browsertab.SelectionState.line:
@@ -262,89 +262,89 @@ class WebKitCaret(browsertab.AbstractCaret):
def move_to_next_char(self, count=1):
if self._selection_state is browsertab.SelectionState.normal:
- act = QWebPage.SelectNextChar
+ act = QWebPage.WebAction.SelectNextChar
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = QWebPage.MoveToNextChar
+ act = QWebPage.WebAction.MoveToNextChar
for _ in range(count):
self._widget.triggerPageAction(act)
def move_to_prev_char(self, count=1):
if self._selection_state is browsertab.SelectionState.normal:
- act = QWebPage.SelectPreviousChar
+ act = QWebPage.WebAction.SelectPreviousChar
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = QWebPage.MoveToPreviousChar
+ act = QWebPage.WebAction.MoveToPreviousChar
for _ in range(count):
self._widget.triggerPageAction(act)
def move_to_end_of_word(self, count=1):
if self._selection_state is browsertab.SelectionState.normal:
- act = [QWebPage.SelectNextWord]
+ act = [QWebPage.WebAction.SelectNextWord]
if utils.is_windows: # pragma: no cover
- act.append(QWebPage.SelectPreviousChar)
+ act.append(QWebPage.WebAction.SelectPreviousChar)
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = [QWebPage.MoveToNextWord]
+ act = [QWebPage.WebAction.MoveToNextWord]
if utils.is_windows: # pragma: no cover
- act.append(QWebPage.MoveToPreviousChar)
+ act.append(QWebPage.WebAction.MoveToPreviousChar)
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
def move_to_next_word(self, count=1):
if self._selection_state is browsertab.SelectionState.normal:
- act = [QWebPage.SelectNextWord]
+ act = [QWebPage.WebAction.SelectNextWord]
if not utils.is_windows: # pragma: no branch
- act.append(QWebPage.SelectNextChar)
+ act.append(QWebPage.WebAction.SelectNextChar)
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = [QWebPage.MoveToNextWord]
+ act = [QWebPage.WebAction.MoveToNextWord]
if not utils.is_windows: # pragma: no branch
- act.append(QWebPage.MoveToNextChar)
+ act.append(QWebPage.WebAction.MoveToNextChar)
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
def move_to_prev_word(self, count=1):
if self._selection_state is browsertab.SelectionState.normal:
- act = QWebPage.SelectPreviousWord
+ act = QWebPage.WebAction.SelectPreviousWord
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = QWebPage.MoveToPreviousWord
+ act = QWebPage.WebAction.MoveToPreviousWord
for _ in range(count):
self._widget.triggerPageAction(act)
def move_to_start_of_line(self):
if self._selection_state is browsertab.SelectionState.normal:
- act = QWebPage.SelectStartOfLine
+ act = QWebPage.WebAction.SelectStartOfLine
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = QWebPage.MoveToStartOfLine
+ act = QWebPage.WebAction.MoveToStartOfLine
self._widget.triggerPageAction(act)
def move_to_end_of_line(self):
if self._selection_state is browsertab.SelectionState.normal:
- act = QWebPage.SelectEndOfLine
+ act = QWebPage.WebAction.SelectEndOfLine
elif self._selection_state is browsertab.SelectionState.line:
return
else:
- act = QWebPage.MoveToEndOfLine
+ act = QWebPage.WebAction.MoveToEndOfLine
self._widget.triggerPageAction(act)
def move_to_start_of_next_block(self, count=1):
if self._selection_state is not browsertab.SelectionState.none:
- act = [QWebPage.SelectNextLine,
- QWebPage.SelectStartOfBlock]
+ act = [QWebPage.WebAction.SelectNextLine,
+ QWebPage.WebAction.SelectStartOfBlock]
else:
- act = [QWebPage.MoveToNextLine,
- QWebPage.MoveToStartOfBlock]
+ act = [QWebPage.WebAction.MoveToNextLine,
+ QWebPage.WebAction.MoveToStartOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
@@ -353,11 +353,11 @@ class WebKitCaret(browsertab.AbstractCaret):
def move_to_start_of_prev_block(self, count=1):
if self._selection_state is not browsertab.SelectionState.none:
- act = [QWebPage.SelectPreviousLine,
- QWebPage.SelectStartOfBlock]
+ act = [QWebPage.WebAction.SelectPreviousLine,
+ QWebPage.WebAction.SelectStartOfBlock]
else:
- act = [QWebPage.MoveToPreviousLine,
- QWebPage.MoveToStartOfBlock]
+ act = [QWebPage.WebAction.MoveToPreviousLine,
+ QWebPage.WebAction.MoveToStartOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
@@ -366,11 +366,11 @@ class WebKitCaret(browsertab.AbstractCaret):
def move_to_end_of_next_block(self, count=1):
if self._selection_state is not browsertab.SelectionState.none:
- act = [QWebPage.SelectNextLine,
- QWebPage.SelectEndOfBlock]
+ act = [QWebPage.WebAction.SelectNextLine,
+ QWebPage.WebAction.SelectEndOfBlock]
else:
- act = [QWebPage.MoveToNextLine,
- QWebPage.MoveToEndOfBlock]
+ act = [QWebPage.WebAction.MoveToNextLine,
+ QWebPage.WebAction.MoveToEndOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
@@ -379,9 +379,9 @@ class WebKitCaret(browsertab.AbstractCaret):
def move_to_end_of_prev_block(self, count=1):
if self._selection_state is not browsertab.SelectionState.none:
- act = [QWebPage.SelectPreviousLine, QWebPage.SelectEndOfBlock]
+ act = [QWebPage.WebAction.SelectPreviousLine, QWebPage.WebAction.SelectEndOfBlock]
else:
- act = [QWebPage.MoveToPreviousLine, QWebPage.MoveToEndOfBlock]
+ act = [QWebPage.WebAction.MoveToPreviousLine, QWebPage.WebAction.MoveToEndOfBlock]
for _ in range(count):
for a in act:
self._widget.triggerPageAction(a)
@@ -390,18 +390,18 @@ class WebKitCaret(browsertab.AbstractCaret):
def move_to_start_of_document(self):
if self._selection_state is not browsertab.SelectionState.none:
- act = QWebPage.SelectStartOfDocument
+ act = QWebPage.WebAction.SelectStartOfDocument
else:
- act = QWebPage.MoveToStartOfDocument
+ act = QWebPage.WebAction.MoveToStartOfDocument
self._widget.triggerPageAction(act)
if self._selection_state is browsertab.SelectionState.line:
self._select_line()
def move_to_end_of_document(self):
if self._selection_state is not browsertab.SelectionState.none:
- act = QWebPage.SelectEndOfDocument
+ act = QWebPage.WebAction.SelectEndOfDocument
else:
- act = QWebPage.MoveToEndOfDocument
+ act = QWebPage.WebAction.MoveToEndOfDocument
self._widget.triggerPageAction(act)
def toggle_selection(self, line=False):
@@ -418,7 +418,7 @@ class WebKitCaret(browsertab.AbstractCaret):
self.selection_toggled.emit(self._selection_state)
def drop_selection(self):
- self._widget.triggerPageAction(QWebPage.MoveToNextChar)
+ self._widget.triggerPageAction(QWebPage.WebAction.MoveToNextChar)
def selection(self, callback):
callback(self._widget.selectedText())
@@ -433,9 +433,9 @@ class WebKitCaret(browsertab.AbstractCaret):
}""")
def _select_line(self):
- self._widget.triggerPageAction(QWebPage.SelectStartOfLine)
+ self._widget.triggerPageAction(QWebPage.WebAction.SelectStartOfLine)
self.reverse_selection()
- self._widget.triggerPageAction(QWebPage.SelectEndOfLine)
+ self._widget.triggerPageAction(QWebPage.WebAction.SelectEndOfLine)
self.reverse_selection()
def _select_line_to_end(self):
@@ -443,11 +443,11 @@ class WebKitCaret(browsertab.AbstractCaret):
# of focus) has to be checked before moving selection
# to the end of line
if self._js_selection_left_to_right():
- self._widget.triggerPageAction(QWebPage.SelectEndOfLine)
+ self._widget.triggerPageAction(QWebPage.WebAction.SelectEndOfLine)
def _select_line_to_start(self):
if not self._js_selection_left_to_right():
- self._widget.triggerPageAction(QWebPage.SelectStartOfLine)
+ self._widget.triggerPageAction(QWebPage.WebAction.SelectStartOfLine)
def _js_selection_left_to_right(self):
"""Return True iff the selection's direction is left to right."""
@@ -460,7 +460,7 @@ class WebKitCaret(browsertab.AbstractCaret):
def _follow_selected(self, *, tab=False):
if QWebSettings.globalSettings().testAttribute(
- QWebSettings.JavascriptEnabled):
+ QWebSettings.WebAttribute.JavascriptEnabled):
if tab:
self._tab.data.override_target = usertypes.ClickTarget.tab
self._tab.run_js_async("""
@@ -558,7 +558,7 @@ class WebKitScroller(browsertab.AbstractScroller):
elif x is None and y == 100:
self.bottom()
else:
- for val, orientation in [(x, Qt.Horizontal), (y, Qt.Vertical)]:
+ for val, orientation in [(x, Qt.Orientation.Horizontal), (y, Qt.Orientation.Vertical)]:
if val is not None:
frame = self._widget.page().mainFrame()
maximum = frame.scrollBarMaximum(orientation)
@@ -583,36 +583,36 @@ class WebKitScroller(browsertab.AbstractScroller):
self._tab.fake_key_press(key)
def up(self, count=1):
- self._key_press(Qt.Key_Up, count, 'scrollBarMinimum', Qt.Vertical)
+ self._key_press(Qt.Key.Key_Up, count, 'scrollBarMinimum', Qt.Orientation.Vertical)
def down(self, count=1):
- self._key_press(Qt.Key_Down, count, 'scrollBarMaximum', Qt.Vertical)
+ self._key_press(Qt.Key.Key_Down, count, 'scrollBarMaximum', Qt.Orientation.Vertical)
def left(self, count=1):
- self._key_press(Qt.Key_Left, count, 'scrollBarMinimum', Qt.Horizontal)
+ self._key_press(Qt.Key.Key_Left, count, 'scrollBarMinimum', Qt.Orientation.Horizontal)
def right(self, count=1):
- self._key_press(Qt.Key_Right, count, 'scrollBarMaximum', Qt.Horizontal)
+ self._key_press(Qt.Key.Key_Right, count, 'scrollBarMaximum', Qt.Orientation.Horizontal)
def top(self):
- self._key_press(Qt.Key_Home)
+ self._key_press(Qt.Key.Key_Home)
def bottom(self):
- self._key_press(Qt.Key_End)
+ self._key_press(Qt.Key.Key_End)
def page_up(self, count=1):
- self._key_press(Qt.Key_PageUp, count, 'scrollBarMinimum', Qt.Vertical)
+ self._key_press(Qt.Key.Key_PageUp, count, 'scrollBarMinimum', Qt.Orientation.Vertical)
def page_down(self, count=1):
- self._key_press(Qt.Key_PageDown, count, 'scrollBarMaximum',
- Qt.Vertical)
+ self._key_press(Qt.Key.Key_PageDown, count, 'scrollBarMaximum',
+ Qt.Orientation.Vertical)
def at_top(self):
return self.pos_px().y() == 0
def at_bottom(self):
frame = self._widget.page().currentFrame()
- return self.pos_px().y() >= frame.scrollBarMaximum(Qt.Vertical)
+ return self.pos_px().y() >= frame.scrollBarMaximum(Qt.Orientation.Vertical)
class WebKitHistoryPrivate(browsertab.AbstractHistoryPrivate):
@@ -848,7 +848,7 @@ class WebKitTab(browsertab.AbstractTab):
def _make_private(self, widget):
settings = widget.settings()
- settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
+ settings.setAttribute(QWebSettings.WebAttribute.PrivateBrowsingEnabled, True)
def load_url(self, url):
self._load_url_prepare(url)
@@ -880,9 +880,9 @@ class WebKitTab(browsertab.AbstractTab):
def reload(self, *, force=False):
if force:
- action = QWebPage.ReloadAndBypassCache
+ action = QWebPage.WebAction.ReloadAndBypassCache
else:
- action = QWebPage.Reload
+ action = QWebPage.WebAction.Reload
self._widget.triggerPageAction(action)
def stop(self):