Files
gotify-tray-customized/gotify_tray/database/settings.py
kdusek 5138303016
Some checks failed
build / build-pip (push) Failing after 16s
build / build-win64 (push) Has been cancelled
build / build-macos (push) Has been cancelled
Fix tray visibility and message reception issues
- Disable sound initialization to prevent hanging
- Add missing import re in utils.py
- Fix settings loading for QSettings
- Update file paths to use PROJECT_ROOT
- Revert to working API paths and listener from commit efdc63e
2025-12-07 22:39:07 +01:00

45 lines
1.2 KiB
Python

import pickle
from typing import Any
from .default_settings import DEFAULT_SETTINGS
from PyQt6 import QtCore
class Settings(QtCore.QSettings):
def __init__(self, organization: str):
super().__init__(organization)
def value(self, key: str, defaultValue: Any = None, type: Any = None) -> Any:
if type:
return super().value(
key, defaultValue=defaultValue or DEFAULT_SETTINGS.get(key), type=type
)
else:
return super().value(
key, defaultValue=defaultValue or DEFAULT_SETTINGS.get(key)
)
def export(self, path: str):
data = {
key: self.value(key)
for key in self.allKeys()
if not ( # skip settings that might not translate well between platforms
isinstance(self.value(key), QtCore.QByteArray)
or key == "export/path"
or key == "message/last"
)
}
with open(path, "wb") as f:
pickle.dump(data, f)
def load(self, path: str):
with open(path, "rb") as f:
data = pickle.load(f)
self.clear()
for key in data:
self.setValue(key, data[key])