Skip to content

Commit

Permalink
Fetch and Update parameters from Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Satanarious committed Aug 29, 2023
1 parent c741ab3 commit 1fb813c
Show file tree
Hide file tree
Showing 3 changed files with 635 additions and 29 deletions.
129 changes: 101 additions & 28 deletions Data/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
from typing import TYPE_CHECKING
import json

# Relative Imports
from Registry.reg_edit import EditRegistry
from Data.defaults import Defaults
from Dialogs.color_picker import ColorPicker

if TYPE_CHECKING:
from main import Main

# Dump Residue or Previously Present Parameters
with open("user_Settings.json", "w") as json_file:
json.dump(EditRegistry.fetchAllValues(), json_file)

rawDefaults: dict = dict(json.load(open("user_settings.json", "r")))

Expand All @@ -19,38 +27,38 @@ def joinVars(*vars: str) -> str:
dropdown: str = "DropDown"
menu: str = "Menu"
animation: str = "Animation"
disabledHot: str = "Disabled Hot"
disabledHot: str = "DisabledHot"
focusing: str = "Focusing"
hot: str = "Hot"
separator: str = "Separator"
tooltip: str = "Tooltip"
effectType: str = "Effect Type"
cornerType: str = "Corner Type"
enableDropShadow: str = "Enable Drop Shadow"
noBorderColor: str = "No Border Color"
darkModeBorderColor: str = "Dark Mode Border Color"
lightModeBorderColor: str = "Light Mode Border Color"
darkModeGradientColor: str = "Dark Mode Gradient Color"
lightModeGradientColor: str = "Light Mode Gradient Color"
disabled: str = "Disabled"
noSystemDropShadow: str = "No System Drop Shadow"
enableImmersiveStyle: str = "Enable Immersive Style"
enableCustomRendering: str = "Enable Custom Rendering"
enableFluentAnimation: str = "Enable Fluent Animation"
noModernAppBackgroundColor: str = "No Modern App Background Color"
colorTreatAsTransparent: str = "Color Treat As Transparent"
colorTreatAsTransparentThreshold: str = "Color Treat As Transparent Threshold"
fadeOutTime: str = "Fade Out Time"
popInTime: str = "Pop In Time"
fadeInTime: str = "Fade In Time"
popInStyle: str = "Pop In Style"
startRatio: str = "Start Ratio"
enableImmediateInterupting: str = "Enable Immediate Interupting"
cornerRadius: str = "Corner Radius"
darkModeColor: str = "Dark Mode Color"
lightModeColor: str = "Light Mode Color"
enableThemeColorization: str = "Enable Theme Colorization"
width: str = "Width"
effectType: str = "effectType"
cornerType: str = "cornerType"
enableDropShadow: str = "enableDropShadow"
noBorderColor: str = "noBorderColor"
darkModeBorderColor: str = "darkModeBorderColor"
lightModeBorderColor: str = "lightModeBorderColor"
darkModeGradientColor: str = "darkModeGradientColor"
lightModeGradientColor: str = "lightModeGradientColor"
disabled: str = "disabled"
noSystemDropShadow: str = "noSystemDropShadow"
enableImmersiveStyle: str = "enableImmersiveStyle"
enableCustomRendering: str = "enableCustomRendering"
enableFluentAnimation: str = "enableFluentAnimation"
noModernAppBackgroundColor: str = "noModernAppBackgroundColor"
colorTreatAsTransparent: str = "colorTreatAsTransparent"
colorTreatAsTransparentThreshold: str = "colorTreatAsTransparentThreshold"
fadeOutTime: str = "fadeOutTime"
popInTime: str = "popInTime"
fadeInTime: str = "fadeInTime"
popInStyle: str = "popInStyle"
startRatio: str = "startRatio"
enableImmediateInterupting: str = "enableImmediateInterupting"
cornerRadius: str = "cornerRadius"
darkModeColor: str = "darkModeColor"
lightModeColor: str = "lightModeColor"
enableThemeColorization: str = "enableThemeColorization"
width: str = "width"


# Keys from JSON file
Expand Down Expand Up @@ -109,9 +117,17 @@ def updateUI(window: Main):
window.noBorderColor1.setCurrentIndex(Saved.Global.noBorderColor)
window.enableThemeColorization1.setCurrentIndex(Saved.Global.enableThemeColorization)
window.darkModeBorderColor1.setText(Saved.Global.darkModeBorderColor)
if Saved.Global.darkModeBorderColor != Defaults.Global.darkModeBorderColor:
ColorPicker.changeButtonColor(Saved.Global.darkModeBorderColor, window.dark_mode_border_color_picker1)
window.lightModeBorderColor1.setText(Saved.Global.lightModeBorderColor)
if Saved.Global.lightModeBorderColor != Defaults.Global.lightModeBorderColor:
ColorPicker.changeButtonColor(Saved.Global.lightModeBorderColor, window.light_mode_border_color_picker1)
window.darkModeGradientColor1.setText(Saved.Global.darkModeGradientColor)
if Saved.Global.darkModeGradientColor != Defaults.Global.darkModeGradientColor:
ColorPicker.changeButtonColor(Saved.Global.darkModeGradientColor, window.dark_mode_gradient_color_picker1)
window.lightModeGradientColor1.setText(Saved.Global.lightModeGradientColor)
if Saved.Global.lightModeGradientColor != Defaults.Global.lightModeGradientColor:
ColorPicker.changeButtonColor(Saved.Global.lightModeGradientColor, window.light_mode_gradient_color_picker1)
window.disabledEffect1.setCurrentIndex(Saved.Global.disabled)

# DropDown
Expand All @@ -121,25 +137,46 @@ def updateUI(window: Main):
window.noBorderColor2.setCurrentIndex(Saved.DropDown.noBorderColor)
window.enableThemeColorization2.setCurrentIndex(Saved.DropDown.enableThemeColorization)
window.darkModeBorderColor2.setText(Saved.DropDown.darkModeBorderColor)
if Saved.DropDown.darkModeBorderColor != Defaults.DropDown.darkModeBorderColor:
ColorPicker.changeButtonColor(Saved.DropDown.darkModeBorderColor, window.dark_mode_border_color_picker2)
window.lightModeBorderColor2.setText(Saved.DropDown.lightModeBorderColor)
if Saved.DropDown.lightModeBorderColor != Defaults.DropDown.lightModeBorderColor:
ColorPicker.changeButtonColor(Saved.DropDown.lightModeBorderColor, window.light_mode_border_color_picker2)
window.darkModeGradientColor2.setText(Saved.DropDown.darkModeGradientColor)
if Saved.DropDown.darkModeGradientColor != Defaults.DropDown.darkModeGradientColor:
ColorPicker.changeButtonColor(Saved.DropDown.darkModeGradientColor, window.dark_mode_gradient_color_picker2)
window.lightModeGradientColor2.setText(Saved.DropDown.lightModeGradientColor)
if Saved.DropDown.lightModeGradientColor != Defaults.DropDown.lightModeGradientColor:
ColorPicker.changeButtonColor(Saved.DropDown.lightModeGradientColor, window.light_mode_gradient_color_picker2)
window.disabledEffect2.setCurrentIndex(Saved.DropDown.disabled)

# Menu-General
window.noSystemDropShadow.setCurrentIndex(Saved.Menu.noSystemDropShadow)
window.enableImmersiveStyle.setCurrentIndex(Saved.Menu.enableImmersiveStyle)
window.enableCustomRendering.setCurrentIndex(Saved.Menu.enableCustomRendering)
window.enableFluentAnimation.setCurrentIndex(Saved.Menu.enableFluentAnimation)
window.noModernAppBackgroundColor.setCurrentIndex(Saved.Menu.noModernAppBackgroundColor)
window.colorTreatAsTransparent.setText(Saved.Menu.colorTreatAsTransparent)
if Saved.Menu.colorTreatAsTransparent != Defaults.Menu.colorTreatAsTransparent:
ColorPicker.changeButtonColor(Saved.Menu.colorTreatAsTransparent, window.color_treat_as_transparent_color_picker)
window.colorTreatAsTransparentThreshold.setValue(Saved.Menu.colorTreatAsTransparentThreshold)
window.effectType3.setCurrentIndex(Saved.Menu.effectType)
window.cornerType3.setCurrentIndex(Saved.Menu.cornerType)
window.enableDropShadow3.setCurrentIndex(Saved.Menu.enableDropShadow)
window.noBorderColor3.setCurrentIndex(Saved.Menu.noBorderColor)
window.enableThemeColorization3_1.setCurrentIndex(Saved.Menu.enableThemeColorization)
window.darkModeBorderColor3.setText(Saved.Menu.darkModeBorderColor)
if Saved.Menu.darkModeBorderColor != Defaults.Menu.darkModeBorderColor:
ColorPicker.changeButtonColor(Saved.Menu.darkModeBorderColor, window.dark_mode_border_color_picker3)
window.lightModeBorderColor3.setText(Saved.Menu.lightModeBorderColor)
if Saved.Menu.lightModeBorderColor != Defaults.Menu.lightModeBorderColor:
ColorPicker.changeButtonColor(Saved.Menu.lightModeBorderColor, window.light_mode_border_color_picker3)
window.darkModeGradientColor3.setText(Saved.Menu.darkModeGradientColor)
if Saved.Menu.darkModeGradientColor != Defaults.Menu.darkModeGradientColor:
ColorPicker.changeButtonColor(Saved.Menu.darkModeGradientColor, window.dark_mode_gradient_color_picker3)
window.lightModeGradientColor3.setText(Saved.Menu.lightModeGradientColor)
if Saved.Menu.lightModeGradientColor != Defaults.Menu.lightModeGradientColor:
ColorPicker.changeButtonColor(Saved.Menu.lightModeGradientColor, window.light_mode_gradient_color_picker3)
window.disabledEffect3_1.setCurrentIndex(Saved.Menu.disabled)

# Menu-Animation
Expand All @@ -152,34 +189,70 @@ def updateUI(window: Main):

# Menu-Hot
window.darkModeColor1_1.setText(Saved.Menu.Hot.darkModeColor)
if Saved.Menu.Hot.darkModeColor != Defaults.Menu.Hot.darkModeColor:
ColorPicker.changeButtonColor(Saved.Menu.Hot.darkModeColor, window.dark_mode_color_picker1_1)
window.lightModeColor1_1.setText(Saved.Menu.Hot.lightModeColor)
if Saved.Menu.Hot.lightModeColor != Defaults.Menu.Hot.lightModeColor:
ColorPicker.changeButtonColor(Saved.Menu.Hot.lightModeColor, window.light_mode_color_picker1_1)
window.disabledEffect3_2.setCurrentIndex(Saved.Menu.Hot.disabled)
window.cornerRadius1_1.setValue(Saved.Menu.Hot.cornerRadius)
window.enableThemeColorization3_2.setCurrentIndex(Saved.Menu.Hot.enableThemeColorization)

# Menu-Disabled Hot
window.darkModeColor1_2.setText(Saved.Menu.DisabledHot.darkModeColor)
if Saved.Menu.DisabledHot.darkModeColor != Defaults.Menu.DisabledHot.darkModeColor:
ColorPicker.changeButtonColor(Saved.Menu.DisabledHot.darkModeColor, window.dark_mode_color_picker1_2)
window.lightModeColor1_2.setText(Saved.Menu.DisabledHot.lightModeColor)
if Saved.Menu.DisabledHot.lightModeColor != Defaults.Menu.DisabledHot.lightModeColor:
ColorPicker.changeButtonColor(Saved.Menu.DisabledHot.lightModeColor, window.light_mode_color_picker1_2)
window.disabledEffect3_3.setCurrentIndex(Saved.Menu.DisabledHot.disabled)
window.cornerRadius1_2.setValue(Saved.Menu.DisabledHot.cornerRadius)
window.enableThemeColorization3_3.setCurrentIndex(Saved.Menu.DisabledHot.enableThemeColorization)

# Menu-Focusing
window.width1_1.setValue(Saved.Menu.Focusing.width)
window.darkModeColor1_3.setText(Saved.Menu.Focusing.darkModeColor)
if Saved.Menu.Focusing.darkModeColor != Defaults.Menu.Focusing.darkModeColor:
ColorPicker.changeButtonColor(Saved.Menu.Focusing.darkModeColor, window.dark_mode_color_picker1_3)
window.lightModeColor1_3.setText(Saved.Menu.Focusing.lightModeColor)
if Saved.Menu.Focusing.lightModeColor != Defaults.Menu.Focusing.lightModeColor:
ColorPicker.changeButtonColor(Saved.Menu.Focusing.lightModeColor, window.light_mode_color_picker1_3)
window.disabledEffect3_4.setCurrentIndex(Saved.Menu.Focusing.disabled)
window.cornerRadius1_3.setValue(Saved.Menu.Focusing.cornerRadius)
window.enableThemeColorization3_4.setCurrentIndex(Saved.Menu.Focusing.enableThemeColorization)

# Menu-Separator
window.width1_2.setValue(Saved.Menu.Separator.width)
window.darkModeColor1_4.setText(Saved.Menu.Separator.darkModeColor)
if Saved.Menu.Separator.darkModeColor != Defaults.Menu.Separator.darkModeColor:
ColorPicker.changeButtonColor(Saved.Menu.Separator.darkModeColor, window.dark_mode_color_picker1_4)
window.lightModeColor1_4.setText(Saved.Menu.Separator.lightModeColor)
if Saved.Menu.Separator.lightModeColor != Defaults.Menu.Separator.lightModeColor:
ColorPicker.changeButtonColor(Saved.Menu.Separator.lightModeColor, window.light_mode_color_picker1_4)
window.disabledEffect3_5.setCurrentIndex(Saved.Menu.Separator.disabled)
window.cornerRadius1_4.setValue(Saved.Menu.Separator.cornerRadius)
window.enableThemeColorization3_5.setCurrentIndex(Saved.Menu.Separator.enableThemeColorization)

# Tooltip
window.effectType4.setCurrentIndex(Saved.Tooltip.effectType)
window.cornerType4.setCurrentIndex(Saved.Tooltip.cornerType)
window.enableDropShadow4.setCurrentIndex(Saved.Tooltip.enableDropShadow)
window.noBorderColor4.setCurrentIndex(Saved.Tooltip.noBorderColor)
window.enableThemeColorization4.setCurrentIndex(Saved.Tooltip.enableThemeColorization)
window.darkModeBorderColor4.setText(Saved.Tooltip.darkModeBorderColor)
if Saved.Tooltip.darkModeBorderColor != Defaults.Tooltip.darkModeBorderColor:
ColorPicker.changeButtonColor(Saved.Tooltip.darkModeBorderColor, window.dark_mode_border_color_picker4)
window.lightModeBorderColor4.setText(Saved.Tooltip.lightModeBorderColor)
if Saved.Tooltip.lightModeBorderColor != Defaults.Tooltip.lightModeBorderColor:
ColorPicker.changeButtonColor(Saved.Tooltip.lightModeBorderColor, window.light_mode_border_color_picker4)
window.darkModeGradientColor4.setText(Saved.Tooltip.darkModeGradientColor)
if Saved.Tooltip.darkModeGradientColor != Defaults.Tooltip.darkModeGradientColor:
ColorPicker.changeButtonColor(Saved.Tooltip.darkModeGradientColor, window.dark_mode_gradient_color_picker4)
window.lightModeGradientColor4.setText(Saved.Tooltip.lightModeGradientColor)
if Saved.Tooltip.lightModeGradientColor != Defaults.Tooltip.lightModeGradientColor:
ColorPicker.changeButtonColor(Saved.Tooltip.lightModeGradientColor, window.light_mode_gradient_color_picker4)
window.disabledEffect4.setCurrentIndex(Saved.Tooltip.disabled)

class Global:
effectType: int = rawDefaults[Key._global][Key.effectType]
cornerType: int = rawDefaults[Key._global][Key.cornerType]
Expand Down
Loading

0 comments on commit 1fb813c

Please sign in to comment.