Skip to content

Commit

Permalink
Correct tour window visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
danifranco committed Dec 22, 2024
1 parent 4e79e8f commit 844ce22
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
20 changes: 8 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from ui_function import *
from ui_utils import (examine, mark_syntax_error, expand_hide_advanced_options, change_page, get_git_revision_short_hash,
load_yaml_config, resource_path, load_yaml_to_GUI, set_text, start_wizard_questionary, change_wizard_page, eval_wizard_answer,
clear_answers, check_models_from_other_sources, check_data_from_path, export_wizard_summary, wizard_path_changed)
clear_answers, check_models_from_other_sources, check_data_from_path, export_wizard_summary, wizard_path_changed,
save_biapy_config)
from settings import Settings
from widget_conditions import Widget_conditions
from ui.ui_main import Ui_MainWindow
Expand Down Expand Up @@ -754,16 +755,10 @@ def tour_exec(self):
self.tour.exec()

# Save users election
try:
with open(self.log_info["config_file"], 'r') as file:
data = json.load(file)
except:
data = {}
data["HIDE_TOUR_WINDOW"] = self.tour.basic_window.dont_show_message_checkbox.checkState() == Qt.Checked
data["GUI_VERSION"] = str(self.cfg.settings["biapy_gui_version"])

with open(self.log_info["config_file"], "w") as outfile:
json.dump(data, outfile, indent=4)
data = {
"HIDE_TOUR_WINDOW": self.tour.basic_window.dont_show_message_checkbox.checkState() == Qt.Checked,
}
save_biapy_config(self, data, self.cfg.settings["biapy_gui_version"])

def dialog_exec(self, message, reason):
"""
Expand Down Expand Up @@ -1137,6 +1132,7 @@ def eventFilter(self, obj, ev):
window.check_new_gui_version()

# Start tour window
save_biapy_config(window, {}, str(window.cfg.settings["biapy_gui_version"]))
hide_tour = False
version = ""
try:
Expand All @@ -1147,7 +1143,7 @@ def eventFilter(self, obj, ev):
except:
pass

if hide_tour and version != str(window.cfg.settings["biapy_gui_version"]):
if version != str(window.cfg.settings["biapy_gui_version"]):
hide_tour = False

if not hide_tour:
Expand Down
29 changes: 28 additions & 1 deletion ui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3770,4 +3770,31 @@ def check_supported_container_versions(gui_version, logger):
exc = traceback.format_exc()
logger.error(exc)
return compatible_versions


def save_biapy_config(main_window, data, biapy_version=""):
"""
Save BiaPy configuration.
Parameters
----------
main_window : QMainWindow
Main window of the application.
data: dict
Data dict to save.
biapy_version : str, optional
Data version to save if there is no one in the config file.
"""
try:
with open(main_window.log_info["config_file"], 'r') as file:
old_data = json.load(file)
except:
old_data = {}
old_data.update(data)

if biapy_version != "" and "GUI_VERSION" not in old_data:
old_data["GUI_VERSION"] = biapy_version

with open(main_window.log_info["config_file"], "w") as outfile:
json.dump(old_data, outfile, indent=4)

0 comments on commit 844ce22

Please sign in to comment.