Example #1
0
    def slot_transportViewMenu(self):
        menu = QMenu(self)
        actHMS = menu.addAction("Hours:Minutes:Seconds")
        actBBT = menu.addAction("Beat:Bar:Tick")
        actFrames = menu.addAction("Frames")

        actHMS.setCheckable(True)
        actBBT.setCheckable(True)
        actFrames.setCheckable(True)

        if self.fCurTransportView == TRANSPORT_VIEW_HMS:
            actHMS.setChecked(True)
        elif self.fCurTransportView == TRANSPORT_VIEW_BBT:
            actBBT.setChecked(True)
        elif self.fCurTransportView == TRANSPORT_VIEW_FRAMES:
            actFrames.setChecked(True)

        actSelected = menu.exec_(QCursor().pos())

        if actSelected == actHMS:
            self.setTransportView(TRANSPORT_VIEW_HMS)
        elif actSelected == actBBT:
            self.setTransportView(TRANSPORT_VIEW_BBT)
        elif actSelected == actFrames:
            self.setTransportView(TRANSPORT_VIEW_FRAMES)
Example #2
0
    def contextMenuEvent(self, event):
        popup_menu = self.createStandardContextMenu()

        menu_lint = QMenu(self.tr("Ignore Lint"))
        ignoreLineAction = menu_lint.addAction(
            self.tr("Ignore This Line"))
        ignoreSelectedAction = menu_lint.addAction(
            self.tr("Ignore Selected Area"))
        self.connect(ignoreLineAction, SIGNAL("triggered()"),
            lambda: helpers.lint_ignore_line(self))
        self.connect(ignoreSelectedAction, SIGNAL("triggered()"),
            lambda: helpers.lint_ignore_selection(self))
        popup_menu.insertSeparator(popup_menu.actions()[0])
        popup_menu.insertMenu(popup_menu.actions()[0], menu_lint)
        popup_menu.insertAction(popup_menu.actions()[0],
            self.__actionFindOccurrences)
        #add extra menus (from Plugins)
        lang = file_manager.get_file_extension(self.ID)
        extra_menus = self.EXTRA_MENU.get(lang, None)
        if extra_menus:
            popup_menu.addSeparator()
            for menu in extra_menus:
                popup_menu.addMenu(menu)
        #show menu
        popup_menu.exec_(event.globalPos())
Example #3
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()
 def create_menu_switch_sink(self):
     sink_menu = QMenu(i18n("Move To"), self.popup_menu)
     sinks = self.veromix.get_sink_widgets()
     for sink in sinks:
         action = QAction(sink.name(), self.popup_menu)
         sink_menu.addAction(action)
     self.popup_menu.addMenu(sink_menu)
Example #5
0
 def __init__(self, mwHandle):
     self.mw = mwHandle
     
     for x in xrange(2, 20):
         pin = eval("self.mw.pin%02d" % (x))
         menu = QMenu(pin)
         modeGroup = QActionGroup(self.mw)
         modeGroup.setExclusive(True)
         none = menu.addAction("&None")
         modeGroup.addAction(none)
         none.triggered.connect(self.clickNone)
         none.setCheckable(True)
         none.setChecked(True)
         input = menu.addAction("&Input")
         modeGroup.addAction(input)
         input.triggered.connect(self.clickInput)
         input.setCheckable(True)
         output = menu.addAction("&Output")
         modeGroup.addAction(output)
         output.triggered.connect(self.clickOutput)
         output.setCheckable(True)
         if self.mw.board.pins[x].PWM_CAPABLE:
             pwm = menu.addAction("&PWM")
             modeGroup.addAction(pwm)
             pwm.triggered.connect(self.clickPWM)
             pwm.setCheckable(True)
         if self.mw.board.pins[x].type == 2:
             analogic = menu.addAction(u"&Analógico")
             modeGroup.addAction(analogic)
             analogic.triggered.connect(self.clickAnalog)
             analogic.setCheckable(True)
         pin.setMenu(menu)
         pin.setStyleSheet("/* */") # force stylesheet update
Example #6
0
 def customContext(self, pos):
     index = self.listView.indexAt(pos)
     index = self.proxyModel.mapToSource(index)
     if not index.isValid():
         self.rmAction.setEnabled(False)
         self.openAction.setEnabled(False)
         self.loadAction.setEnabled(False)
     elif not self.model.isDir(index):
         info = self.model.fileInfo(index)
         suffix = info.suffix()
         if suffix in ("Rd","Rdata","RData"):
             self.loadAction.setEnabled(True)
             self.openAction.setEnabled(False)
             self.loadExternal.setEnabled(False)
         elif suffix in ("txt","csv","R","r"):
             self.openAction.setEnabled(True)
             self.loadAction.setEnabled(False)
             self.loadExternal.setEnabled(True)
         else:
             self.loadAction.setEnabled(False)
             self.openAction.setEnabled(False)
             self.loadExternal.setEnabled(True)
     menu = QMenu(self)
     for action in self.actions:
         menu.addAction(action)
     menu.exec_(self.listView.mapToGlobal(pos))
Example #7
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 #8
0
 def contextMenuEvent(self, e):
     menu = QMenu(self)
     subMenu = QMenu(menu)
     titleHistoryMenu = QCoreApplication.translate("PythonConsole", "Command History")
     subMenu.setTitle(titleHistoryMenu)
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Show"),
         self.showHistory, 'Ctrl+Shift+SPACE')
     subMenu.addSeparator()
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Save"),
         self.writeHistoryFile)
     subMenu.addSeparator()
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Clear File"),
         self.clearHistory)
     subMenu.addAction(
         QCoreApplication.translate("PythonConsole", "Clear Session"),
         self.clearHistorySession)
     menu.addMenu(subMenu)
     menu.addSeparator()
     copyAction = menu.addAction(
         QCoreApplication.translate("PythonConsole", "Copy"),
         self.copy, QKeySequence.Copy)
     pasteAction = menu.addAction(
         QCoreApplication.translate("PythonConsole", "Paste"),
         self.paste, QKeySequence.Paste)
     copyAction.setEnabled(False)
     pasteAction.setEnabled(False)
     if self.hasSelectedText():
         copyAction.setEnabled(True)
     if QApplication.clipboard().text():
         pasteAction.setEnabled(True)
     menu.exec_(self.mapToGlobal(e.pos()))
Example #9
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 #10
0
    def eventFilter(self, obj, event):
        '''
        @param obj QObject
        @paramn event QEvent
        '''

        #        if (event.type() == QEvent.MouseButtonPress):
        #            print "Mouse pressed"
        #
        if (event.type() == QEvent.ContextMenu):

            # Now we know that event is an instance of QContextMenuEvent

            menu = QMenu(self)

            newPos = self.adjustPosition(event.pos())
            modelIndex = self.indexAt(newPos)

            self.showTransactions = QAction(self.tr("Show transactions"), self)
            menu.addAction(self.showTransactions)
            self.connect(self.showTransactions,
                         SIGNAL("triggered()"),
                         lambda : self.parentWindow.showTransactionsForPosition(modelIndex))

            self.openWebpage = QAction(self.tr("Open Google Finance webpage"), self)
            menu.addAction(self.openWebpage)
            self.connect(self.openWebpage,
                         SIGNAL("triggered()"),
                         lambda : self.parentWindow.openWebpageForPosition(modelIndex))

            menu.exec_(event.globalPos())


        return QListView.eventFilter(self, obj, event)
Example #11
0
class centro(QGraphicsPixmapItem):
      def __init__(self, *args):
            QGraphicsPixmapItem.__init__(self, *args)
            self.setPixmap(QPixmap("sprites/calle/centro.png"))
            self.setTransformOriginPoint(self.boundingRect().width()/2.0,self.boundingRect().height()/2.0)
            self.setZValue(1)
            self.menu = QMenu()
            self.Actions =[] #arreglo de acciones 
            self.Actions.append( self.menu.addAction("girar clockwise") )
            self.Actions.append( self.menu.addAction("girar anti-clockwise") )
            self.Actions.append( self.menu.addAction("Duplicar") )
            self.Actions.append( self.menu.addAction("Eliminar") )
            self.menu.triggered[QAction].connect(self.test)
            self.offset=QPointF(0,0)
      def test(self,act):
            print act.text()
            if act.text()=="girar clockwise":
                  self.setRotation(self.rotation()-45)
            if act.text()=="girar anti-clockwise":
                  self.setRotation(self.rotation()+45)
            if act.text()=="Duplicar":
                  self.scene().addItem(centro())
            if act.text()=="Eliminar":
                  self.scene().removeItem(self)
      def contextMenuEvent(self,event):
            self.menu.popup(event.screenPos())
      def mousePressEvent(self, event):
            p = event.pos()
            self.offset= QPointF(p.x()*1.0,p.y()*1.0)
      def mouseMoveEvent(self, event):
            #print self.offset,event.scenePos()
            self.setPos(event.scenePos()-self.offset)
Example #12
0
 def showSnippets(self, evt):
     popupmenu = QMenu()
     for name, snippet in self.snippets.iteritems():
         action = QAction(self.tr(name), self.btnSnippets)
         action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet))
         popupmenu.addAction(action)
     popupmenu.exec_(QCursor.pos())
class TrayIconUpdates(QSystemTrayIcon):

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

    def setup_menu(self, show_downloads=False):
        self.menu = QMenu()

        #accion deshabilitar filtrado
        self.deshabilitarFiltradoAction = self.menu.addAction(
                            #self.style.standardIcon(QStyle.SP_DialogNoButton),
                            'Deshabilitar Filtrado'
                            )
        #accion habilitar filtrado
        self.habilitarFiltradoAction = self.menu.addAction(
                            #self.style.standardIcon(QStyle.SP_DialogYesButton),
                            'Habilitar Filtrado'
                            )
        self.habilitarFiltradoAction.setVisible(False)
        #cambiar password
        self.cambiarPasswordAction = self.menu.addAction(
                #self.style.standardIcon(QStyle.SP_BrowserReload),
                'Cambiar password de administrador'
                )
        #accion salir
        self.exitAction = self.menu.addAction(
                #self.style.standardIcon(QStyle.SP_TitleBarCloseButton),
                'Salir')
        self.setContextMenu(self.menu)
Example #14
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 #15
0
def show(main_window):
    """Show a system tray icon with a small icon."""
    _fix_unity_systray()
    icon = QIcon(multiplatform.get_path("encuentro/logos/icon-192.png"))
    sti = QSystemTrayIcon(icon, main_window)
    if not sti.isSystemTrayAvailable():
        logger.warning("System tray not available.")
        return

    def showhide(_):
        """Show or hide the main window."""
        if main_window.isVisible():
            main_window.hide()
        else:
            main_window.show()

    _menu = QMenu(main_window)
    _act = _menu.addAction("Mostrar/Ocultar")
    _act.triggered.connect(showhide)
    _act = _menu.addAction("Acerca de")
    _act.triggered.connect(main_window.open_about_dialog)
    _act = _menu.addAction("Salir")
    _act.triggered.connect(main_window.on_close)
    sti.setContextMenu(_menu)
    sti.show()
Example #16
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 #17
0
def slot_transportViewMenu(self_):
    menu = QMenu(self_)
    act_t_hms = menu.addAction("Hours:Minutes:Seconds")
    act_t_bbt = menu.addAction("Beat:Bar:Tick")
    act_t_fr  = menu.addAction("Frames")

    act_t_hms.setCheckable(True)
    act_t_bbt.setCheckable(True)
    act_t_fr.setCheckable(True)

    if self_.m_selected_transport_view == TRANSPORT_VIEW_HMS:
        act_t_hms.setChecked(True)
    elif self_.m_selected_transport_view == TRANSPORT_VIEW_BBT:
        act_t_bbt.setChecked(True)
    elif self_.m_selected_transport_view == TRANSPORT_VIEW_FRAMES:
        act_t_fr.setChecked(True)

    act_selected = menu.exec_(QCursor().pos())

    if act_selected == act_t_hms:
        setTransportView(self_, TRANSPORT_VIEW_HMS)
    elif act_selected == act_t_bbt:
        setTransportView(self_, TRANSPORT_VIEW_BBT)
    elif act_selected == act_t_fr:
        setTransportView(self_, TRANSPORT_VIEW_FRAMES)
Example #18
0
    def handleEditorRightClick(self, position5d, globalWindowCoordinate):
        names = self.topLevelOperatorView.opCarving.doneObjectNamesForPosition(position5d[1:4])
       
        op = self.topLevelOperatorView.opCarving
        
        menu = QMenu(self)
        menu.addAction("position %d %d %d" % (position5d[1], position5d[2], position5d[3]))
        for name in names:
            menu.addAction("edit %s" % name)
            menu.addAction("delete %s" % name)
            if self.render:
                if name in self._shownObjects3D:
                    menu.addAction("remove %s from 3D view" % name)
                else:
                    menu.addAction("show 3D %s" % name)

        act = menu.exec_(globalWindowCoordinate)
        for name in names:
            if act is not None and act.text() == "edit %s" %name:
                op.loadObject(name)
            elif act is not None and act.text() =="delete %s" % name:
                op.deleteObject(name)
                if self.render and self._renderMgr.ready:
                    self._update_rendering()
            elif act is not None and act.text() == "show 3D %s" % name:
                label = self._renderMgr.addObject()
                self._shownObjects3D[name] = label
                self._update_rendering()
            elif act is not None and act.text() == "remove %s from 3D view" % name:
                label = self._shownObjects3D.pop(name)
                self._renderMgr.removeObject(label)
                self._update_rendering()
 def contextMenuEvent(self, event): 
     if event.reason() == event.Mouse: 
         pos = event.globalPos() 
         item = self.itemAt(event.pos()) 
     else: 
         pos = None 
         selection = self.selectedItems() 
         if selection: 
             item = selection[0] 
         else: 
             item = self.currentItem() 
             if item is None: 
                 item = self.invisibleRootItem().child(0) 
         if item is not None: 
             parent = item.parent() 
             while parent is not None: 
                 parent.setExpanded(True) 
                 parent = parent.parent() 
             itemrect = self.visualItemRect(item) 
             portrect = self.viewport().rect() 
             if not portrect.contains(itemrect.topLeft()): 
                 self.scrollToItem( 
                     item, QTreeWidget.PositionAtCenter) 
                 itemrect = self.visualItemRect(item) 
             itemrect.setLeft(portrect.left()) 
             itemrect.setWidth(portrect.width()) 
             pos = self.mapToGlobal(itemrect.center()) 
     if pos is not None: 
         menu = QMenu(self) 
         menu.addAction(item.text(0)) 
         menu.popup(pos) 
     event.accept() 
Example #20
0
    def menu_button(self, main_action_id, ids, widget):
        '''
            Creates an :obj:`.OWButton` with a popup-menu and adds it to the parent ``widget``.
        '''
        id, name, attr_name, attr_value, callback, icon_name = self._expand_id(main_action_id)
        b = OWButton(parent=widget)
        m = QMenu(b)
        b.setMenu(m)
        b._actions = {}

        QObject.connect(m, SIGNAL("triggered(QAction*)"), b, SLOT("setDefaultAction(QAction*)"))

        if main_action_id:
            main_action = OWAction(self._plot, icon_name, attr_name, attr_value, callback, parent=b)
            QObject.connect(m, SIGNAL("triggered(QAction*)"), main_action, SLOT("trigger()"))

        for id in ids:
            id, name, attr_name, attr_value, callback, icon_name = self._expand_id(id)
            a = OWAction(self._plot, icon_name, attr_name, attr_value, callback, parent=m)
            m.addAction(a)
            b._actions[id] = a

        if m.actions():
            b.setDefaultAction(m.actions()[0])
        elif main_action_id:
            b.setDefaultAction(main_action)


        b.setPopupMode(QToolButton.MenuButtonPopup)
        b.setMinimumSize(40, 30)
        return b
Example #21
0
File: QPTG.py Project: mplamann/PTG
 def displayHandMenu(self, pt):
     def flipCard():
         for index in self.lvHand.selectedIndexes():
             self.handModel.flipCardAtIndex(index)
     menu = QMenu(self)
     menu.addAction("Flip", flipCard)
     menu.exec_(self.lvHand.mapToGlobal(pt))
Example #22
0
class TabNavigator(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.setContextMenuPolicy(Qt.DefaultContextMenu)
        self.setMinimumHeight(38)
        hbox = QHBoxLayout(self)
        self.btnPrevious = QPushButton(QIcon(resources.IMAGES["nav-code-left"]), "")
        self.btnPrevious.setToolTip(self.tr("Right click to change navigation options"))
        styles.set_style(self.btnPrevious, "tab-navigator")
        self.btnNext = QPushButton(QIcon(resources.IMAGES["nav-code-right"]), "")
        self.btnNext.setToolTip(self.tr("Right click to change navigation options"))
        styles.set_style(self.btnNext, "tab-navigator")
        hbox.addWidget(self.btnPrevious)
        hbox.addWidget(self.btnNext)
        self.setContentsMargins(0, 0, 0, 0)

        self.menuNavigate = QMenu(self.tr("Navigate"))
        self.codeAction = self.menuNavigate.addAction(self.tr("Code Jumps"))
        self.codeAction.setCheckable(True)
        self.codeAction.setChecked(True)
        self.bookmarksAction = self.menuNavigate.addAction(self.tr("Bookmarks"))
        self.bookmarksAction.setCheckable(True)
        self.breakpointsAction = self.menuNavigate.addAction(self.tr("Breakpoints"))
        self.breakpointsAction.setCheckable(True)

        # 0 = Code Jumps
        # 1 = Bookmarks
        # 2 = Breakpoints
        self.operation = 0

        self.connect(self.codeAction, SIGNAL("triggered()"), self._show_code_nav)
        self.connect(self.breakpointsAction, SIGNAL("triggered()"), self._show_breakpoints)
        self.connect(self.bookmarksAction, SIGNAL("triggered()"), self._show_bookmarks)

    def contextMenuEvent(self, event):
        self.menuNavigate.exec_(event.globalPos())

    def _show_bookmarks(self):
        self.btnPrevious.setIcon(QIcon(resources.IMAGES["book-left"]))
        self.btnNext.setIcon(QIcon(resources.IMAGES["book-right"]))
        self.bookmarksAction.setChecked(True)
        self.breakpointsAction.setChecked(False)
        self.codeAction.setChecked(False)
        self.operation = 1

    def _show_breakpoints(self):
        self.btnPrevious.setIcon(QIcon(resources.IMAGES["break-left"]))
        self.btnNext.setIcon(QIcon(resources.IMAGES["break-right"]))
        self.bookmarksAction.setChecked(False)
        self.breakpointsAction.setChecked(True)
        self.codeAction.setChecked(False)
        self.operation = 2

    def _show_code_nav(self):
        self.btnPrevious.setIcon(QIcon(resources.IMAGES["nav-code-left"]))
        self.btnNext.setIcon(QIcon(resources.IMAGES["nav-code-right"]))
        self.bookmarksAction.setChecked(False)
        self.breakpointsAction.setChecked(False)
        self.codeAction.setChecked(True)
        self.operation = 0
Example #23
0
    def showCellContextMenu(self, point):
        """Display the menu that occurs when right clicking on a table cell."""
        
        clickedCell = self.indexAt(point)

        if not clickedCell.isValid():
            # User clicked on a part of the table without a cell
            return False

        cellMenu = QMenu(self)
        insertCellAction = QAction("Insert Cells", cellMenu)
        deleteCellAction = QAction("Delete Cells", cellMenu)
        
        cellMenu.addAction(insertCellAction)
        cellMenu.addAction(deleteCellAction)

        # Connect signals
        insertCellAction.triggered.connect(self.insertCells)
        deleteCellAction.triggered.connect(self.deleteCells)

        # Display menu
        cellMenu.exec_(self.mapToGlobal(point))

        # Disconnect signals
        insertCellAction.triggered.disconnect(self.insertCells)
        deleteCellAction.triggered.disconnect(self.deleteCells)
Example #24
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 #25
0
    def popup(self, pos):

        from ui.ligne_edit import EditLigneViewWidget
        from ui.deleteview import DeleteViewWidget
        from data_helper import check_befor_update_data
        row = self.selectionModel().selection().indexes()[0].row()
        if (len(self.data) - 1) < row:
            return False
        menu = QMenu()
        editaction = menu.addAction("Modifier cette ligne")
        delaction = menu.addAction("Supprimer cette ligne")
        action = menu.exec_(self.mapToGlobal(pos))
        report = Report.get(id=self.data[row][-1])
        if action == editaction:
            try:
                self.parent.open_dialog(EditLigneViewWidget, modal=True,
                                        table_p=self, report=report)
            except IndexError:
                pass
        if action == delaction:
            list_error = check_befor_update_data(report)
            if list_error == []:
                if len(self.data) < 2:
                    self.parent.cancellation()
                else:
                    self.parent.open_dialog(
                        DeleteViewWidget, modal=True, obj=report, table_p=self,)
            else:
                from Common.ui.util import raise_error
                raise_error(u"Impossible de supprimer", """<h3>L'article {} :</h3>
                        Aura <b>{}</b> comme dernier restant.""".format(
                    report.product.name, list_error[-1]))
Example #26
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() )
 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 #28
0
    def __init__(self):
        QWidget.__init__(self)
        self._line_edit = ClearableLineEdit()

        self._calendar_button = QToolButton()
        self._calendar_button.setPopupMode(QToolButton.InstantPopup)
        self._calendar_button.setFixedSize(26, 26)
        self._calendar_button.setAutoRaise(True)
        self._calendar_button.setIcon(resourceIcon("calendar.png"))
        self._calendar_button.setStyleSheet("QToolButton::menu-indicator { image: none; }")

        tool_menu = QMenu(self._calendar_button)
        self._calendar_widget = QCalendarWidget(tool_menu)
        action = QWidgetAction(tool_menu)
        action.setDefaultWidget(self._calendar_widget)
        tool_menu.addAction(action)
        self._calendar_button.setMenu(tool_menu)

        layout = QHBoxLayout()
        layout.setMargin(0)
        layout.addWidget(self._line_edit)
        layout.addWidget(self._calendar_button)
        self.setLayout(layout)

        self._calendar_widget.activated.connect(self.setDate)
Example #29
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):
        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 #31
0
 def showHeaderMenu( self ):
     depts   = settings.departments()
     labels  = settings.departmentLabels(depts)
     visible = settings.enabledDepartments()
     
     # create the menu
     menu = QMenu(self)
     for d, dept in enumerate(depts):
         act = menu.addAction(labels[d])
         act.setObjectName(dept)
         act.setCheckable(True)
         act.setChecked( dept in visible )
     
     menu.triggered.connect( self.toggleDeptTriggered )
     
     menu.exec_(QCursor.pos())
Example #32
0
def menu_file(parent):
    m = QMenu(parent)
    m.setTitle(_("menu title", "&File"))
    m.addAction(icons.get('document-new'), _("action: new document", "&New"),
                file_new)
    m.addMenu(menu_file_new_from_template(m))
    m.addAction(icons.get('tools-score-wizard'),
                _("New Score with &Wizard..."), file_new_with_wizard)
    m.addSeparator()
    m.addAction(icons.get('document-open'), _("&Open..."), file_open)
    m.addMenu(menu_file_open_recent(m))
    m.addSeparator()
    m.addMenu(menu_file_import(m))
    m.addSeparator()
    role = QAction.QuitRole if use_osx_menu_roles() else QAction.NoRole
    m.addAction(icons.get('application-exit'), _("&Quit"),
                app.qApp.quit).setMenuRole(role)
    return m
Example #33
0
 def createDbPerspectiveContextMenu(self, position):
     menu = QMenu()
     item = self.permissionTreeWidget.itemAt(position)
     if item:
         if item.text(0) <> '':
             menu.addAction(self.tr('Revoke all permissions'), self.revokeAll)
         elif item.text(1) <> '':
             menu.addAction(self.tr('Manage User Permissions'), self.manageUserPermissions)
         elif item.text(2) <> '':
             menu.addAction(self.tr('Revoke User'), self.revokeSelectedUser)
     menu.exec_(self.permissionTreeWidget.viewport().mapToGlobal(position))
Example #34
0
 def createUserPerspectiveContextMenu(self, position):
     menu = QMenu()
     item = self.permissionTreeWidget.itemAt(position)
     if item:
         if item.text(0) != '':
             menu.addAction(self.tr('Revoke permissions on all granted databases'), self.revokeAllDbs)
         elif item.text(1) != '':
             menu.addAction(self.tr('Manage Permissions on database'), self.managePermissionsOnDb)
         elif item.text(2) != '':
             menu.addAction(self.tr('Revoke Permission'), self.revokeSelectedPermission)
     menu.exec_(self.permissionTreeWidget.viewport().mapToGlobal(position))
Example #35
0
    def _createProjectMenu(self):
        # Create a menu for "General" (non-applet) actions
        menu = QMenu("&Project", self)

        shellActions = ShellActions()

        # Menu item: New Project
        shellActions.newProjectAction = menu.addAction("&New Project...")
        shellActions.newProjectAction.setShortcuts(QKeySequence.New)
        shellActions.newProjectAction.triggered.connect(
            self.onNewProjectActionTriggered)

        # Menu item: Open Project
        shellActions.openProjectAction = menu.addAction("&Open Project...")
        shellActions.openProjectAction.setShortcuts(QKeySequence.Open)
        shellActions.openProjectAction.triggered.connect(
            self.onOpenProjectActionTriggered)

        # Menu item: Save Project
        shellActions.saveProjectAction = menu.addAction("&Save Project")
        shellActions.saveProjectAction.setShortcuts(QKeySequence.Save)
        shellActions.saveProjectAction.triggered.connect(
            self.onSaveProjectActionTriggered)

        # Menu item: Save Project As
        shellActions.saveProjectAsAction = menu.addAction(
            "&Save Project As...")
        shellActions.saveProjectAsAction.setShortcuts(QKeySequence.SaveAs)
        shellActions.saveProjectAsAction.triggered.connect(
            self.onSaveProjectAsActionTriggered)

        # Menu item: Save Project Snapshot
        shellActions.saveProjectSnapshotAction = menu.addAction(
            "&Take Snapshot...")
        shellActions.saveProjectSnapshotAction.triggered.connect(
            self.onSaveProjectSnapshotActionTriggered)

        # Menu item: Import Project
        shellActions.importProjectAction = menu.addAction("&Import Project...")
        shellActions.importProjectAction.triggered.connect(
            self.onImportProjectActionTriggered)

        # Menu item: Quit
        shellActions.quitAction = menu.addAction("&Quit")
        shellActions.quitAction.setShortcuts(QKeySequence.Quit)
        shellActions.quitAction.triggered.connect(self.onQuitActionTriggered)
        shellActions.quitAction.setShortcut(QKeySequence.Quit)

        return (menu, shellActions)
Example #36
0
    def menus(self):
        menus = super(PixelClassificationGui, self).menus()

        # For now classifier selection is only available in debug mode
        if ilastik_config.getboolean('ilastik', 'debug'):

            def handleClassifierAction():
                dlg = ClassifierSelectionDlg(self.topLevelOperatorView,
                                             parent=self)
                dlg.exec_()

            advanced_menu = QMenu("Advanced", parent=self)
            classifier_action = advanced_menu.addAction("Classifier...")
            classifier_action.triggered.connect(handleClassifierAction)
            menus += [advanced_menu]

        return menus
Example #37
0
 def on_historyButton_pressed(self):
     menu = QMenu()
     results = {
         menu.addAction('Today'): datetime.date.today(),
         menu.addAction('Last 24 Hours'): datetime.datetime.now() - datetime.timedelta(1),
         menu.addAction('Last 7 Days'): datetime.datetime.now() - datetime.timedelta(7),
         menu.addAction('Last 30 Days'): datetime.datetime.now() - datetime.timedelta(30),
         menu.addAction('Last 6 Month'): datetime.datetime.now() - datetime.timedelta(30 * 6),
         menu.addAction('Last Year'): datetime.datetime.now() - datetime.timedelta(365),
         menu.addAction('All Time'): 0,
         menu.addAction('None'): datetime.datetime.now(),
     }
     result = menu.exec_(self.historyButton.mapToGlobal(QPoint(0, self.historyButton.height())))
     if result in results:
         self.showHistorySince(results[result])
Example #38
0
def createTrayMenu(trayIcon):
    trayIconMenu = QMenu()
    action = QAction("显示主界面", trayIcon)
    action.triggered.connect(lambda: trayClick(3))
    trayIconMenu.addAction(action)
    action = QAction("取消自动登录", trayIcon)
    action.triggered.connect(AppProperty.MainWin.cancelAutoLogin)
    trayIconMenu.addAction(action)
    action = QAction("退出", trayIcon)
    action.triggered.connect(QApplication.instance().quit)
    trayIconMenu.addAction(action)
    return trayIconMenu
Example #39
0
    def setupPlotsMenu(self):
        """ Configure the plots button menu.

        @return None
        """
        plotButton = self.plotButton
        pop = QMenu(plotButton)
        plotButton.setMenu(pop)
        pop.addAction(self.actionNewPlot)
        pop.addAction(self.actionClosePlot)
        pop.addSeparator()
        pop.addAction(self.actionSyncWithData)
Example #40
0
 def onQuickDesktopContextMenuRequest(self, pos):
     index = self.listView.indexAt(pos)
     self.listView.setCurrentIndex(index)
     menu = QMenu()
     menu.addAction(self.actionCreateShortcut)
     menu.addAction(self.actionCreateBookmark)
     menu2 = menu.addMenu(self.trUtf8("创建特殊快捷方式(&S)"))
     if os.name == "nt":
         menu2.addAction(self.actionCreateComputer)
     menu2.addAction(self.actionCreateDocuments)
     menu2.addAction(self.actionCreatePictures)
     menu2.addAction(self.actionCreateMusic)
     if index.isValid():
         menu.addAction(self.actionRemoveShortcut)
         if not self.quickDesktopModel.isSpecialShortcut(index):
             menu.addAction(self.actionEditShortcut)
         menu.addAction(self.actionRenameShortcut)
     try:
         getattr(menu, "exec")(QCursor.pos())
     except AttributeError:
         getattr(menu, "exec_")(QCursor.pos())
Example #41
0
 def showMenu(self, point):
     """
     Displays the menu for this filter widget.
     """
     menu = QMenu(self)
     acts = {}
     acts['edit'] = menu.addAction('Edit quick filter...')
     
     trigger = menu.exec_(self.mapToGlobal(point))
     
     if trigger == acts['edit']:
         text, accepted = XTextEdit.getText(self.window(),
                                               'Edit Format',
                                               'Format:',
                                               self.filterFormat(),
                                               wrapped=False)
         
         if accepted:
             self.setFilterFormat(text)
Example #42
0
 def chooseVariant(tile, variants):
     """make the user choose from a list of possible melds for the target.
     The melds do not contain real Tiles, just the scoring strings."""
     idx = 0
     if len(variants) > 1:
         menu = QMenu(m18n('Choose from'))
         for idx, variant in enumerate(variants):
             action = menu.addAction(shortcuttedMeldName(variant.meldType))
             action.setData(QVariant(idx))
         if Internal.field.centralView.dragObject:
             menuPoint = QCursor.pos()
         else:
             menuPoint = tile.board.tileFaceRect().bottomRight()
             view = Internal.field.centralView
             menuPoint = view.mapToGlobal(view.mapFromScene(tile.graphics.mapToScene(menuPoint)))
         action = menu.exec_(menuPoint)
         if not action:
             return None
         idx = action.data().toInt()[0]
     return variants[idx]
Example #43
0
 def init(self):
     menu = QMenu('', self)
     menu.menuAction().setIcon(QIcon('rsc/scene.png'))
     a = QAction(QIcon('rsc/scene.png'), 'Scene', self)
     a.setIconVisibleInMenu(True)
     self.connect(a, SIGNAL('triggered()'), self.menu_action)
     menu.addAction(a)
     a = QAction(QIcon('rsc/node.png'), 'Node', self)
     a.setIconVisibleInMenu(True)
     menu.addAction(a)
     self.connect(a, SIGNAL('triggered()'), self.menu_action)
     a = QAction(QIcon('rsc/tree.png'), 'Tree', self)
     a.setIconVisibleInMenu(True)
     menu.addAction(a)
     self.connect(a, SIGNAL('triggered()'), self.menu_action)
     a = QAction(QIcon('rsc/menu.png'), 'Menu', self)
     a.setIconVisibleInMenu(True)
     self.connect(a, SIGNAL('triggered()'), self.menu_action)
     menu.addAction(a)
     self.addAction(menu.menuAction())
     self.__menu = menu
     return
Example #44
0
    def contextMenuEvent(self, event):
        if not self.support_merges or not self.allowDelete:
            return

        from_index = self._table.indexAt(event.pos())
        if not (0 <= from_index.row() < self.model.rowCount()):
            return

        from_name = self.model.data(from_index, Qt.DisplayRole)
        menu = QMenu(parent=self)
        for to_row in range(self.model.rowCount()):
            to_index = self.model.index(to_row, LabelListModel.ColumnID.Name)
            to_name = self.model.data(to_index, Qt.DisplayRole)
            action = menu.addAction( "Merge {} into {}".format( from_name, to_name ),
                                     partial( self.mergeRequested.emit, from_index.row(), str(from_name),
                                                                        to_row,           str(to_name)) )
            if to_row == from_index.row():
                action.setEnabled(False)

        menu.exec_( self.mapToGlobal(event.pos()) )
Example #45
0
 def on_listWidget_customContextMenuRequested(self, pos):
     """
     Slot documentation goes here.
     代码筛选框中的右键
     """
     # TODO: not implemented yet
     cur = self.cursor()
     curPos = cur.pos()
     log.log(curPos.x(), curPos.y())
     menu = QMenu(self)
     menu.addAction(self.action_addGroup)
     if self.listWidget.itemAt(pos):
         menu.addAction(self.action_editGroup)
         menu.addAction(self.action_deleteGroup)
     menu.exec_(curPos)
Example #46
0
 def handleEditorRightClick(self, currentImageIndex, position5d, globalWindowCoordinate):
     names = self._carvingApplet.topLevelOperator.doneObjectNamesForPosition(position5d[1:4], currentImageIndex)
    
     m = QMenu(self)
     m.addAction("position %d %d %d" % (position5d[1], position5d[2], position5d[3]))
     for n in names:
         m.addAction("edit %s" % n)
         m.addAction("delete %s" % n)
         
     act = m.exec_(globalWindowCoordinate) 
     for n in names:
         if act is not None and act.text() == "edit %s" %n:
             self._carvingApplet.topLevelOperator.loadObject(n, self.imageIndex)
         elif act is not None and act.text() =="delete %s" % n:
             self._carvingApplet.topLevelOperator.deleteObject(n,self.imageIndex) 
Example #47
0
 def colorMenu(self):
     pixmap = QPixmap(22, 22)
     menu = QMenu("Colour")
     for text, color in (
             ("&Black", Qt.black),
             ("B&lue", Qt.blue),
             ("Dark Bl&ue", Qt.darkBlue),
             ("&Cyan", Qt.cyan),
             ("Dar&k Cyan", Qt.darkCyan),
             ("&Green", Qt.green),
             ("Dark Gr&een", Qt.darkGreen),
             ("M&agenta", Qt.magenta),
             ("Dark Mage&nta", Qt.darkMagenta),
             ("&Red", Qt.red),
             ("&Dark Red", Qt.darkRed)):
         color = QColor(color)
         pixmap.fill(color)
         action = menu.addAction(QIcon(pixmap), text, self.setColor)
         action.setData(QVariant(color))
     self.ensureCursorVisible()
     menu.exec_(self.viewport().mapToGlobal(
                self.cursorRect().center()))
Example #48
0
    def _open_menu(self, position):
        indexes = self._view.selectedIndexes()
        ids = [index.internalPointer().type_id for index in indexes]
        menu = QMenu()

        if len(indexes) == 0:
            newAction = NewTypeAction('0', self._refresh, self)
            menu.addAction(newAction)

        if len(indexes) == 1:
            newAction = NewTypeAction(ids[0], self._refresh, self)
            menu.addAction(newAction)

        deleteAction = DeleteTypeAction(ids, self._refresh, self)
        menu.addAction(deleteAction)

        menu.exec_(self._view.viewport().mapToGlobal(position))
Example #49
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 #50
0
    def __setMenubar(self):
        newChatIcon = QIcon(qtUtils.getAbsoluteImagePath('new_chat.png'))
        helpIcon = QIcon(qtUtils.getAbsoluteImagePath('help.png'))
        exitIcon = QIcon(qtUtils.getAbsoluteImagePath('exit.png'))
        menuIcon = QIcon(qtUtils.getAbsoluteImagePath('menu.png'))

        newChatAction = QAction(newChatIcon, '&New chat', self)
        authChatAction = QAction(newChatIcon, '&Authenticate chat', self)
        helpAction = QAction(helpIcon, 'Show &help', self)
        exitAction = QAction(exitIcon, '&Exit', self)

        newChatAction.triggered.connect(lambda: self.addNewTab())
        authChatAction.triggered.connect(self.__showAuthDialog)
        helpAction.triggered.connect(self.__showHelpDialog)
        exitAction.triggered.connect(self.__exit)

        newChatAction.setShortcut('Ctrl+N')
        helpAction.setShortcut('Ctrl+H')
        exitAction.setShortcut('Ctrl+Q')

        optionsMenu = QMenu()

        optionsMenu.addAction(newChatAction)
        optionsMenu.addAction(authChatAction)
        optionsMenu.addAction(helpAction)
        optionsMenu.addAction(exitAction)

        optionsMenuButton = QToolButton()
        newChatButton = QToolButton()
        exitButton = QToolButton()

        newChatButton.clicked.connect(lambda: self.addNewTab())
        exitButton.clicked.connect(self.__exit)

        optionsMenuButton.setIcon(menuIcon)
        newChatButton.setIcon(newChatIcon)
        exitButton.setIcon(exitIcon)

        optionsMenuButton.setMenu(optionsMenu)
        optionsMenuButton.setPopupMode(QToolButton.InstantPopup)

        toolbar = QToolBar(self)
        toolbar.addWidget(optionsMenuButton)
        toolbar.addWidget(newChatButton)
        toolbar.addWidget(exitButton)
        self.addToolBar(Qt.LeftToolBarArea, toolbar)
Example #51
0
 def mousePressEvent(self, event):
     self.raise_()
     if event.button() == Qt.LeftButton:
         self.moving = True
         width = self.width()
         height = self.height()
         if 0 < event.x() < self.edge:
             if 0 < event.y() < self.edge:
                 self.orientation = "leftTop"
             elif height - self.edge < event.y() < height:
                 self.orientation = "leftBottom"
             else:
                 self.orientation = "left"
         elif width - self.edge < event.x() < width:
             if 0 < event.y() < self.edge:
                 self.orientation = "rightTop"
             elif height - self.edge < event.y() < height:
                 self.orientation = "rightBottom"
             else:
                 self.orientation = "right"
         elif 0 < event.y() < self.edge:
             self.orientation = "top"
         elif height - self.edge < event.y() < height:
             self.orientation = "bottom"
         else:
             self.orientation = "center"
             self.originalPos = event.globalPos()
             self.originalTopLeft = self.geometry().topLeft()
             self.originalTopLeft += QPoint( - 3, -3)
     elif event.button() == Qt.RightButton:
         menu = QMenu()
         actionDelete = menu.addAction(QIcon(":/images/remove.png"), self.trUtf8("删除(&R)"))
         try:
             result = getattr(menu, "exec_")(event.globalPos())
         except AttributeError:
             result = getattr(menu, "exec")(event.globalPos())
         if result is actionDelete:
             self.deleteMe.emit()
Example #52
0
 def textEffectMenu(self):
     format = self.currentCharFormat()
     menu = QMenu("Text Effect")
     for text, shortcut, data, checked in (
             ("&Bold", "Ctrl+B", RichTextLineEdit.Bold,
              self.fontWeight() > QFont.Normal),
             ("&Italic", "Ctrl+I", RichTextLineEdit.Italic,
              self.fontItalic()),
             ("Strike &out", None, RichTextLineEdit.StrikeOut,
              format.fontStrikeOut()),
             ("&Underline", "Ctrl+U", RichTextLineEdit.Underline,
              self.fontUnderline()),
             ("&Monospaced", None, RichTextLineEdit.Monospaced,
              format.fontFamily() == self.monofamily),
             ("&Serifed", None, RichTextLineEdit.Serif,
              format.fontFamily() == self.seriffamily),
             ("S&ans Serif", None, RichTextLineEdit.Sans,
              format.fontFamily() == self.sansfamily),
             ("&No super or subscript", None,
              RichTextLineEdit.NoSuperOrSubscript,
              format.verticalAlignment() ==
              QTextCharFormat.AlignNormal),
             ("Su&perscript", None, RichTextLineEdit.Superscript,
              format.verticalAlignment() ==
              QTextCharFormat.AlignSuperScript),
             ("Subs&cript", None, RichTextLineEdit.Subscript,
              format.verticalAlignment() ==
              QTextCharFormat.AlignSubScript)):
         action = menu.addAction(text, self.setTextEffect)
         if shortcut is not None:
             action.setShortcut(QKeySequence(shortcut))
         action.setData(QVariant(data))
         action.setCheckable(True)
         action.setChecked(checked)
     self.ensureCursorVisible()
     menu.exec_(self.viewport().mapToGlobal(
                self.cursorRect().center()))
Example #53
0
class Tray():
    def __init__(self, parent):

        icon = AppIcon.getAppIcon()
        if icon:
            self.tray = QSystemTrayIcon(icon)
        else:
            self.tray = QSystemTrayIcon()
        self.parent = parent

        self.tray.setToolTip("Droid Navi")

        # Menu
        self.menu = QMenu()
        self.menu.addAction("Show Connected List", partial(self.maximize))
        self.menu.addAction("Options", partial(self.parent.openSettings))
        self.menu.addAction("Exit", partial(self.parent.close))
        self.tray.setContextMenu(self.menu)

        # Connect handlers
        self.tray.activated.connect(self.activated)

    def getTray(self):
        return self.tray

    def display(self, show):
        ''' Toggle showing the tray '''

        if show:
            self.tray.show()
        else:
            self.tray.hide()

    @pyqtSlot()
    def maximize(self):
        ''' Show the main window and hide tray icon '''

        self.display(False)
        self.parent.maximizeFromTray()

    @pyqtSlot()
    def activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.maximize()
Example #54
0
    def __init__(self, plugin_handler):
        """
        @type plugin_handler: PluginHandler
        """
        enabled = len(plugin_handler) > 0
        super(PluginsTool, self).__init__("Plugins",
                                          "tools/plugins",
                                          resourceIcon("ide/plugin"),
                                          enabled,
                                          popup_menu=True)

        self.__plugins = {}

        menu = QMenu()
        for plugin in plugin_handler:
            plugin_runner = PluginRunner(plugin)
            plugin_runner.setPluginFinishedCallback(self.trigger)

            self.__plugins[plugin] = plugin_runner
            plugin_action = menu.addAction(plugin.getName())
            plugin_action.setToolTip(plugin.getDescription())
            plugin_action.triggered.connect(plugin_runner.run)

        self.getAction().setMenu(menu)
Example #55
0
class SysTray(QSystemTrayIcon):

	"""The Qnotero system tray icon"""
	
	def __init__(self, qnotero):
	
		"""
		Constructor
		
		Arguments:
		qnotero -- a Qnotero instance
		"""
	
		QSystemTrayIcon.__init__(self, qnotero)
		self.qnotero = qnotero		
		self.setIcon(self.qnotero.theme.icon("qnotero"))		
		self.menu = QMenu()
		self.menu.addAction(self.qnotero.theme.icon("qnotero"), \
			"Show", self.qnotero.popUp)
		self.menu.addAction(self.qnotero.theme.icon("preferences"), \
			"Preferences", self.qnotero.preferences)			
		self.menu.addAction(self.qnotero.theme.icon("close"), \
			"Close", self.qnotero.close)
		self.setContextMenu(self.menu)
		self.activated.connect(self.activate)
		QObject.connect(self, SIGNAL("listenerActivated"), self.activate)
				
	def activate(self, reason=None):
	
		"""
		Handle clicks on the systray icon
		
		Keyword arguments:
		reason -- the reason for activation (default=None)
		"""
	
		
		if reason == QSystemTrayIcon.Context:
			return		
		if self.qnotero.isVisible():
			self.qnotero.popDown()
		else:
			self.qnotero.popUp()
Example #56
0
 def showContextMenu(self, pos):
     menu = QMenu(self)
     menu.aboutToHide.connect(menu.deleteLater)
     viewspace = self.parent()
     manager = viewspace.manager()
     
     a = QAction(icons.get('view-split-top-bottom'), _("Split &Horizontally"), menu)
     menu.addAction(a)
     a.triggered.connect(lambda: manager.splitViewSpace(viewspace, Qt.Vertical))
     a = QAction(icons.get('view-split-left-right'), _("Split &Vertically"), menu)
     menu.addAction(a)
     a.triggered.connect(lambda: manager.splitViewSpace(viewspace, Qt.Horizontal))
     menu.addSeparator()
     a = QAction(icons.get('view-close'), _("&Close View"), menu)
     a.triggered.connect(lambda: manager.closeViewSpace(viewspace))
     a.setEnabled(manager.canCloseViewSpace())
     menu.addAction(a)
     
     menu.exec_(pos)
Example #57
0
    def __init__(self):
        super(QWidget, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.systemTray = QSystemTrayIcon(self)
        self.systemTray.setIcon(QIcon(':/images/icon.png'))
        self.act_autostart = QAction('开机启动', self)
        self.act_autostart.setCheckable(True)
        is_autostart = self.is_autostart()
        self.act_autostart.setChecked(is_autostart)
        self.act_autostart.triggered.connect(self.on_autostart)
        act_setting = QAction('设置启动项', self)
        act_setting.triggered.connect(self.on_settings)
        act_exit = QAction('退出', self)
        act_exit.triggered.connect(self.on_exit)
        self.menu_run = QMenu('运行', self)
        menu = QMenu('菜单', self)
        menu.addMenu(self.menu_run)
        menu.addAction(act_setting)
        menu.addSeparator()
        menu.addAction(self.act_autostart)
        menu.addAction(act_exit)
        self.systemTray.setContextMenu(menu)
        self.systemTray.show()
        self.showMessage('启动工具正在运行')

        self.ui.btn_add.clicked.connect(self.on_add)
        self.ui.btn_delete.clicked.connect(self.on_delete)
        self.ui.btn_apply.clicked.connect(self.on_apply)
        self.ui.btn_env_add.clicked.connect(self.on_env_add)
        self.ui.btn_env_del.clicked.connect(self.on_env_del)
        self.ui.btn_open.clicked.connect(self.on_open)
        self.ui.btn_run.clicked.connect(self.on_run)
        self.ui.le_args.textEdited.connect(self.on_edited)
        self.ui.le_desc.textEdited.connect(self.on_edited)
        self.ui.le_exe.textEdited.connect(self.on_edited)
        self.ui.cb_process.currentIndexChanged.connect(self.on_index_changed)
        self.ui.le_exe.installEventFilter(self)
        self.init()
Example #58
0
    def contextMenuEvent(self, event):
        menu = QMenu(self)

        dc = QAction('Disconnect', None)
        rc = QAction('Reconnect', None)
        about = QAction('About', None)

        if self.state != ClientState.DISCONNECTED:
            menu.addAction(dc)
        if self.state != ClientState.ONLINE\
            and self.state != ClientState.RECONNECTING:
            menu.addAction(rc)

        menu.addAction(about)

        action = menu.exec_(self.mapToGlobal(event.pos()))
        if action == dc:
            self.disconnect_requested.emit()
        elif action == rc:
            self.reconnect_requested.emit()
        elif action == about:
            self.about_dialog_requested.emit()
Example #59
0
    def create_prefetch_menu(self, layer_name):
        def prefetch_layer(axis='z'):
            layer_index = self.layerstack.findMatchingIndex(
                lambda l: l.name == layer_name)
            num_slices = self.editor.dataShape['txyzc'.index(axis)]
            view2d = self.editor.imageViews['xyz'.index(axis)]
            view2d.scene().triggerPrefetch([layer_index],
                                           spatial_axis_range=(0, num_slices))

        prefetch_menu = QMenu("Prefetch")
        prefetch_menu.addAction(
            QAction("All Z-slices",
                    prefetch_menu,
                    triggered=partial(prefetch_layer, 'z')))
        prefetch_menu.addAction(
            QAction("All Y-slices",
                    prefetch_menu,
                    triggered=partial(prefetch_layer, 'y')))
        prefetch_menu.addAction(
            QAction("All X-slices",
                    prefetch_menu,
                    triggered=partial(prefetch_layer, 'x')))
        return prefetch_menu
    def taskCellContextMenuEvent(self, event):
        item = self.ui.tWTasks.itemAt(event.pos())
        if not item:
            return
        taskName = str(item.text())
        if taskName not in self.tasks.keys():
            return
        #self.appContext.currentTaskList = self.tasks[taskName]

        actfun = partial(self._storeToDefault, self.tasks[taskName])
        self.act_storeTodefault = QAction(u'设置成默认', self, triggered=actfun)

        actfun = partial(self._addAccount, self.tasks[taskName])
        self.act_addAccount = QAction(u'添加账户', self, triggered=actfun)

        actfun = partial(self._deleteTaskList, taskName)
        self.act_delete = QAction(u'删除', self, triggered=actfun)

        popMenu = QMenu()
        popMenu.addAction(self.act_storeTodefault)
        popMenu.addAction(self.act_addAccount)
        popMenu.addAction(self.act_delete)
        popMenu.exec_(self.cursor().pos())