4
4
import numpy as np
5
5
6
6
from larray import LArray , Session , zeros
7
- from larray_editor .utils import PYQT5 , _ , create_action , show_figure , ima , commonpath
7
+ from larray_editor .utils import (PY2 , PYQT5 , _ , create_action , show_figure , ima , commonpath , dependencies ,
8
+ get_versions , urls )
8
9
from larray_editor .arraywidget import ArrayEditorWidget
9
-
10
10
from qtpy .QtCore import Qt , QSettings , QUrl , Slot
11
11
from qtpy .QtGui import QDesktopServices , QKeySequence
12
12
from qtpy .QtWidgets import (QMainWindow , QWidget , QVBoxLayout , QListWidget , QListWidgetItem , QSplitter , QFileDialog ,
@@ -250,6 +250,10 @@ def _reset(self):
250
250
def setup_menu_bar (self ):
251
251
"""Setup menu bar"""
252
252
menu_bar = self .menuBar ()
253
+
254
+ ###############
255
+ # File Menu #
256
+ ###############
253
257
file_menu = menu_bar .addMenu ('&File' )
254
258
255
259
file_menu .addAction (create_action (self , _ ('&New' ), shortcut = "Ctrl+N" , triggered = self .new ))
@@ -275,12 +279,23 @@ def setup_menu_bar(self):
275
279
file_menu .addSeparator ()
276
280
file_menu .addAction (create_action (self , _ ('&Quit' ), shortcut = "Ctrl+Q" , triggered = self .close ))
277
281
282
+ ###############
283
+ # Help Menu #
284
+ ###############
278
285
help_menu = menu_bar .addMenu ('&Help' )
279
286
help_menu .addAction (create_action (self , _ ('Online &Documentation' ), shortcut = "Ctrl+H" ,
280
287
triggered = self .open_documentation ))
281
288
help_menu .addAction (create_action (self , _ ('Online &Tutorial' ), triggered = self .open_tutorial ))
282
289
help_menu .addAction (create_action (self , _ ('Online Objects and Functions (API) &Reference' ),
283
290
triggered = self .open_api_documentation ))
291
+ help_menu .addSeparator ()
292
+ help_menu .addAction (create_action (self , _ ('Report &Issue...' ), triggered = self .report_issue ))
293
+ help_menu .addAction (create_action (self , _ ('&Users Discussion...' ), triggered = self .open_users_group ))
294
+ help_menu .addAction (create_action (self , _ ('New Releases And &Announces Mailing List...' ),
295
+ triggered = self .open_announce_group ))
296
+
297
+ help_menu .addSeparator ()
298
+ help_menu .addAction (create_action (self , _ ('&About' ), triggered = self .about ))
284
299
285
300
def data_changed (self ):
286
301
# We do not set self._unsaved_modifications to True because if users click on `Discard` button
@@ -657,13 +672,76 @@ def load_example(self):
657
672
self ._open_file (filepath )
658
673
659
674
def open_documentation (self ):
660
- QDesktopServices .openUrl (QUrl ("http://larray.readthedocs.io/en/stable/" ))
675
+ QDesktopServices .openUrl (QUrl (urls [ 'doc_stable' ] ))
661
676
662
677
def open_tutorial (self ):
663
- QDesktopServices .openUrl (QUrl ("http://larray.readthedocs.io/en/stable/tutorial.html" ))
678
+ QDesktopServices .openUrl (QUrl (urls [ 'doc_tutorial' ] ))
664
679
665
680
def open_api_documentation (self ):
666
- QDesktopServices .openUrl (QUrl ("http://larray.readthedocs.io/en/stable/api.html" ))
681
+ QDesktopServices .openUrl (QUrl (urls ['doc_api' ]))
682
+
683
+ def report_issue (self ):
684
+ if PY2 :
685
+ from urllib import quote
686
+ else :
687
+ from urllib .parse import quote
688
+
689
+ versions = get_versions ()
690
+ issue_template = """\
691
+ ## Description
692
+ **What steps will reproduce the problem?**
693
+ 1.
694
+ 2.
695
+ 3.
696
+
697
+ **What is the expected output? What do you see instead?**
698
+
699
+
700
+ **Please provide any additional information below**
701
+
702
+
703
+ ## Version and main components
704
+ * Python {python} on {system} {bitness:d}bits
705
+ * Qt {qt}, {qt_api} {qt_api_ver}
706
+ """
707
+ for dep in dependencies :
708
+ issue_template += "* {dep} {{{dep}}}\n " .format (dep = dep )
709
+ issue_template = issue_template .format (** versions )
710
+
711
+ url = QUrl (urls ['new_issue' ])
712
+ if PYQT5 :
713
+ from qtpy .QtCore import QUrlQuery
714
+ query = QUrlQuery ()
715
+ query .addQueryItem ("body" , quote (issue_template ))
716
+ url .setQuery (query )
717
+ else :
718
+ url .addEncodedQueryItem ("body" , quote (issue_template ))
719
+ QDesktopServices .openUrl (url )
720
+
721
+ def open_users_group (self ):
722
+ QDesktopServices .openUrl (QUrl (urls ['users_group' ]))
723
+
724
+ def open_announce_group (self ):
725
+ QDesktopServices .openUrl (QUrl (urls ['announce_group' ]))
726
+
727
+ def about (self ):
728
+ """About Editor"""
729
+ kwargs = get_versions ()
730
+ kwargs .update (urls )
731
+ message = """\
732
+ <b>LArray Editor {editor}</b>: The Graphical User Interface for LArray.
733
+ <br>Licensed under the terms of the <a href="{GPL3}">GNU GENERAL PUBLIC LICENSE Version 3</a>.
734
+ <p>Developed and maintained by the <a href="{fpb}">Federal Planning Bureau</a> (Belgium).
735
+ <p><b>Versions of underlying libraries</b>:
736
+ <ul>
737
+ <li>Python {python} on {system} {bitness:d}bits</li>
738
+ <li>Qt {qt}, {qt_api} {qt_api_ver}</li>
739
+ """
740
+ for dep in dependencies :
741
+ if kwargs [dep ] != 'N/A' :
742
+ message += "<li>{dep} {{{dep}}}</li>\n " .format (dep = dep )
743
+ message += "</ul>"
744
+ QMessageBox .about (self , _ ("About Larray Editor" ), message .format (** kwargs ))
667
745
668
746
def set_current_file (self , filepath ):
669
747
self .update_recent_files ([filepath ])
0 commit comments