Esempio n. 1
0
    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())
Esempio n. 2
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))
    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)
Esempio n. 4
0
    def showProfileMenu(self, point):
        """
        Prompts the user for profile menu options.  Editing needs to be enabled
        for this to work.
        """
        if not self.isEditingEnabled():
            return

        trigger = self.actionAt(point)
        if (isinstance(trigger, XViewProfileAction)):
            prof = trigger.profile()
        else:
            prof = None

        # define the menu
        menu = QMenu(self)
        acts = {}
        text = self.profileText()

        # user right clicked on a profile
        if prof:
            acts['edit'] = menu.addAction('Edit {0}...'.format(text))
            acts['save'] = menu.addAction('Save Layout')

            menu.addSeparator()

            acts['copy'] = menu.addAction('Copy {0}'.format(text))
            acts['export'] = menu.addAction('Export {0}...'.format(text))

            menu.addSeparator()

            acts['remove'] = menu.addAction('Delete {0}'.format(text))

        # show toolbar options
        else:
            acts['new'] = menu.addAction('New Layout'.format(text))

            menu.addSeparator()

            acts['save_as'] = menu.addAction('Save Layout as...')

            if QApplication.clipboard().text():
                acts['paste'] = menu.addAction('Paste {0}'.format(text))
            acts['import'] = menu.addAction('Import {0}...'.format(text))

        for key, act in acts.items():
            act.setIcon(QIcon(resources.find('img/{0}.png'.format(key))))

        # run the menu
        act = menu.exec_(QCursor.pos())

        # create a new profile
        if act is None:
            return

        elif act == acts.get('new'):
            self.clearActive()

        # create a new clear profile
        elif act == acts.get('save_as'):
            self.saveProfileAs()

        # edit an existing profile
        elif act == acts.get('edit'):
            self.editProfile(prof)

        # save or create a new profile
        elif act == acts.get('save'):
            self.saveProfileLayout(prof)

        # copy profile
        elif act == acts.get('copy'):
            QApplication.clipboard().setText(prof.toString())

        # export
        elif act == acts.get('export'):
            self.exportProfile(prof)

        # export
        elif act == acts.get('import'):
            self.importProfile()

        # paste profile
        elif act == acts.get('paste'):
            text = QApplication.clipboard().text()
            try:
                prof = XViewProfile.fromString(text)
            except:
                prof = None
                QMessageBox.information(self.window(),
                                        'Invalid {0}'.format(text),
                                        'The clipboard text does not contain '\
                                        'a properly formated {0}'.format(text))

            if prof and not prof.isEmpty():
                self.createProfile(profile=prof)

        # paste as profile
        elif act == acts.get('paste_as'):
            text = QApplication.clipboard().text()
            prof = XViewProfile.fromString(text)
            if not prof.isEmpty():
                if XViewProfileDialog.edit(self, prof):
                    self.createProfile(profile=prof)

        # remove the profile
        elif act == acts.get('remove'):
            self.removeProfile(prof)