Ejemplo n.º 1
0
    def fromXml(xprofile):
        """
        Restores the profile information from XML.
        
        :param      xprofile | <xml.etree.ElementTree.Element>
        
        :return     <XViewProfile>
        """
        # determine the proper version
        if xprofile.tag != 'profile':
            return XViewProfile()

        version = int(xprofile.get('version', '1'))

        # load the legacy information - just layout data
        if version == 1:
            prof = XViewProfile()
            prof.setXmlElement(xprofile)
            return prof

        # load latest information
        prof = XViewProfile()
        prof.setName(xprofile.get('name', ''))
        prof.setVersion(float(xprofile.get('profile_version', '1.0')))

        ico = xprofile.get('icon')
        if ico is not None:
            prof.setIcon(os.path.expandvars(ico))
        else:
            ico = xprofile.find('icon')
            if ico is not None:
                prof.setIcon(projexui.generatePixmap(ico.text))

        # restore data
        xdata = xprofile.find('data')
        if (xdata is not None):
            prof._customData = DataSet.fromXml(xdata)

        # load description
        xdesc = xprofile.find('desc')
        if (xdesc is not None):
            prof.setDescription(xdesc.text)

        # load layout
        xlayout = xprofile.find('layout')
        if (xlayout is not None):
            prof.setXmlElement(xlayout)

        return prof
Ejemplo n.º 2
0
 def fromXml( xprofile ):
     """
     Restores the profile information from XML.
     
     :param      xprofile | <xml.etree.ElementTree.Element>
     
     :return     <XViewProfile>
     """
     # determine the proper version
     if xprofile.tag != 'profile':
         return XViewProfile()
     
     version = int(xprofile.get('version', '1'))
     
     # load the legacy information - just layout data
     if version == 1:
         prof = XViewProfile()
         prof.setXmlElement(xprofile)
         return prof
     
     # load latest information
     prof = XViewProfile()
     prof.setName(xprofile.get('name', ''))
     prof.setVersion(float(xprofile.get('profile_version', '1.0')))
     
     ico = xprofile.get('icon')
     if ico is not None:
         prof.setIcon(os.path.expandvars(ico))
     else:
         ico = xprofile.find('icon')
         if ico is not None:
             prof.setIcon(projexui.generatePixmap(ico.text))
     
     # restore data
     xdata = xprofile.find('data')
     if ( xdata is not None ):
         prof._customData = DataSet.fromXml(xdata)
     
     # load description
     xdesc = xprofile.find('desc')
     if ( xdesc is not None ):
         prof.setDescription(xdesc.text)
     
     # load layout
     xlayout = xprofile.find('layout')
     if ( xlayout is not None ):
         prof.setXmlElement(xlayout)
     
     return prof
Ejemplo n.º 3
0
 def buildIcon(icon):
     """
     Builds an icon from the inputed information.
     
     :param      icon | <variant>
     """
     if icon is None:
         return QIcon()
     
     if type(icon) == buffer:
         try:
             icon = QIcon(projexui.generatePixmap(icon))
         except:
             icon = QIcon()
     else:
         try:
             icon = QIcon(icon)
         except:
             icon = QIcon()
     
     return icon
Ejemplo n.º 4
0
    def buildIcon(icon):
        """
        Builds an icon from the inputed information.
        
        :param      icon | <variant>
        """
        if icon is None:
            return QIcon()

        if type(icon) == buffer:
            try:
                icon = QIcon(projexui.generatePixmap(icon))
            except:
                icon = QIcon()
        else:
            try:
                icon = QIcon(icon)
            except:
                icon = QIcon()

        return icon