def bugReport(self): # Open the bug report link & zip the log files prompt the log.zip folder webbrowser.open_new(Paths.bugreport_link) with ZipFile(Paths.bugreport_zipfile, 'w') as logzip: logzip.write(Paths.ucs_log) logzip.write(Paths.error_log) Global.openFile(Paths.bugreport_dir)
def initUI(self): # Create "File" Menu menuBar = self.menuBar() menuBar.setNativeMenuBar(False) # Connect any slots that need connecting self.consoleWidget.settingsChanged.connect(lambda: self.env.updateSettings("consoleSettings", self.consoleWidget.settings)) # Create File Menu and actions fileMenu = menuBar.addMenu(self.tr('File')) newAction = QtWidgets.QAction( QtGui.QIcon(Paths.file_new), self.tr('New Task'), self) saveAction = QtWidgets.QAction(QtGui.QIcon(Paths.file_save), self.tr('Save Task'), self) saveAsAction = QtWidgets.QAction(QtGui.QIcon(Paths.file_save), self.tr('Save Task As'), self) loadAction = QtWidgets.QAction(QtGui.QIcon(Paths.file_load), self.tr('Load Task'), self) homeDirAction = QtWidgets.QAction(QtGui.QIcon(Paths.file_homedir), self.tr('Open Home Folder'), self) aboutMessage = lambda: QtWidgets.QMessageBox.information(self, self.tr("About"), self.tr("Version: ") + version + "\n\n" + self.tr("Protocol Version: ") + PROTOCOL_VERSION) saveAction.setShortcut("Ctrl+S") newAction.triggered.connect( lambda: self.newTask(promptSave=True)) saveAction.triggered.connect( self.saveTask) saveAsAction.triggered.connect( lambda: self.saveTask(True)) homeDirAction.triggered.connect(lambda: Global.openFile(Paths.ucs_home_dir)) fileMenu.addAction(newAction) fileMenu.addAction(saveAction) fileMenu.addAction(saveAsAction) fileMenu.addAction(loadAction) fileMenu.addAction(homeDirAction) # Create Community Menu communityMenu = menuBar.addMenu(self.tr('Community')) forumAction = QtWidgets.QAction( QtGui.QIcon(Paths.taskbar), self.tr('Visit the forum!'), self) redditAction = QtWidgets.QAction(QtGui.QIcon(Paths.reddit_link), self.tr('Visit our subreddit!'), self) forumAction.triggered.connect( lambda: webbrowser.open("https://forum.ufactory.cc/", new=0, autoraise=True)) redditAction.triggered.connect(lambda: webbrowser.open("https://www.reddit.com/r/uArm/", new=0, autoraise=True)) communityMenu.addAction(forumAction) communityMenu.addAction(redditAction) # Create Resources Menu resourceMenu = menuBar.addMenu(self.tr('New Resource')) visAction = QtWidgets.QAction( QtGui.QIcon(Paths.event_recognize), self.tr('Vision Object'), self) grpAction = QtWidgets.QAction( QtGui.QIcon(Paths.event_recognize), self.tr('Vision Group'), self) recAction = QtWidgets.QAction( QtGui.QIcon(Paths.record_start), self.tr('Movement Recording'), self) fncAction = QtWidgets.QAction(QtGui.QIcon(Paths.command_run_func), self.tr('Function'), self) visAction.triggered.connect(lambda: MakeObjectWindow( None, self.env, parent=self)) grpAction.triggered.connect(lambda: MakeGroupWindow( None, self.env, parent=self)) recAction.triggered.connect(lambda: MakeRecordingWindow(None, self.env, parent=self)) fncAction.triggered.connect(lambda: MakeFunctionWindow( None, self.env, parent=self)) resourceMenu.addAction(visAction) resourceMenu.addAction(grpAction) resourceMenu.addAction(recAction) resourceMenu.addAction(fncAction) # Settings Menug settingsMenu = menuBar.addMenu(self.tr('Settings')) resetLayoutAction = QtWidgets.QAction(QtGui.QIcon(Paths.file_layout), self.tr('Reset Layout'), self) resetLayoutAction.triggered.connect(self.resetLayoutState) settingsMenu.addAction(resetLayoutAction) # Create Languages Menu languageMenu = settingsMenu.addMenu(self.tr('Languages')) enLanAction = QtWidgets.QAction(QtGui.QIcon(Paths.languages_english), self.tr('English'), self) cnLanAction = QtWidgets.QAction(QtGui.QIcon(Paths.languages_chinese), self.tr('Chinese'), self) cnLanAction.triggered.connect(lambda: self.updateLanguageSetting(Global.ZH_CN)) enLanAction.triggered.connect(lambda: self.updateLanguageSetting(Global.EN_US)) languageMenu.addAction(enLanAction) languageMenu.addAction(cnLanAction) # Create survey Action surveyMenu = menuBar.addMenu(self.tr('Win A Gift!')) surveyMenu.setObjectName('surveyMenu') # surveyMenu.setStyleSheet('QMenu::item {color: Red; }') surveyLinkAction = QtWidgets.QAction(self.tr('Win A Gift!'), self) surveyLinkAction.triggered.connect(lambda: webbrowser.open_new(Paths.survey_link)) surveyMenu.addAction(surveyLinkAction) # Create Help Menu helpMenu = menuBar.addMenu(self.tr('Help')) bugReportAction = QtWidgets.QAction(QtGui.QIcon(Paths.help_bugreport), self.tr('Bug Report'), self) aboutAction = QtWidgets.QAction( QtGui.QIcon(Paths.file_about), self.tr('About'), self) helpAction = QtWidgets.QAction( QtGui.QIcon(Paths.file_help), self.tr('User Manual'), self) loadAction.triggered.connect( self.loadTask) aboutAction.triggered.connect( aboutMessage) helpAction.triggered.connect( lambda: Global.openFile(Paths.user_manual)) bugReportAction.triggered.connect(self.bugReport) helpMenu.addAction(bugReportAction) helpMenu.addAction(aboutAction) helpMenu.addAction(helpAction) # Add menus to menuBar menuBar.addMenu(fileMenu) menuBar.addMenu(communityMenu) menuBar.addMenu(resourceMenu) menuBar.addMenu(settingsMenu) menuBar.addMenu(helpMenu) menuBar.addMenu(surveyMenu) # Create Toolbar toolbar = self.addToolBar(self.tr("MainToolbar")) toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) calibrateBtn = QtWidgets.QAction(QtGui.QIcon(Paths.calibrate), self.tr('Calibrate'), self) objMngrBtn = QtWidgets.QAction(QtGui.QIcon(Paths.objectManager), self.tr('Resources'), self) self.scriptToggleBtn.setToolTip(self.tr('Run/Pause the command script (Ctrl+R)')) self.devicesBtn.setToolTip( self.tr('Open Camera and Robot settings')) calibrateBtn.setToolTip( self.tr('Open Robot and Camera Calibration Center')) objMngrBtn.setToolTip( self.tr('Open Resource Manager')) self.scriptToggleBtn.setShortcut(self.tr('Ctrl+R')) self.scriptToggleBtn.triggered.connect(self.toggleScript) self.devicesBtn.triggered.connect(self.openDevices) calibrateBtn.triggered.connect(self.openCalibrations) objMngrBtn.triggered.connect(self.openObjectManager) toolbar.addAction(self.scriptToggleBtn) toolbar.addAction(self.devicesBtn) toolbar.addAction(calibrateBtn) toolbar.addAction(objMngrBtn) # Add Camera Widget, as a QDockWidget def createDockWidget(widget, name): dockWidget = QtWidgets.QDockWidget() dockWidget.setObjectName(name) # Without this, self.restoreState() won't work dockWidget.setWindowTitle(name) dockWidget.setWidget(widget) dockWidget.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable | QtWidgets.QDockWidget.DockWidgetMovable) # titleBarWidget = QtWidgets.QWidget() # iconLbl = QtWidgets.QLabel() # iconLbl.setPixmap(QtGui.QPixmap(icon)) # titleLbl = QtWidgets.QLabel(name) # mainHLayout = QtWidgets.QHBoxLayout() # mainHLayout.addWidget(iconLbl) # mainHLayout.addWidget(titleLbl) # titleBarWidget.setLayout(mainHLayout) # dockWidget.setTitleBarWidget(titleBarWidget) return dockWidget cameraDock = createDockWidget( self.cameraWidget, self.tr('Camera')) consoleDock = createDockWidget(self.consoleWidget, self.tr('Console')) # Add the consoleWidgets to the window, and tabify them self.addDockWidget(QtCore.Qt.RightDockWidgetArea, cameraDock) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, consoleDock) self.tabifyDockWidget(consoleDock, cameraDock) # Create the main layout self.setCentralWidget(self.controlPanel) # Final touches self.setWindowTitle(self.programTitle) self.setWindowIcon(QtGui.QIcon(Paths.taskbar)) self.show()