def _setupHelpActions(self): actionsgroup = QtWidgets.QActionGroup(self) # About icon = qtsupport.geticon('about.svg', __name__) QtWidgets.QAction( icon, self.tr('&About'), actionsgroup, objectName='aboutAction', toolTip=self.tr('Show program information'), statusTip=self.tr('Show program information'), triggered=lambda: self.aboutdialog.exec_()) # AboutQt icon = QtGui.QIcon(':/qt-project.org/qmessagebox/images/qtlogo-64.png') # @COMPATIBILITY: Qt4 --> Qt5 if not icon.availableSizes(): icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png') if not icon.availableSizes(): icon = QtGui.QIcon.fromTheme('qtlogo-64') QtWidgets.QAction( icon, self.tr('About &Qt'), actionsgroup, objectName='aboutQtAction', toolTip=self.tr('Show information about Qt'), statusTip=self.tr('Show information about Qt'), triggered=lambda: QtWidgets.QMessageBox.aboutQt(self)) return actionsgroup
def _setupActions(self): actions = QtWidgets.QActionGroup(self) # KML export icon = qtsupport.geticon('area.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('KML export'), actions, objectName='kmlExportAction', statusTip=self.tr('KML export'), triggered=self.exportKML) # Open in google earth icon = qtsupport.geticon('earth.svg', __name__) QtWidgets.QAction(icon, self.tr('Open in Google Earth'), actions, objectName='openInGoogleEarthAction', statusTip=self.tr('Open in Google Earth'), triggered=self.openInGoogleEarth) # Open in google maps icon = qtsupport.geticon('overview.svg', 'gsdview.gdalbackend') QtWidgets.QAction(icon, self.tr('Open in Google Maps'), actions, objectName='openInGoogleMapsAction', statusTip=self.tr('Open in Google Maps'), triggered=self.openInGoogleMaps) return actions
def _setupMajorObjectItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open metadata view icon = qtsupport.geticon('metadata.svg', __name__) QtWidgets.QAction(icon, self.tr('Open &Metadata View'), actionsgroup, objectName='actionOpenItemMetadataView', shortcut=self.tr('Ctrl+M'), toolTip=self.tr('Show metadata in a new window'), statusTip=self.tr('Show metadata in a new window'), triggered=self.openItemMatadataView, enabled=False) # @TODO: remove # show properties # @TODO: standard info icon from gdsview package icon = qtsupport.geticon('info.svg', 'gsdview') QtWidgets.QAction( icon, self.tr('&Show Properties'), actionsgroup, objectName='actionShowItemProperties', shortcut=self.tr('Ctrl+S'), toolTip=self.tr('Show the property dialog for the cutent item'), statusTip=self.tr('Show the property dialog for the cutent item'), triggered=self.showItemProperties) return actionsgroup
def _setupFileActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) QtWidgets.QAction(icon, self.tr('Open Vector'), actions, objectName='openVectorAction', statusTip=self.tr('Open Vector'), triggered=self.onOpenVector) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogResetButton) QtWidgets.QAction(icon, self.tr('Close All'), actions, objectName='claseAllAction', statusTip=self.tr('Close All'), triggered=self.reset) QtWidgets.QAction(actions).setSeparator(True) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) QtWidgets.QAction(icon, self.tr('Exit'), actions, objectName='exitAction', statusTip=self.tr('Exit'), triggered=self.close) return actions
def _setupHelpActions(self): actions = QtWidgets.QActionGroup(self) icon = QtGui.QIcon( ':/trolltech/styles/commonstyle/images/fileinfo-32.png') QtWidgets.QAction(icon, 'About', actions, triggered=self.about) icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png') QtWidgets.QAction(icon, 'About Qt', actions, triggered=QtWidgets.QApplication.aboutQt) 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='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 = super(LayerManager, self)._setupActions() icon = QtGui.QIcon( ':/trolltech/styles/commonstyle/images/viewdetailed-128.png') QtWidgets.QAction(icon, self.tr('Select all'), actions, objectName='selectAllAction', statusTip=self.tr('Select all'), shortcut=self.tr('Ctrl-A'), triggered=self.view.selectAll) # connect actions action = actions.findChild(QtWidgets.QAction, 'moveToTopAction') action.triggered.connect(self.moveSelectionToTop) action = actions.findChild(QtWidgets.QAction, 'moveUpAction') action.triggered.connect(self.moveSelectionUp) action = actions.findChild(QtWidgets.QAction, 'moveDownAction') action.triggered.connect(self.moveSelectionDown) action = actions.findChild(QtWidgets.QAction, 'moveToBottomAction') action.triggered.connect(self.moveSelectionToBottom) action = actions.findChild(QtWidgets.QAction, 'removeLayerAction') action.triggered.connect(self.removeSelectedLayers) action = actions.findChild(QtWidgets.QAction, 'showLayerAction') action.triggered.connect(self.checkSelectedItems) action = actions.findChild(QtWidgets.QAction, 'hideLayerAction') action.triggered.connect(self.uncheckSelectedItems) return actions
def _setupViewActions(self): actions = QtWidgets.QActionGroup(self) icon = QtGui.QIcon( ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-in-32.png') QtWidgets.QAction(icon, self.tr('Zoom In'), actions, objectName='zoomInAction', statusTip=self.tr('Zoom In'), shortcut=self.tr('Ctrl++'), triggered=lambda: self.graphicsview.scale(1.2, 1.2)) icon = QtGui.QIcon( ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-out-32.png') QtWidgets.QAction( icon, self.tr('Zoom Out'), actions, objectName='zoomOutAction', statusTip=self.tr('Zoom Out'), shortcut=self.tr('Ctrl+-'), triggered=lambda: self.graphicsview.scale(1 / 1.2, 1 / 1.2)) icon = QtGui.QIcon( ':/trolltech/dialogs/qprintpreviewdialog/images/page-setup-24.png') QtWidgets.QAction(icon, self.tr('Zoom 1:1'), actions, objectName='zoomResetAction', statusTip=self.tr('Zoom 1:1'), triggered=lambda: self.graphicsview.setTransform( QtGui.QTransform(1, 0, 0, -1, 0, 0))) icon = QtGui.QIcon( ':/trolltech/dialogs/qprintpreviewdialog/images/fit-page-32.png') QtWidgets.QAction( icon, self.tr('Zoom Fit'), actions, objectName='zoomFitAction', statusTip=self.tr('Zoom Fit'), #checkable=True, triggered=lambda: self.graphicsview.fitInView( self.graphicsview.sceneRect(), QtCore.Qt.KeepAspectRatio)) return actions
def _setupFileActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) QtWidgets.QAction(icon, 'Open', actions, triggered=self.openfile) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton) QtWidgets.QAction(icon, 'Close', actions, triggered=self.scene.clear) QtWidgets.QAction(actions).setSeparator(True) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) QtWidgets.QAction(icon, 'Exit', actions, triggered=self.close) return actions
def _setupFileActions(self): style = self.style() actions = QtWidgets.QActionGroup(self) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) QtWidgets.QAction(icon, self.tr('&Open'), actions, objectName='openAction', shortcut=self.tr('Ctrl+O'), statusTip=self.tr('Open'), triggered=self.onOpen) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogSaveButton) QtWidgets.QAction(icon, self.tr('&Save As'), actions, objectName='saveAsAction', shortcut=self.tr('Ctrl+S'), statusTip=self.tr('Save as'), triggered=self.onSave) icon = QtGui.QIcon( ':/trolltech/dialogs/qprintpreviewdialog/images/print-32.png') QtWidgets.QAction(icon, self.tr('&Print'), actions, objectName='printAction', shortcut=self.tr('Ctrl+P'), statusTip=self.tr('Print'), triggered=self.onPrint) QtWidgets.QAction(actions).setSeparator(True) icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) QtWidgets.QAction(icon, self.tr('&Quit'), actions, objectName='exitAction', shortcut=self.tr('Ctrl+Q'), statusTip=self.tr('Quit'), triggered=self.close) return actions
def _setupDatasetItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open RGB # @TODO: find an icon for RGB icon = qtsupport.geticon('rasterband.svg', __name__) QtWidgets.QAction( icon, self.tr('Open as RGB'), actionsgroup, objectName='actionOpenRGBImageView', #shortcut=self.tr('Ctrl+B'), toolTip=self.tr('Display the dataset as an RGB image'), statusTip=self.tr('Open as RGB'), triggered=self.openRGBImageView) # build overviews icon = qtsupport.geticon('overview.svg', __name__) QtWidgets.QAction( icon, self.tr('&Build overviews'), actionsgroup, objectName='actionBuidOverviews', shortcut=self.tr('Ctrl+B'), toolTip=self.tr('Build overviews for all raster bands'), statusTip=self.tr('Build overviews for all raster bands'), triggered=self.buildOverviews) # @TODO: add band, add virtual band, open GCPs view # close icon = qtsupport.geticon('close.svg', 'gsdview') QtWidgets.QAction(icon, self.tr('Close'), actionsgroup, objectName='actionCloseItem', shortcut=self.tr('Ctrl+W'), toolTip=self.tr('Close the current item'), statusTip=self.tr('Close the current item'), triggered=self.closeCurrentItem) self._setupMajorObjectItemActions(actionsgroup) return actionsgroup
def setViewContextActions(widget): assert (widget.contextMenuPolicy() == QtCore.Qt.ActionsContextMenu), \ 'menu policy is not "QtCore.Qt.ActionsContextMenu"' #if widget.contextMenuPolicy() != QtCore.Qt.ActionsContextMenu: # widget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) icon = geticon('copy.svg', __name__) action = QtWidgets.QAction( icon, widget.tr('&Copy'), widget, objectName='copyAction', shortcut=widget.tr('Ctrl+C'), toolTip=widget.tr('Copy selected items'), triggered=lambda: copySelectedItems(widget)) widget.addAction(action) #':/trolltech/dialogs/qprintpreviewdialog/images/view-page-multi-32.png' icon = QtGui.QIcon( ':/trolltech/styles/commonstyle/images/viewlist-128.png') action = QtWidgets.QAction( icon, widget.tr('Select &All'), widget, objectName='selectAllAction', #shortcut=widget.tr('Ctrl+A'), toolTip=widget.tr('Select all items'), triggered=lambda: selectAllItems(widget)) widget.addAction(action) icon = widget.style().standardIcon(QtWidgets.QStyle.SP_DialogSaveButton) action = QtWidgets.QAction( icon, widget.tr('&Save As'), widget, objectName='saveAsAction', shortcut=widget.tr('Ctrl+S'), statusTip=widget.tr('Save as'), triggered=lambda: exportTable(widget.model())) widget.addAction(action) icon = QtGui.QIcon( ':/trolltech/dialogs/qprintpreviewdialog/images/print-32.png') action = QtWidgets.QAction( icon, widget.tr('&Print'), widget, objectName='printAction', shortcut=widget.tr('Ctrl+P'), statusTip=widget.tr('Print'), triggered=lambda: printObject(widget)) widget.addAction(action)
def _setupAction(self): icon = qtsupport.geticon('stretching.svg', __name__) action = QtWidgets.QAction(icon, self.tr('Stretch'), self, objectName='stretchAction', statusTip=self.tr('Stretch'), checkable=True, triggered=self.onButtonToggled) return action
def _setupFileActions(self): # @TODO: add a "close all" (items) action actionsgroup = QtWidgets.QActionGroup(self) # Open icon = qtsupport.geticon('open.svg', __name__) QtWidgets.QAction( icon, self.tr('&Open'), actionsgroup, objectName='openAction', shortcut=self.tr('Ctrl+O'), toolTip=self.tr('Open an existing file'), statusTip=self.tr('Open an existing file'), triggered=self.openFile) # Close icon = qtsupport.geticon('close.svg', __name__) QtWidgets.QAction( icon, self.tr('&Close'), actionsgroup, objectName='closeAction', # 'Ctrl+W' shortcu is used for closing windows #shortcut=self.tr('Ctrl+W'), toolTip=self.tr('Close the current file'), statusTip=self.tr('Close the current file'), triggered=self.closeItem) # Separator QtWidgets.QAction(actionsgroup).setSeparator(True) # objectName='separator') # Exit icon = qtsupport.geticon('quit.svg', __name__) QtWidgets.QAction( icon, self.tr('&Exit'), actionsgroup, objectName='exitAction', shortcut=self.tr('Ctrl+X'), toolTip=self.tr('Exit the program'), statusTip=self.tr('Exit the program'), triggered=self.close) return actionsgroup
def _setupSettingsActions(self): actionsgroup = QtWidgets.QActionGroup(self) # Preferences icon = qtsupport.geticon('preferences.svg', __name__) QtWidgets.QAction( icon, self.tr('&Preferences'), actionsgroup, objectName='preferencesAction', toolTip=self.tr('Open the program preferences dialog'), statusTip=self.tr('Open the program preferences dialog'), triggered=self.showPreferencesDialog) icon = qtsupport.geticon('full-screen.svg', __name__) QtWidgets.QAction( icon, self.tr('&Full Screen'), actionsgroup, objectName='fullScreenAction', shortcut='Ctrl+Meta+F', toolTip=self.tr('Toggle full screen mode'), statusTip=self.tr('Toggle full screen mode'), triggered=self.toggleFullScreenMode) return actionsgroup
def _setupActions(self): qstype = QtWidgets.QApplication.style() # Setup actions self.actions = QtWidgets.QActionGroup(self) # Save As icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogSaveButton) self.actionSaveAs = QtWidgets.QAction( icon, self.tr('&Save As'), self, shortcut=self.tr('Ctrl+S'), statusTip=self.tr('Save text to file'), triggered=self.save) self.actions.addAction(self.actionSaveAs) # Clear icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/' 'standardbutton-clear-32.png') self.actionClear = QtWidgets.QAction( icon, self.tr('&Clear'), self, shortcut=self.tr('Shift+F5'), statusTip=self.tr('Clear the text'), triggered=self.clear) self.actions.addAction(self.actionClear) # Close icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton) self.actionHide = QtWidgets.QAction( icon, self.tr('&Hide'), self, shortcut=self.tr('Ctrl+W'), statusTip=self.tr('Hide the text pane'), triggered=self.paneHideRequest) self.actions.addAction(self.actionHide)
def _newModeAction(self, mode, parent): if isinstance(mode.icon, string_types): icon = QtGui.QIcon(mode.icon) elif isinstance(mode.icon, QtWidgets.QStyle.StandardPixmap): style = QtWidgets.QApplication.style() icon = style.standardIcon(mode.icon) else: icon = mode.icon action = QtWidgets.QAction( icon, self.tr(mode.label), parent, statusTip=self.tr(mode.label), checkable=True) action.triggered.connect(lambda: self.modeChanged.emit(self.mode)) return action
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 syncWithMdiArea(self): '''Syncronize with MDI area This slot is executed immediately prior to each opening of this menu. It removes the previous subwindow navigation actions and adds new ones according to the current state of the attached QMdiArea. :C++ signature: `void syncWithMdiArea()` ''' if not self.mdi and not self._attachToClosestMdiAreaObject(): return self._stdGroup.setEnabled(len(self.mdi.subWindowList()) > 0) self._winMap.clear() for act in self._winGroup.actions(): self.removeAction(act) self._winGroup.removeAction(act) del act idx = 1 for idx, win in enumerate(self.mdi.subWindowList()): if win.isWindowModified(): modMarker = "*" else: modMarker = "" title = win.windowTitle().replace('[*]', modMarker) if idx < 8: text = '&%d %s' % (idx + 1, title) else: text = '%d %s' % (idx + 1, title) icon = self._iconMap.get(win, self._defIcon) action = QtWidgets.QAction(icon, text, self._winGroup, checkable=True) action.setChecked(win == self.mdi.activeSubWindow()) self._winMap[action] = win self.addActions(self._winGroup.actions())
def _setupSubDatasetItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open icon = qtsupport.geticon('open.svg', __name__) QtWidgets.QAction(icon, self.tr('Open Sub Dataset'), actionsgroup, objectName='actionOpenSubDatasetItem', shortcut=self.tr('Ctrl+O'), toolTip=self.tr('Open Sub Dataset'), statusTip=self.tr('Open Sub Dataset'), triggered=self.openSubDataset) self._setupDatasetItemActions(actionsgroup) return actionsgroup
def _setupBandItemActions(self, actionsgroup=None): if actionsgroup is None: actionsgroup = QtWidgets.QActionGroup(self) # open image view icon = qtsupport.geticon('open.svg', __name__) QtWidgets.QAction(icon, self.tr('&Open Image View'), actionsgroup, objectName='actionOpenImageView', shortcut=self.tr('Ctrl+O'), toolTip=self.tr('Open an image view'), statusTip=self.tr('Open a new image view'), triggered=self.openImageView) # @TODO: add a new action for newImageView # @TODO: Masked bands, Compute statistics, Compute histogram # @TODO: dataset --> Build overviews self._setupMajorObjectItemActions(actionsgroup) return actionsgroup
def __init__(self, parent, **kwargs): '''Constructs a QtWindowListMenu object. The *parent* parameter is passed to the QMenu constructor. Although this parameter has the conventional default of 0, you will normally want to explicitly provide a parent object, since the later adding of this menu object to an action container (e.g. QMenuBar) does not cause a reparenting. The container is normally the natural choice for *parent*. ''' super(QtWindowListMenu, self).__init__(parent, **kwargs) self.mdi = None self.setTitle(self.tr('&Windows')) self.aboutToShow.connect(self.syncWithMdiArea) self._stdGroup = QtWidgets.QActionGroup(self, exclusive=False) self._winGroup = QtWidgets.QActionGroup(self, exclusive=True) #, triggered=self.activateWindow) # @COMPATIBILITY: pyside 1.2.2 self._winGroup.triggered.connect(self.activateWindow) # Create the standard menu items. # @Note: Creation order must match the StandardAction enum values ;-) QtWidgets.QAction(self.tr('Cl&ose'), self._stdGroup, shortcut=self.tr('Ctrl+F4'), statusTip=self.tr('Close the active window')) QtWidgets.QAction(self.tr('Close &All'), self._stdGroup, statusTip=self.tr('Close all the windows')) act = self._stdGroup.addAction('') act.setSeparator(True) QtWidgets.QAction(self.tr('&Tile'), self._stdGroup, statusTip=self.tr('Tile the windows')) QtWidgets.QAction(self.tr('&Cascade'), self._stdGroup, statusTip=self.tr('Cascade the windows')) act = self._stdGroup.addAction('') act.setSeparator(True) QtWidgets.QAction( self.tr('Ne&xt'), self._stdGroup, statusTip=self.tr('Move the focus to the next window')) QtWidgets.QAction( self.tr('Pre&vious'), self._stdGroup, statusTip=self.tr('Move the focus to the previous window')) act = self._stdGroup.addAction('') act.setSeparator(True) self.addActions(self._stdGroup.actions()) self._winMap = {} # QMap<QAction *, QMdiSubWindow *> self._iconMap = {} # QMap<const QMdiSubWindow *, QIcon> self._defIcon = QtGui.QIcon()
def _setupContextMenu(self, parent=None): menu = QtWidgets.QMenu(parent) tr = menu.tr # Data pre-processing funcs = collections.OrderedDict() funcs['None'] = None funcs['Abs'] = np.abs funcs['Angle'] = np.angle funcs['Real'] = np.real funcs['Imag'] = np.imag #funcs['Pow'] = lambda x: np.abs(x * x) #funcs['dB'] = lambda x: 20 * np.log10(np.abs(x)) inverse_fmap = dict((v, k) for k, v in funcs.items()) current_func = inverse_fmap.get(self._data_preproc, 'unknown') if current_func == 'unknown': try: current_func = self._data_preproc.__name__ except AttributeError: pass funcs[current_func] = self._data_preproc # @COMPATIBILITY: addSection is new in Qt 5.1 #menu.addSection(tr('Transformation functions')) menu.addSeparator().setText(tr('Transformation functions')) actiongroup = QtWidgets.QActionGroup(menu) actiongroup.setExclusive(True) for name in funcs.keys(): def set_proc_func(checked, key=name): # @TODO: also adjust the stretch object func = funcs[key] if func != self._data_preproc: self._data_preproc = func self.update() action = QtWidgets.QAction( name, actiongroup, checkable=True, enabled=(self._data_preproc is not None and name != 'None'), objectName='actionDataPreProc' + name.capitalize(), toolTip=tr('Transformation function applied to data'), triggered=set_proc_func) action.setChecked(bool(name == current_func)) menu.addAction(action) # Colormap colortables = collections.OrderedDict() colortables['None'] = None colortables['Gray'] = qtsupport.GRAY_COLORTABLE colortables['Jet'] = qtsupport.JET_COLORTABLE inverse_ctmap = dict((id(v), k) for k, v in colortables.items()) current_colortable = inverse_ctmap.get(id(self.colortable), 'unknown') if current_colortable == 'unknown': colortables[current_colortable] = self.colortable # @COMPATIBILITY: addSection is new in Qt 5.1 #menu.addSection(tr('Color table')) menu.addSeparator().setText(tr('Color table')) actiongroup = QtWidgets.QActionGroup(menu) actiongroup.setExclusive(True) for name in colortables.keys(): def set_colortable(checked, key=name): ct = colortables[key] if id(ct) != id(self.colortable): self.colortable = ct self.update() action = QtWidgets.QAction( name, actiongroup, checkable=True, enabled=bool(self.colortable is not None and name != 'None'), objectName='actionColorTable' + name.capitalize(), toolTip=tr('Set the color table to %s') % name, triggered=set_colortable) action.setChecked(bool(name == current_colortable)) menu.addAction(action) return menu
def createActions(self): style = QtWidgets.QApplication.style() icon = style.standardIcon(style.SP_FileIcon) self.newAct = QtWidgets.QAction(icon, self.tr('&New'), self, shortcut=self.tr('Ctrl+N'), statusTip=self.tr('Create a new file'), triggered=self.newFile) icon = style.standardIcon(style.SP_DialogOpenButton) self.openAct = QtWidgets.QAction( icon, self.tr('&Open...'), self, shortcut=self.tr('Ctrl+O'), statusTip=self.tr('Open an existing file'), triggered=self.open) icon = style.standardIcon(style.SP_DialogSaveButton) self.saveAct = QtWidgets.QAction( icon, self.tr('&Save'), self, shortcut=self.tr('Ctrl+S'), statusTip=self.tr('Save the document to disk'), triggered=self.save) self.saveAsAct = QtWidgets.QAction( self.tr('Save &As...'), self, statusTip=self.tr('Save the document under a new name'), triggered=self.saveAs) self.exitAct = QtWidgets.QAction( self.tr('E&xit'), self, shortcut=self.tr('Ctrl+Q'), statusTip=self.tr('Exit the application'), triggered=self.close) icon = geticon('cut.svg', 'gsdview') self.cutAct = QtWidgets.QAction( icon, self.tr('Cu&t'), self, shortcut=self.tr('Ctrl+X'), statusTip=self.tr("Cut the current selection's contents to the " "clipboard"), triggered=self.cut) icon = geticon('copy.svg', 'gsdview.gdalbackend') self.copyAct = QtWidgets.QAction( icon, self.tr('&Copy'), self, shortcut=self.tr("Ctrl+C"), statusTip=self.tr("Copy the current selection's contents to the " "clipboard"), triggered=self.copy) icon = geticon('paste.svg', 'gsdview') self.pasteAct = QtWidgets.QAction( icon, self.tr('&Paste'), self, shortcut=self.tr("Ctrl+V"), statusTip=self.tr("Paste the clipboard's contents into the " "current selection"), triggered=self.paste) self.aboutAct = QtWidgets.QAction( self.tr('&About'), self, statusTip=self.tr("Show the application's About box"), triggered=self.about) self.aboutQtAct = QtWidgets.QAction( self.tr('About &Qt'), self, statusTip=self.tr("Show the Qt library's About box"), triggered=QtWidgets.QApplication.aboutQt)
def _setupActions(self): style = QtWidgets.QApplication.style() actions = QtWidgets.QActionGroup(self) icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/up-128.png') QtWidgets.QAction(icon, self.tr('Move to top'), actions, objectName='moveToTopAction', statusTip=self.tr('Move to top'), shortcut=self.tr('Ctrl+PgUp')) icon = style.standardIcon(QtWidgets.QStyle.SP_ArrowUp) QtWidgets.QAction(icon, self.tr('Move up'), actions, objectName='moveUpAction', statusTip=self.tr('Move up'), shortcut=self.tr('Ctrl+Up')) icon = style.standardIcon(QtWidgets.QStyle.SP_ArrowDown) QtWidgets.QAction(icon, self.tr('Move down'), actions, objectName='moveDownAction', statusTip=self.tr('Move down'), shortcut=self.tr('Ctrl+Down')) icon = QtGui.QIcon( ':/trolltech/styles/commonstyle/images/down-128.png') QtWidgets.QAction(icon, self.tr('Move to bottom'), actions, objectName='moveToBottomAction', statusTip=self.tr('Move to bottom'), shortcut=self.tr('Ctrl+PgDown')) #~ #'standardbutton-closetab-16.png' icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/' 'standardbutton-cancel-128.png') QtWidgets.QAction(icon, self.tr('Remove'), actions, objectName='removeLayerAction', statusTip=self.tr('Remove'), shortcut=self.tr('Del')) icon = QtGui.QIcon( ':/trolltech/styles/commonstyle/images/standardbutton-yes-128.png') QtWidgets.QAction(icon, self.tr('Show'), actions, objectName='showLayerAction', statusTip=self.tr('Show the layer')) icon = QtGui.QIcon( ':/trolltech/styles/commonstyle/images/standardbutton-no-128.png') QtWidgets.QAction(icon, self.tr('Hide'), actions, objectName='hideLayerAction', statusTip=self.tr('Hide the layer')) return actions