Skip to content

Commit

Permalink
Project restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
x211321 committed Jul 4, 2022
1 parent 3855578 commit e0767f8
Show file tree
Hide file tree
Showing 6 changed files with 582 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
28 changes: 28 additions & 0 deletions lib/prefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import lib.var as var
import json

# Load preferences
if not os.path.exists(var.PREFERENCE_DIR):
os.makedirs(var.PREFERENCE_DIR)

# Set default preferences
app_preferences = {
"tray" : False,
"log" : True,
"profiles" : True,
"preview" : True,
"startMinimized": False,
"closeToTray" : False,
"applyStart" : False,
"extendSpeed" : False,
"language" : ""
}

# Get path to preference file
pref_file = os.path.join(var.PREFERENCE_DIR, var.PREFERENCE_FILE)

if os.path.isfile(pref_file):
# Read preferences from file and merge with default preferences
with open(f"{pref_file}", 'rt') as file:
app_preferences = {**app_preferences, **json.load(file)}
62 changes: 62 additions & 0 deletions lib/tray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import wx
from wx.adv import TaskBarIcon

import gettext
_ = gettext.gettext

DYNAMIC_TRAY_START = 5

#######################
# class AcerRGBGUI_Tray
#----------------------
# Handles tray icon
class AcerRGBGUI_Tray(TaskBarIcon):
def __init__(self, parent):
TaskBarIcon.__init__(self)

self.parent = parent

# Set tray icon
self.SetIcon(wx.Icon('./assets/icon.png', wx.BITMAP_TYPE_PNG), _("RGB Config"))

# Static bindings for hide / restore and quit
self.Bind(wx.EVT_MENU, self.on_toggle_gui , id=1)
self.Bind(wx.EVT_MENU, self.parent.on_force_close, id=2)

# Hide / restore main window on left click
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_toggle_gui)

def CreatePopupMenu(self):
menu = wx.Menu()
menuID = DYNAMIC_TRAY_START

# Add available profiles dynamically
for profile in self.parent.profiles:
menu.Append(menuID, profile)
self.Bind(wx.EVT_MENU, self.on_quick_profile, id=menuID)

menuID += 1

# Separate profiles from static menu items
menu.AppendSeparator()

# Add static menu items
menu.Append(1, _("RGB Config"))
menu.Append(2, _("Close"))

return menu

def on_toggle_gui(self, event):
if self.parent.IsShown():
self.parent.Hide()

# Destroy about dialog if open
if self.parent.aboutDlg:
self.parent.aboutDlg.Destroy()
self.parent.aboutDlg = None
else:
self.parent.Show()

def on_quick_profile(self, event):
self.parent.loadProfile(self.parent.profiles[event.Id-DYNAMIC_TRAY_START])
self.parent.apply()
Loading

0 comments on commit e0767f8

Please sign in to comment.