Skip to content

Commit

Permalink
(fix) saving configurations in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
javadr committed Aug 16, 2023
1 parent ea34ab6 commit 0a1147e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023-08-16 -- v0.8.1
-- Fixed issue with saving configurations in Windows

2023-08-16 -- v0.8
-- All configurations will be saved in a TOML file to be loaded in the next run.

Expand Down
3 changes: 2 additions & 1 deletion negar_gui/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import platform
from pathlib import Path

__version__ = "0.8"
__version__ = "0.8.1"

APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else "."
SETTING_FILE = Path.home() / f"{APPDATA}negar-gui/settings.toml"
SETTING_FILE.parent.mkdir(parents=True, exist_ok=True)

if platform.system() == "Windows":
LOGO = ":/images/icons/logo_small.png"
Expand Down
4 changes: 2 additions & 2 deletions negar_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ def __save_settings(self):
"window_position": {"x": self.x(), "y": self.y()},
})

with open(SETTING_FILE, "w") as toml_file:
with SETTING_FILE.open("w") as toml_file:
toml.dump(self.settings, toml_file)

logging.info("Settings Saved on Close!")

def __load_settings(self):
try:
with open(SETTING_FILE) as toml_file:
with SETTING_FILE.open() as toml_file:
self.settings.update(toml.load(toml_file))
window_size = QSize(
self.settings["window_size"]["width"],
Expand Down

0 comments on commit 0a1147e

Please sign in to comment.