From 4269c9f4a092da5c1df6a5f720786604ddc18d31 Mon Sep 17 00:00:00 2001 From: qewer33 Date: Thu, 31 Aug 2023 22:04:50 +0300 Subject: [PATCH] Turn StartPage "Import" quickstart button into "Open" --- src/Mod/Start/StartPage/CMakeLists.txt | 2 +- src/Mod/Start/StartPage/LoadNew.py | 10 ++++++---- src/Mod/Start/StartPage/StartPage.py | 6 +++--- src/Mod/Start/StartPage/TranslationTexts.py | 4 ++-- .../{new_import_file.png => new_open_file.png} | Bin 5 files changed, 12 insertions(+), 10 deletions(-) rename src/Mod/Start/StartPage/images/{new_import_file.png => new_open_file.png} (100%) diff --git a/src/Mod/Start/StartPage/CMakeLists.txt b/src/Mod/Start/StartPage/CMakeLists.txt index b09ccbea0e..0bbedbb8cc 100644 --- a/src/Mod/Start/StartPage/CMakeLists.txt +++ b/src/Mod/Start/StartPage/CMakeLists.txt @@ -27,7 +27,7 @@ SET(StartPage_ImageResources images/new_file_thumbnail.svg images/icon_settings.png images/new_empty_file.png - images/new_import_file.png + images/new_open_file.png images/new_parametric_part.png images/new_csg_part.png images/new_2d_draft.png diff --git a/src/Mod/Start/StartPage/LoadNew.py b/src/Mod/Start/StartPage/LoadNew.py index be697589ae..3668632f33 100644 --- a/src/Mod/Start/StartPage/LoadNew.py +++ b/src/Mod/Start/StartPage/LoadNew.py @@ -29,10 +29,12 @@ template_name = str(template) if template_name == "empty_file": FreeCADGui.runCommand('Std_New') StartPage.postStart() -elif template_name == "import_file": - FreeCADGui.runCommand('Std_New') - StartPage.postStart() - FreeCADGui.runCommand("Std_Import") +elif template_name == "open_file": + previous_doc = FreeCADGui.ActiveDocument + FreeCADGui.runCommand("Std_Open") + # workaround to not run postStart() if user cancels the Open dialog + if FreeCADGui.ActiveDocument != previous_doc: + StartPage.postStart() elif template_name == "parametric_part": FreeCADGui.runCommand('Std_New') FreeCADGui.activateWorkbench("PartDesignWorkbench") diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index 803044d944..f02928d392 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -258,7 +258,7 @@ def build_new_file_card(template): templates = { "empty_file": [TranslationTexts.T_TEMPLATE_EMPTYFILE_NAME, TranslationTexts.T_TEMPLATE_EMPTYFILE_DESC], - "import_file": [TranslationTexts.T_TEMPLATE_IMPORTFILE_NAME, TranslationTexts.T_TEMPLATE_IMPORTFILE_DESC], + "open_file": [TranslationTexts.T_TEMPLATE_OPENFILE_NAME, TranslationTexts.T_TEMPLATE_OPENFILE_DESC], "parametric_part": [TranslationTexts.T_TEMPLATE_PARAMETRICPART_NAME, TranslationTexts.T_TEMPLATE_PARAMETRICPART_DESC], # "csg_part": [TranslationTexts.T_TEMPLATE_CSGPART_NAME, TranslationTexts.T_TEMPLATE_CSGPART_DESC], "2d_draft": [TranslationTexts.T_TEMPLATE_2DDRAFT_NAME, TranslationTexts.T_TEMPLATE_2DDRAFT_DESC], @@ -266,7 +266,7 @@ def build_new_file_card(template): } if template not in templates: - return + return "" image = 'file:///'+os.path.join(os.path.join(FreeCAD.getResourceDir(), "Mod", "Start", "StartPage"), 'images/new_'+template+".png").replace('\\','/') @@ -439,7 +439,7 @@ def handle(): SECTION_NEW_FILE = "

"+TranslationTexts.T_NEWFILE+"

" SECTION_NEW_FILE += "