OpenStructure
Loading...
Searching...
No Matches
init_menubar.py
Go to the documentation of this file.
1#------------------------------------------------------------------------------
2# This file is part of the OpenStructure project <www.openstructure.org>
3#
4# Copyright (C) 2008-2020 by the OpenStructure authors
5#
6# This library is free software; you can redistribute it and/or modify it under
7# the terms of the GNU Lesser General Public License as published by the Free
8# Software Foundation; either version 3.0 of the License, or (at your option)
9# any later version.
10# This library is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13# details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this library; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#------------------------------------------------------------------------------
19
20import sys
21from ost import gui
22from ost import gfx
23import ost
24
25from PyQt5 import QtCore, QtGui
26from ost.gui import FileLoader
27from ost.gui.init_splash import _InitSplash
28from ost.gui.dng import termuse
29class InitMenuBar(QtCore.QObject):
30 def __init__(self, menu_bar=None):
31 QtCore.QObject.__init__(self, menu_bar)
32
33 persp=gui.GostyApp.Instance().perspective
34 file=persp.GetMenu("File")
35 options=persp.GetMenu("Options")
36 window=persp.GetMenu("Window")
37 help=persp.GetMenu("Help")
38
39 load = QtGui.QAction(QtGui.QIcon('icons/open.png'), '&Open', self)
40 load.setStatusTip('Load a file')
41 load.setShortcut('Ctrl+O')
42 self.connect(load, QtCore.SIGNAL('triggered()'), self.LoadLoad)
43 file.addAction(load)
44
45 webpage = QtGui.QAction('&Documentation', self)
46 webpage.setStatusTip('Documentation')
47 webpage.setShortcut('Ctrl+D')
48 self.connect(webpage, QtCore.SIGNAL('triggered()'), self.OpenDocsOpenDocs)
49 help.addAction(webpage)
50 if sys.platform=='darwin':
51 install_ctl=QtGui.QAction('Install Command Line Tool', self)
52 self.connect(install_ctl, QtCore.SIGNAL('triggered()'),
53 termuse.InstallTerminalPrograms)
54 help.addAction(install_ctl)
55 about = QtGui.QAction('&About', self)
56 about.setStatusTip('About')
57 about.setShortcut('Ctrl+A')
58 self.connect(about, QtCore.SIGNAL('triggered()'), self.AboutAbout)
59 help.addAction(about)
60
61
62 window.addMenu(persp.panels.menu)
63 gl_win = QtGui.QAction('&GL Window', self)
64 gl_win.setStatusTip('Display gl windows')
65 gl_win.setShortcut('Ctrl+G')
66 self.connect(gl_win, QtCore.SIGNAL('triggered()'), self.ShowGLWinShowGLWin)
67 window.addAction(gl_win)
68
69 reset = QtGui.QAction('Reset View', self)
70 reset.setStatusTip('Reset the Panels and Widgets')
71 self.connect(reset, QtCore.SIGNAL('triggered()'), self.ResetViewResetView)
72 window.addAction(reset)
73
74 def Exit(self):
75 reply = QtGui.QMessageBox()
76 reply.addButton(QtGui.QMessageBox.Yes)
77
78
79 def Load(self):
80 filename = QtGui.QFileDialog.getOpenFileName(None, 'Open file','')
81 if(QtCore.QFileInfo(filename).isFile()):
82 FileLoader.LoadObject(str(filename))
83
84 def OpenDocs(self):
85 QtGui.QDesktopServices.openUrl(QtCore.QUrl("http://www.openstructure.org/docs/"))
86
87 def About(self):
88 _InitSplash()
89
90 def ShowGLWin(self):
91 gosty=gui.GostyApp.Instance()
92 gl_win=gosty.GetGLWin()
93 if gl_win and gl_win.qobject.isHidden():
94 gl_win.Show()
95
96 def ResetView(self):
97 msg_box = QtGui.QMessageBox()
98 msg_box.setWindowTitle("Reset the Panels and Widget");
99 msg_box.setIcon(QtGui.QMessageBox.Question)
100 msg_box.setText("Do you really want to reset the Panels and Widgets?");
101 msg_box.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel);
102 msg_box.setDefaultButton(QtGui.QMessageBox.Cancel);
103 ret = msg_box.exec_();
104 if(ret == QtGui.QMessageBox.Yes):
105 settings = QtCore.QSettings()
106 settings.setValue("restore_settings",QtCore.QVariant(False))
107 info_box = QtGui.QMessageBox()
108 info_box.setStandardButtons(QtGui.QMessageBox.Ok)
109 info_box.setIcon(QtGui.QMessageBox.Information)
110 info_box.setWindowTitle("Restart OpenStructure")
111 info_box.setText("You must restart OpenStructure for the changes to take effect!");
112 info_box.exec_();
113
114def _InitMenuBar(app):
115 #InitMenuBar(app.perspective.menubar)
116 pass
117
__init__(self, menu_bar=None)