Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/kosmolebryce/shyft into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmo committed Jun 15, 2024
2 parents 3fa82b5 + cc71574 commit f09544a
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 62 deletions.
Binary file modified Shyft.dmg
Binary file not shown.
Binary file modified ShyftApp/Shyft.app/Contents/MacOS/Shyft
Binary file not shown.
74 changes: 49 additions & 25 deletions ShyftApp/Shyft.app/Contents/Resources/Shyft.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,40 @@ def minimize_window(event=None):
class TimerWindow:
def __init__(self, root, time_color="#A78C7B", bg_color="#FFBE98"):
self.root = root
self.root.title("Timer")
if platform.system() == "Darwin":
self.root.geometry("140x70")
self.config = configparser.ConfigParser()
self.config.read(CONFIG_FILE)

if not self.config.has_section("Window"):
self.config.add_section("Window")
self.custom_width = 180
self.custom_height = 90
logger.debug("No 'Window' section found in config file, using default dimensions.")
else:
self.root.geometry("200x85")
self.custom_width = self.config.getint("Window", "width", fallback=180)
self.custom_height = self.config.getint("Window", "height", fallback=90)
logger.debug(f"Loaded custom dimensions from config file: width={self.custom_width}, height={self.custom_height}")

self.root.title("Timer")
self.root.geometry(f"{self.custom_width}x{self.custom_height}")
self.root.configure(bg=bg_color)

self.elapsed_time = timedelta(0)
self.running = False
self.last_time = None
self.time_color = time_color
self.bg_color = bg_color

self.timer_label = tk.Label(
self.root,
text="00:00:00",
font=("Helvetica Neue", 32, "bold"),
fg=self.time_color,
bg=self.bg_color,
)
self.timer_label.pack(padx=5, pady=0)
self.timer_label.pack(expand=True, padx=10, pady=(5, 0))

button_frame = tk.Frame(self.root, bg=self.bg_color)
button_frame.pack(fill="x", pady=0)
button_frame.pack(fill="x", padx=10, pady=(0, 5))

button_font = ("Helvetica", 10)
self.start_button = tk.Button(
Expand Down Expand Up @@ -159,7 +169,7 @@ def __init__(self, root, time_color="#A78C7B", bg_color="#FFBE98"):
self.update_timer_thread.start()
logger.info("Timer window initialized.")

self.root.protocol("WM_DELETE_WINDOW", self.destroy)
self.root.protocol("WM_DELETE_WINDOW", self.on_close)

def start(self):
if not self.running:
Expand All @@ -180,7 +190,8 @@ def reset(self):
logger.debug("Timer reset.")

def update_label(self, text):
self.timer_label.config(text=text)
if self.timer_label.winfo_exists():
self.timer_label.config(text=text)

def update_timer(self):
while True:
Expand All @@ -191,10 +202,15 @@ def update_timer(self):
self.root.after(0, self.update_label, str(elapsed).split(".")[0].rjust(8, "0"))
time.sleep(0.1)

def destroy(self):
def on_close(self):
self.running = False
self.config.set("Window", "width", str(self.root.winfo_width()))
self.config.set("Window", "height", str(self.root.winfo_height()))
with open(CONFIG_FILE, "w") as config_file:
self.config.write(config_file)
logger.debug(f"Timer window dimensions saved: width={self.root.winfo_width()}, height={self.root.winfo_height()}")
self.root.after(0, self.root.destroy)
logger.debug("Timer window destroyed.")
logger.debug("Timer window closed.")

class ShyftGUI:
def __init__(self, root):
Expand All @@ -207,11 +223,13 @@ def __init__(self, root):
self.root.configure(bg=self.bg_color)
self.config = configparser.ConfigParser()
self.config.read(CONFIG_FILE)
if not self.config.has_section("Theme"):
self.config.add_section("Theme")
if platform.system() == "Darwin":
self.selected_theme = "aqua"
else:
self.selected_theme = "default"
self.timer_topmost = False
self.timer_topmost = self.config.getboolean("Theme", "timer_topmost", fallback=False)
self.timer_topmost_var = tk.BooleanVar(value=self.timer_topmost)
self.configure_styles()
self.data = {}
Expand All @@ -229,10 +247,11 @@ def toggle_timer_topmost(self):
current_topmost_state = self.timer_window.root.attributes("-topmost")
new_topmost_state = not current_topmost_state
self.timer_window.root.attributes("-topmost", new_topmost_state)
self.config.set("Theme", "timer_topmost", str(new_topmost_state))
with open(CONFIG_FILE, "w") as config_file:
self.config.write(config_file)
logger.debug(f"Timer topmost state set to {new_topmost_state}.")
self.config.set("Theme", "timer_topmost", str(new_topmost_state))
with open(CONFIG_FILE, "w") as config_file:
self.config.write(config_file)
self.timer_topmost_var.set(new_topmost_state)
logger.debug(f"Timer topmost state set to {new_topmost_state}.")

def on_quit(self, event=None):
self.running = False
Expand Down Expand Up @@ -726,7 +745,7 @@ def save_data_and_update_view(self, notes_window):

if self.timer_window:
self.timer_window.reset()
self.timer_window.destroy()
self.timer_window.on_close()
self.timer_window = None
self.enable_theme_menu()
self.disable_topmost_menu()
Expand All @@ -740,12 +759,12 @@ def save_data_and_update_view(self, notes_window):

def reinitialize_timer_window(self):
if self.timer_window:
self.timer_window.destroy()
self.timer_window.on_close()
self.timer_window = TimerWindow(
tk.Toplevel(self.root), time_color=self.time_color, bg_color=self.bg_color
)
self.timer_window.start()
topmost_state = self.config.getboolean("Theme", "timer_topmost")
topmost_state = self.config.getboolean("Theme", "timer_topmost", fallback=False)
self.timer_window.root.attributes("-topmost", topmost_state)
logger.info("Timer window reinitialized with new settings.")

Expand Down Expand Up @@ -800,9 +819,14 @@ def choose_btn_text_color(self):
def save_config(self):
if not self.config.has_section("Colors"):
self.config.add_section("Colors")
if not self.config.has_section("Window"):
self.config.add_section("Window")
self.config.set("Colors", "time_color", self.time_color)
self.config.set("Colors", "bg_color", self.bg_color)
self.config.set("Colors", "btn_text_color", self.btn_text_color)
if self.timer_window:
self.config.set("Window", "width", str(self.timer_window.root.winfo_width()))
self.config.set("Window", "height", str(self.timer_window.root.winfo_height()))
with open(CONFIG_FILE, "w") as config_file:
self.config.write(config_file)
self.update_styles()
Expand Down Expand Up @@ -867,13 +891,13 @@ def insert_divider():
timer_window, time_color=self.time_color, bg_color=self.bg_color
)
self.timer_window.start()
topmost_state = self.config.getboolean("Theme", "timer_topmost")
topmost_state = self.config.getboolean("Theme", "timer_topmost", fallback=False)
self.timer_window.root.attributes("-topmost", topmost_state)
self.disable_theme_menu()
self.enable_topmost_menu()

def submit_notes():
if self.timer_window:
if self.timer_window and tk.Toplevel.winfo_exists(self.timer_window.root):
self.timer_window.stop()
elapsed_time = self.timer_window.elapsed_time

Expand Down Expand Up @@ -917,9 +941,9 @@ def submit_notes():
logger.error("Failed to log shift: Timer is not running.")

def cancel_notes():
if self.timer_window:
if self.timer_window and tk.Toplevel.winfo_exists(self.timer_window.root):
self.timer_window.reset()
self.timer_window.destroy()
self.timer_window.on_close()
self.timer_window = None
self.enable_theme_menu()
self.disable_topmost_menu()
Expand Down Expand Up @@ -971,7 +995,7 @@ def setup_menu(self):
self.menu_bar = tk.Menu(self.root)
self.setup_theme_menu()
self.setup_view_menu()
self.setup_settings_menu() # New method to set up Settings menu
self.setup_settings_menu()
self.root.config(menu=self.menu_bar)

def setup_theme_menu(self):
Expand Down
18 changes: 9 additions & 9 deletions ShyftApp/Shyft.app/Contents/_CodeSignature/CodeResources
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dict>
<key>Resources/Shyft.py</key>
<data>
silMLtZcK1J9uyNgVpCIHfvAARI=
SWngnLp4CAN4aKV5CZxGhNkSVOI=
</data>
<key>Resources/__boot__.py</key>
<data>
Expand Down Expand Up @@ -714,7 +714,7 @@
</data>
<key>Resources/lib/python310.zip</key>
<data>
Orz6byCTab+czc7mu21nKbd/1oM=
lbDkyCylqasbnuRqLP4H7CgdNZA=
</data>
<key>Resources/lib/tcl8.6/auto.tcl</key>
<data>
Expand Down Expand Up @@ -2306,7 +2306,7 @@
</data>
<key>Resources/site.pyc</key>
<data>
tsBvGf6D28UOXG3IMLMvyL1lxGw=
TTepRdAZme81fp84FelZaySNc4Y=
</data>
<key>Resources/zlib.cpython-310-darwin.so</key>
<data>
Expand Down Expand Up @@ -2373,11 +2373,11 @@
<dict>
<key>hash</key>
<data>
silMLtZcK1J9uyNgVpCIHfvAARI=
SWngnLp4CAN4aKV5CZxGhNkSVOI=
</data>
<key>hash2</key>
<data>
RrKXHBgnFzUjWybm9AX4ErJQGJ8ce/tHpjHswRowdSM=
CAjtwmtL8nEIbQMDGFfl+2W9jytGnywoOPx2hn1kDcs=
</data>
</dict>
<key>Resources/__boot__.py</key>
Expand Down Expand Up @@ -4325,11 +4325,11 @@
<dict>
<key>hash</key>
<data>
Orz6byCTab+czc7mu21nKbd/1oM=
lbDkyCylqasbnuRqLP4H7CgdNZA=
</data>
<key>hash2</key>
<data>
o1HmbcOOPJSAp1RJsTRMd3yWMhXq9GRjD8IknCekeTk=
VVOKz5zK0s8noYjmUhIcuBhiJR3Y8muDIrhbgT2WiM4=
</data>
</dict>
<key>Resources/lib/tcl8.6/auto.tcl</key>
Expand Down Expand Up @@ -8703,11 +8703,11 @@
<dict>
<key>hash</key>
<data>
tsBvGf6D28UOXG3IMLMvyL1lxGw=
TTepRdAZme81fp84FelZaySNc4Y=
</data>
<key>hash2</key>
<data>
ekVbW7zbIKbg9O/VkoUJ0K/mQpr/cMf79PV9UKfNMHM=
dAgqWPKozb4sEtocjypgXQyWG+yZ6wziW4CmAh9qhKg=
</data>
</dict>
<key>Resources/zlib.cpython-310-darwin.so</key>
Expand Down
Binary file modified ShyftEXE/Shyft.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions ShyftEXE/_internal/config.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Theme]
selected = default
timer_topmost = False
[Window]
width = 200
height = 100

Loading

0 comments on commit f09544a

Please sign in to comment.