00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 import sys
00021 from ost import gui
00022 import sip
00023 from ost import gfx
00024 import ost
00025
00026 from PyQt4 import QtCore, QtGui
00027 from ost.gui import FileLoader
00028 from ost.gui.init_splash import _InitSplash
00029 from ost.gui.dng import termuse
00030 class InitMenuBar(QtCore.QObject):
00031 def __init__(self, menu_bar=None):
00032 QtCore.QObject.__init__(self, menu_bar)
00033
00034 persp=gui.GostyApp.Instance().perspective
00035 file=persp.GetMenu("File")
00036 options=persp.GetMenu("Options")
00037 window=persp.GetMenu("Window")
00038 help=persp.GetMenu("Help")
00039
00040 load = QtGui.QAction(QtGui.QIcon('icons/open.png'), '&Open', self)
00041 load.setStatusTip('Load a file')
00042 load.setShortcut('Ctrl+O')
00043 self.connect(load, QtCore.SIGNAL('triggered()'), self.Load)
00044 file.addAction(load)
00045
00046 webpage = QtGui.QAction('&Documentation', self)
00047 webpage.setStatusTip('Documentation')
00048 webpage.setShortcut('Ctrl+D')
00049 self.connect(webpage, QtCore.SIGNAL('triggered()'), self.OpenDocs)
00050 help.addAction(webpage)
00051 if sys.platform=='darwin':
00052 install_ctl=QtGui.QAction('Install Command Line Tool', self)
00053 self.connect(install_ctl, QtCore.SIGNAL('triggered()'),
00054 termuse.InstallTerminalPrograms)
00055 help.addAction(install_ctl)
00056 about = QtGui.QAction('&About', self)
00057 about.setStatusTip('About')
00058 about.setShortcut('Ctrl+A')
00059 self.connect(about, QtCore.SIGNAL('triggered()'), self.About)
00060 help.addAction(about)
00061
00062
00063 window.addMenu(persp.panels.menu)
00064 gl_win = QtGui.QAction('&GL Window', self)
00065 gl_win.setStatusTip('Display gl windows')
00066 gl_win.setShortcut('Ctrl+G')
00067 self.connect(gl_win, QtCore.SIGNAL('triggered()'), self.ShowGLWin)
00068 window.addAction(gl_win)
00069
00070 reset = QtGui.QAction('Reset View', self)
00071 reset.setStatusTip('Reset the Panels and Widgets')
00072 self.connect(reset, QtCore.SIGNAL('triggered()'), self.ResetView)
00073 window.addAction(reset)
00074
00075 def Exit(self):
00076 reply = QtGui.QMessageBox()
00077 reply.addButton(QtGui.QMessageBox.Yes)
00078
00079
00080 def Load(self):
00081 filename = QtGui.QFileDialog.getOpenFileName(None, 'Open file','')
00082 if(QtCore.QFileInfo(filename).isFile()):
00083 FileLoader.LoadObject(str(filename))
00084
00085 def OpenDocs(self):
00086 QtGui.QDesktopServices.openUrl(QtCore.QUrl("http://www.openstructure.org/docs/"))
00087
00088 def About(self):
00089 _InitSplash()
00090
00091 def ShowGLWin(self):
00092 gosty=gui.GostyApp.Instance()
00093 gl_win=gosty.GetGLWin()
00094 if gl_win and gl_win.qobject.isHidden():
00095 gl_win.Show()
00096
00097 def ResetView(self):
00098 msg_box = QtGui.QMessageBox()
00099 msg_box.setWindowTitle("Reset the Panels and Widget");
00100 msg_box.setIcon(QtGui.QMessageBox.Question)
00101 msg_box.setText("Do you really want to reset the Panels and Widgets?");
00102 msg_box.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel);
00103 msg_box.setDefaultButton(QtGui.QMessageBox.Cancel);
00104 ret = msg_box.exec_();
00105 if(ret == QtGui.QMessageBox.Yes):
00106 settings = QtCore.QSettings()
00107 settings.setValue("restore_settings",QtCore.QVariant(False))
00108 info_box = QtGui.QMessageBox()
00109 info_box.setStandardButtons(QtGui.QMessageBox.Ok)
00110 info_box.setIcon(QtGui.QMessageBox.Information)
00111 info_box.setWindowTitle("Restart OpenStructure")
00112 info_box.setText("You must restart OpenStructure for the changes to take effect!");
00113 info_box.exec_();
00114
00115 def _InitMenuBar(app):
00116
00117 pass
00118
00119
00120
00121