def __init__(self, desktopFileName=None): if desktopFileName is None: desktopFileName = 'default' self.tileSize = None self.faceSize = None self.__renderer = None self.__shadowOffsets = None self.defineCatalog() self.path = locateTileset(desktopFileName + '.desktop') if self.path.isEmpty(): self.path = locateTileset('default.desktop') if self.path.isEmpty(): directories = '\n\n' +'\n'.join(str(x) for x in KGlobal.dirs().resourceDirs("kmahjonggtileset")) logException(TileException(m18n( \ 'cannot find any tileset in the following directories, is libkmahjongg installed?') + directories)) else: logWarning(m18n('cannot find tileset %1, using default', desktopFileName)) self.desktopFileName = 'default' else: self.desktopFileName = desktopFileName self.darkenerAlpha = 120 if self.desktopFileName == 'jade' else 50 tileconfig = KConfig(self.path, KConfig.SimpleConfig) group = KConfigGroup(tileconfig.group("KMahjonggTileset")) self.name = group.readEntry("Name", "unknown tileset").toString() # Returns translated data self.author = group.readEntry("Author", "unknown author").toString() self.description = group.readEntry("Description", "no description available").toString() self.authorEmail = group.readEntry("AuthorEmail", "no E-Mail address available").toString() #Version control tileversion, entryOK = group.readEntry("VersionFormat", QVariant(0)).toInt() #Format is increased when we have incompatible changes, meaning that # older clients are not able to use the remaining information safely if not entryOK or tileversion > TILESETVERSIONFORMAT: logException(TileException('tileversion file / program: %d/%d' % \ (tileversion, TILESETVERSIONFORMAT))) graphName = QString(group.readEntry("FileName")) self.__graphicspath = locateTileset(graphName) if self.__graphicspath.isEmpty(): logException(TileException('cannot find kmahjongglib/tilesets/%s for %s' % \ (graphName, self.desktopFileName ))) self.renderer() # now that we get the sizes from the svg, we need the renderer right away self.svgName = { 'wn': 'WIND_1', 'ws': 'WIND_2', 'we': 'WIND_3', 'ww': 'WIND_4', 'db': 'DRAGON_1', 'dg': 'DRAGON_2', 'dr': 'DRAGON_3'} for value in '123456789': self.svgName['s%s' % value] = 'ROD_%s' % value self.svgName['b%s' % value] = 'BAMBOO_%s' % value self.svgName['c%s' % value] = 'CHARACTER_%s' % value for idx, wind in enumerate('eswn'): self.svgName['f%s' % wind] = 'FLOWER_%d' % (idx + 1) self.svgName['y%s' % wind] = 'SEASON_%d' % (idx + 1)
def __init__(self, dummyName): """continue __build""" self.group = KConfig(self.path).group(self.configGroupName) self.name = self.group.readEntry("Name") or i18n("unknown name") self.author = self.group.readEntry("Author") or i18n("unknown author") self.description = self.group.readEntry("Description") or i18n( "no description available") self.authorEmail = self.group.readEntry("AuthorEmail") or i18n( "no E-Mail address available") # Version control resourceVersion = self.group.readInteger("VersionFormat", default=0) # Format is increased when we have incompatible changes, meaning that # older clients are not able to use the remaining information safely if resourceVersion > RESOURCEFORMAT: logException('version file / program: %d/%d' % (resourceVersion, RESOURCEFORMAT))
def konfigGroup(path, groupName): """returns access to a group of config options""" config = KConfig(path, KConfig.SimpleConfig) return config, KConfigGroup(config.group(groupName))