Ejemplo n.º 1
0
    def editProfile(self, profile):
        """
        Prompts the user to edit the given profile.
        
        :param      profile | <projexui.widgets.xviewwidget.XViewProfile>
        """
        mod = XViewProfileDialog.edit(self, profile)
        if (not mod):
            return False

        # update the action interface
        for act in self._profileGroup.actions():
            if (act.profile() == profile):
                act.setProfile(profile)
                break

        # signal the change
        if (not self.signalsBlocked()):
            self.profileChanged.emit(profile)

        return True
Ejemplo n.º 2
0
 def editProfile( self, profile ):
     """
     Prompts the user to edit the given profile.
     
     :param      profile | <projexui.widgets.xviewwidget.XViewProfile>
     """
     mod = XViewProfileDialog.edit(self, profile)
     if ( not mod ):
         return False
     
     # update the action interface
     for act in self._profileGroup.actions():
         if ( act.profile() == profile ):
             act.setProfile(profile)
             break
     
     # signal the change
     if ( not self.signalsBlocked() ):
         self.profileChanged.emit(profile)
     
     return True
Ejemplo n.º 3
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)
Ejemplo 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)