mirror of https://gitlab.com/pamhyr/pamhyr2
doc: Add mage documentation open action.
parent
2825d02cb2
commit
7365bf70b6
|
|
@ -36,7 +36,8 @@ class DocWindow(PamhyrWindow):
|
|||
_pamhyr_ui = "WebView"
|
||||
_pamhyr_name = "Doc"
|
||||
|
||||
def _path_file(self, filename):
|
||||
@classmethod
|
||||
def _path_file(cls, filename):
|
||||
if ".py" in sys.argv[0]:
|
||||
return os.path.abspath(
|
||||
os.path.join(
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ from queue import Queue
|
|||
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
QKeySequence, QDesktopServices,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QTranslator, QEvent
|
||||
QTranslator, QEvent, QUrl,
|
||||
)
|
||||
from PyQt5.QtWidgets import (
|
||||
QMainWindow, QApplication, QAction,
|
||||
|
|
@ -190,6 +190,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
"action_menu_pamhyr_developers_pdf": lambda: self.open_doc_dev(ext="pdf"),
|
||||
"action_menu_pamhyr_users_html": lambda: self.open_doc_user(ext="html"),
|
||||
"action_menu_pamhyr_developers_html": lambda: self.open_doc_dev(ext="html"),
|
||||
"action_menu_mage": self.open_doc_mage,
|
||||
"action_menu_about": self.open_about,
|
||||
# ToolBar action
|
||||
"action_toolBar_quit": self.close,
|
||||
|
|
@ -721,13 +722,20 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
|
||||
self.open_solver_results(self._last_solver, self._last_results)
|
||||
|
||||
def open_doc(self, filename):
|
||||
doc = DocWindow(
|
||||
filename = filename,
|
||||
parent = self
|
||||
)
|
||||
doc.show()
|
||||
#################
|
||||
# DOCUMENTATION #
|
||||
#################
|
||||
|
||||
def open_doc(self, filename):
|
||||
if ".odt" in filename:
|
||||
url = QUrl(f"file://{DocWindow._path_file(filename)}")
|
||||
QDesktopServices.openUrl(url)
|
||||
else:
|
||||
doc = DocWindow(
|
||||
filename = filename,
|
||||
parent = self
|
||||
)
|
||||
doc.show()
|
||||
|
||||
def open_doc_user(self, ext="pdf"):
|
||||
self.open_doc(f"Pamhyr2-users.{ext}")
|
||||
|
|
@ -735,6 +743,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
def open_doc_dev(self, ext="pdf"):
|
||||
self.open_doc(f"Pamhyr2-dev.{ext}")
|
||||
|
||||
def open_doc_mage(self):
|
||||
self.open_doc("Mage-8.odt")
|
||||
|
||||
#########
|
||||
# DEBUG #
|
||||
#########
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@
|
|||
<addaction name="action_menu_pamhyr_developers_html"/>
|
||||
</widget>
|
||||
<addaction name="menuPamhyr2"/>
|
||||
<addaction name="action_menu_Mage"/>
|
||||
<addaction name="action_menu_mage"/>
|
||||
</widget>
|
||||
<addaction name="menuDoc"/>
|
||||
<addaction name="action_menu_about"/>
|
||||
|
|
@ -920,7 +920,7 @@
|
|||
<string>Pamhyr2 developer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_menu_Mage">
|
||||
<action name="action_menu_mage">
|
||||
<property name="text">
|
||||
<string>Mage</string>
|
||||
</property>
|
||||
|
|
|
|||
Loading…
Reference in New Issue