def _appendMenubarAndPreferences(self): m = self.menuBar() m.setFixedHeight(25) # m.setMaximumHeight(25) m.aboutWidget.setModule(dataArtist) m.aboutWidget.setInstitutionLogo( MEDIA_FOLDER.join('institution_logo.svg')) #hide the menu so toolbars can only be show/hidden via gui->view->toolbars: m.setContextMenuPolicy(QtCore.Qt.PreventContextMenu) self.undoRedo = UndoRedo(MEDIA_FOLDER) self.gTools = GlobalTools() self.gTools.addWidget(self.undoRedo) m.setCornerWidget(self.gTools) #APPEND PREFERENCES t = m.file_preferences.tabs t.addTab(PreferencesView(self), 'View') t.addTab(self.pref_import, 'Import') t.addTab(PreferencesCommunication(self), 'Communication') #APPEND MENUBAR #MENU - FILE f = m.menu_file p = f.action_preferences action_file = QtGui.QAction('&Import', f) action_file.triggered.connect(self.openFile) action_file.setShortcut( QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_I)) f.insertAction(p, action_file) f.insertSeparator(p) #MENU VIEW v = m.menu_view #ACTION PRINT VIEW aPrintView = QtGui.QAction('Print view', v) aPrintView.setCheckable(True) aPrintView.triggered.connect( lambda checked: self.currentWorkspace().setPrintView(checked)) v.addAction(aPrintView) #SHOW/HIDE history aHistory = QtGui.QAction('Program history', v) aHistory.setShortcut(QtCore.Qt.Key_F4) aHistory.setCheckable(True) def showhideHistory(checked): s = self.currentWorkspace().middle_splitter r = s.getRange(1)[1] if checked: r /= 1.5 return s.moveSplitter(r, 1) def isHistoryVisible(): s = self.currentWorkspace().middle_splitter aHistory.setChecked(s.sizes()[1] != 0) aHistory.triggered.connect(showhideHistory) v.aboutToShow.connect(isHistoryVisible) v.addAction(aHistory) #SHOW/HIDE preferences aPref = QtGui.QAction('Dock preferences', v) aPref.setShortcut(QtCore.Qt.Key_F3) aPref.setCheckable(True) def showhidePref(checked): s = self.currentWorkspace().vert_splitter r = s.getRange(1)[1] if checked: r /= 3 else: r = 0 return s.moveSplitter(r, 1) def isPrefVisible(): w = self.currentWorkspace() s = w.vert_splitter aPref.setChecked(s.sizes()[0] != 0) aPref.setEnabled(w.displayPrefTabs.isVisible()) aPref.triggered.connect(showhidePref) v.aboutToShow.connect(isPrefVisible) v.addAction(aPref) #ACTION VIEW2CLIPBOARD aClipboard = QtGui.QAction('Copy view to clipboard', v) aClipboard.triggered.connect( lambda checked: self.currentWorkspace().copyViewToClipboard()) v.addAction(aClipboard) #ACTION Display2CLIPBOARD aClipboard = QtGui.QAction('Copy active display to clipboard', v) aClipboard.triggered.connect(lambda checked: self.currentWorkspace(). copyCurrentDisplayToClipboard()) v.addAction(aClipboard) #MENU - TOOLS t = m.menu_tools = QtGui.QMenu('Dock') m.insertMenuBefore(m.menu_workspace, t) #ADD DISPLAY mDisplay = t.addMenu('Add Display') for i, name in ( #(1, 'Dot'), (2, 'Graph'), (3, 'Image/Video'), #(4, 'Surface') #TODO: #(4, 'TODO: Surface'), #(5, 'TODO: Volume') ): mDisplay.addAction('%sD - %s' % (i - 1, name)).triggered.connect( lambda checked, i=i: self.currentWorkspace().addDisplay(axes=i )) #ADD TABLE t.addAction('Add Table').triggered.connect( lambda: self.currentWorkspace().addTableDock()) #ADD NOTEPAD t.addAction('Add Notepad').triggered.connect( lambda: self.currentWorkspace().addTextDock()) t.addSeparator() #DUPLICATE CURRENT DOCK t.addAction('Duplicate current display').triggered.connect( self._duplicateCurrentDiplay) self._m_duplDisp = t.addMenu('Move current display to other workspace') self._m_duplDisp.aboutToShow.connect(self._fillMenuDuplicateToOtherWS) #MENU - TOOLBARS self.menu_toolbars = QtGui.QMenu('Toolbars', m) self.connect(self.menu_toolbars, QtCore.SIGNAL("hovered(QAction *)"), lambda action, m=self.menu_toolbars: _showActionToolTipInMenu(m, action)) #SHOW ALL TOOLBARS - ACTION a = self.menu_toolbars.a_show = QtGui.QAction('show', m) f = a.font() f.setBold(True) a.setFont(f) a.setCheckable(True) a.setChecked(True) a.triggered.connect(self._toggleShowSelectedToolbars) self.menu_toolbars.aboutToShow.connect(self._listToolbarsInMenu) m.insertMenuBefore(m.menu_workspace, self.menu_toolbars) #MENU HELP m.menu_help.addAction('User manual').triggered.connect( lambda checked: os.startfile(HELP_FILE)) #TUTORIALS ####not used at the moment # self.m_tutorials = TutorialMenu( # tutorialFolder=PathStr.getcwd('dataArtist').join('tutorials'), # openFunction=self._openFnForTutorial, # saveFunction=self.app.session.blockingSave) # m.menu_help.addMenu(self.m_tutorials) m.menu_help.addAction('Online tutorials').triggered.connect( lambda checked: os.startfile( 'http://www.youtube.com/channel/UCjjngrC3jPdx1HL8zJ8yqLQ')) m.menu_help.addAction('Support').triggered.connect( lambda checked: os.startfile( 'https://github.com/radjkarl/dataArtist/issues'))