Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions mal_gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
QPushButton,
QDialogButtonBox,
QFileDialog,
QMessageBox
QMessageBox,
)
from .main_window import MainWindow


class FileSelectionDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
Expand All @@ -46,15 +47,16 @@ def __init__(self, parent=None):

# Load the config file containing latest lang file path
config_file_dir = user_config_dir("mal-gui", "mal-lang")
self.config_file_path = config_file_dir + '/config.ini'
self.config_file_path = config_file_dir + "/config.ini"

# Make sure config file exists
os.makedirs(os.path.dirname(self.config_file_path), exist_ok=True)

self.config = configparser.ConfigParser()
self.config.read(self.config_file_path)
self.selected_lang_file = self.config.get(
'Settings', 'langFilePath', fallback=None)
"Settings", "langFilePath", fallback=None
)
print(f"Initial langFilePath path: {self.selected_lang_file}")

self.lang_file_path_text.setText(self.selected_lang_file)
Expand Down Expand Up @@ -98,27 +100,25 @@ def save_lang_file_path(self):

selected_lang_file = self.lang_file_path_text.text()

if selected_lang_file.endswith('.mar') or \
selected_lang_file.endswith('.mal'):
if selected_lang_file.endswith(".mar") or selected_lang_file.endswith(".mal"):
self.selected_lang_file = selected_lang_file

# Remember language choice in user settings
try:
self.config.add_section('Settings')
self.config.add_section("Settings")
except configparser.DuplicateSectionError:
pass

self.config.set('Settings', 'langFilePath',
self.selected_lang_file)
self.config.set("Settings", "langFilePath", self.selected_lang_file)

with open(self.config_file_path, 'w', encoding='utf-8') as conf_file:
with open(self.config_file_path, "w", encoding="utf-8") as conf_file:
self.config.write(conf_file)

self.accept() # Close the dialog and return accepted
else:
QMessageBox.warning(
self, "Invalid File",
"Please select a valid .mal or .mar file.")
self, "Invalid File", "Please select a valid .mal or .mar file."
)

def get_selected_file(self):
return self.selected_lang_file
Expand Down
5 changes: 1 addition & 4 deletions mal_gui/assets_container/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from .assets_container_rectangle_box import AssetsContainerRectangleBox
from .assets_container import AssetsContainer

__all__ = [
"AssetsContainerRectangleBox",
"AssetsContainer"
]
__all__ = ["AssetsContainerRectangleBox", "AssetsContainer"]
Loading
Loading