summaryrefslogtreecommitdiff
path: root/qutebrowser/utils/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/utils/utils.py')
-rw-r--r--qutebrowser/utils/utils.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index a28d662b3..b42a8474b 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -44,7 +44,7 @@ except ImportError: # pragma: no cover
"""Empty stub at runtime."""
-from PyQt5.QtCore import QUrl, QVersionNumber, QRect
+from PyQt5.QtCore import QUrl, QVersionNumber, QRect, QPoint
from PyQt5.QtGui import QClipboard, QDesktopServices
from PyQt5.QtWidgets import QApplication
@@ -839,3 +839,18 @@ def parse_rect(s: str) -> QRect:
raise ValueError("Invalid rectangle")
return rect
+
+
+def parse_point(s: str) -> QPoint:
+ """Parse a point string like 13,-42."""
+ try:
+ x, y = map(int, s.split(',', maxsplit=1))
+ except ValueError:
+ raise ValueError(f"String {s} does not match X,Y")
+
+ try:
+ point = QPoint(x, y)
+ except OverflowError as e:
+ raise ValueError(e)
+
+ return point