def _setupActions(self): actions = QtWidgets.QActionGroup(self) # Zoom in icon = qtsupport.geticon('zoom-in.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Zoom In'), actions, objectName='zoomInAction', statusTip=self.tr('Zoom In'), shortcut=QtGui.QKeySequence(self.tr('Ctrl++')), triggered=self.zoomIn) # Zoom out icon = qtsupport.geticon('zoom-out.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Zoom Out'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom Out'), shortcut=QtGui.QKeySequence(self.tr('Ctrl+-')), triggered=self.zoomOut) # Zoom fit icon = qtsupport.geticon('zoom-fit.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Zoom Fit'), actions, objectName='zoomFitAction', statusTip=self.tr('Zoom to fit the window size'), triggered=self.zoomFit) # Zoom 100 icon = qtsupport.geticon('zoom-100.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Zoom 100%'), actions, objectName='zoom100Action', statusTip=self.tr('Original size'), triggered=self.zoom100) # Manual Zoom #icon = QtGui.QIcon() #qt4support.geticon('zoom-100.svg', 'gsdview') #QtWidgets.QWidgetAction( # icon, self.tr('Zoom 100%'), actions, # statusTip=self.tr('Original size'), # triggered=self.zoom100) return actions
def _setupActions(self): actions = QtWidgets.QActionGroup(self) # Zoom in icon = qtsupport.geticon('zoom-in.svg', 'gsdview') QtWidgets.QAction( icon, self.tr('Zoom In'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom In'), shortcut=QtGui.QKeySequence(self.tr('Ctrl++')), enabled=False, triggered=lambda: self._zoom(+1)) # Zoom out icon = qtsupport.geticon('zoom-out.svg', 'gsdview') QtWidgets.QAction( icon, self.tr('Zoom Out'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom Out'), shortcut=QtGui.QKeySequence(self.tr('Ctrl+-')), enabled=False, triggered=lambda: self._zoom(-1)) return actions
def __init__(self, debug=False): super(QtShell, self).__init__() # Icon self.setWindowIcon( self.style().standardIcon(QtWidgets.QStyle.SP_ComputerIcon)) # Command box self.cmdbox = QtWidgets.QComboBox() self.cmdbox.setEditable(True) self.cmdbox.addItem('') self.cmdbox.setCurrentIndex(self.cmdbox.count() - 1) # @TODO: complete #self.entry.populate_popup.connect(self.on_populate_popup) icon = self.style().standardIcon(QtWidgets.QStyle.SP_MediaPlay) self.cmdbutton = QtWidgets.QPushButton(icon, 'Run') self.cmdbutton.clicked.connect(self.execute) lineedit = self.cmdbox.lineEdit() lineedit.returnPressed.connect(self.cmdbutton.click) hLayout = QtWidgets.QHBoxLayout() hLayout.addWidget(QtWidgets.QLabel('cmd > ')) hLayout.addWidget(self.cmdbox, 1) hLayout.addWidget(self.cmdbutton) # Output pane outputpane = QtOutputPane() outputpane.setReadOnly(True) outputpane.actions.removeAction(outputpane.actionHide) vLayout = QtWidgets.QVBoxLayout() vLayout.addLayout(hLayout) vLayout.addWidget(outputpane) # Main window centralWidget = QtWidgets.QWidget() centralWidget.setLayout(vLayout) self.setCentralWidget(centralWidget) self.quit_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence.Quit, self) self.eof_shortcut = QtWidgets.QShortcut( QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_D), self) self.setWindowTitle('Qt Shell') self.setGeometry(0, 0, 800, 600) self.quit_shortcut.activated.connect(self.close) self.eof_shortcut.activated.connect(self.close) # Setup the log system if debug: level = logging.DEBUG logging.basicConfig(level=level) else: level = logging.INFO self.logger = logging.getLogger() formatter = logging.Formatter('%(levelname)s: %(message)s') handler = QtLoggingHandler(outputpane) handler.setLevel(level) handler.setFormatter(formatter) self.logger.addHandler(handler) formatter = logging.Formatter('%(message)s') handler = QtDialogLoggingHandler(parent=self, dialog=None) handler.setLevel(logging.WARNING) handler.setFormatter(formatter) self.logger.addHandler(handler) self.logger.setLevel(level) # Setup high level components and initialize the parent classes handler = QtOutputHandler(self.logger, self.statusBar()) self.tool = exectools.ToolDescriptor('', stdout_handler=handler) self.controller = QtToolController(self.logger, parent=self) self.controller.finished.connect(lambda returncode: self.reset()) #self.shell = True self._state = 'ready' # or maybe __state self.logger.debug('qtshell session started at %s.' % time.asctime()) self.load_history()