From 4038cbf732a0351f173ad02e598eddd5b5e55e05 Mon Sep 17 00:00:00 2001 From: admar Date: Sun, 23 Apr 2023 18:26:37 +0200 Subject: [PATCH] Finish support for themes --- clock.py | 76 +++++++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/clock.py b/clock.py index 1440bd4..c3aa608 100644 --- a/clock.py +++ b/clock.py @@ -10,6 +10,7 @@ from kivy.config import Config from kivy.properties import ObjectProperty import time from sounds import WakeUpSounds +import json def is_arm(): if (uname()[4][:3] == 'arm') or (uname()[4][:7] == 'aarch64'): @@ -75,55 +76,34 @@ Position = collections.namedtuple('Position', 'x y') class Theme(): def __init__(self, x="Dark"): - self.name = x - if x == "Dark": - self.color_background = [0, 0, 0] - self.color_shade = [.1, .1, .1] - self.color_clock_hands_hours = [.9, .9, .9] - self.color_clock_hands_minutes = [.8, .8, .8] - self.color_clock_hands_seconds = [.7, .7, .7] - self.color_alarm_hands_hours = [.9, .0, .0] - self.color_alarm_hands_minutes = [.8, .0, .0] - self.color_alarm_hands_seconds = [.7, .0, .0] - self.color_font = [1, 1, 1] - self.color_numbers = [1, 1, 1] - self.color_button = [.2, .2, .2, 1] - self.color_funky = [.5, .2, .1, 0.2] + print("reading themes/" + x + "/theme.json") + f = open("themes/" + x + "/theme.json") + j = json.load(f) + f.close() + self.name = j["name"] + self.color_background = j["color_background"] + self.color_shade = j["color_shade"] + self.color_clock_hands_hours = j["color_clock_hands_hours"] + self.color_clock_hands_minutes = j["color_clock_hands_minutes"] + self.color_clock_hands_seconds = j["color_clock_hands_seconds"] + self.color_alarm_hands_hours = j["color_alarm_hands_hours"] + self.color_alarm_hands_minutes = j["color_alarm_hands_minutes"] + self.color_alarm_hands_seconds = j["color_alarm_hands_seconds"] + self.color_font = j["color_font"] + self.color_numbers = j["color_numbers"] + self.color_button = j["color_button"] + self.color_funky = j["color_funky"] - self.icon_light_off = 'themes/Dark/light_off.png' - self.icon_light_reading = 'themes/Dark/light_reading.png' - self.icon_light_sunrise = 'themes/Dark/light_sunrise.png' - self.icon_light_on = 'themes/Dark/light_on.png' - self.icon_media_playing = 'themes/Dark/media_playing.png' - self.icon_media_stopped = 'themes/Dark/media_stopped.png' - self.icon_alarm_on = 'themes/Dark/alarm_on.png' - self.icon_alarm_off = 'themes/Dark/alarm_off.png' - self.icon_settings_visible = 'themes/Dark/settings_visible.png' - self.icon_settings_not_visible = 'themes/Dark/settings_not_visible.png' - elif x == "Light": - self.color_background = [1, 1, 1] - self.color_shade = [.9, .9, .9] - self.color_clock_hands_hours = [.1, .1, .1] - self.color_clock_hands_minutes = [.2, .2, .2] - self.color_clock_hands_seconds = [.3, .3, .3] - self.color_alarm_hands_hours = [.9, .0, .0] - self.color_alarm_hands_minutes = [.8, .0, .0] - self.color_alarm_hands_seconds = [.7, .0, .0] - self.color_font = [0, 0, 0] - self.color_numbers = [0, 0, 0] - self.color_button = [.8, .8, .8, 1] - self.color_funky = [.1, .2, .5, 0.2] - - self.icon_light_off = 'themes/Light/light_off.png' - self.icon_light_reading = 'themes/Light/light_reading.png' - self.icon_light_sunrise = 'themes/Light/light_sunrise.png' - self.icon_light_on = 'themes/Light/light_on.png' - self.icon_media_playing = 'themes/Light/media_playing.png' - self.icon_media_stopped = 'themes/Light/media_stopped.png' - self.icon_alarm_on = 'themes/Light/alarm_on.png' - self.icon_alarm_off = 'themes/Light/alarm_off.png' - self.icon_settings_visible = 'themes/Light/settings_visible.png' - self.icon_settings_not_visible = 'themes/Light/settings_not_visible.png' + self.icon_light_off = "themes/" + x + "/light_off.png" + self.icon_light_reading = "themes/" + x + "/light_reading.png" + self.icon_light_sunrise = "themes/" + x + "/light_sunrise.png" + self.icon_light_on = "themes/" + x + "/light_on.png" + self.icon_media_playing = "themes/" + x + "/media_playing.png" + self.icon_media_stopped = "themes/" + x + "/media_stopped.png" + self.icon_alarm_on = "themes/" + x + "/alarm_on.png" + self.icon_alarm_off = "themes/" + x + "/alarm_off.png" + self.icon_settings_visible = "themes/" + x + "/settings_visible.png" + self.icon_settings_not_visible = "themes/" + x + "/settings_not_visible.png" class AlarmSettings(): alarm_time = datetime.datetime(2022, 12, 10, 7, 30, 0, 0)