Allow different background file formats

main
Bob Mottram 2020-07-25 17:12:14 +01:00
parent 10b9f2818d
commit 2dca999231
2 changed files with 30 additions and 21 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -608,6 +608,7 @@ def setThemeImages(baseDir: str, name: str) -> None:
backgroundNames = ('login', 'shares', 'delete', 'follow', backgroundNames = ('login', 'shares', 'delete', 'follow',
'options', 'block', 'search', 'calendar') 'options', 'block', 'search', 'calendar')
extensions = ('png', 'jpg', 'gif')
for subdir, dirs, files in os.walk(baseDir + '/accounts'): for subdir, dirs, files in os.walk(baseDir + '/accounts'):
for acct in dirs: for acct in dirs:
@ -619,26 +620,34 @@ def setThemeImages(baseDir: str, name: str) -> None:
os.path.join(baseDir + '/accounts', acct) os.path.join(baseDir + '/accounts', acct)
for backgroundType in backgroundNames: for backgroundType in backgroundNames:
for ext in extensions:
if themeNameLower == 'default': if themeNameLower == 'default':
backgroundImageFilename = \ backgroundImageFilename = \
baseDir + '/img/' + backgroundType + '-background.png' baseDir + '/img/' + backgroundType + \
'-background.' + ext
else: else:
backgroundImageFilename = \ backgroundImageFilename = \
baseDir + '/img/' + backgroundType + '_background_' + \ baseDir + '/img/' + backgroundType + \
themeNameLower + '.png' '_background_' + \
themeNameLower + '.' + ext
if os.path.isfile(backgroundImageFilename): if os.path.isfile(backgroundImageFilename):
try: try:
copyfile(backgroundImageFilename, copyfile(backgroundImageFilename,
baseDir + '/accounts/' + backgroundType + baseDir + '/accounts/' + backgroundType +
'-background.png') '-background.' + ext)
break
except BaseException: except BaseException:
pass pass
elif os.path.isfile(baseDir + '/accounts/' + backgroundType + # background image was not found
'-background.png'): # so remove any existing file
if os.path.isfile(baseDir + '/accounts/' +
backgroundType +
'-background.' + ext):
try: try:
os.remove(baseDir + '/accounts/' + backgroundType + os.remove(baseDir + '/accounts/' +
'-background.png') backgroundType +
'-background.' + ext)
except BaseException: except BaseException:
pass pass