develop #11

Merged
itdominator merged 36 commits from develop into master 2023-09-19 01:11:24 +00:00
7 changed files with 126 additions and 98 deletions
Showing only changes of commit 5264103f31 - Show all commits

View File

@ -47,13 +47,6 @@ class SettingsManager(StartCheckMixin, Singleton):
if not os.path.exists(self._PLUGINS_PATH):
os.mkdir(self._PLUGINS_PATH)
if not os.path.exists(self._CONFIG_FILE):
import shutil
try:
shutil.copyfile(self._USR_CONFIG_FILE, self._CONFIG_FILE)
except Exception as e:
raise
if not os.path.exists(self._DEFAULT_ICONS):
self._DEFAULT_ICONS = f"{self._USR_PATH}/icons"
if not os.path.exists(self._DEFAULT_ICONS):
@ -158,8 +151,13 @@ class SettingsManager(StartCheckMixin, Singleton):
self._debug = debug
def load_settings(self):
if not os.path.exists(self._CONFIG_FILE):
self.settings = Settings()
return
with open(self._CONFIG_FILE) as file:
data = json.load(file)
data["load_defaults"] = False
self.settings = Settings(**data)
def save_settings(self):

View File

@ -1,5 +1,5 @@
# Python imports
from dataclasses import dataclass
from dataclasses import dataclass, field
# Lib imports
@ -8,25 +8,25 @@ from dataclasses import dataclass
@dataclass
class Config:
base_of_home: str
hide_hidden_files: str
thumbnailer_path: str
blender_thumbnailer_path: str
go_past_home: str
lock_folder: str
locked_folders: str
mplayer_options: str
music_app: str
media_app: str
image_app: str
office_app: str
pdf_app: str
code_app: str
text_app: str
terminal_app: str
container_icon_wh: []
video_icon_wh: []
sys_icon_wh: []
file_manager_app: str
steam_cdn_url: str
remux_folder_max_disk_usage: str
base_of_home: str = ""
hide_hidden_files: str = "true"
thumbnailer_path: str = "ffmpegthumbnailer"
blender_thumbnailer_path: str = ""
go_past_home: str = "true"
lock_folder: str = "false"
locked_folders: list = field(default_factory=lambda: ["venv", "flasks"])
mplayer_options: str = "-quiet -really-quiet -xy 1600 -geometry 50%:50%"
music_app: str = "deadbeef"
media_app: str = "mpv"
image_app: str = "mirage"
office_app: str = "libreoffice"
pdf_app: str = "evince"
code_app: str = "atom"
text_app: str = "mousepad"
terminal_app: str = "terminator"
file_manager_app: str = "solarfm"
container_icon_wh: list = field(default_factory=lambda: [128, 128])
video_icon_wh: list = field(default_factory=lambda: [128, 64])
sys_icon_wh: list = field(default_factory=lambda: [56, 56])
steam_cdn_url: str = "https://steamcdn-a.akamaihd.net/steam/apps/"
remux_folder_max_disk_usage: str = "8589934592"

View File

@ -8,5 +8,5 @@ from dataclasses import dataclass
@dataclass
class Debugging:
ch_log_lvl: int
fh_log_lvl: int
ch_log_lvl: int = 10
fh_log_lvl: int = 20

View File

@ -1,5 +1,5 @@
# Python imports
from dataclasses import dataclass
from dataclasses import dataclass, field
# Lib imports
@ -8,11 +8,83 @@ from dataclasses import dataclass
@dataclass
class Filters:
meshs: []
code: []
videos: []
office: []
images: []
text: []
music: []
pdf: []
meshs: list = field(default_factory=lambda: [
".blend",
".dae",
".fbx",
".gltf",
".obj",
".stl"
])
code: list = field(default_factory=lambda: [
".cpp",
".css",
".c",
".go",
".html",
".htm",
".java",
".js",
".json",
".lua",
".md",
".py",
".rs",
".toml",
".xml",
".pom"
])
videos: list = field(default_factory=lambda:[
".mkv",
".mp4",
".webm",
".avi",
".mov",
".m4v",
".mpg",
".mpeg",
".wmv",
".flv"
])
office: list = field(default_factory=lambda: [
".doc",
".docx",
".xls",
".xlsx",
".xlt",
".xltx",
".xlm",
".ppt",
".pptx",
".pps",
".ppsx",
".odt",
".rtf"
])
images: list = field(default_factory=lambda: [
".png",
".jpg",
".jpeg",
".gif",
".ico",
".tga",
".webp"
])
text: list = field(default_factory=lambda: [
".txt",
".text",
".sh",
".cfg",
".conf",
".log"
])
music: list = field(default_factory=lambda: [
".psf",
".mp3",
".ogg",
".flac",
".m4a"
])
pdf: list = field(default_factory=lambda: [
".pdf"
])

View File

@ -1,5 +1,5 @@
# Python imports
from dataclasses import dataclass
from dataclasses import dataclass, field
from dataclasses import asdict
# Gtk imports
@ -13,16 +13,19 @@ from .debugging import Debugging
@dataclass
class Settings:
config: Config
filters: Filters
theming: Theming
debugging: Debugging
load_defaults: bool = True
config: Config = field(default_factory=lambda: Config())
filters: Filters = field(default_factory=lambda: Filters())
theming: Theming = field(default_factory=lambda: Theming())
debugging: Debugging = field(default_factory=lambda: Debugging())
def __post_init__(self):
self.config = Config(**self.config)
self.filters = Filters(**self.filters)
self.theming = Theming(**self.theming)
self.debugging = Debugging(**self.debugging)
if not self.load_defaults:
self.load_defaults = False
self.config = Config(**self.config)
self.filters = Filters(**self.filters)
self.theming = Theming(**self.theming)
self.debugging = Debugging(**self.debugging)
def as_dict(self):
return asdict(self)

View File

@ -8,6 +8,6 @@ from dataclasses import dataclass
@dataclass
class Theming:
success_color: str
warning_color: str
error_color: str
success_color: str = "#88cc27"
warning_color: str = "#ffa800"
error_color: str = "#ff0000"

View File

@ -1,45 +0,0 @@
{
"config": {
"base_of_home": "",
"hide_hidden_files": "true",
"thumbnailer_path": "ffmpegthumbnailer",
"blender_thumbnailer_path": "",
"go_past_home": "true",
"lock_folder": "false",
"locked_folders": "venv::::flasks",
"mplayer_options": "-quiet -really-quiet -xy 1600 -geometry 50%:50%",
"music_app": "deadbeef",
"media_app": "mpv",
"image_app": "mirage2",
"office_app": "libreoffice",
"pdf_app": "evince",
"code_app": "atom",
"text_app": "mousepad",
"terminal_app": "terminator",
"container_icon_wh": [128, 128],
"video_icon_wh": [128, 64],
"sys_icon_wh": [56, 56],
"file_manager_app": "solarfm",
"steam_cdn_url": "https://steamcdn-a.akamaihd.net/steam/apps/",
"remux_folder_max_disk_usage": "8589934592"
},
"filters": {
"meshs": [".dae", ".fbx", ".gltf", ".obj", ".stl"],
"code": [".cpp", ".css", ".c", ".go", ".html", ".htm", ".java", ".js", ".json", ".lua", ".md", ".py", ".rs", ".toml", ".xml", ".pom"],
"videos": [".mkv", ".mp4", ".webm", ".avi", ".mov", ".m4v", ".mpg", ".mpeg", ".wmv", ".flv"],
"office": [".doc", ".docx", ".xls", ".xlsx", ".xlt", ".xltx", ".xlm", ".ppt", ".pptx", ".pps", ".ppsx", ".odt", ".rtf"],
"images": [".png", ".jpg", ".jpeg", ".gif", ".ico", ".tga", ".webp"],
"text": [".txt", ".text", ".sh", ".cfg", ".conf", ".log"],
"music": [".psf", ".mp3", ".ogg", ".flac", ".m4a"],
"pdf": [".pdf"]
},
"theming":{
"success_color": "#88cc27",
"warning_color": "#ffa800",
"error_color": "#ff0000"
},
"debugging": {
"ch_log_lvl": 20,
"fh_log_lvl": 10
}
}