Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions .github/workflows/build.yml

This file was deleted.

674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from src._version import __version__

# Project details
PROJECT_NAME = f"AppUsageGUI-v{__version__}"
PROJECT_NAME = "AppUsageGUI"
ENTRY_POINT = "src/main.py"
BUILD_DIR = "build"
DIST_DIR = "dist"
Expand Down
6 changes: 3 additions & 3 deletions installer/windows_installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "AppUsageGUI"
#define MyAppVersion "1.0.5"
#define MyAppVersion "1.1.4"
#define MyAppPublisher "Adam Blair-Smith"
#define MyAppURL "https://github.com/Adam-Color/AppUsageGUI"
#define MyAppExeName "AppUsageGUI-v1.0.5.exe"
#define MyInstallerName "AppUsageGUI_v1.0.5_WINDOWS_setup"
#define MyAppExeName "AppUsageGUI.exe"
#define MyInstallerName "AppUsageGUI_v1.1.4_WINDOWS_setup"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ PyScreeze==1.0.1
pytweening==1.2.0
rubicon-objc==0.5.0
pyinstaller
requests
2 changes: 1 addition & 1 deletion src/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.4"
__version__ = "1.1.4"
9 changes: 0 additions & 9 deletions src/core/gui_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,30 @@ def show_frame(self, page_name):
frame = self.frames[page_name]
frame.tkraise()

#FIXME: thread duplication in update_total_time
def reset_frames(self):
print("Resetting frames...") #! Debugging prints

try:
# Stop trackers
if self.logic_controller.app_tracker:
print("Stopping AppTracker...")
self.logic_controller.app_tracker.reset()

if self.logic_controller.time_tracker:
print("Stopping TimeTracker...")
self.logic_controller.time_tracker.reset()

if self.logic_controller.mouse_tracker:
print("Stopping MouseTracker...")
self.logic_controller.mouse_tracker.stop()

# Stop GUI threads
for frame_name, frame in self.frames.items():
if hasattr(frame, "stop_threads"):
print(f"Stopping threads for {frame_name}...")
frame.stop_threads()

# Destroy frames
for frame_name, frame in self.frames.items():
print(f"Destroying frame {frame_name}...")
frame.destroy()

self.frames = {}

# Reinitialize screens
print("Reinitializing screens...")
self.init_screens()

except Exception as e:
Expand Down
1 change: 0 additions & 1 deletion src/core/logic/file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def load_session_data(self, filename):
self.data = None
except _pickle.UnpicklingError as e:
self.corrupt_sessions.append((filename, "Data is corrupt"))
print(filename + ": " + str(e))
self.data = None
else:
self.corrupt_sessions.append((filename, "No hash file found"))
Expand Down
Binary file modified src/core/resources/icon-resources/icon.psd
Binary file not shown.
2 changes: 0 additions & 2 deletions src/core/screens/create_session_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def on_confirm(self):
def session_save(self, session_name):
self.logic_controller.file_handler.set_file_name(session_name)
session_time = self.logic_controller.time_tracker.get_time(saved=True)
print("Session time: ", session_time) #!
session_app_name = self.logic_controller.app_tracker.get_selected_app()
print("Session_app_name: ", session_app_name) #!

data = {'app_name': session_app_name, 'time_spent': session_time}

Expand Down
6 changes: 5 additions & 1 deletion src/core/screens/main_window.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import tkinter as tk

from core.utils.file_utils import sessions_exist

class MainWindow(tk.Frame):
def __init__(self, parent, controller, logic_controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.controller = controller # GUI controller
self.logic_controller = logic_controller

label_text = "To begin app tracking, start a new session:"
Expand All @@ -27,3 +28,6 @@ def __init__(self, parent, controller, logic_controller):
button3 = tk.Button(self, text=" Configure custom rules ", command=lambda: controller.
show_frame("TrackerSettingsWindow"))
button3.pack(pady=3)

exit_button = tk.Button(self, text=" Exit ", command=lambda: controller.on_close())
exit_button.pack(pady=10, side='bottom')
3 changes: 2 additions & 1 deletion src/core/screens/select_app_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ def __init__(self, parent, controller, logic_controller):
def select_app(self):
selected_index = self.app_listbox.curselection()
if selected_index:
self.controller.frames["TrackerWindow"].start_update_thread()
selected_app = self.app_listbox.get(selected_index)
self.controller.show_frame("TrackerWindow")
self.app_tracker.set_selected_app(selected_app)
self.controller.show_frame("TrackerWindow")
else:
messagebox.showerror("Error", "No application selected")

Expand Down
2 changes: 1 addition & 1 deletion src/core/screens/sessions_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def select_session(self):
if not self.get_session_text():
tk.messagebox.showerror("Error", "No session selected")
return 0
self.controller.frames["TrackerWindow"].start_update_thread()
selected_app_name = self.get_session_text().split(": ")[1].split(", ")[0]
selected_session_name = self.get_session_text().split(": ")[0]

Expand All @@ -88,7 +89,6 @@ def select_session(self):
# start/reset tracking threads
self.logic_controller.app_tracker.reset()
self.logic_controller.app_tracker.set_selected_app(selected_app_name)
self.logic_controller.app_tracker.start()
self.logic_controller.time_tracker.reset(add_time=self.logic_controller.file_handler.get_data()['time_spent'])
self.logic_controller.time_tracker.start()
self.logic_controller.time_tracker.clock()
Expand Down
5 changes: 3 additions & 2 deletions src/core/screens/tracker_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class TrackerWindow(tk.Frame):
def __init__(self, parent, controller, logic_controller):
print("init") #! debug
tk.Frame.__init__(self, parent)
self.controller = controller
self.logic_controller = logic_controller
Expand Down Expand Up @@ -39,7 +38,6 @@ def __init__(self, parent, controller, logic_controller):

self.update_thread = threading.Thread(target=self.update_time_label)
self.update_thread.daemon = True
self.update_thread.start()

self.periodic_update()

Expand Down Expand Up @@ -113,6 +111,9 @@ def periodic_update(self):
except queue.Empty:
pass
self.after(500, self.periodic_update)

def start_update_thread(self):
self.update_thread.start()

def stop_threads(self):
self.stop_event.set()
2 changes: 1 addition & 1 deletion src/core/utils/time_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
def format_time(secs):
hours, remainder = divmod(secs, 3600)
minutes, seconds = divmod(remainder, 60)
return f"{hours}h {minutes}m {seconds}s"
return f"{hours}h {minutes}m {seconds}s"
58 changes: 57 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import tkinter as tk
import os
import sys
import time
import webbrowser
import requests

from _version import __version__

Expand Down Expand Up @@ -51,8 +54,61 @@ def apply_dark_theme(root):

root.tk_setPalette(background=dark_bg, foreground=dark_fg)

def new_updates():
"""Check for new updates on GitHub. Returns a boolean"""
try:
response = requests.get("https://api.github.com/repos/adam-color/AppUsageGUI/releases/latest", timeout=10)
response.raise_for_status() # Raises an HTTPError for bad responses

data = response.json()
latest_version = data["tag_name"].lstrip('v').split('.')
current_version = __version__.split('.')

# Compare version numbers
for latest, current in zip(latest_version, current_version):
if int(latest) > int(current):
return True
elif int(latest) < int(current):
return False

# If we've gotten here, the versions are equal
return False

except requests.RequestException as e:
print(f"Error checking for updates: Network error - {str(e)}")
except (KeyError, ValueError, IndexError) as e:
print(f"Error checking for updates: Parsing error - {str(e)}")
except Exception as e:
print(f"Error checking for updates: Unexpected error - {str(e)}")
return False

def splash_screen():
"""Display a splash screen while the application loads."""
# Check for new updates
if new_updates():
ask_update = tk.messagebox.askquestion('AppUsageGUI Updates', "A new update is available. Would you like to download it from the github page?")
if ask_update == "yes":
webbrowser.open_new_tab("https://github.com/adam-color/AppUsageGUI/releases/latest")

splash_window = tk.Tk()
splash_window.attributes("-topmost", True)
splash_window.geometry("200x50")
splash_window.title("AppUsageGUI - Loading...")

# Display loading text
loading_label = tk.Label(splash_window, text="\nLoading...")
loading_label.pack()

# Simulate loading process
for i in range(10):
splash_window.update_idletasks()
splash_window.update()
time.sleep(0.1)

splash_window.destroy()

def main():
splash_screen()
root = tk.Tk()

icon_name = "core/resources/icon.ico" if os.name == 'nt' else "core/resources/icon.icns"
Expand All @@ -64,7 +120,7 @@ def main():
win = GUIRoot(root)
win.pack(side="top", fill="both", expand=True)

if is_dark_mode():
if os.name == 'nt' and is_dark_mode():
apply_dark_theme(root)

# calls to create the app directories
Expand Down