Example #1
0
    def _load_menu_for_root(self, point):
        """ Carga el menú para el root """

        menu = QMenu(self)
        create_file_action = menu.addAction(QIcon(":image/add"),
                                            self.tr("Agregar Archivo"))
        create_folder_action = menu.addAction(QIcon(":image/new-folder"),
                                              self.tr("Agregar Carpeta"))
        menu.addSeparator()
        refresh_project_action = menu.addAction(QIcon(":image/reload"),
                                                self.tr("Recargar Proyecto"))
        close_project_action = menu.addAction(QIcon(":image/exit"),
                                              self.tr("Cerrar Proyecto"))

        # Conexiones
        self.connect(create_file_action, SIGNAL("triggered()"),
                     self._create_file)
        self.connect(create_folder_action, SIGNAL("triggered()"),
                    self._create_folder)
        self.connect(refresh_project_action, SIGNAL("triggered()"),
                     self._refresh_project)
        self.connect(close_project_action, SIGNAL("triggered()"),
                    self._close_project)

        menu.exec_(self.mapToGlobal(point))
 def showContextMenu(self, pos):
     """show context menu for item at pos"""
     mi = self.treeView.indexAt(pos)
     t, n = self.model.dsNode(mi)
     self.selectedNode = n
     self.selectedMI = mi
     m = QMenu()
     if t == 'R':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Close'), self.closeDatabase)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Reload'), self.reloadDatabase)
     elif t == 'P':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'New sensorgroup'), self.newSensorGroup)
     elif t == 'G':
         nCharts = len(n.charts)
         if nCharts > 0:
             txt = str(QCoreApplication.translate('DataStorageBrowser', 'Show all charts (%d)')) % nCharts
             m.addAction(txt, self.showAllCharts)
             m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Save all charts as images'), self.saveAllChartImages)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Add chart'), self.newChart)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Add/update data'), self.importFiles)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Export data'), self.exportSensors)
     elif t == 'S':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'New plot (Qwt)'), self.showQwtPlot)
         if qwtPlotWindowActive():
             m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Add to plot (Qwt)'), self.addToQwtPlot)
     elif t == 'C':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Show'), self.showChart)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Delete'), self.deleteItem)
     if t in 'RPGS':
         m.addSeparator()
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Edit metadata'), self.editMetadata)
     a = m.exec_(self.treeView.mapToGlobal(pos))
Example #3
0
 def contextMenu(self, point):
     globalPos = self.mapToGlobal(point)
     menu = QMenu()
     resource = self.currentText()
     refreshAction = QAction("&Refresh", menu)
     if len(resource):
         queryIdAction = QAction("Query %s for ID" % resource, menu)
         menu.addAction(queryIdAction)
     else:
         queryIdAction = None
     queryAllAction = QAction("Query all for ID", menu)
     menu.addAction(queryAllAction)
     menu.addSeparator()
     menu.addAction(refreshAction)
     selected = menu.exec_(globalPos)
     
     if selected == queryIdAction:
         print("Query selected")
         thread = QueryIdThread([resource], self)
         thread.idObtained.connect(self.updateToolTip)
         thread.start()
     elif selected == queryAllAction:
         resources = []
         for i in range(self.count()):
             resources.append(self.itemText(i))
         thread = QueryIdThread(resources, self)
         thread.idObtained.connect(self.updateToolTip)
         thread.start()
     elif selected == refreshAction:
         print("Refresh")
         self.populate()
Example #4
0
File: dyr.py Project: iacopy/dyr
    def on_context_menu(self, point):
        sel = self.selection
        popMenu = QMenu()
        # describing objects
        desc = desc_objects(sel)

        # Copy selected objects
        editCopyAction = self.createAction(u"&Copy {}".format(desc), self.edit_copy,
            QKeySequence.Copy, icon='icon_copy', tip=u'Copy selected files to clipboard')
        popMenu.addAction(editCopyAction)

        # AddOns actions
        #popMenu.addSeparator()
        for addon in self.addOns:
            addon.on_context_menu(popMenu, sel)

        # Python command-line scripts
        popMenu.addSeparator()
        for py_fpath in py_scripts:
            dirpath, filename = path.split(py_fpath)
            name, ext = path.splitext(filename)
            menuItemText = u'Run {}'.format(py_fpath)
            scriptAction = self.createAction(menuItemText, slot=self.run_script, icon='icon_python',
                tip=u'Run {} on {}'.format(py_fpath, desc))
            popMenu.addAction(scriptAction)
        popMenu.exec_(self.view.mapToGlobal(point))
Example #5
0
 def onTodoListContextMenuReqeusted(self, pos):
     index = self.tvTodoList.indexAt(pos)
     if index.isValid():
         self.tvTodoList.setCurrentIndex(index)
     menu = QMenu()
     if index.isValid():
         task = self.todoListModel.taskAt(index)
         if task["finishment"] == 0:
             menu.addAction(self.actionMarkProcessing)
             menu.addAction(self.actionMarkFinished)
         elif task["finishment"] < 100:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkFinished)
         else:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkProcessing)
     menu.addSeparator()
     menu.addAction(self.actionCreateTodo)
     if index.isValid():
         menu.addAction(self.actionRemoveTodo)
         menu.addAction(self.actionModifyTodoSubject)
         menu.addAction(self.actionEditTodo)
     try:
         getattr(menu, "exec")(QCursor.pos())
     except AttributeError:
         getattr(menu, "exec_")(QCursor.pos())
Example #6
0
 def createMenu( self, parent ):
     """
     Creates a new menu for the inputed parent item.
     
     :param      parent | <QMenu>
     """
     menu = QMenu(parent)
     menu.setTitle('&View')
     
     act = menu.addAction('Lock/Unlock Layout')
     act.setIcon(QIcon(projexui.resources.find('img/view/lock.png')))
     act.triggered.connect(self.toggleLocked)
     
     menu.addSeparator()
     act = menu.addAction('Export Layout as...')
     act.setIcon(QIcon(projexui.resources.find('img/view/export.png')))
     act.triggered.connect(self.exportProfile)
     
     act = menu.addAction('Import Layout from...')
     act.setIcon(QIcon(projexui.resources.find('img/view/import.png')))
     act.triggered.connect(self.importProfile)
     
     menu.addSeparator()
     act = menu.addAction('Reset Layout')
     act.setIcon(QIcon(projexui.resources.find('img/view/remove.png')))
     act.triggered.connect(self.reset)
     
     return menu
 def showHeaderMenu( self, point ):
     # determine the column that was clicked on
     index = self.uiPlaylistTREE.header().logicalIndexAt(point)
     self._currentHeaderColumn = index
     
     # create the menu
     menu = QMenu(self)
     
     act = menu.addAction( 'Sort Ascending' )
     act.setIcon( resources.icon( 'img/playlist/sort_ascending.png' ) )
     act.triggered.connect( self.sortAscending )
     
     act = menu.addAction( 'Sort Descending' )
     act.setIcon( resources.icon( 'img/playlist/sort_descending.png' ) )
     act.triggered.connect( self.sortDescending )
     
     menu.addSeparator()
     
     # create a columns menu
     columns = menu.addMenu( 'Columns...' )
     columns.setIcon( resources.icon( 'img/playlist/columns.png' ) )
     
     for c, col in enumerate(self.COLUMNS):
         act = columns.addAction( col )
         act.setCheckable(True)
         act.setChecked( not self.uiPlaylistTREE.isColumnHidden(c) )
     
     columns.triggered.connect( self.toggleColumnTriggered )
     
     # popup the menu
     menu.exec_( QCursor.pos() )
Example #8
0
    def show_context_menu(self, item, resource, where):
        menu = QMenu()

        # Load layers action
        action_open_layer = QAction(self.tr(u'Carregar camada'), None)
        action_open_layer.triggered.connect(
            lambda: self._load_layer_on_qgis(resource))
        menu.addAction(action_open_layer)

        # Load layers as...
        # action_open_layer_as = QAction(self.tr(u'Carregar camada como...'), None)
        # action_open_layer_as.triggered.connect(lambda: self._load_layer_from_url(item.text(0), item.text(1)))
        # menu.addAction(action_open_layer_as)

        menu.addSeparator()

        # Montar Operações
        action_open_editor = QAction(self.tr(u'Montar operações'), None)
        action_open_editor.triggered.connect(
            lambda: self.open_operations_editor(item.text(0), item.text(1)))
        menu.addAction(action_open_editor)

        menu.addSeparator()

        action_edit = QAction(self.tr(u'Editar'), None)
        action_edit.triggered.connect(lambda: self.open_edit_dialog(item))
        menu.addAction(action_edit)

        menu.exec_(self.list_resource.viewport().mapToGlobal(where))
Example #9
0
    def _menu_context_tree(self, point):
        """Context menu"""
        index = self.tree.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(translations.TR_FOLD_ALL)
        u_all = menu.addAction(translations.TR_UNFOLD_ALL)
        menu.addSeparator()
        u_class = menu.addAction(translations.TR_UNFOLD_CLASSES)
        u_class_method = menu.addAction(
            translations.TR_UNFOLD_CLASSES_AND_METHODS)
        u_class_attr = menu.addAction(
            translations.TR_UNFOLD_CLASSES_AND_ATTRIBUTES)
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
                     lambda: self.tree.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
                     lambda: self.tree.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
                     self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
                     self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
        #self._save_symbols_state)

        menu.exec_(QCursor.pos())
Example #10
0
    def menu_right(self):
        """
        Create the context menu.
        It shows up on left click.

        Note: icons will not be displayed on every GNU/Linux
        distributions, it depends on the graphical environment.
        """

        if not self.__menu_right:
            style = QApplication.style()
            menu = QMenu()
            menu.addAction(
                style.standardIcon(QStyle.SP_FileDialogInfoView),
                Translator.get('SETTINGS'),
                self.application.show_settings,
            )
            menu.addSeparator()
            menu.addAction(style.standardIcon(QStyle.SP_MessageBoxQuestion),
                           Translator.get('HELP'), self.application.open_help)
            menu.addSeparator()
            menu.addAction(style.standardIcon(QStyle.SP_DialogCloseButton),
                           Translator.get('QUIT'), self.application.quit)
            self.__menu_right = menu

        return self.__menu_right
Example #11
0
    def _onTvFilesCustomContextMenuRequested(self, pos ):
        """Connected automatically by uic
        """
        menu = QMenu()
        
        menu.addAction( core.actionManager().action( "mFile/mClose/aCurrent" ) )
        menu.addAction( core.actionManager().action( "mFile/mSave/aCurrent" ) )
        menu.addAction( core.actionManager().action( "mFile/mReload/aCurrent" ) )
        menu.addSeparator()
        
        # sort menu
        sortMenu = QMenu( self )
        group = QActionGroup( sortMenu )

        group.addAction( self.tr( "Opening order" ) )
        group.addAction( self.tr( "File name" ) )
        group.addAction( self.tr( "URL" ) )
        group.addAction( self.tr( "Suffixes" ) )
        group.triggered.connect(self._onSortTriggered)
        sortMenu.addActions( group.actions() )
        
        for i, sortMode in enumerate(["OpeningOrder", "FileName", "URL", "Suffixes"]):
            action = group.actions()[i]
            action.setData( sortMode )
            action.setCheckable( True )
            if sortMode == self.model.sortMode():
                action.setChecked( True )
        
        aSortMenu = QAction( self.tr( "Sorting" ), self )
        aSortMenu.setMenu( sortMenu )
        aSortMenu.setIcon( QIcon( ":/enkiicons/sort.png" ))
        aSortMenu.setToolTip( aSortMenu.text() )
        
        menu.addAction( sortMenu.menuAction() )
        menu.exec_( self.tvFiles.mapToGlobal( pos ) )
Example #12
0
    def set_menu_registry(self, menu_registry):
        self.menu_registry = menu_registry

        for menu_instance in self.menu_registry.menus():
            try:
                menu_instance.setCanvasMainWindow(self)

                custom_menu = QMenu(menu_instance.name, self)

                sub_menus = menu_instance.getSubMenuNamesList()

                for index in range(0, len(sub_menus)):
                    if menu_instance.isSeparator(sub_menus[index]):
                        custom_menu.addSeparator()
                    else:
                        custom_action = \
                            QAction(sub_menus[index], self,
                                    objectName=sub_menus[index].lower() + "-action",
                                    toolTip=self.tr(sub_menus[index]),
                                    )

                        custom_action.triggered.connect(getattr(menu_instance, 'executeAction_' + str(index+1)))

                        custom_menu.addAction(custom_action)

                self.menuBar().addMenu(custom_menu)
            except Exception as exception:
                print("Error in creating Customized Menu: " + str(menu_instance))
                print(str(exception.args[0]))
                continue
Example #13
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        item = self.itemAt(point)
        handler = None
        menu = QMenu(self)
        if item.isFolder or item.parent() is None:
            self._add_context_menu_for_folders(menu, item)
        elif not item.isFolder:
            self._add_context_menu_for_files(menu, item)
        if item.parent() is None:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(item.projectType)
            self._add_context_menu_for_root(menu, item)

        #menu for all items (legacy API)!
        extra_menus = self.extra_menus.get('all', ())
        #menu for all items!
        extra_menus_by_scope = self.extra_menus_by_scope['all']
        for m in (extra_menus + extra_menus_by_scope):
            if isinstance(m, QMenu):
                menu.addSeparator()
                menu.addMenu(m)
        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(self.tr("Fold all"))
        u_all = menu.addAction(self.tr("Unfold all"))
        menu.addSeparator()
        u_class = menu.addAction(self.tr("Unfold classes"))
        u_class_method = menu.addAction(self.tr("Unfold classes and methods"))
        u_class_attr = menu.addAction(self.tr("Unfold classes and attributes"))
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
                     lambda: self.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
                     lambda: self.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
                     self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
                     self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
Example #15
0
    def _create_menu(self):
        mbar = self._ui.menubar
        menu = QMenu(mbar)
        menu.setTitle("File")

        menu.addAction(self._actions['data_new'])
        menu.addAction(self._actions['session_save'])
        menu.addAction(self._actions['session_restore'])

        menu.addAction(self._actions['tab_new'])
        menu.addAction(self._actions['window_new'])
        mbar.addMenu(menu)

        menu = QMenu(mbar)
        menu.setTitle("Tab")
        menu.addAction(self._actions['tab_new'])
        menu.addAction(self._actions['window_new'])
        menu.addSeparator()
        menu.addAction(self._actions['cascade'])
        menu.addAction(self._actions['tile'])
        menu.addAction(self._actions['tab_rename'])
        mbar.addMenu(menu)

        menu = QMenu(mbar)
        menu.setTitle("Layers")
        menu.addActions(self._ui.layerWidget.actions())
        a = act("Define new component", self,
                tip="Define a new component using python expressions")
        a.triggered.connect(self._create_component)
        menu.addAction(a)

        mbar.addMenu(menu)
Example #16
0
class MenuView(object):

    def __init__(self, menu, parent, main):
        self._main = main
        self._parent = parent

        self.hideConsoleAction = menu.addAction('Show/Hide &Console (F4)')
        self.hideConsoleAction.setCheckable(True)
        self.hideEditorAction = menu.addAction('Show/Hide &Editor (F3)')
        self.hideEditorAction.setCheckable(True)
        self.hideAllAction = menu.addAction('Show/Hide &All (F11)')
        self.hideAllAction.setCheckable(True)
        self.hideExplorerAction = menu.addAction('Show/Hide &Explorer (F2)')
        self.hideExplorerAction.setCheckable(True)
        menu.addSeparator()
        splitTabHAction = menu.addAction(QIcon(resources.images['splitH']), 'Split Tabs Horizontally (F10)')
        splitTabVAction = menu.addAction(QIcon(resources.images['splitV']), 'Split Tabs Vertically (F9)')
        menu.addSeparator()
        #Panels Properties
        self.menuProperties = QMenu('Panels Properties')
        self.splitCentralOrientation = self.menuProperties.addAction('Change Central Splitter Orientation')
        self.splitMainOrientation = self.menuProperties.addAction('Change Main Splitter Orientation')
        self.menuProperties.addSeparator()
        self.splitCentralRotate = self.menuProperties.addAction(QIcon(resources.images['splitCRotate']), 'Rotate Central Panels')
        self.splitMainRotate = self.menuProperties.addAction(QIcon(resources.images['splitMRotate']), 'Rotate GUI Panels')
        menu.addMenu(self.menuProperties)
        menu.addSeparator()
        #Zoom
        zoomInAction = menu.addAction('Zoom &In ('+OS_KEY+'+Wheel-Up)')
        zoomOutAction = menu.addAction('Zoom &Out ('+OS_KEY+'+Wheel-Down)')
        menu.addSeparator()
        fadeInAction = menu.addAction('Fade In (Alt+Wheel-Up)')
        fadeOutAction = menu.addAction('Fade Out (Alt+Wheel-Down)')

        self._parent._toolbar.addSeparator()
        self._parent._toolbar.addAction(splitTabHAction)
        self._parent._toolbar.addAction(splitTabVAction)

        QObject.connect(self.hideConsoleAction, SIGNAL("triggered()"), self._main._hide_container)
        QObject.connect(self.hideEditorAction, SIGNAL("triggered()"), self._main._hide_editor)
        QObject.connect(self.hideExplorerAction, SIGNAL("triggered()"), self._main._hide_explorer)
        QObject.connect(self.hideAllAction, SIGNAL("triggered()"), self._main._hide_all)
        QObject.connect(splitTabHAction, SIGNAL("triggered()"), lambda: self._main.split_tab(True))
        QObject.connect(splitTabVAction, SIGNAL("triggered()"), lambda: self._main.split_tab(False))
        QObject.connect(zoomInAction, SIGNAL("triggered()"), lambda: self._main._central.actual_tab().obtain_editor().zoom_in())
        QObject.connect(zoomOutAction, SIGNAL("triggered()"), lambda: self._main._central.actual_tab().obtain_editor().zoom_out())
        QObject.connect(self.splitCentralOrientation, SIGNAL("triggered()"), self._main._splitter_central_orientation)
        QObject.connect(self.splitMainOrientation, SIGNAL("triggered()"), self._main._splitter_main_orientation)
        QObject.connect(self.splitCentralRotate, SIGNAL("triggered()"), self._main._splitter_central_rotate)
        QObject.connect(self.splitMainRotate, SIGNAL("triggered()"), self._main._splitter_main_rotate)
        QObject.connect(fadeInAction, SIGNAL("triggered()"), self._fade_in)
        QObject.connect(fadeOutAction, SIGNAL("triggered()"), self._fade_out)

    def _fade_in(self):
        event = QWheelEvent(QPoint(), 120, Qt.NoButton, Qt.AltModifier)
        self._parent.wheelEvent(event)

    def _fade_out(self):
        event = QWheelEvent(QPoint(), -120, Qt.NoButton, Qt.AltModifier)
        self._parent.wheelEvent(event)
    def _menu_context_tree(self, point, isRoot=False, root_path=None):
        index = self.indexAt(point)
        if not index.isValid() and not isRoot:
            return

        handler = None
        menu = QMenu(self)
        if isRoot or self.model().isDir(index):
            self._add_context_menu_for_folders(menu, isRoot, root_path)
        else:
            filename = self.model().fileName(index)
            lang = file_manager.get_file_extension(filename)
            self._add_context_menu_for_files(menu, lang)
        if isRoot:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(
                self.project.project_type)
            self._add_context_menu_for_root(menu)

        menu.addMenu(self._folding_menu)

        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
Example #18
0
    def menu_right(self):
        """
        Create the context menu.
        It shows up on left click.

        Note: icons will not be displayed on every GNU/Linux
        distributions, it depends on the graphical environment.
        """

        if not self.__menu_right:
            style = QApplication.style()
            menu = QMenu()
            menu.addAction(
                style.standardIcon(QStyle.SP_FileDialogInfoView),
                Translator.get('SETTINGS'),
                self.application.show_settings,
            )
            menu.addSeparator()
            menu.addAction(
                style.standardIcon(QStyle.SP_MessageBoxQuestion),
                Translator.get('HELP'),
                self.application.open_help)
            menu.addSeparator()
            menu.addAction(
                style.standardIcon(QStyle.SP_DialogCloseButton),
                Translator.get('QUIT'),
                self.application.quit)
            self.__menu_right = menu

        return self.__menu_right
Example #19
0
 def createContextMenu(self):
     if not self._view.currentNode():
         return None
     menu = QMenu()
     node = self._view.currentNode()
     if node.nodeType() == QgsLayerTreeNode.NodeGroup:
         menu.addAction(self._zoomGroup)
         if not self._plugin.isArkGroup(node.name()):
             menu.addAction(self._rename)
             menu.addAction(self._remove)
         if node.name() == self._plugin.drawingsGroupName:
             menu.addAction(self._removeDrawings)
     elif node.nodeType() == QgsLayerTreeNode.NodeLayer:
         menu.addAction(self._zoomLayer)
         if node.layer().type() == QgsMapLayer.VectorLayer:
             menu.addAction(self._featureCount)
             menu.addAction(self._openAttributes)
         layerId = node.layerId()
         parent = node.parent()
         if parent.nodeType() == QgsLayerTreeNode.NodeGroup and parent.name(
         ) == self._plugin.drawingsGroupName:
             menu.addAction(self._removeDrawings)
         if not self._plugin.isArkLayer(layerId):
             menu.addSeparator()
             menu.addAction(self._rename)
             menu.addAction(self._remove)
             if not QgsProject.instance().layerIsEmbedded(layerId):
                 menu.addAction(self._openProperties)
     return menu
Example #20
0
    def contextMenuEvent(self, ev):
        index = self.indexAt(ev.pos())
        if not index.isValid():
            return

        if index != self.currentIndex():
            self.itemChanged(index)

        item = self.currentItem()

        menu = QMenu(self)

        if isinstance(item, (Table, Schema)):
            menu.addAction(self.tr("Rename"), self.rename)
            menu.addAction(self.tr("Delete"), self.delete)

            if isinstance(item, Table) and item.canBeAddedToCanvas():
                menu.addSeparator()
                menu.addAction(self.tr("Add to canvas"), self.addLayer)

        elif isinstance(item, DBPlugin):
            if item.database() is not None:
                menu.addAction(self.tr("Re-connect"), self.reconnect)
            menu.addAction(self.tr("Remove"), self.delete)

        elif not index.parent().isValid() and item.typeName() == "spatialite":
            menu.addAction(self.tr("New Connection..."), self.newConnection)

        if not menu.isEmpty():
            menu.exec_(ev.globalPos())

        menu.deleteLater()
Example #21
0
    def showHeaderMenu(self, point):
        # determine the column that was clicked on
        index = self.uiPlaylistTREE.header().logicalIndexAt(point)
        self._currentHeaderColumn = index

        # create the menu
        menu = QMenu(self)

        act = menu.addAction('Sort Ascending')
        act.setIcon(resources.icon('img/playlist/sort_ascending.png'))
        act.triggered.connect(self.sortAscending)

        act = menu.addAction('Sort Descending')
        act.setIcon(resources.icon('img/playlist/sort_descending.png'))
        act.triggered.connect(self.sortDescending)

        menu.addSeparator()

        # create a columns menu
        columns = menu.addMenu('Columns...')
        columns.setIcon(resources.icon('img/playlist/columns.png'))

        for c, col in enumerate(self.COLUMNS):
            act = columns.addAction(col)
            act.setCheckable(True)
            act.setChecked(not self.uiPlaylistTREE.isColumnHidden(c))

        columns.triggered.connect(self.toggleColumnTriggered)

        # popup the menu
        menu.exec_(QCursor.pos())
 def showContextMenu(self, pos):
     """show context menu for item at pos"""
     mi = self.treeView.indexAt(pos)
     t, n = self.model.dsNode(mi)
     self.selectedNode = n
     self.selectedMI = mi
     m = QMenu()
     if t == 'R':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Close'), self.closeDatabase)
     elif t == 'P':
         pass
     elif t == 'G':
         nCharts = len(n.charts)
         if nCharts > 0:
             txt = str(QCoreApplication.translate('DataStorageBrowser', 'Show all Charts (%d)')) % nCharts
             m.addAction(txt, self.showAllCharts)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Add Chart'), self.newChart)
     elif t == 'S':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Plot (Qwt)'), self.showQwtPlot)
     elif t == 'C':
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Show'), self.showMplChart)
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Delete'), self.deleteItem)
     if t in 'RPGS':
         m.addSeparator()
         m.addAction(QCoreApplication.translate('DataStorageBrowser', 'Edit metadata'), self.editMetadata)
     a = m.exec_(self.treeView.mapToGlobal(pos))
Example #23
0
    def _load_menu_combo_file(self, point):
        """ Muestra el menú """

        menu = QMenu()
        editor_container = Edis.get_component("principal")
        save_as_action = menu.addAction(QIcon(":image/save-as"),
                                        self.tr("Guardar como..."))
        reload_action = menu.addAction(QIcon(":image/reload"),
                                       self.tr("Recargar"))
        menu.addSeparator()
        compile_action = menu.addAction(QIcon(":image/build"),
                                        self.tr("Compilar"))
        execute_action = menu.addAction(QIcon(":image/run"),
                                        self.tr("Ejecutar"))
        menu.addSeparator()
        close_action = menu.addAction(QIcon(":image/close"),
                                      self.tr("Cerrar archivo"))

        # Conexiones
        self.connect(save_as_action, SIGNAL("triggered()"),
                     editor_container.save_file_as)
        self.connect(reload_action, SIGNAL("triggered()"),
                     editor_container.reload_file)
        self.connect(compile_action, SIGNAL("triggered()"),
                     editor_container.build_source_code)
        self.connect(execute_action, SIGNAL("triggered()"),
                     editor_container.run_binary)
        self.connect(close_action, SIGNAL("triggered()"),
                     editor_container.close_file)

        menu.exec_(self.mapToGlobal(point))
Example #24
0
class TrayIconUpdates(QSystemTrayIcon):
    def __init__(self, parent):
        QSystemTrayIcon.__init__(self, parent)
        icon = QIcon(resources.IMAGES['iconUpdate'])
        self.setIcon(icon)
        self.setup_menu()

        if settings.NOTIFY_UPDATES:
            self.thread = ThreadUpdates()

            self.connect(self.thread, SIGNAL("finished()"),
                         self._show_messages)
            self.thread.start()
        else:
            self.show = self.hide

    def setup_menu(self, show_downloads=False):
        self.menu = QMenu()
        if show_downloads:
            self.download = QAction(self.tr("Download Version: %1!").arg(
                self.thread.ide['version']),
                                    self,
                                    triggered=self._show_download)
            self.menu.addAction(self.download)
            self.menu.addSeparator()
        self.quit_action = QAction(self.tr("Close Update Notifications"),
                                   self,
                                   triggered=self.hide)
        self.menu.addAction(self.quit_action)

        self.setContextMenu(self.menu)

    def _show_messages(self):
        try:
            local_version = version.LooseVersion(ninja_ide.__version__)
            web_version = version.LooseVersion(self.thread.ide['version'])
            if local_version < web_version:
                if self.supportsMessages():
                    self.setup_menu(True)
                    self.showMessage(self.tr("NINJA-IDE Updates"),
                        self.tr("New Version of NINJA-IDE\nAvailable: ") + \
                        self.thread.ide['version'] + \
                        self.tr("\n\nCheck the Update Icon Menu to Download!"),
                        QSystemTrayIcon.Information, 10000)
                else:
                    button = QMessageBox.information(self.parent(),
                        self.tr("NINJA-IDE Updates"),
                        self.tr("New Version of NINJA-IDE\nAvailable: ") + \
                        self.thread.ide['version'])
                    if button == QMessageBox.Ok:
                        self._show_download()
            else:
                self.hide()
        except:
            logger.warning('Versions can not be compared.')
            self.hide()

    def _show_download(self):
        webbrowser.open(self.thread.ide['downloads'])
        self.hide()
Example #25
0
class CategorySelector( QToolButton ):
    def __init__( self, items, parent = None ):
        QToolButton.__init__( self, parent )
        self.setText( "All categories" )

        self.setPopupMode( QToolButton.InstantPopup )

        self.menu = QMenu( self )
        self.setMenu( self.menu )

        self.items = items
        self.actions = map( self.createAction, self.items )
        self.menu.addSeparator()
        self.menu.addAction( "Select All" )
        self.menu.addAction( "Select None" )

        self.connect( self.menu, SIGNAL( 'aboutToShow()' ), self.slotMenuAboutToShow )

    def createAction( self, item ):
        action = self.menu.addAction( item )
        action.setCheckable( True )
        action.setChecked( True )
        return action

    def slotMenuAboutToShow( self ):
        self.menu.setMinimumWidth( self.width() )
Example #26
0
    def showPopupMenu(self, point):
        item = self.algorithmTree.itemAt(point)
        if isinstance(item, TreeAlgorithmItem):
            alg = item.alg
            popupmenu = QMenu()
            executeAction = QAction(self.tr("Execute"), self.algorithmTree)
            executeAction.triggered.connect(self.executeAlgorithm)
            popupmenu.addAction(executeAction)
            if alg.canRunInBatchMode and not alg.allowOnlyOpenedLayers:
                executeBatchAction = QAction(self.tr("Execute as batch process"), self.algorithmTree)
                executeBatchAction.triggered.connect(self.executeAlgorithmAsBatchProcess)
                popupmenu.addAction(executeBatchAction)
            popupmenu.addSeparator()
            editRenderingStylesAction = QAction(self.tr("Edit rendering styles for outputs"), self.algorithmTree)
            editRenderingStylesAction.triggered.connect(self.editRenderingStyles)
            popupmenu.addAction(editRenderingStylesAction)
            actions = Processing.contextMenuActions
            if len(actions) > 0:
                popupmenu.addSeparator()
            for action in actions:
                action.setData(alg, self)
                if action.isEnabled():
                    contextMenuAction = QAction(action.name, self.algorithmTree)
                    contextMenuAction.triggered.connect(action.execute)
                    popupmenu.addAction(contextMenuAction)

            popupmenu.exec_(self.algorithmTree.mapToGlobal(point))
Example #27
0
    def _menu_context_tree(self, point, isRoot=False, root_path=None):
        index = self.indexAt(point)
        if not index.isValid() and not isRoot:
            return

        handler = None
        menu = QMenu(self)
        if isRoot or self.model().isDir(index):
            self._add_context_menu_for_folders(menu, isRoot, root_path)
        else:
            filename = self.model().fileName(index)
            lang = file_manager.get_file_extension(filename)
            self._add_context_menu_for_files(menu, lang)
        if isRoot:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(
                self.project.project_type)
            self._add_context_menu_for_root(menu)

        menu.addMenu(self._folding_menu)

        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
Example #28
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        item = self.itemAt(point)
        handler = None
        menu = QMenu(self)
        if item.isFolder or item.parent() is None:
            self._add_context_menu_for_folders(menu, item)
        elif not item.isFolder:
            self._add_context_menu_for_files(menu, item)
        if item.parent() is None:
            #get the extra context menu for this projectType
            handler = settings.get_project_type_handler(item.projectType)
            self._add_context_menu_for_root(menu, item)

        menu.addMenu(self._folding_menu)

        #menu for all items (legacy API)!
        extra_menus = self.extra_menus.get('all', ())
        #menu for all items!
        for m in extra_menus:
            if isinstance(m, QMenu):
                menu.addSeparator()
                menu.addMenu(m)
        #menu for the Project Type(if present)
        if handler:
            for m in handler.get_context_menus():
                if isinstance(m, QMenu):
                    menu.addSeparator()
                    menu.addMenu(m)
        #show the menu!
        menu.exec_(QCursor.pos())
Example #29
0
 def onTodoListContextMenuReqeusted(self, pos):
     index = self.tvTodoList.indexAt(pos)
     if index.isValid():
         self.tvTodoList.setCurrentIndex(index)
     menu = QMenu()
     if index.isValid():
         task = self.todoListModel.taskAt(index)
         if task["finishment"] == 0:
             menu.addAction(self.actionMarkProcessing)
             menu.addAction(self.actionMarkFinished)
         elif task["finishment"] < 100:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkFinished)
         else:
             menu.addAction(self.actionMarkUnfinished)
             menu.addAction(self.actionMarkProcessing)
     menu.addSeparator()
     menu.addAction(self.actionCreateTodo)
     if index.isValid():
         menu.addAction(self.actionRemoveTodo)
         menu.addAction(self.actionModifyTodoSubject)
         menu.addAction(self.actionEditTodo)
     try:
         getattr(menu, "exec")(QCursor.pos())
     except AttributeError:
         getattr(menu, "exec_")(QCursor.pos())
Example #30
0
def layercontextmenu(layer, pos, parent=None):
    '''Show a context menu to manipulate properties of layer.

    layer -- a volumina layer instance
    pos -- QPoint 

    '''
    menu = QMenu("Menu", parent)

    # Title
    title = QAction("%s" % layer.name, menu)
    title.setEnabled(False)
    menu.addAction(title)

    # Export
    global _has_lazyflow
    if _has_lazyflow:
        export = QAction("Export...", menu)
        export.setStatusTip("Export Layer...")
        export.triggered.connect(
            partial(get_settings_and_export_layer, layer, menu))

    menu.addAction(export)
    menu.addSeparator()
    _add_actions(layer, menu)

    # Layer-custom context menu items
    menu.addSeparator()
    for name, callback in layer.contexts:
        action = QAction(name, menu)
        action.triggered.connect(callback)
        menu.addAction(action)

    menu.exec_(pos)
Example #31
0
    def createMenu(self, parent):
        """
        Creates a new menu for the inputed parent item.
        
        :param      parent | <QMenu>
        """
        menu = QMenu(parent)
        menu.setTitle('&View')

        act = menu.addAction('Lock/Unlock Layout')
        act.setIcon(QIcon(projexui.resources.find('img/view/lock.png')))
        act.triggered.connect(self.toggleLocked)

        menu.addSeparator()
        act = menu.addAction('Export Layout as...')
        act.setIcon(QIcon(projexui.resources.find('img/view/export.png')))
        act.triggered.connect(self.exportProfile)

        act = menu.addAction('Import Layout from...')
        act.setIcon(QIcon(projexui.resources.find('img/view/import.png')))
        act.triggered.connect(self.importProfile)

        menu.addSeparator()
        act = menu.addAction('Reset Layout')
        act.setIcon(QIcon(projexui.resources.find('img/view/remove.png')))
        act.triggered.connect(self.reset)

        return menu
Example #32
0
class ScripterMenu(QObject):
    """
    Scripter menu item in mainWindow menubar
    """

    def __init__(self, parent):
        QObject.__init__(self, parent)
        self.setObjectName("Menu")
        self.popup = QMenu(i18n("Scripter"))
        MenuHooks().insertMenuAfter("E&xtras", self.popup)
        self._load_entries()


    def _load_entries(self):
        for path in [scripter_path, os.path.expanduser("~/.scribus/scripter/")]:
            autoload_path = os.path.join(path, "autoload")
            if not os.path.exists(autoload_path):
                continue
            sys.path.insert(0, autoload_path)
            from scribusscript import load_scripts
            self.autoload_scripts = scripts = load_scripts(autoload_path)
            for sd in scripts:
                try:
                    sd.install()
                except:
                    excepthook.show_current_error(i18n("Error installing %r") % sd.name)


    def addAction(self, title, callback, *args):
        self.popup.addAction(title, callback, *args)


    def addSeparator(self):
        self.popup.addSeparator()
Example #33
0
class ScripterMenu(QObject):
    """
    Scripter menu item in mainWindow menubar
    """
    def __init__(self, parent):
        QObject.__init__(self, parent)
        self.setObjectName("Menu")
        self.popup = QMenu(i18n("Scripter"))
        MenuHooks().insertMenuAfter("E&xtras", self.popup)
        self._load_entries()

    def _load_entries(self):
        for path in [
                scripter_path,
                os.path.expanduser("~/.scribus/scripter/")
        ]:
            autoload_path = os.path.join(path, "autoload")
            if not os.path.exists(autoload_path):
                continue
            sys.path.insert(0, autoload_path)
            from scribusscript import load_scripts
            self.autoload_scripts = scripts = load_scripts(autoload_path)
            for sd in scripts:
                try:
                    sd.install()
                except:
                    excepthook.show_current_error(
                        i18n("Error installing %r") % sd.name)

    def addAction(self, title, callback, *args):
        self.popup.addAction(title, callback, *args)

    def addSeparator(self):
        self.popup.addSeparator()
Example #34
0
    def _menu_context_tree(self, point):
        """Context menu"""
        index = self.tree.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(translations.TR_FOLD_ALL)
        u_all = menu.addAction(translations.TR_UNFOLD_ALL)
        menu.addSeparator()
        u_class = menu.addAction(translations.TR_UNFOLD_CLASSES)
        u_class_method = menu.addAction(
                         translations.TR_UNFOLD_CLASSES_AND_METHODS)
        u_class_attr = menu.addAction(
                       translations.TR_UNFOLD_CLASSES_AND_ATTRIBUTES)
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
            lambda: self.tree.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
            lambda: self.tree.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
            self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
            self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
Example #35
0
    def textEffectMenu(self):
        format = self.currentCharFormat()
        cursor = self.textCursor()
        blockformat = cursor.blockFormat()
        menu = QMenu("Text Effect")
        for text, shortcut, data, checked in (
                ("&Bold", "Ctrl+B", notetextedit.Bold,
                 self.fontWeight() > QFont.Normal),
                ("&Italic", "Ctrl+I", notetextedit.Italic,
                 self.fontItalic()),
                ("&Monospaced", None, notetextedit.Code,
                 self.fontFixedPitch())
                ): 

            action = menu.addAction(text, self.setTextEffect)
            #if shortcut is not None:
                #action.setShortcut(QKeySequence(shortcut)) # becau
            action.setData(QVariant(data))
            action.setCheckable(True)
            action.setChecked(checked)

        menu.addSeparator()

        action = menu.addAction("Anchor", self.setTextEffect)
        action.setData(notetextedit.Anchor)

        action = menu.addAction("Code Block", self.setTextEffect)
        action.setData(notetextedit.Pre)

        action = menu.addAction("Numbered List", self.setTextEffect)
        action.setData(notetextedit.List)

        header_menu = QMenu("Header")
        action = header_menu.addAction('H1', self.setTextEffect)
        action.setData(notetextedit.H1)
        action.setCheckable(True)
        action.setChecked(self.which_header()=='H1')

        action = header_menu.addAction('H2', self.setTextEffect)
        action.setData(notetextedit.H2)
        action.setCheckable(True)
        action.setChecked(self.which_header()=='H2')

        action = header_menu.addAction('H3', self.setTextEffect)
        action.setData(notetextedit.H3)
        action.setCheckable(True)
        action.setChecked(self.which_header()=='H3')

        action = menu.addAction("Remove All Formatting", self.setTextEffect)
        action.setData(notetextedit.Remove)

        menu.addMenu(header_menu)

        menu.addSeparator()

        action = menu.addAction("Save", self.setTextEffect)
        action.setData(notetextedit.Save)

        self.ensureCursorVisible()
        menu.exec_(self.viewport().mapToGlobal(self.cursorRect().center()))
Example #36
0
    def _menu_context_tree(self, point):
        index = self.indexAt(point)
        if not index.isValid():
            return

        menu = QMenu(self)
        f_all = menu.addAction(self.tr("Fold all"))
        u_all = menu.addAction(self.tr("Unfold all"))
        menu.addSeparator()
        u_class = menu.addAction(self.tr("Unfold classes"))
        u_class_method = menu.addAction(self.tr("Unfold classes and methods"))
        u_class_attr = menu.addAction(self.tr("Unfold classes and attributes"))
        menu.addSeparator()
        #save_state = menu.addAction(self.tr("Save State"))

        self.connect(f_all, SIGNAL("triggered()"),
            lambda: self.collapseAll())
        self.connect(u_all, SIGNAL("triggered()"),
            lambda: self.expandAll())
        self.connect(u_class, SIGNAL("triggered()"), self._unfold_class)
        self.connect(u_class_method, SIGNAL("triggered()"),
            self._unfold_class_method)
        self.connect(u_class_attr, SIGNAL("triggered()"),
            self._unfold_class_attribute)
        #self.connect(save_state, SIGNAL("triggered()"),
            #self._save_symbols_state)

        menu.exec_(QCursor.pos())
 def showMenu( self ):
     """
     Creates a menu to display for the editing of template information.
     """
     item = self.uiMenuTREE.currentItem()
     
     menu = QMenu(self)
     act = menu.addAction('Add Menu...')
     act.setIcon(QIcon(projexui.resources.find('img/folder.png')))
     act.triggered.connect(self.createMenu)
     
     if ( item and item.data(0, Qt.UserRole) == 'menu' ):
         act = menu.addAction('Rename Menu...')
         ico = QIcon(projexui.resources.find('img/edit.png'))
         act.setIcon(ico)
         act.triggered.connect(self.renameMenu)
     
     act = menu.addAction('Add Separator')
     act.setIcon(QIcon(projexui.resources.find('img/ui/splitter.png')))
     act.triggered.connect(self.createSeparator)
     
     menu.addSeparator()
     
     act = menu.addAction('Remove Item')
     act.setIcon(QIcon(projexui.resources.find('img/remove.png')))
     act.triggered.connect(self.removeItem)
     act.setEnabled(item is not None)
     
     menu.exec_(QCursor.pos())
Example #38
0
 def slotShowContextMenu(self, pos):
     hit = self.webview.page().currentFrame().hitTestContent(pos)
     menu = QMenu()
     if hit.linkUrl().isValid():
         a = self.webview.pageAction(QWebPage.CopyLinkToClipboard)
         a.setIcon(icons.get("edit-copy"))
         a.setText(_("Copy &Link"))
         menu.addAction(a)
         menu.addSeparator()
         a = menu.addAction(icons.get("window-new"),
                            _("Open Link in &New Window"))
         a.triggered.connect(
             (lambda url: lambda: self.slotNewWindow(url))(hit.linkUrl()))
     else:
         if hit.isContentSelected():
             a = self.webview.pageAction(QWebPage.Copy)
             a.setIcon(icons.get("edit-copy"))
             a.setText(_("&Copy"))
             menu.addAction(a)
             menu.addSeparator()
         a = menu.addAction(icons.get("window-new"),
                            _("Open Document in &New Window"))
         a.triggered.connect((lambda url: lambda: self.slotNewWindow(url))(
             self.webview.url()))
     if menu.actions():
         menu.exec_(self.webview.mapToGlobal(pos))
def showContextMenu(self):
    opts = [
        [_("Mark Note"), "*", self.onMark],
        [_("Bury Note"), "-", self.onBuryNote],
        [_("Suspend Card"), "@", self.onSuspendCard],
        [_("Suspend Note"), "!", self.onSuspend],
        [_("Delete Note"), "Delete", self.onDelete],
        [_("Options"), "O", self.onOptions],
        None,
        [_("Replay Audio"), "R", self.replayAudio],
        [_("Record Own Voice"), "Shift+V", self.onRecordVoice],
        [_("Replay Own Voice"), "V", self.onReplayRecorded],
    ]
    m = QMenu(self.mw)
    for row in opts:
        if not row:
            m.addSeparator()
            continue
        label, scut, func = row
        a = m.addAction(label)
        a.setShortcut(QKeySequence(scut))
        a.connect(a, SIGNAL("triggered()"), func)
        #Only change is the following statement
    runHook("Reviewer.contextMenuEvent", self, m)
    m.exec_(QCursor.pos())
    def showMenu(self):
        """
        Creates a menu to display for the editing of template information.
        """
        item = self.uiMenuTREE.currentItem()

        menu = QMenu(self)
        act = menu.addAction('Add Menu...')
        act.setIcon(QIcon(projexui.resources.find('img/folder.png')))
        act.triggered.connect(self.createMenu)

        if (item and item.data(0, Qt.UserRole) == 'menu'):
            act = menu.addAction('Rename Menu...')
            ico = QIcon(projexui.resources.find('img/edit.png'))
            act.setIcon(ico)
            act.triggered.connect(self.renameMenu)

        act = menu.addAction('Add Separator')
        act.setIcon(QIcon(projexui.resources.find('img/ui/splitter.png')))
        act.triggered.connect(self.createSeparator)

        menu.addSeparator()

        act = menu.addAction('Remove Item')
        act.setIcon(QIcon(projexui.resources.find('img/remove.png')))
        act.triggered.connect(self.removeItem)
        act.setEnabled(item is not None)

        menu.exec_(QCursor.pos())
def showContextMenu(self):
    opts = [
        [_("Mark Note"), "*", self.onMark],
        [_("Bury Note"), "-", self.onBuryNote],
        [_("Suspend Card"), "@", self.onSuspendCard],
        [_("Suspend Note"), "!", self.onSuspend],
        [_("Delete Note"), "Delete", self.onDelete],
        [_("Options"), "O", self.onOptions],
        None,
        [_("Replay Audio"), "R", self.replayAudio],
        [_("Record Own Voice"), "Shift+V", self.onRecordVoice],
        [_("Replay Own Voice"), "V", self.onReplayRecorded],
    ]
    m = QMenu(self.mw)
    for row in opts:
        if not row:
            m.addSeparator()
            continue
        label, scut, func = row
        a = m.addAction(label)
        a.setShortcut(QKeySequence(scut))
        a.connect(a, SIGNAL("triggered()"), func)
        #Only change is the following statement
    runHook("Reviewer.contextMenuEvent", self, m)
    m.exec_(QCursor.pos())
Example #42
0
def layercontextmenu( layer, pos, parent=None, volumeEditor = None ):
    '''Show a context menu to manipulate properties of layer.

    layer -- a volumina layer instance
    pos -- QPoint 

    '''
    def onExport():
        
        if _has_lazyflow:
            inputArray = layer.datasources[0].request((slice(None),)).wait()
            expDlg = ExportDialog(parent = menu)
            g = Graph()
            piper = OpArrayPiper(g)
            piper.inputs["Input"].setValue(inputArray)
            expDlg.setInput(piper.outputs["Output"],g)
        expDlg.show()
        
    menu = QMenu("Menu", parent)
    title = QAction("%s" % layer.name, menu)
    title.setEnabled(False)
    
    export = QAction("Export...",menu)
    export.setStatusTip("Export Layer...")
    export.triggered.connect(onExport)
    
    menu.addAction(title)
    menu.addAction(export)
    menu.addSeparator()
    _add_actions( layer, menu )
    menu.exec_(pos)    
Example #43
0
    def showPopupMenu(self, point):
        item = self.algorithmTree.itemAt(point)
        if isinstance(item, TreeAlgorithmItem):
            alg = item.alg
            popupmenu = QMenu()
            executeAction = QAction(self.tr('Execute'), self.algorithmTree)
            executeAction.triggered.connect(self.executeAlgorithm)
            popupmenu.addAction(executeAction)
            if alg.canRunInBatchMode and not alg.allowOnlyOpenedLayers:
                executeBatchAction = QAction(
                    self.tr('Execute as batch process'),
                    self.algorithmTree)
                executeBatchAction.triggered.connect(
                    self.executeAlgorithmAsBatchProcess)
                popupmenu.addAction(executeBatchAction)
            popupmenu.addSeparator()
            editRenderingStylesAction = QAction(
                self.tr('Edit rendering styles for outputs'),
                self.algorithmTree)
            editRenderingStylesAction.triggered.connect(
                self.editRenderingStyles)
            popupmenu.addAction(editRenderingStylesAction)
            actions = Processing.contextMenuActions
            if len(actions) > 0:
                popupmenu.addSeparator()
            for action in actions:
                action.setData(alg, self)
                if action.isEnabled():
                    contextMenuAction = QAction(action.name,
                                                self.algorithmTree)
                    contextMenuAction.triggered.connect(action.execute)
                    popupmenu.addAction(contextMenuAction)

            popupmenu.exec_(self.algorithmTree.mapToGlobal(point))
 def showContextMenu(self, pos):
     """show context menu for item at pos"""
     mi = self.treeView.indexAt(pos)
     t, n = self.model.dsNode(mi)
     self.selectedNode = n
     self.selectedMI = mi
     m = QMenu()
     if t == "R":
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Close"), self.closeDatabase)
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Reload"), self.reloadDatabase)
     elif t == "P":
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "New sensorgroup"), self.newSensorGroup)
     elif t == "G":
         nCharts = len(n.getCharts())
         if nCharts > 0:
             txt = str(QCoreApplication.translate("DataStorageBrowser", "Show all charts (%d)")) % nCharts
             m.addAction(txt, self.showAllCharts)
             m.addAction(
                 QCoreApplication.translate("DataStorageBrowser", "Save all charts as images"),
                 self.saveAllChartImages,
             )
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Add chart"), self.newChart)
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Add/update data"), self.importFiles)
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Export data"), self.exportSensors)
     elif t == "S":
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "New plot (Qwt)"), self.showQwtPlot)
         if qwtPlotWindowActive():
             m.addAction(QCoreApplication.translate("DataStorageBrowser", "Add to plot (Qwt)"), self.addToQwtPlot)
     elif t == "C":
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Show"), self.showChart)
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Delete"), self.deleteItem)
     if t in "RPGS":
         m.addSeparator()
         m.addAction(QCoreApplication.translate("DataStorageBrowser", "Edit metadata"), self.editMetadata)
     a = m.exec_(self.treeView.mapToGlobal(pos))
Example #45
0
    def textEffectMenu(self):
        format = self.currentCharFormat()
        cursor = self.textCursor()
        blockformat = cursor.blockFormat()
        menu = QMenu("Text Effect")
        for text, shortcut, data, checked in (
                ("&Bold", "Ctrl+B", notetextedit.Bold,
                 self.fontWeight() > QFont.Normal),
                ("&Italic", "Ctrl+I", notetextedit.Italic,
                 self.fontItalic()),
                ("&Monospaced", None, notetextedit.Code,
                 self.fontFixedPitch())
                ):

            action = menu.addAction(text, self.setTextEffect)
            #if shortcut is not None:
                #action.setShortcut(QKeySequence(shortcut)) # becau
            action.setData(QVariant(data))
            action.setCheckable(True)
            action.setChecked(checked)

        menu.addSeparator()

        action = menu.addAction("Anchor", self.setTextEffect)
        action.setData(notetextedit.Anchor)

        action = menu.addAction("Code Block", self.setTextEffect)
        action.setData(notetextedit.Pre)

        action = menu.addAction("Numbered List", self.setTextEffect)
        action.setData(notetextedit.List)

        header_menu = QMenu("Header")
        action = header_menu.addAction('H1', self.setTextEffect)
        action.setData(notetextedit.H1)
        action.setCheckable(True)
        action.setChecked(self.which_header()=='H1')

        action = header_menu.addAction('H2', self.setTextEffect)
        action.setData(notetextedit.H2)
        action.setCheckable(True)
        action.setChecked(self.which_header()=='H2')

        action = header_menu.addAction('H3', self.setTextEffect)
        action.setData(notetextedit.H3)
        action.setCheckable(True)
        action.setChecked(self.which_header()=='H3')

        action = menu.addAction("Remove All Formatting", self.setTextEffect)
        action.setData(notetextedit.Remove)

        menu.addMenu(header_menu)

        menu.addSeparator()

        action = menu.addAction("Save", self.setTextEffect)
        action.setData(notetextedit.Save)

        self.ensureCursorVisible()
        menu.exec_(self.viewport().mapToGlobal(self.cursorRect().center()))
Example #46
0
class CategorySelector(QToolButton):
    def __init__(self, items, parent=None):
        QToolButton.__init__(self, parent)
        self.setText("All categories")

        self.setPopupMode(QToolButton.InstantPopup)

        self.menu = QMenu(self)
        self.setMenu(self.menu)

        self.items = items
        self.actions = map(self.createAction, self.items)
        self.menu.addSeparator()
        self.menu.addAction("Select All")
        self.menu.addAction("Select None")

        self.connect(self.menu, SIGNAL('aboutToShow()'),
                     self.slotMenuAboutToShow)

    def createAction(self, item):
        action = self.menu.addAction(item)
        action.setCheckable(True)
        action.setChecked(True)
        return action

    def slotMenuAboutToShow(self):
        self.menu.setMinimumWidth(self.width())
Example #47
0
def layercontextmenu( layer, pos, parent=None ):
    '''Show a context menu to manipulate properties of layer.

    layer -- a volumina layer instance
    pos -- QPoint 

    '''
    menu = QMenu("Menu", parent)

    # Title
    title = QAction("%s" % layer.name, menu)
    title.setEnabled(False)
    menu.addAction(title)

    # Export
    global _has_lazyflow
    if _has_lazyflow:    
        export = QAction("Export...",menu)
        export.setStatusTip("Export Layer...")
        export.triggered.connect( partial( get_settings_and_export_layer, layer, menu ) )

    menu.addAction(export)
    menu.addSeparator()
    _add_actions( layer, menu )

    # Layer-custom context menu items
    menu.addSeparator()
    for name, callback in layer.contexts:
        action = QAction(name, menu)
        action.triggered.connect(callback)
        menu.addAction(action)

    menu.exec_(pos)
Example #48
0
class SearchTable(QTableWidget):
    def __init__(self, parent = None):
        super(SearchTable, self).__init__(parent)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.setRowCount(0)
        self.setColumnCount(5)

        self.hideColumn(4)
        self.hideColumn(5)
        headers  =  ( "评分","歌曲", "歌手", "专辑", "musicId")  
        self.setHorizontalHeaderLabels(headers)
#        self.setShowGrid(False)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.verticalHeader().setVisible(False)
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)
#        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.create_contextmenu()
        
    def add_record(self, score, music, artist, album, musicRid):
            countRow  =  self.rowCount()
            scoreItem = QTableWidgetItem(score)
            musicItem  =  QTableWidgetItem(music)
            artistItem  =  QTableWidgetItem(artist)
            albumItem =  QTableWidgetItem(album)            
            musicRidItem  =  QTableWidgetItem(musicRid)
#            totalTimeItem.setTextAlignment(Qt.AlignCenter)
#            artistIdItem  =  QTableWidgetItem(artistId)
            
            self.insertRow(countRow)
            self.setItem(countRow, 0, scoreItem)
            self.setItem(countRow, 1, musicItem)
            self.setItem(countRow, 2, artistItem)
            self.setItem(countRow, 3, albumItem)
            self.setItem(countRow, 4, musicRidItem)           
#            self.setItem(countRow, 5, artistIdItem)
            
    def clear_search_table(self):
        while self.rowCount():
            self.removeRow(0)
   
    def create_contextmenu(self):
        self.listMenu  =  QMenu()
        self.listenOnlineAction = QAction('试听', self)
        self.addBunchToListAction = QAction('添加到‘在线试听’', self)
        self.downloadAction  =  QAction('下载', self)
        self.switchToOnlineListAction = QAction("切换到试听列表", self)
        self.listMenu.addAction(self.listenOnlineAction)
        self.listMenu.addAction(self.addBunchToListAction)
        self.listMenu.addSeparator()
        self.listMenu.addAction(self.downloadAction)
        self.listMenu.addSeparator()
        self.listMenu.addAction(self.switchToOnlineListAction)
        
        self.customContextMenuRequested.connect(self.music_table_menu)
                
    def music_table_menu(self, pos):
        pos += QPoint(0, 30)
        self.listMenu.exec_(self.mapToGlobal(pos))
Example #49
0
    class QTrayIcon(QSystemTrayIcon, auxilia.Actions):
        def __init__(self, icon, parent):
            QSystemTrayIcon.__init__(self, icon, parent)
            self.parent = parent
            self.pauseIcon = auxilia.PIcon("media-playback-pause")
            self.startIcon = auxilia.PIcon("media-playback-start")
            self.actionList = []
            self.menu = QMenu('Pythagora MPD client', parent)
            self.menu.addAction(menuTitle(icon, 'Pythagora', parent))
            self.setContextMenu(self.menu)
            self.hideResoreAction = QAction('Minimize', self.menu)
            self.connect(self.hideResoreAction, SIGNAL('triggered()'),
                         self.__activated)
            self.connect(
                self, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
                self.__activated)
            self.connect(self.menu, SIGNAL('aboutToShow()'), self.__buildMenu)
            self.show()

        def addMenuItem(self, action):
            self.actionList.append(action)

        def setState(self, state):
            if state == 'play':
                self.setIcon(self.startIcon)
            else:
                self.setIcon(self.pauseIcon)

        def setToolTip(self, iconPath, text):
            super(QTrayIcon, self).setToolTip(
                'Pythagora,&nbsp;Now&nbsp;Playing:<br>%s' % text)

        def __activated(self, reason=None):
            if reason == QSystemTrayIcon.MiddleClick:
                self.emit(SIGNAL('secondaryActivateRequested(QPoint)'),
                          QPoint())
            if reason == None or reason == QSystemTrayIcon.Trigger:
                self.emit(SIGNAL('activate()'))

        def __buildMenu(self):
            if self.parent.isVisible():
                self.hideResoreAction.setText('Minimize')
            else:
                self.hideResoreAction.setText('Restore')
            for action in self.actionList:
                self.menu.addAction(action)
            self.menu.addSeparator()
            self.menu.addAction(self.hideResoreAction)
            self.menu.addAction(self.parent.actionExit)

        def event(self, event):
            if event.type() == 31:  # enum: QEvent.wheel
                event.accept()
                self.emit(SIGNAL('scrollRequested(int, Qt::Orientation)'),
                          event.delta(), Qt.Horizontal)
                return True
            else:
                super(QTrayIcon, self).event(event)
                return False
Example #50
0
class WingedBox(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.setWindowTitle('WingedBox')
        pixmap = QPixmap(config.images['icon'])
        self.setWindowIcon(QIcon(pixmap))

        self.user = ''
        self.password = ''

        self._vbox = QVBoxLayout(self)
        self._login = Login(self, HOME_WINGED_PATH)
        self._vbox.addWidget(self._login)
        self._winged = Winged(self, pref)
        self._winged.setVisible(False)
        self._vbox.addWidget(self._winged)

        #SystemTray Menu
        self._menu = QMenu('WingedBox')
        self._myfiles = self._menu.addAction(QIcon(config.images['icon']), 'Files')
        self._myfiles.setEnabled(False)
        self._init = self._menu.addAction(self.style().standardIcon(QStyle.SP_DialogOkButton), 'Init Session')
        self._close = self._menu.addAction(self.style().standardIcon(QStyle.SP_DialogCloseButton), 'Close Session')
        self._close.setVisible(False)
        self._menu.addSeparator()
        self._properties = self._menu.addAction('Preferences')
        self._menu.addSeparator()
        exit = self._menu.addAction(self.style().standardIcon(QStyle.SP_TitleBarCloseButton), 'Exit')

        #SystemTray
        self._tray = QSystemTrayIcon(QIcon(pixmap), self)
        self._tray.setToolTip('WingedBox')
        self._tray.setVisible(True)
        self._tray.setContextMenu(self._menu)

        #Signal -> Slot
        self.connect(exit, SIGNAL("triggered()"), sys.exit)
        self.connect(self._myfiles, SIGNAL("triggered()"), self.show)
        self.connect(self._init, SIGNAL("triggered()"), self.show)
        self.connect(self._properties, SIGNAL("triggered()"), self.show_properties)
        self.connect(self._close, SIGNAL("triggered()"), self.disconnect)

    def show_properties(self):
        self.prop = preferences.Preferences(self, pref)
        self.prop.show()

    def disconnect(self):
        self.user = ''
        self.password = ''
        self._myfiles.setEnabled(False)
        self._init.setVisible(True)
        self._close.setVisible(False)
        self._winged.hide()
        self._login.show()

    def closeEvent(self, event):
        event.ignore()
        self.hide()
Example #51
0
class TrayIconUpdates(QSystemTrayIcon):

    def __init__(self, parent):
        QSystemTrayIcon.__init__(self, parent)
        icon = QIcon(resources.IMAGES['iconUpdate'])
        self.setIcon(icon)
        self.setup_menu()

        if settings.NOTIFY_UPDATES:
            self.thread = ThreadUpdates()

            self.connect(self.thread, SIGNAL("finished()"),
                self._show_messages)
            self.thread.start()
        else:
            self.show = self.hide

    def setup_menu(self, show_downloads=False):
        self.menu = QMenu()
        if show_downloads:
            self.download = QAction(self.tr("Download Version: %1!").arg(
                self.thread.ide['version']),
                self, triggered=self._show_download)
            self.menu.addAction(self.download)
            self.menu.addSeparator()
        self.quit_action = QAction(self.tr("Close Update Notifications"),
            self, triggered=self.hide)
        self.menu.addAction(self.quit_action)

        self.setContextMenu(self.menu)

    def _show_messages(self):
        try:
            local_version = version.LooseVersion(ninja_ide.__version__)
            web_version = version.LooseVersion(self.thread.ide['version'])
            if local_version < web_version:
                if self.supportsMessages():
                    self.setup_menu(True)
                    self.showMessage(self.tr("NINJA-IDE Updates"),
                        self.tr("New Version of NINJA-IDE\nAvailable: ") + \
                        self.thread.ide['version'] + \
                        self.tr("\n\nCheck the Update Icon Menu to Download!"),
                        QSystemTrayIcon.Information, 10000)
                else:
                    button = QMessageBox.information(self.parent(),
                        self.tr("NINJA-IDE Updates"),
                        self.tr("New Version of NINJA-IDE\nAvailable: ") + \
                        self.thread.ide['version'])
                    if button == QMessageBox.Ok:
                        self._show_download()
            else:
                self.hide()
        except:
            logger.warning('Versions can not be compared.')
            self.hide()

    def _show_download(self):
        webbrowser.open(self.thread.ide['downloads'])
        self.hide()
Example #52
0
 def create_custom_menu_for_node(self, node):
     menu = QMenu(self.view)
     if node is self.model.root_node():
         self.add_default_menu_items_for_widget(menu)
     elif not self.add_custom_menu_items_for_node(node, menu):
         if not menu.isEmpty():
             menu.addSeparator()
         self.add_default_menu_items_for_node(node, menu)
     return menu
Example #53
0
    def contextMenuEvent(self, ev):
        item = self.itemAt(ev.pos())
        if not item:
            return

        mainwindow = self.parentWidget().mainwindow()

        selection = self.selectedItems()
        doc = self.document(item)

        if len(selection) <= 1 and doc:
            # a single document is right-clicked
            import documentcontextmenu
            menu = documentcontextmenu.DocumentContextMenu(mainwindow)
            menu.exec_(doc, ev.globalPos())
            menu.deleteLater()
            return

        menu = QMenu(mainwindow)
        save = menu.addAction(icons.get('document-save'), '')
        menu.addSeparator()
        close = menu.addAction(icons.get('document-close'), '')

        if len(selection) > 1:
            # multiple documents are selected
            save.setText(_("Save selected documents"))
            close.setText(_("Close selected documents"))
            documents = [self.document(item) for item in selection]
        else:
            documents = [
                self.document(item.child(i)) for i in range(item.childCount())
            ]
            if item._path:
                # a directory item is right-clicked
                save.setText(_("Save documents in this folder"))
                close.setText(_("Close documents in this folder"))
            else:
                # the "Untitled" group is right-clicked
                save.setText(_("Save all untitled documents"))
                close.setText(_("Close all untitled documents"))

        @save.triggered.connect
        def savedocuments():
            for d in documents:
                if d.url().isEmpty() or d.isModified():
                    mainwindow.setCurrentDocument(d)
                if not mainwindow.saveDocument(d):
                    break

        @close.triggered.connect
        def close_documents():
            for d in documents:
                if not mainwindow.closeDocument(d):
                    break

        menu.exec_(ev.globalPos())
        menu.deleteLater()
Example #54
0
def show(position, panel, link, cursor):
    """Shows a context menu.
    
    position: The global position to pop up
    panel: The music view panel, giving access to mainwindow and view widget
    link: a popplerqt4 LinkBrowse instance or None
    cursor: a QTextCursor instance or None
    
    """
    m = QMenu(panel)

    # selection? -> Copy
    if panel.widget().view.surface().hasSelection():
        m.addAction(panel.actionCollection.music_copy_image)

    if cursor:
        a = m.addAction(icons.get("document-edit"), _("Edit in Place"))

        @a.triggered.connect
        def edit():
            from . import editinplace
            editinplace.edit(panel.widget(), cursor, position)
    elif link:
        a = m.addAction(icons.get("window-new"), _("Open Link in &New Window"))

        @a.triggered.connect
        def open_in_browser():
            import helpers
            helpers.openUrl(QUrl(link.url()))

        a = m.addAction(icons.get("edit-copy"), _("Copy &Link"))

        @a.triggered.connect
        def copy_link():
            QApplication.clipboard().setText(link.url())

    # no actions yet? insert Fit Width/Height
    if not m.actions():
        m.addAction(panel.actionCollection.music_fit_width)
        m.addAction(panel.actionCollection.music_fit_height)
        m.addAction(panel.actionCollection.music_zoom_original)
        m.addSeparator()
        m.addAction(panel.actionCollection.music_sync_cursor)

    # help
    m.addSeparator()
    a = m.addAction(icons.get("help-contents"), _("Help"))

    @a.triggered.connect
    def help():
        import userguide
        userguide.show("musicview")

    # show it!
    if m.actions():
        m.exec_(position)
    m.deleteLater()
Example #55
0
 def contextMenuEvent(self, event):
     menu = QMenu(self)
     menu.addAction(self.refreshAction)
     menu.addSeparator()
     for action in self.actions[1:-1]:
         menu.addAction(action)
     menu.addSeparator()
     menu.addAction(self.rmAction)
     menu.exec_(event.globalPos())
Example #56
0
    def createStandardContextMenu(self):
        menu = QMenu(self)

        self.add_toggle_action_to_menu(menu, str("Show A&ddress"), self.show_address, self.setShowAddress )
        self.add_toggle_action_to_menu(menu, str("Show &Hex"), self.show_hex, self.setShowHexDump )
        self.add_toggle_action_to_menu(menu, str("Show &ASCII"), self.show_ascii, self.setShowAsciiDump )

        menu.addSeparator()
        menu.addAction(str("&Copy Selection To Clipboard"), self.mnuCopy)
        return menu
Example #57
0
    def context_menu(self):
        """Add context menu fonctions."""

        menu = QMenu(self.dlg.composerList)
        menu.addAction(self.tr(u'Check...'), self.actionCheckComposer)
        menu.addAction(self.tr(u'Uncheck...'), self.actionUncheckComposer)
        menu.addSeparator()
        menu.addAction(self.tr(u'Show...'), self.actionShowComposer)
        menu.addAction(self.tr(u'Close...'), self.actionHideComposer)
        menu.exec_(QCursor.pos())
Example #58
0
    def showMenu(self, pos):
        """
        Popups a menu for this widget.
        """
        menu = QMenu(self)
        menu.setAttribute(Qt.WA_DeleteOnClose)
        menu.addAction('Clear').triggered.connect(self.clearFilepath)
        menu.addSeparator()
        menu.addAction('Copy Filepath').triggered.connect(self.copyFilepath)

        menu.exec_(self.mapToGlobal(pos))