Skip to content

Commit

Permalink
refactor: change local to roaming
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpinet committed May 9, 2024
1 parent 42221e6 commit 690e6d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 0 additions & 3 deletions config.ini

This file was deleted.

8 changes: 6 additions & 2 deletions main.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

from util import gui

from PyQt5 import QtWidgets, QtGui
from PyQt5 import QtWidgets

import sys
import configparser
import os


# ------------------------------MAIN FUNCTION------------------------------
Expand Down Expand Up @@ -47,8 +48,11 @@ def main() -> None:
ui.setupUi(MainWindow)
MainWindow.show()

config_dir = os.path.join(os.environ["APPDATA"], "NyaaDownloader")
config_path = os.path.join(config_dir, "config.ini")

config = configparser.ConfigParser()
config.read("config.ini")
config.read(config_path)

if not config.has_option("Settings", "ShowPopup") or config.getboolean("Settings", "ShowPopup"):
gui.Ui_MainWindow.show_info_popup(MainWindow, message, never_show_again=True)
Expand Down
10 changes: 7 additions & 3 deletions util/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import nyaa

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox, QDialog, QInputDialog, QLineEdit, QCheckBox
from PyQt5.QtWidgets import QMessageBox, QDialog, QInputDialog, QLineEdit
from PyQt5.QtCore import Qt, QThread, pyqtSignal
from winotify import Notification, audio
from shutil import move
Expand All @@ -31,15 +31,19 @@ def update_config(key: str, value: str) -> None:
key (str): Key to update
value (str): Value to set for the key
"""
config_dir = os.path.join(os.environ["APPDATA"], "NyaaDownloader")
os.makedirs(config_dir, exist_ok=True)
config_path = os.path.join(config_dir, "config.ini")

config = configparser.ConfigParser()
config.read("config.ini")
config.read(config_path)

if not config.has_section("Settings"):
config.add_section("Settings")

config.set("Settings", key, value)

with open("config.ini", "w") as configfile:
with open(config_path, "w") as configfile:
config.write(configfile)

# Generated with Qt Designer (first time using this one)
Expand Down

0 comments on commit 690e6d2

Please sign in to comment.