diff --git a/.gitignore b/.gitignore index 1d86080..2dcd9e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ build +dist .venv diff --git a/OSCRUI/app.py b/OSCRUI/app.py index e0dcdc8..db7394f 100644 --- a/OSCRUI/app.py +++ b/OSCRUI/app.py @@ -12,7 +12,7 @@ from .translation import init_translation from .leagueconnector import OSCRClient -from .iofunctions import get_asset_path, load_icon_series, load_icon, open_link, reset_temp_folder +from .iofunctions import get_asset_path, load_icon_series, load_icon, open_link from .textedit import format_path from .widgets import AnalysisPlot, BannerLabel, FlipButton, WidgetStorage from .widgetbuilder import ABOTTOM, ACENTER, AHCENTER, ALEFT, ARIGHT, ATOP, AVCENTER @@ -87,7 +87,6 @@ def __init__(self, theme, args, path, config, versions) -> None: self.update_translation() self.league_api = None - reset_temp_folder(self.config['templog_folder_path']) self.app, self.window = self.create_main_window() self.copy_shortcut = QShortcut( QKeySequence.StandardKey.Copy, self.window, self.copy_analysis_table_callback) @@ -159,8 +158,14 @@ def init_settings(self): """ Prepares settings. Loads stored settings. Saves current settings for next startup. """ - settings_path = os.path.abspath(self.app_dir + self.config["settings_path"]) - self.settings = QSettings(settings_path, QSettings.Format.IniFormat) + + # For Windows, Keep the Local settings for now as people are more familiar with that. + if os.name == "nt": + settings_path = os.path.abspath(self.app_dir + self.config["settings_path"]) + self.settings = QSettings(settings_path, QSettings.Format.IniFormat) + else: + self.settings = QSettings("OSCR", "OSCR-UI") + for setting, value in self.config['default_settings'].items(): if self.settings.value(setting, None) is None: self.settings.setValue(setting, value) @@ -173,8 +178,6 @@ def init_config(self): """ self.current_combat_id = -1 self.current_combat_path = '' - self.config['templog_folder_path'] = os.path.abspath( - self.app_dir + self.config['templog_folder_path']) self.config['ui_scale'] = self.settings.value('ui_scale', type=float) self.config['live_scale'] = self.settings.value('live_scale', type=float) self.config['icon_size'] = round( @@ -193,7 +196,6 @@ def parser_settings(self) -> dict: setting = self.settings.value(setting_key, type=settings_type, defaultValue='') if setting: settings[setting_key] = setting - settings['templog_folder_path'] = self.config['templog_folder_path'] return settings @property @@ -1269,4 +1271,4 @@ def setup_settings_frame(self): scroll_layout.addLayout(sec_2) scroll_frame.setLayout(scroll_layout) - scroll_area.setWidget(scroll_frame) \ No newline at end of file + scroll_area.setWidget(scroll_frame) diff --git a/OSCRUI/callbacks.py b/OSCRUI/callbacks.py index f08c6f2..9da17c7 100644 --- a/OSCRUI/callbacks.py +++ b/OSCRUI/callbacks.py @@ -1,6 +1,7 @@ import os from PySide6.QtWidgets import QFileDialog, QLineEdit +from PySide6.QtCore import QTemporaryDir from OSCR import ( LIVE_TABLE_HEADER, OSCR, repair_logfile as oscr_repair_logfile, split_log_by_combat, @@ -315,4 +316,5 @@ def repair_logfile(self): """ """ log_path = os.path.abspath(self.entry.text()) - oscr_repair_logfile(log_path, self.config['templog_folder_path']) + dir = QTemporaryDir() + oscr_repair_logfile(log_path, dir.path()) diff --git a/OSCRUI/iofunctions.py b/OSCRUI/iofunctions.py index 774dc0d..ec63353 100644 --- a/OSCRUI/iofunctions.py +++ b/OSCRUI/iofunctions.py @@ -124,18 +124,6 @@ def store_json(data: dict | list, path: str): sys.stdout.write(f'[Error] Data could not be saved: {e}') -def reset_temp_folder(path: str): - ''' - Deletes and re-creates folder housing temporary log files. - ''' - if os.path.exists(path): - if os.path.isdir(path): - shutil.rmtree(path) - else: - raise FileExistsError(f'Expected path to folder, got "{path}"') - os.mkdir(path) - - def sanitize_file_name(txt, chr_set='extended') -> str: """Converts txt to a valid filename. diff --git a/OSCRUI/leagueconnector.py b/OSCRUI/leagueconnector.py index 28c6a3d..ebd081d 100644 --- a/OSCRUI/leagueconnector.py +++ b/OSCRUI/leagueconnector.py @@ -10,6 +10,7 @@ from OSCR_django_client.api import (CombatlogApi, LadderApi, LadderEntriesApi, VariantApi) from PySide6.QtWidgets import QMessageBox +from PySide6.QtCore import QTemporaryDir from .datafunctions import CustomThread, analyze_log_callback from .datamodels import LeagueTableModel, SortingProxy @@ -207,8 +208,13 @@ def download_and_view_combat(self, translation): log_id = table_model._combatlog_id_list[row] result = self.league_api.download(log_id) result = gzip.decompress(result) + + dir = QTemporaryDir() + if not dir.isValid(): + raise Exception("Invalid temporary directory") + with tempfile.NamedTemporaryFile( - mode="w", encoding="utf-8", dir=self.config["templog_folder_path"], delete=False + mode="w", encoding="utf-8", dir=dir.path(), delete=False ) as file: file.write(result.decode()) analyze_log_callback( diff --git a/OSCRUI/subwindows.py b/OSCRUI/subwindows.py index 910e7cf..1d8ca11 100644 --- a/OSCRUI/subwindows.py +++ b/OSCRUI/subwindows.py @@ -360,11 +360,11 @@ def create_live_parser_window(self, translate): live_window = LiveParserWindow() live_window.setStyleSheet(get_style(self, 'live_parser')) + live_window.setWindowTitle("Live Parser") live_window.setWindowFlags( live_window.windowFlags() | Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.WindowDoesNotAcceptFocus - | Qt.WindowType.SubWindow | Qt.WindowType.FramelessWindowHint) # live_window.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating, True) live_window.setWindowOpacity(self.settings.value('live_parser_opacity', type=float)) diff --git a/main.py b/main.py index 98f93fb..7d623a4 100644 --- a/main.py +++ b/main.py @@ -6,8 +6,8 @@ class Launcher(): - version = '2024.08b210' - __version__ = '0.2' + version = '2024.09b50' + __version__ = '0.4' # holds the style of the app theme = { @@ -758,7 +758,7 @@ def app_config() -> dict: 'heal_columns|12': True, 'heal_columns_length': 13, 'split_log_after': 480000, - 'seconds_between_combats': 100, + 'seconds_between_combats': 45, 'excluded_event_ids': ['Autodesc.Combatevent.Falling', ''], 'graph_resolution': 0.2, 'combats_to_parse': 10, diff --git a/pyproject.toml b/pyproject.toml index c29d9c7..bae7a00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ dependencies = [ "PySide6==6.7.2", "pyqtgraph==0.13.7", "numpy==1.26.4", - "STO-OSCR>=2024.9b20", + "STO-OSCR>=2024.9b50", "OSCR-django-client>=2024.9.2.1", "pydantic==2.7.3", ]