Beispiel #1
0
    def _setupActions(self):
        actions = QtGui.QActionGroup(self)

        # KML export
        icon = qt4support.geticon('area.svg', 'gsdview')
        QtGui.QAction(icon,
                      self.tr('KML export'),
                      actions,
                      objectName='kmlExportAction',
                      statusTip=self.tr('KML export'),
                      triggered=self.exportKML)

        # Open in google earth
        icon = qt4support.geticon('earth.svg', __name__)
        QtGui.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 = qt4support.geticon('overview.svg', 'gsdview.gdalbackend')
        QtGui.QAction(icon,
                      self.tr('Open in Google Maps'),
                      actions,
                      objectName='openInGoogleMapsAction',
                      statusTip=self.tr('Open in Google Maps'),
                      triggered=self.openInGoogleMaps)

        return actions
Beispiel #2
0
    def _setupMajorObjectItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtGui.QActionGroup(self)

        # open metadata view
        icon = qt4support.geticon('metadata.svg', __name__)
        QtGui.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 = qt4support.geticon('info.svg', 'gsdview')
        QtGui.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
Beispiel #3
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtGui.QActionGroup(self)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogOpenButton)
        QtGui.QAction(icon, self.tr('Open Vector'), actions,
                      objectName='openVectorAction',
                      statusTip=self.tr('Open Vector'),
                      triggered=self.onOpenVector)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogResetButton)
        QtGui.QAction(icon, self.tr('Close All'), actions,
                      objectName='claseAllAction',
                      statusTip=self.tr('Close All'),
                      triggered=self.reset)

        QtGui.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogCancelButton)
        QtGui.QAction(icon, self.tr('Exit'), actions,
                      objectName='exitAction',
                      statusTip=self.tr('Exit'),
                      triggered=self.close)

        return actions
Beispiel #4
0
    def _setupHelpActions(self):
        actions = QtGui.QActionGroup(self)

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/fileinfo-32.png')
        QtGui.QAction(icon, 'About', actions, triggered=self.about)

        icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png')
        QtGui.QAction(icon,
                      'About Qt',
                      actions,
                      triggered=QtGui.QApplication.aboutQt)

        return actions
Beispiel #5
0
    def _setupActions(self):
        actions = super(LayerManager, self)._setupActions()

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/viewdetailed-128.png')
        QtGui.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(QtGui.QAction, 'moveToTopAction')
        action.triggered.connect(self.moveSelectionToTop)
        action = actions.findChild(QtGui.QAction, 'moveUpAction')
        action.triggered.connect(self.moveSelectionUp)
        action = actions.findChild(QtGui.QAction, 'moveDownAction')
        action.triggered.connect(self.moveSelectionDown)
        action = actions.findChild(QtGui.QAction, 'moveToBottomAction')
        action.triggered.connect(self.moveSelectionToBottom)
        action = actions.findChild(QtGui.QAction, 'removeLayerAction')
        action.triggered.connect(self.removeSelectedLayers)
        action = actions.findChild(QtGui.QAction, 'showLayerAction')
        action.triggered.connect(self.checkSelectedItems)
        action = actions.findChild(QtGui.QAction, 'hideLayerAction')
        action.triggered.connect(self.uncheckSelectedItems)

        return actions
Beispiel #6
0
    def _setupHelpActions(self):
        actions = QtGui.QActionGroup(self)

        icon = QtGui.QIcon(
                    ':/trolltech/styles/commonstyle/images/fileinfo-32.png')
        QtGui.QAction(icon, self.tr('About'), actions,
                      objectName='aboutAction',
                      statusTip=self.tr('About'),
                      triggered=self.about)

        icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png')
        QtGui.QAction(icon, self.tr('About Qt'), actions,
                      objectName='aboutQtAction',
                      statusTip=self.tr('About Qt'),
                      triggered=QtGui.QApplication.aboutQt)

        return actions
Beispiel #7
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtGui.QActionGroup(self)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogOpenButton)
        QtGui.QAction(icon, 'Open', actions, triggered=self.openfile)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogCloseButton)
        QtGui.QAction(icon, 'Close', actions, triggered=self.scene.clear)

        QtGui.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogCancelButton)
        QtGui.QAction(icon, 'Exit', actions, triggered=self.close)

        return actions
Beispiel #8
0
    def _setupDatasetItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtGui.QActionGroup(self)

        # open RGB
        # @TODO: find an icon for RGB
        icon = qt4support.geticon('rasterband.svg', __name__)
        QtGui.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 = qt4support.geticon('overview.svg', __name__)
        QtGui.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 = qt4support.geticon('close.svg', 'gsdview')
        QtGui.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
Beispiel #9
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtGui.QActionGroup(self)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogOpenButton)
        QtGui.QAction(icon,
                      self.tr('&Open'),
                      actions,
                      objectName='openAction',
                      shortcut=self.tr('Ctrl+O'),
                      statusTip=self.tr('Open'),
                      triggered=self.onOpen)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogSaveButton)
        QtGui.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')
        QtGui.QAction(icon,
                      self.tr('&Print'),
                      actions,
                      objectName='printAction',
                      shortcut=self.tr('Ctrl+P'),
                      statusTip=self.tr('Print'),
                      triggered=self.onPrint)

        QtGui.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtGui.QStyle.SP_DialogCancelButton)
        QtGui.QAction(icon,
                      self.tr('&Quit'),
                      actions,
                      objectName='exitAction',
                      shortcut=self.tr('Ctrl+Q'),
                      statusTip=self.tr('Quit'),
                      triggered=self.close)

        return actions
Beispiel #10
0
    def add_action(self, data):
        """
        :type data: ControlBar.ActionData
        :rtype: QtGui.QAction
        """

        logging.debug("Create action: %s" % data.name)

        if data.icon is not None:
            logging.debug("Set action icon")
            if self.__toolbar is None:
                self.__toolbar = QtGui.QToolBar(self.__text, self.__parent)
                self.__toolbar.setObjectName("ToolBar_" + self.objectName())
                self.__parent.addToolBar(self.__toolbar)

            self.__actions[data.name] = QtGui.QAction(data.icon, data.text,
                                                      self)
            self.__toolbar.addAction(self.__actions[data.name])
        else:
            self.__actions[data.name] = QtGui.QAction(data.text, self)

        if data.status_tip is not None:
            logging.debug("Set action status tip")
            self.__actions[data.name].setStatusTip(data.status_tip)

        if data.shortcut is not None:
            logging.debug("Set action shortcut")
            self.__actions[data.name].setShortcut(data.shortcut)

        if data.callback is not None:
            logging.debug("Set action callback")
            connect(self.__actions[data.name].triggered, data.callback)

        logging.debug("Add action to menubar")
        self.__menubar.addAction(self.__actions[data.name])

        logging.debug("Set object name")
        self.__actions[data.name].setObjectName("%s.%s" %
                                                (self.objectName(), data.name))

        logging.debug("Enable action")
        self.__actions[data.name].setEnabled(data.enabled)

        logging.debug("Action %s created successfully" % data.name)
        return self.__actions[data.name]
Beispiel #11
0
    def _setupFileActions(self):
        # @TODO: add a "close all" (items) action
        actionsgroup = QtGui.QActionGroup(self)

        # Open
        icon = qt4support.geticon('open.svg', __name__)
        QtGui.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 = qt4support.geticon('close.svg', __name__)
        QtGui.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
        QtGui.QAction(actionsgroup).setSeparator(True)
        # objectName='separator')

        # Exit
        icon = qt4support.geticon('quit.svg', __name__)
        QtGui.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
Beispiel #12
0
    def _setupAction(self):
        icon = qt4support.geticon('stretching.svg', __name__)
        action = QtGui.QAction(icon,
                               self.tr('Stretch'),
                               self,
                               objectName='stretchAction',
                               statusTip=self.tr('Stretch'),
                               checkable=True,
                               triggered=self.onButtonToggled)

        return action
Beispiel #13
0
    def _setupActions(self):
        actions = QtGui.QActionGroup(self)

        # Zoom in
        icon = qt4support.geticon('zoom-in.svg', 'gsdview')
        QtGui.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 = qt4support.geticon('zoom-out.svg', 'gsdview')
        QtGui.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 = qt4support.geticon('zoom-fit.svg', 'gsdview')
        QtGui.QAction(icon, self.tr('Zoom Fit'), actions,
                      objectName='zoomFitAction',
                      statusTip=self.tr('Zoom to fit the window size'),
                      triggered=self.zoomFit)

        # Zoom 100
        icon = qt4support.geticon('zoom-100.svg', 'gsdview')
        QtGui.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')
        #QtGui.QWidgetAction(icon, self.tr('Zoom 100%'), actions,
        #              statusTip=self.tr('Original size'),
        #              triggered=self.zoom100)

        return actions
Beispiel #14
0
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 = QtGui.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 = QtGui.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(QtGui.QStyle.SP_DialogSaveButton)
    action = QtGui.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 = QtGui.QAction(icon, widget.tr('&Print'), widget,
                           objectName='printAction',
                           shortcut=widget.tr('Ctrl+P'),
                           statusTip=widget.tr('Print'),
                           triggered=lambda: printObject(widget))
    widget.addAction(action)
Beispiel #15
0
    def _setupActions(self):
        actions = QtGui.QActionGroup(self)

        # Zoom in
        icon = qt4support.geticon('zoom-in.svg', 'gsdview')
        QtGui.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 = qt4support.geticon('zoom-out.svg', 'gsdview')
        QtGui.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
Beispiel #16
0
    def _setupViewActions(self):
        actions = QtGui.QActionGroup(self)

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-in-32.png')
        QtGui.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')
        QtGui.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')
        QtGui.QAction(icon, self.tr('Zoom 1:1'), actions,
                      objectName='zoomResetAction',
                      statusTip=self.tr('Zoom 1:1'),
                      triggered=lambda: self.graphicsview.setMatrix(
                                            QtGui.QMatrix(1, 0, 0, -1, 0, 0)))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/fit-page-32.png')
        QtGui.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
Beispiel #17
0
    def _setupActions(self):
        qstype = QtGui.QApplication.style()

        # Setup actions
        self.actions = QtGui.QActionGroup(self)

        # Save As
        icon = qstype.standardIcon(QtGui.QStyle.SP_DialogSaveButton)
        self.actionSaveAs = QtGui.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 = QtGui.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(QtGui.QStyle.SP_DialogCloseButton)
        self.actionHide = QtGui.QAction(
            icon,
            self.tr('&Hide'),
            self,
            shortcut=self.tr('Ctrl+W'),
            statusTip=self.tr('Hide the text plane'),
            triggered=self.planeHideRequest)
        self.actions.addAction(self.actionHide)
Beispiel #18
0
 def onCustomContextMenu(self, point):
     index = self.indexAt(point)
     item = self.itemAt(point)
     if isinstance(item, ParentItem):
         #            if index.isValid():
         menu = qg.QMenu()
         menu.addAction(qg.QAction('edit...',menu,triggered=lambda: self.signal_edit.emit(item.userdata)))
         menu.addAction(qg.QAction('rename...',menu,triggered=lambda: self.edit(index)))
         menu.addAction(qg.QAction('delete',menu,triggered=lambda: self.delete_indeces([index])))
         menu.addAction(qg.QAction('parents',menu,triggered=lambda: self.show_parents(item)))
         menu.addAction(qg.QAction('children',menu,triggered=lambda: self.show_children(item)))
         menu.addAction(qg.QAction('edit description...',menu,triggered=item.userdata.edit_description))
         menu.addAction(qg.QAction('set main image',menu,triggered=lambda: self.set_main_image(item)))
         menu.addAction(qg.QAction('mass properties...',menu,triggered=lambda: self.get_mass_props(item.userdata.output[0])))
         menu.exec_(self.mapToGlobal(point))
     else:
         menu = qg.QMenu()
         menu.addAction(qg.QAction('mass properties...',menu,triggered=lambda: self.get_mass_props(item.userdata)))
         menu.exec_(self.mapToGlobal(point))
Beispiel #19
0
    def _setupSettingsActions(self):
        actionsgroup = QtGui.QActionGroup(self)

        # Preferences
        icon = qt4support.geticon('preferences.svg', __name__)
        QtGui.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)

        return actionsgroup
Beispiel #20
0
    def _newModeAction(self, mode, parent):
        if isinstance(mode.icon, basestring):
            icon = QtGui.QIcon(mode.icon)
        elif isinstance(mode.icon, QtGui.QStyle.StandardPixmap):
            style = QtGui.QApplication.style()
            icon = style.standardIcon(mode.icon)
        else:
            icon = mode.icon

        action = QtGui.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
Beispiel #21
0
    def build_action(key, parent, action_defs, shortcuts_translation, icons):
        kwargs = action_defs[key]

        action_kwargs = {}
        try:
            action_kwargs['icon'] = icons[kwargs['icon']]
        except KeyError:
            pass

        try:
            action_kwargs['statusTip'] = kwargs['statusTip']
        except KeyError:
            pass

        try:
            action_kwargs['shortcut'] = shortcuts_translation[
                kwargs['shortcut']]
        except KeyError:
            pass

        action = qg.QAction(parent, **action_kwargs)

        try:
            action.setText(kwargs['text'])
        except KeyError:
            pass

        try:
            action.setCheckable(kwargs['is_checkable'])
        except KeyError:
            pass

        try:
            action.setChecked(kwargs['is_checked'])
        except KeyError:
            pass

        try:
            parent_trigger_method_name = kwargs['triggered']
            if hasattr(parent_trigger_method_name, '__call__'):
                parent_trigger_method = parent_trigger_method_name
            else:
                parent_trigger_method = getattr(parent,
                                                parent_trigger_method_name)
            action.triggered.connect(parent_trigger_method)
        except (KeyError, AttributeError):
            pass

        return action
Beispiel #22
0
    def _setupHelpActions(self):
        actionsgroup = QtGui.QActionGroup(self)

        # About
        icon = qt4support.geticon('about.svg', __name__)
        QtGui.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(':/trolltech/qmessagebox/images/qtlogo-64.png')
        QtGui.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: QtGui.QMessageBox.aboutQt(self))

        return actionsgroup
Beispiel #23
0
    def _setupSubDatasetItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtGui.QActionGroup(self)

        # open
        icon = qt4support.geticon('open.svg', __name__)
        QtGui.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
Beispiel #24
0
    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 = QtGui.QAction(icon, text, self._winGroup, checkable=True)
            action.setChecked(win == self.mdi.activeSubWindow())
            self._winMap[action] = win

        self.addActions(self._winGroup.actions())
Beispiel #25
0
    def _setupBandItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtGui.QActionGroup(self)

        # open image view
        icon = qt4support.geticon('open.svg', __name__)
        QtGui.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
Beispiel #26
0
    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 = QtGui.QActionGroup(self, exclusive=False)
        self._winGroup = QtGui.QActionGroup(self, exclusive=True)
        #, triggered=self.activateWindow)

        # @COMPATIBILITY: with pyside 1.0.1
        self._winGroup.triggered.connect(self.activateWindow)

        # Create the standard menu items.
        # @Note: Creation order must match the StandardAction enum values ;-)
        QtGui.QAction(self.tr('Cl&ose'),
                      self._stdGroup,
                      shortcut=self.tr('Ctrl+F4'),
                      statusTip=self.tr('Close the active window'))

        QtGui.QAction(self.tr('Close &All'),
                      self._stdGroup,
                      statusTip=self.tr('Close all the windows'))

        act = self._stdGroup.addAction('')
        act.setSeparator(True)

        QtGui.QAction(self.tr('&Tile'),
                      self._stdGroup,
                      statusTip=self.tr('Tile the windows'))

        QtGui.QAction(self.tr('&Cascade'),
                      self._stdGroup,
                      statusTip=self.tr('Cascade the windows'))

        act = self._stdGroup.addAction('')
        act.setSeparator(True)

        QtGui.QAction(self.tr('Ne&xt'),
                      self._stdGroup,
                      statusTip=self.tr('Move the focus to the next window'))

        QtGui.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()
Beispiel #27
0
 def setupUi(self, w):
     super(MasterTable, self).setupUi(w)
     self.action_cols = action = QtGui.QAction("&Columns", self)
     self._context_items.append(action)
Beispiel #28
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 545)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.cSplit = Splitter(self.centralwidget)
        self.cSplit.setOrientation(QtCore.Qt.Horizontal)
        self.cSplit.setObjectName("cSplit")
        self.layoutWidget = QtGui.QWidget(self.cSplit)
        self.layoutWidget.setObjectName("layoutWidget")
        self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget)
        self.verticalLayout.setMargin(0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.tbtree = QtGui.QWidget(self.layoutWidget)
        self.tbtree.setObjectName("tbtree")
        self.horizontalLayout = QtGui.QHBoxLayout(self.tbtree)
        self.horizontalLayout.setMargin(0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.toolButton = QtGui.QToolButton(self.tbtree)
        self.toolButton.setObjectName("toolButton")
        self.horizontalLayout.addWidget(self.toolButton)
        self.toolButton_2 = QtGui.QToolButton(self.tbtree)
        self.toolButton_2.setObjectName("toolButton_2")
        self.horizontalLayout.addWidget(self.toolButton_2)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.verticalLayout.addWidget(self.tbtree)
        self.tree = LoggerTree(self.layoutWidget)
        self.tree.setObjectName("tree")
        self.verticalLayout.addWidget(self.tree)
        self.verticalLayout.setStretch(1, 1)
        self.mSplit = Splitter(self.cSplit)
        self.mSplit.setOrientation(QtCore.Qt.Vertical)
        self.mSplit.setObjectName("mSplit")
        self.layoutWidget1 = QtGui.QWidget(self.mSplit)
        self.layoutWidget1.setObjectName("layoutWidget1")
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget1)
        self.verticalLayout_2.setMargin(0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.tbmaster = QtGui.QWidget(self.layoutWidget1)
        self.tbmaster.setEnabled(True)
        self.tbmaster.setObjectName("tbmaster")
        self.gridLayout = QtGui.QGridLayout(self.tbmaster)
        self.gridLayout.setMargin(0)
        self.gridLayout.setObjectName("gridLayout")
        self.wantDebug = QtGui.QCheckBox(self.tbmaster)
        self.wantDebug.setChecked(True)
        self.wantDebug.setObjectName("wantDebug")
        self.gridLayout.addWidget(self.wantDebug, 0, 0, 1, 1)
        self.wantInfo = QtGui.QCheckBox(self.tbmaster)
        self.wantInfo.setChecked(True)
        self.wantInfo.setObjectName("wantInfo")
        self.gridLayout.addWidget(self.wantInfo, 1, 0, 1, 1)
        self.clearAll = QtGui.QToolButton(self.tbmaster)
        self.clearAll.setEnabled(False)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.clearAll.sizePolicy().hasHeightForWidth())
        self.clearAll.setSizePolicy(sizePolicy)
        self.clearAll.setObjectName("clearAll")
        self.gridLayout.addWidget(self.clearAll, 0, 3, 1, 1)
        self.colprefs = QtGui.QToolButton(self.tbmaster)
        self.colprefs.setObjectName("colprefs")
        self.gridLayout.addWidget(self.colprefs, 1, 3, 1, 1)
        self.wantCritical = QtGui.QCheckBox(self.tbmaster)
        self.wantCritical.setChecked(True)
        self.wantCritical.setObjectName("wantCritical")
        self.gridLayout.addWidget(self.wantCritical, 0, 2, 1, 1)
        self.wantAll = QtGui.QCheckBox(self.tbmaster)
        self.wantAll.setChecked(True)
        self.wantAll.setObjectName("wantAll")
        self.gridLayout.addWidget(self.wantAll, 1, 2, 1, 1)
        self.wantError = QtGui.QCheckBox(self.tbmaster)
        self.wantError.setChecked(True)
        self.wantError.setObjectName("wantError")
        self.gridLayout.addWidget(self.wantError, 1, 1, 1, 1)
        self.wantWarning = QtGui.QCheckBox(self.tbmaster)
        self.wantWarning.setChecked(True)
        self.wantWarning.setObjectName("wantWarning")
        self.gridLayout.addWidget(self.wantWarning, 0, 1, 1, 1)
        self.search = QtGui.QToolButton(self.tbmaster)
        self.search.setEnabled(False)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.search.sizePolicy().hasHeightForWidth())
        self.search.setSizePolicy(sizePolicy)
        self.search.setObjectName("search")
        self.gridLayout.addWidget(self.search, 4, 3, 1, 1)
        self.match = QtGui.QLineEdit(self.tbmaster)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.match.sizePolicy().hasHeightForWidth())
        self.match.setSizePolicy(sizePolicy)
        self.match.setObjectName("match")
        self.gridLayout.addWidget(self.match, 4, 1, 1, 1)
        self.matchlabel = QtGui.QLabel(self.tbmaster)
        self.matchlabel.setObjectName("matchlabel")
        self.gridLayout.addWidget(self.matchlabel, 4, 0, 1, 1)
        self.useRegexp = QtGui.QCheckBox(self.tbmaster)
        self.useRegexp.setObjectName("useRegexp")
        self.gridLayout.addWidget(self.useRegexp, 4, 2, 1, 1)
        self.line = QtGui.QFrame(self.tbmaster)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName("line")
        self.gridLayout.addWidget(self.line, 3, 0, 1, 4)
        self.verticalLayout_2.addWidget(self.tbmaster)
        self.master = MasterTable(self.layoutWidget1)
        self.master.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.master.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.master.setObjectName("master")
        self.verticalLayout_2.addWidget(self.master)
        self.verticalLayout_2.setStretch(1, 1)
        self.detail = DetailTable(self.mSplit)
        self.detail.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
        self.detail.setObjectName("detail")
        self.verticalLayout_3.addWidget(self.cSplit)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
        self.menubar.setObjectName("menubar")
        self.menu_Help = QtGui.QMenu(self.menubar)
        self.menu_Help.setObjectName("menu_Help")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.action_About = QtGui.QAction(MainWindow)
        self.action_About.setObjectName("action_About")
        self.menu_Help.addAction(self.action_About)
        self.menubar.addAction(self.menu_Help.menuAction())
        self.matchlabel.setBuddy(self.match)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        MainWindow.setTabOrder(self.toolButton, self.toolButton_2)
        MainWindow.setTabOrder(self.toolButton_2, self.tree)
        MainWindow.setTabOrder(self.tree, self.wantDebug)
        MainWindow.setTabOrder(self.wantDebug, self.wantWarning)
        MainWindow.setTabOrder(self.wantWarning, self.wantCritical)
        MainWindow.setTabOrder(self.wantCritical, self.wantInfo)
        MainWindow.setTabOrder(self.wantInfo, self.wantError)
        MainWindow.setTabOrder(self.wantError, self.wantAll)
        MainWindow.setTabOrder(self.wantAll, self.clearAll)
        MainWindow.setTabOrder(self.clearAll, self.colprefs)
        MainWindow.setTabOrder(self.colprefs, self.match)
        MainWindow.setTabOrder(self.match, self.useRegexp)
        MainWindow.setTabOrder(self.useRegexp, self.search)
        MainWindow.setTabOrder(self.search, self.master)
        MainWindow.setTabOrder(self.master, self.detail)
Beispiel #29
0
    def createActions(self):
        style = QtGui.QApplication.style()

        icon = style.standardIcon(style.SP_FileIcon)
        self.newAct = QtGui.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 = QtGui.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 = QtGui.QAction(icon,
                                     self.tr('&Save'),
                                     self,
                                     shortcut=self.tr('Ctrl+S'),
                                     statusTip=self.tr('Save the document to '
                                                       'disk'),
                                     triggered=self.save)

        self.saveAsAct = QtGui.QAction(self.tr('Save &As...'),
                                       self,
                                       statusTip=self.tr('Save the document '
                                                         'under a new name'),
                                       triggered=self.saveAs)

        self.exitAct = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.QAction(self.tr('&About'),
                                      self,
                                      statusTip=self.tr("Show the "
                                                        "application's About "
                                                        "box"),
                                      triggered=self.about)

        self.aboutQtAct = QtGui.QAction(self.tr('About &Qt'),
                                        self,
                                        statusTip=self.tr("Show the Qt "
                                                          "library's About "
                                                          "box"),
                                        triggered=QtGui.QApplication.aboutQt)
Beispiel #30
0
    def _setupActions(self):
        style = QtGui.QApplication.style()

        actions = QtGui.QActionGroup(self)

        icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/up-128.png')
        QtGui.QAction(icon,
                      self.tr('Move to top'),
                      actions,
                      objectName='moveToTopAction',
                      statusTip=self.tr('Move to top'),
                      shortcut=self.tr('Ctrl+PgUp'))

        icon = style.standardIcon(QtGui.QStyle.SP_ArrowUp)
        QtGui.QAction(icon,
                      self.tr('Move up'),
                      actions,
                      objectName='moveUpAction',
                      statusTip=self.tr('Move up'),
                      shortcut=self.tr('Ctrl+Up'))

        icon = style.standardIcon(QtGui.QStyle.SP_ArrowDown)
        QtGui.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')
        QtGui.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')
        QtGui.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')
        QtGui.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')
        QtGui.QAction(icon,
                      self.tr('Hide'),
                      actions,
                      objectName='hideLayerAction',
                      statusTip=self.tr('Hide the layer'))

        return actions