Skip to content
Snippets Groups Projects
Commit bd0529ae authored by Florian Bruhin's avatar Florian Bruhin
Browse files

Add ext opening for report

Notebook is more involved as it's not a file on-disk

See #7
parent 6c1f862f
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ from PyQt6.QtWidgets import QWidget, QTextEdit, QStackedLayout
from PyQt6.QtGui import QTextCursor, QTextDocument
from PyQt6.QtCore import QUrl, pyqtSlot
from commander.gui import utils
class ReportView(QWidget):
......@@ -24,6 +26,8 @@ class ReportView(QWidget):
self._webview = QWebEngineView()
self._layout.addWidget(self._webview)
utils.init_open_action(self, self._webview.url)
@pyqtSlot(str)
def scroll_to_nodeid(self, nodeid: str) -> None:
if self._layout.currentWidget() is self._webview:
......@@ -94,4 +98,3 @@ class ReportView(QWidget):
self._webview.setUrl(QUrl.fromLocalFile(str(path)))
self._layout.setCurrentWidget(self._webview)
self.setFocusProxy(self._webview)
import pathlib
from typing import Callable
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QColor
from PyQt6.QtCore import Qt, QUrl
from PyQt6.QtGui import QAction, QColor, QDesktopServices, QKeySequence
from PyQt6.QtWidgets import QWidget
REPO_DIR = pathlib.Path(__file__).parents[2]
......@@ -33,3 +35,12 @@ def removeprefix(s: str, prefix: str) -> str:
return s[len(prefix):]
else:
return s[:]
def init_open_action(widget: QWidget, url_getter: Callable[[], QUrl]) -> QAction:
open_action = QAction(widget)
open_action.setShortcut(QKeySequence('Ctrl+Return'))
open_action.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
open_action.triggered.connect(
lambda: QDesktopServices.openUrl(url_getter()))
widget.addAction(open_action)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment