def getThemeIcon(iconName): iconName = '/' + iconName if QFile.exists(QgsApplication.activeThemePath() + iconName): return QIcon(QgsApplication.activeThemePath() + iconName) elif QFile.exists(QgsApplication.defaultThemePath() + iconName): return QIcon(QgsApplication.defaultThemePath() + iconName) else: themePath = ':/icons/' + QSettings().value('/Themes', '', str) + iconName if QFile.exists(themePath): return QIcon(themePath) else: return QIcon(':/icons/default' + iconName)
def getThemeIcon(theName): myPath = correctedPath(os.path.dirname(__file__)); myDefPathIcons = myPath + os.sep + "icons" + os.sep myDefPath = myPath.replace("\\",os.sep)+ theName; myDefPathIcons = myDefPathIcons.replace("\\", os.sep)+ theName; myCurThemePath = QgsApplication.activeThemePath() + os.sep + "plugins" + os.sep + theName; myDefThemePath = QgsApplication.defaultThemePath() + os.sep + "plugins" + os.sep + theName; # Attention, ci-dessous, le chemin est à persoonaliser : # Remplacer "extension" par le nom du répertoire de l'extension. myQrcPath = "python" + os.sep + "plugins" + os.sep + "CeremaCartEau3" + os.sep + theName; if QFile.exists(myDefPath): return myDefPath elif QFile.exists(myDefPathIcons): return myDefPathIcons elif QFile.exists(myCurThemePath): return myCurThemePath elif QFile.exists(myDefThemePath): return myDefThemePath elif QFile.exists(myQrcPath): return myQrcPath elif QFile.exists(theName): return theName else: return "" return