From d3ef243bbec05bd8a63ee701bc1c1fb624734077 Mon Sep 17 00:00:00 2001 From: tgwoodcock Date: Wed, 27 Nov 2024 11:02:32 +0100 Subject: [PATCH] Added docs to Help menu in application Under the help menu, the hdf5view documentation can be opened by a click. A keyboard shortcut, platform independent for the standard help key, is also provided. --- src/hdf5view/mainwindow.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/hdf5view/mainwindow.py b/src/hdf5view/mainwindow.py index 16b23da..4880864 100644 --- a/src/hdf5view/mainwindow.py +++ b/src/hdf5view/mainwindow.py @@ -11,8 +11,10 @@ QRect, QSettings, Qt, + QUrl, ) from qtpy.QtGui import ( + QDesktopServices, QIcon, QKeySequence, ) @@ -115,6 +117,15 @@ def init_actions(self): triggered=self.handle_open_about, ) + self.docs_action = QAction( + QIcon("icons:hdf5view.ico"), + "&hdf5view documentation", + self, + statusTip="hdf5view docs", + triggered=self.handle_open_docs, + shortcut=QKeySequence.HelpContents, + ) + # # Plot/image actions # @@ -165,6 +176,7 @@ def init_menus(self): # Help menu self.help_menu = menu.addMenu("&Help") + self.help_menu.addAction(self.docs_action) self.help_menu.addAction(self.about_action) def init_toolbars(self): @@ -401,6 +413,12 @@ def handle_open_about(self): ), ) + def handle_open_docs(self): + """Link to the hdf5view documentation.""" + url = QUrl("https://tgwoodcock.github.io/hdf5view") + if not QDesktopServices.openUrl(url): + QMessageBox.warning(self, "Open Url", "Could not open docs") + def handle_tree_selection_changed(self): """ Enable/disable the plots toolbar when