mirror of
https://github.com/nixietab/picodulce.git
synced 2025-04-10 10:28:56 +01:00
put the loading theme background in a separate function
This commit is contained in:
parent
4f4ff35ee5
commit
fc7f47d273
43
picodulce.py
43
picodulce.py
@ -210,26 +210,17 @@ class PicomcVersionSelector(QWidget):
|
|||||||
self.movie_label.setGeometry(0, 0, 400, 320)
|
self.movie_label.setGeometry(0, 0, 400, 320)
|
||||||
event.accept() # Accept the resize event
|
event.accept() # Accept the resize event
|
||||||
|
|
||||||
|
def load_theme_background(self):
|
||||||
|
"""Load and set the theme background image from base64 data in the theme configuration."""
|
||||||
|
if not self.config.get("ThemeBackground", False): # Default to False if ThemeBackground is missing
|
||||||
|
return
|
||||||
|
|
||||||
def init_ui(self):
|
|
||||||
self.setWindowTitle('PicoDulce Launcher') # Change window title
|
|
||||||
current_date = datetime.now()
|
|
||||||
if (current_date.month == 12 and current_date.day >= 8) or (current_date.month == 1 and current_date.day <= 1):
|
|
||||||
self.setWindowIcon(QIcon('holiday.ico')) # Set holiday icon
|
|
||||||
else:
|
|
||||||
self.setWindowIcon(QIcon('launcher_icon.ico')) # Set regular icon
|
|
||||||
|
|
||||||
self.setGeometry(100, 100, 400, 250)
|
|
||||||
|
|
||||||
# Set application style and theme
|
|
||||||
QApplication.setStyle("Fusion")
|
|
||||||
with open("config.json", "r") as config_file:
|
|
||||||
config = json.load(config_file)
|
|
||||||
|
|
||||||
if self.config.get("ThemeBackground", False): # Default to False if ThemeBackground is missing
|
|
||||||
# Get the base64 string for the background image from the theme file
|
# Get the base64 string for the background image from the theme file
|
||||||
theme_background_base64 = self.theme.get("background_image_base64", "")
|
theme_background_base64 = self.theme.get("background_image_base64", "")
|
||||||
if theme_background_base64:
|
if not theme_background_base64:
|
||||||
|
print("No background GIF base64 string found in the theme file.")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Decode the base64 string to get the binary data
|
# Decode the base64 string to get the binary data
|
||||||
background_image_data = QByteArray.fromBase64(theme_background_base64.encode())
|
background_image_data = QByteArray.fromBase64(theme_background_base64.encode())
|
||||||
@ -262,8 +253,24 @@ class PicomcVersionSelector(QWidget):
|
|||||||
print("Error: Failed to load background GIF from base64 string.")
|
print("Error: Failed to load background GIF from base64 string.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: Failed to decode and set background GIF. {e}")
|
print(f"Error: Failed to decode and set background GIF. {e}")
|
||||||
|
|
||||||
|
def init_ui(self):
|
||||||
|
self.setWindowTitle('PicoDulce Launcher') # Change window title
|
||||||
|
current_date = datetime.now()
|
||||||
|
if (current_date.month == 12 and current_date.day >= 8) or (current_date.month == 1 and current_date.day <= 1):
|
||||||
|
self.setWindowIcon(QIcon('holiday.ico')) # Set holiday icon
|
||||||
else:
|
else:
|
||||||
print("No background GIF base64 string found in the theme file.")
|
self.setWindowIcon(QIcon('launcher_icon.ico')) # Set regular icon
|
||||||
|
|
||||||
|
self.setGeometry(100, 100, 400, 250)
|
||||||
|
|
||||||
|
# Set application style and theme
|
||||||
|
QApplication.setStyle("Fusion")
|
||||||
|
with open("config.json", "r") as config_file:
|
||||||
|
config = json.load(config_file)
|
||||||
|
|
||||||
|
# Load theme background
|
||||||
|
self.load_theme_background()
|
||||||
|
|
||||||
# Create title label
|
# Create title label
|
||||||
title_label = QLabel('PicoDulce Launcher') # Change label text
|
title_label = QLabel('PicoDulce Launcher') # Change label text
|
||||||
|
Loading…
Reference in New Issue
Block a user