Esempio n. 1
0
 def createPopupMenu(self, pos=None):
     if pos is None:
         menu = KTextEdit.createPopupMenu(self)
     else:
         menu = KTextEdit.createPopupMenu(self, pos)
     #ident = menu.insertItem('Hello There', self.slotHelloThere)
     #if self.hasSelectedText():
     #    print self.selectedText()
     #    print self.getSelection()
     #print 'ident', ident
     #menu.setItemParameter(ident, 777)
     env = self.trait.get_full_environment()
     # make a magic number to start id's on variables
     varcount = 1234
     lookup = {}
     for trait, traitvars in env:
         tmenu = QPopupMenu(menu)
         menu.insertItem(trait, tmenu)
         keys = traitvars.keys()
         keys.sort()
         for key in keys:
             varcount += 1
             ident = tmenu.insertItem(key, self.slotPopupMenuItemSelected)
             tmenu.setItemParameter(ident, varcount)
             lookup[varcount] = (trait, key)
     self.lookup = lookup
     menu.insertItem('Create New Variable', self.slotCreateNewVariable)
     return menu
Esempio n. 2
0
 def createPopupMenu(self, pos=None):
     if pos is None:
         menu = KTextEdit.createPopupMenu(self)
     else:
         menu = KTextEdit.createPopupMenu(self, pos)
     #ident = menu.insertItem('Hello There', self.slotHelloThere)
     #if self.hasSelectedText():
     #    print self.selectedText()
     #    print self.getSelection()
     #print 'ident', ident
     #menu.setItemParameter(ident, 777)
     env = self.trait.get_full_environment()
     # make a magic number to start id's on variables
     varcount = 1234
     lookup = {}
     for trait, traitvars in env:
         tmenu = QPopupMenu(menu)
         menu.insertItem(trait, tmenu)
         keys = traitvars.keys()
         keys.sort()
         for key in keys:
             varcount += 1
             ident = tmenu.insertItem(key, self.slotPopupMenuItemSelected)
             tmenu.setItemParameter(ident, varcount)
             lookup[varcount] = (trait, key)
     self.lookup = lookup
     menu.insertItem('Create New Variable', self.slotCreateNewVariable)
     return menu
Esempio n. 3
0
File: tab.py Progetto: pipacs/etc
 def initMenus(self):
     fileMenu = QPopupMenu(self)
     self.openAction.plug(fileMenu)
     fileMenu.insertSeparator()
     self.quitAction.plug(fileMenu)
     self.menuBar().insertItem(i18n("&File"), fileMenu)
     
     helpMenu = self.helpMenu("")
     self.menuBar().insertItem(i18n("&Help"), helpMenu)
Esempio n. 4
0
    def initMenus(self):
        fileMenu = QPopupMenu(self)
        self.openAction.plug(fileMenu)
        fileMenu.insertSeparator()
        self.quitAction.plug(fileMenu)
        self.menuBar().insertItem(i18n("&File"), fileMenu)

        helpMenu = self.helpMenu("")
        self.menuBar().insertItem(i18n("&Help"), helpMenu)
Esempio n. 5
0
class SearchByItemTypePlugin:
    def __init__(self, pluginContext):
        parentMenu = pluginContext.getPulldownMenu(
            4)  # should be the Tools menu
        self.typeMenu = QPopupMenu(parentMenu)
        iconWrapper = QIconSet(SearchByItemTypePlugin.resultIcon)
        parentMenu.insertItem(iconWrapper, _('Find Items By Type'),
                              self.typeMenu)
        parentMenu.connect(self.typeMenu, SIGNAL('activated(int)'),
                           self.doSearch)
        self.context = pluginContext
        self.context.setFileOpenCallback(self.updateTypeMenu)

    def updateTypeMenu(self):
        typeNames = self.context.getNodeFormatNames()
        self.typeMenu.clear()
        index = 0
        for name in typeNames:
            self.typeMenu.insertItem(name, index)
            index += 1

    def doSearch(self, typeIndex):
        typeName = self.context.getNodeFormatNames()[typeIndex]
        rootNode = self.context.getRootNode()
        self.context.changeSelection([rootNode
                                      ])  # move selection out of the way
        rootNode.openBranch(False)  # reset tree structure
        self.searchSubtree(rootNode, typeName)  # reconfigure tree structure
        self.context.updateViews()  # initialize widgets
        self.highlightSubtree(rootNode, typeName)  # apply highlights

    def searchSubtree(self, node, typeName):
        if node.nodeFormat.name == typeName:
            node.openParents(False)
        for child in node.childList:
            self.searchSubtree(child, typeName)

    def highlightSubtree(self, node, typeName):
        if node.nodeFormat.name == typeName:
            node.viewData.setPixmap(0, SearchByItemTypePlugin.resultIcon)
        for child in node.childList:
            self.highlightSubtree(child, typeName)

    resultIcon = QPixmap([
        "16 16 22 1", ". c none", "a c #000000", "i c #202000", "t c #454500",
        "c c #505030", "y c #777777", "x c #7e7e88", "p c #808000",
        "j c #828200", "r c #858500", "n c #888800", "v c #8c8c00",
        "b c #9090a0", "u c #969600", "q c #a4a428", "m c #abab6f",
        "o c #acac20", "w c #b4b428", "k c #b7978f", "h c #caca18",
        "# c #d7a700", "d c #ffc0a0", "................", "................",
        "................", "................", "................",
        "................", "................", "...###########..",
        "abcdddddddddddh.", "aidddddddjkkkm..", "andddddddo......",
        "apddddddq.......", "arddddd#........", "atuvvnw.........",
        "ax..............", "yy.............."
    ])
Esempio n. 6
0
 def __init__(self, pluginContext):
     parentMenu = pluginContext.getPulldownMenu(
         4)  # should be the Tools menu
     self.typeMenu = QPopupMenu(parentMenu)
     iconWrapper = QIconSet(SearchByItemTypePlugin.resultIcon)
     parentMenu.insertItem(iconWrapper, _('Find Items By Type'),
                           self.typeMenu)
     parentMenu.connect(self.typeMenu, SIGNAL('activated(int)'),
                        self.doSearch)
     self.context = pluginContext
     self.context.setFileOpenCallback(self.updateTypeMenu)
Esempio n. 7
0
    def _setupMenus(self):
        self._setupActions()

        self.fileMenu = QPopupMenu(self)
        self.menuBar().insertItem("&Dosya", self.fileMenu)
        self.newAction.addTo(self.fileMenu)
        self.deleteAction.addTo(self.fileMenu)
        self.quitAction.addTo(self.fileMenu)

        self.editMenu = QPopupMenu(self)
        self.menuBar().insertItem(u"&Düzenle", self.editMenu)
        self.imgAction.addTo(self.editMenu)
        self.previewAction.addTo(self.editMenu)
Esempio n. 8
0
    def edsm_iconview_contextMenuRequested(self, item, pos):
        popup_items = self.find_items_at(pos, item)

        if not popup_items:
            self._iconview.clearSelection()
            self.edsm_tools_buttongroup.setButton(0)
            return

        has_icon = False
        for item in popup_items:
            if isinstance(item, QIconViewItem):
                has_icon = True
                break

        if not has_icon:
            self._iconview.clearSelection()

        if len(popup_items) == 1:
            popup_items[0].show_popup_menu(pos)
        else:
            default_title = self.tr('Item')
            popup_menu = QPopupMenu(self)
            popup_menu.setCheckable(False)
            for item in popup_items:
                title = item.name
                if not title:
                    title = getattr(item, 'type_name', default_title)
                popup_menu.insertItem(title, item.popup_menu())
            popup_menu.popup(pos)

        self.__popup_menu_showing = True
Esempio n. 9
0
 def initMenus(self):
     mainmenu = QPopupMenu(self)
     self.newGameAction.addTo(mainmenu)
     self.launchDosboxAction.addTo(mainmenu)
     mainmenu.insertSeparator()
     self.prepareAllGamesAction.addTo(mainmenu)
     self.cleanAllGamesAction.addTo(mainmenu)
     self.archiveAllGamesAction.addTo(mainmenu)
     self.quitAction.addTo(mainmenu)
     optionmenu = QPopupMenu(self)
     self.flatViewAction.addTo(optionmenu)
     self.treeViewAction.addTo(optionmenu)
     self.nameViewAction.addTo(optionmenu)
     self.titleViewAction.addTo(optionmenu)
     optionmenu.insertSeparator()
     self.filterAllGamesAction.addTo(optionmenu)
     self.filterAvailableGamesAction.addTo(optionmenu)
     self.filterUnavailableGamesAction.addTo(optionmenu)
     menubar = self.menuBar()
     menubar.insertItem('&Main', mainmenu)
     menubar.insertItem('&Options', optionmenu)
Esempio n. 10
0
    def __init__(self, *args):
        apply(KMainWindow.__init__, (self,) + args)
        
        self.lastDir = "/var/log"
        self.monitors = []
        self.currentPage = None
        self.tab = QTabWidget(self)
        self.settingsDlg = SettingsDlg(self)
        self.cfg = LoviConfig().getInstance()
        self.bellIcon = \
            QIconSet(KIconLoader().loadIcon("idea", KIcon.Small, 11))
        self.noIcon = QIconSet()
        self.findDlg = KEdFind(self, "find", False)
        self.connect(self.findDlg, SIGNAL("search()"), self.doFind)
        
        self.setCentralWidget(self.tab)
        self.connect(self.tab, SIGNAL("currentChanged(QWidget *)"), 
            self.onPageChange)
        self.setGeometry(0, 0, 600, 400)
        self.setCaption(makeCaption("(none)"))

        # Timers
        self.timer = QTimer(self)
        self.timer.start(MainWin.MON_TIMEOUT)
        self.statusTimer = QTimer(self)
        self.connect(self.statusTimer, SIGNAL("timeout()"), 
            self.onStatusTimeout)
        self.changeTimer = QTimer(self)
        self.changeTimer.start(MainWin.CHANGE_TIMEOUT)
        self.connect(self.changeTimer, SIGNAL("timeout()"),
            self.onChangeTimeout)

        # Initialize actions
        actions = self.actionCollection()
        self.openAction = KStdAction.open(self.onOpen, actions)
        self.closeAction = KStdAction.close(self.onClose, actions)
        self.closeAction.setEnabled(False)
        self.quitAction = KStdAction.quit(self.onQuit, actions)
        self.copyAction = KStdAction.copy(self.onCopy, actions)
        self.copyAction.setEnabled(False)
        self.clearAction = KStdAction.clear(self.onClear, actions)
        self.clearAction.setEnabled(False)
        self.selectAllAction = KStdAction.selectAll(self.onSelectAll, actions)
        self.selectAllAction.setEnabled(False)
        self.addBookmarkAction = \
            KStdAction.addBookmark(self.onAddBookmark, actions)
        self.addBookmarkAction.setEnabled(False)
        self.settingsAction = KStdAction.preferences(self.onSettings, actions)
        self.findAction = KStdAction.find(self.onFind, actions)
        self.findAction.setEnabled(False)
        self.findNextAction = KStdAction.findNext(self.onFindNext, actions)
        self.findNextAction.setEnabled(False)
        self.findPrevAction = KStdAction.findPrev(self.onFindPrev, actions)
        self.findPrevAction.setEnabled(False)
        
        # Initialize menus
        
        fileMenu = QPopupMenu(self)
        self.openAction.plug(fileMenu)
        self.closeAction.plug(fileMenu)
        fileMenu.insertSeparator()
        self.quitAction.plug(fileMenu)
        self.menuBar().insertItem(i18n("&File"), fileMenu)
        
        editMenu = QPopupMenu(self)
        self.copyAction.plug(editMenu)
        self.clearAction.plug(editMenu)
        editMenu.insertSeparator()
        self.selectAllAction.plug(editMenu)
        self.addBookmarkAction.plug(editMenu)
        editMenu.insertSeparator()
        self.findAction.plug(editMenu)
        self.findNextAction.plug(editMenu)
        self.findPrevAction.plug(editMenu)
        self.menuBar().insertItem(i18n("&Edit"), editMenu)
        
        settingsMenu = QPopupMenu(self)
        self.settingsAction.plug(settingsMenu)
        self.menuBar().insertItem(i18n("&Settings"), settingsMenu)
        
        helpMenu = self.helpMenu("")
        self.menuBar().insertItem(i18n("&Help"), helpMenu)
        
        # Initialize status bar
        self.sb = self.statusBar()
        self.bell = BellButton(None)
        self.displayStatus(False, "")
Esempio n. 11
0
 def __init__(self, theFrame, parent, context, widgetName = 0):
     QPopupMenu.__init__(self, parent, widgetName)
     self.myFrame = theFrame
     self.initContextMenu(context)
Esempio n. 12
0
    def initContextMenu(self, context):
        """
        Initiates the popup menu depending on the context and
        adds appropriate menu items.
        """

        #ACTION TO ARRANGE THE ICONS IN A LINE
        arrangeIcons01Action = QAction("Lines", QKeySequence(), self,
                                       "arrangeIcons01Actions")
        arrangeIcons01Action.setIconSet(QIconSet())
        self.connect(arrangeIcons01Action, SIGNAL("activated()"),
                     self.parent().arrangeIconsInLines)

        #ACTION TO ARRANGE THE ICONS IN A CIRCLE
        arrangeIcons02Action = QAction("Circle", QKeySequence(), self,
                                       "arrangeIcons02Actions")
        arrangeIcons02Action.setIconSet(QIconSet())
        self.connect(arrangeIcons02Action, SIGNAL("activated()"),
                     self.parent().arrangeIconsInCircle)

        #SUBMENU TO CHOOSE THE WAY OF ARRANGEMENT
        #----------------------------------------
        subMenu01 = QPopupMenu(self, "Arrange Icons")
        arrangeIcons01Action.addTo(subMenu01)
        arrangeIcons02Action.addTo(subMenu01)

        #ACTION TO UPDATE THE SCREEN
        updateCanvasViewAction = QAction("Update Screen", QKeySequence(), self,
                                         "updateCanvasViewAction")
        updateCanvasViewAction.setIconSet(QIconSet())
        self.connect(updateCanvasViewAction, SIGNAL("activated()"),
                     self.parent().updateCanvasView)

        #ACTION TO ADD A NEW DATATYPE
        newDataTypeAction = QAction("New Data Type...", QKeySequence(), self,
                                    "newDataTypeAction")
        newDataTypeAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("newDataType16.png")))
        self.connect(newDataTypeAction, SIGNAL("activated()"),
                     self.myFrame.addDataTypeSlot)

        #ACTION TO ADD A NEW RELATIONTYPE
        newRelationTypeAction = QAction("New Relation Type...", QKeySequence(),
                                        self, "newRelationTypeAction")
        newRelationTypeAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("newRelationType16.png")))
        self.connect(newRelationTypeAction, SIGNAL("activated()"),
                     self.myFrame.addRelationTypeSlot)

        #ACTION TO EDIT THE MARKED DATATYPE
        editDataTypeAction = QAction("Edit Data Type...", QKeySequence(), self,
                                     "editDataTypeAction")
        editDataTypeAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("edit16.png")))

        #ACTION TO EDIT THE MARKED RELATIONTYPE
        editRelationTypeAction = QAction("Edit Relation Type...",
                                         QKeySequence(), self,
                                         "editRelationTypeAction")
        editRelationTypeAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("edit16.png")))

        #ACTION TO REMOVE THE MARKED ICON FROM SCREEN
        removeIconAction = QAction("Remove Icon", QKeySequence(), self,
                                   "removeIconAction")
        removeIconAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("delete16.png")))
        self.connect(removeIconAction, SIGNAL("activated()"),
                     self.parent().removeIcon)

        #ACTION TO DELETE THE MARKED DATATYPEICON
        deleteDataTypeAction = QAction("Delete Data Type", QKeySequence(),
                                       self, "deleteDataTypeAction")
        deleteDataTypeAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("delete16.png")))
        self.connect(deleteDataTypeAction, SIGNAL("activated()"),
                     self.myFrame.deleteSelectedDataType)

        #ACTION TO DELETE THE MARKED RELATIONTYPE
        deleteRelationTypeAction = QAction("Delete Relation Type",
                                           QKeySequence(), self,
                                           "deleteRelationTypeAction")
        deleteRelationTypeAction.setIconSet(
            QIconSet(QPixmap.fromMimeSource("delete16.png")))
        self.connect(deleteRelationTypeAction, SIGNAL("activated()"),
                     self.myFrame.deleteSelectedRelationType)

        #CONTEXT-MENU IF NOTHING IS MARKED
        if context == 0:
            newDataTypeAction.addTo(self)
            newRelationTypeAction.addTo(self)

            self.insertSeparator()

            self.insertItem("Arrange Icons...", subMenu01)
            updateCanvasViewAction.addTo(self)

        else:
            #CONTEXT-MENU IF A DATATYPE IS MARKED
            if context.iconType == 1:
                dataTypeController = data_type_dialog.DataTypeController(
                    self.myFrame, context.iconLabel,
                    self.myFrame.repositoryConfiguration)
                self.connect(editDataTypeAction, SIGNAL("activated()"),
                             dataTypeController.show)

                editDataTypeAction.addTo(self)
                deleteDataTypeAction.addTo(self)

                self.insertSeparator()

                newDataTypeAction.addTo(self)
                newRelationTypeAction.addTo(self)

                self.insertSeparator()

                removeIconAction.addTo(self)
                self.insertItem("Arrange Icons...", subMenu01)
                updateCanvasViewAction.addTo(self)

        #CONTEXT-MENU IF A RELATIONTYPE IS MARKED
            if context.iconType == 2:
                relationTypeController = relation_type_dialog.RelationTypeController(
                    self.myFrame, context.iconLabel,
                    self.myFrame.repositoryConfiguration)
                self.connect(editRelationTypeAction, SIGNAL("activated()"),
                             relationTypeController.show)

                editRelationTypeAction.addTo(self)
                deleteRelationTypeAction.addTo(self)

                self.insertSeparator()

                newDataTypeAction.addTo(self)
                newRelationTypeAction.addTo(self)

                self.insertSeparator()

                removeIconAction.addTo(self)
                self.insertItem("Arrange Icons...", subMenu01)
                updateCanvasViewAction.addTo(self)
Esempio n. 13
0
 def __init__(self, theFrame, parent, context, widgetName=0):
     QPopupMenu.__init__(self, parent, widgetName)
     self.myFrame = theFrame
     self.initContextMenu(context)