示例#1
0
    def restoreSettings(self, settings):
        """
        Restores the current structure of the view widget from the inputed \
        settings instance.
        
        :param      settings | <QSettings>
        """
        key = self.objectName()
        value = qt.unwrapVariant(settings.value('%s/profile' % key))

        if (not value):
            self.reset(force=True)
            return False

        profile = value

        # restore the view type settings
        for viewType in self.viewTypes():
            viewType.restoreGlobalSettings(settings)

        # restore the profile
        self.restoreProfile(XViewProfile.fromString(profile))

        if (not self.views()):
            self.reset(force=True)

        return True
示例#2
0
 def restoreSettings( self, settings ):
     """
     Restores the current structure of the view widget from the inputed \
     settings instance.
     
     :param      settings | <QSettings>
     """
     key     = self.objectName()
     value   = qt.unwrapVariant(settings.value('%s/profile' % key))
     
     if ( not value ):
         self.reset(force = True)
         return False
         
     profile = value
     
     # restore the view type settings
     for viewType in self.viewTypes():
         viewType.restoreGlobalSettings(settings)
     
     # restore the profile
     self.restoreProfile(XViewProfile.fromString(profile))
     
     if ( not self.views() ):
         self.reset(force = True)
     
     return True
 def restoreSettings(self, settings):
     """
     Restores settings from the application.
     
     :param      settings | <QSettings>
     """
     settings.beginGroup(self.objectName())
     
     curr_prof = None
     curr_name = unwrapVariant(settings.value('current'))
     
     profiles = []
     for prof_name in settings.childGroups():
         settings.beginGroup(prof_name)
         
         prof_str = unwrapVariant(settings.value('profile'))
         profile  = XViewProfile.fromString(prof_str)
         profile.setName(prof_name)
         
         if prof_name == curr_name:
             curr_prof = profile
         
         profiles.append(profile)
         
         settings.endGroup()
     
     self.blockSignals(True)
     self._profileCombo.blockSignals(True)
     self.setProfiles(profiles)
     
     if curr_prof:
         self.setCurrentProfile(curr_prof)
     
     self._profileCombo.blockSignals(False)
     self.blockSignals(False)
     
     settings.endGroup()
示例#4
0
    def restoreSettings(self, settings):
        """
        Restores settings from the application.
        
        :param      settings | <QSettings>
        """
        settings.beginGroup(self.objectName())

        curr_prof = None
        curr_name = qt.unwrapVariant(settings.value('current'))

        profiles = []
        for prof_name in settings.childGroups():
            settings.beginGroup(prof_name)

            prof_str = qt.unwrapVariant(settings.value('profile'))
            profile = XViewProfile.fromString(prof_str)
            profile.setName(prof_name)

            if (prof_name == curr_name):
                curr_prof = profile

            profiles.append(profile)

            settings.endGroup()

        self.blockSignals(True)
        self._profileCombo.blockSignals(True)
        self.setProfiles(profiles)

        if (curr_prof):
            self.setCurrentProfile(curr_prof)

        self._profileCombo.blockSignals(False)
        self.blockSignals(False)

        settings.endGroup()
 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)
示例#6
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)

        new_act = menu.addAction('New Blank Layout...')
        new_act.setIcon(QIcon(resources.find('img/add.png')))

        if (prof):
            edit_act = menu.addAction('Edit Information...')
            menu.addSeparator()

            save_act = menu.addAction('Save from Current Layout')
            copy_act = menu.addAction('Copy Layout')
            copy_as_act = menu.addAction('Copy Layout as...')
            paste_act = menu.addAction('Paste Layout')

            menu.addSeparator()

            export_act = menu.addAction('Export Toolbar...')
            import_act = menu.addAction('Import Toolbar...')

            menu.addSeparator()

            rem_act = menu.addAction('Remove Layout')

            # set the icons
            save_act.setIcon(QIcon(resources.find('img/save.png')))
            edit_act.setIcon(QIcon(resources.find('img/edit.png')))
            copy_act.setIcon(QIcon(resources.find('img/copy.png')))
            paste_act.setIcon(QIcon(resources.find('img/paste.png')))
            rem_act.setIcon(QIcon(resources.find('img/remove.png')))

            create_current_act = -1
        else:
            create_current_act = menu.addAction('New from Current Layout...')

            menu.addSeparator()

            paste_act = menu.addAction('Paste Layout')

            menu.addSeparator()

            export_act = menu.addAction('Export Toolbar...')
            import_act = menu.addAction('Import Toolbar...')

            save_act = -1
            edit_act = -1
            copy_act = -1
            copy_as_act = -1
            rem_act = -1

            paste_act.setIcon(QIcon(resources.find('img/paste.png')))

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

        # create a new profile
        if (act == new_act):
            self.createProfile()

        # create a new clear profile
        elif (act == create_current_act):
            self.createProfile(clearLayout=False)

        # edit an existing profile
        elif (act == edit_act):
            self.editProfile(prof)

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

        # copy profile
        elif (act == copy_act):
            QApplication.clipboard().setText(prof.toString())

        # copy profile as
        elif (act == copy_as_act):
            self.createProfile(profile=prof.duplicate())

        # export
        elif (act == export_act):
            self.exportProfiles()

        # export
        elif (act == import_act):
            self.importProfiles()

        # paste profile
        elif (act == paste_act):
            text = QApplication.clipboard().text()
            prof = XViewProfile.fromString(text)
            if (not prof.isEmpty()):
                self.createProfile(profile=prof)

        # remove the profile
        elif (act == rem_act):
            self.removeProfile(prof)
示例#7
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)
 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)
     
     new_act  = menu.addAction('New Blank Layout...')
     new_act.setIcon( QIcon(resources.find('img/add.png')))
     
     if ( prof ):
         edit_act = menu.addAction('Edit Information...')
         menu.addSeparator()
         
         save_act    = menu.addAction('Save from Current Layout')
         copy_act    = menu.addAction('Copy Layout')
         copy_as_act = menu.addAction('Copy Layout as...')
         paste_act   = menu.addAction('Paste Layout')
         
         menu.addSeparator()
         
         export_act  = menu.addAction('Export Toolbar...')
         import_act  = menu.addAction('Import Toolbar...')
         
         menu.addSeparator()
         
         rem_act  = menu.addAction('Remove Layout')
         
         # set the icons
         save_act.setIcon(QIcon(resources.find('img/save.png')))
         edit_act.setIcon(QIcon(resources.find('img/edit.png')))
         copy_act.setIcon(QIcon(resources.find('img/copy.png')))
         paste_act.setIcon(QIcon(resources.find('img/paste.png')))
         rem_act.setIcon( QIcon(resources.find('img/remove.png')))
         
         create_current_act = -1
     else:
         create_current_act    = menu.addAction('New from Current Layout...')
         
         menu.addSeparator()
         
         paste_act   = menu.addAction('Paste Layout')
         
         menu.addSeparator()
         
         export_act  = menu.addAction('Export Toolbar...')
         import_act  = menu.addAction('Import Toolbar...')
         
         save_act    = -1
         edit_act    = -1
         copy_act    = -1
         copy_as_act = -1
         rem_act     = -1
         
         paste_act.setIcon(QIcon(resources.find('img/paste.png')))
         
     # run the menu
     act = menu.exec_(QCursor.pos())
     
     # create a new profile
     if ( act == new_act ):
         self.createProfile()
     
     # create a new clear profile
     elif ( act == create_current_act ):
         self.createProfile(clearLayout = False)
     
     # edit an existing profile
     elif ( act == edit_act ):
         self.editProfile(prof)
     
     # save or create a new profile
     elif ( act == save_act ):
         self.saveProfileLayout(prof)
         
     # copy profile
     elif ( act == copy_act ):
         QApplication.clipboard().setText(prof.toString())
     
     # copy profile as
     elif ( act == copy_as_act ):
         self.createProfile(profile = prof.duplicate())
     
     # export
     elif ( act == export_act ):
         self.exportProfiles()
     
     # export
     elif ( act == import_act ):
         self.importProfiles()
     
     # paste profile
     elif ( act == paste_act ):
         text = QApplication.clipboard().text()
         prof = XViewProfile.fromString(text)
         if ( not prof.isEmpty() ):
             self.createProfile(profile = prof)
     
     # remove the profile
     elif ( act == rem_act ):
         self.removeProfile(prof)