From 26fe1bf5e17e479588d7b80be00307679098eb8f Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 17 Sep 2019 14:08:57 +0300 Subject: [PATCH] - if FlatCAM is started with the 'quit' or 'exit' as argument it will close immediately and it will close also another instance of FlatCAM that may be running --- FlatCAM.py | 7 ------- FlatCAMApp.py | 26 +++++++++++++++++++++++--- README.md | 3 ++- camlib.py | 3 ++- config/configuration.txt | 1 + 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/FlatCAM.py b/FlatCAM.py index 177997d1..b44643a2 100644 --- a/FlatCAM.py +++ b/FlatCAM.py @@ -60,11 +60,4 @@ if __name__ == '__main__': fc = App() - if settings.contains("maximized_gui"): - maximized_ui = settings.value('maximized_gui', type=bool) - if maximized_ui is True: - fc.ui.showMaximized() - else: - fc.ui.show() - sys.exit(app.exec_()) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index ac125a8d..7532f095 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1905,7 +1905,7 @@ class App(QtCore.QObject): self.on_excellon_options_button) # when there are arguments at application startup this get launched - self.args_at_startup[list].connect(lambda: self.on_startup_args()) + self.args_at_startup[list].connect(self.on_startup_args) # connect the 'Apply' buttons from the Preferences/File Associations self.ui.fa_defaults_form.fa_excellon_group.exc_list_btn.clicked.connect( @@ -2415,6 +2415,18 @@ class App(QtCore.QObject): # finish the splash self.splash.finish(self.ui) + # ##################################################################################### + # ########################## SHOW GUI ################################################# + # ##################################################################################### + + settings = QSettings("Open Source", "FlatCAM") + if settings.contains("maximized_gui"): + maximized_ui = settings.value('maximized_gui', type=bool) + if maximized_ui is True: + self.ui.showMaximized() + else: + self.ui.show() + @staticmethod def copy_and_overwrite(from_path, to_path): """ @@ -2433,14 +2445,15 @@ class App(QtCore.QObject): from_new_path = os.path.dirname(os.path.realpath(__file__)) + '\\flatcamGUI\\VisPyData\\data' shutil.copytree(from_new_path, to_path) - def on_startup_args(self, args=None): + def on_startup_args(self, args): """ This will process any arguments provided to the application at startup. Like trying to launch a file or project. :param args: a list containing the application args at startup :return: None """ - if args: + + if args is not None: args_to_process = args else: args_to_process = App.args @@ -2491,6 +2504,13 @@ class App(QtCore.QObject): except Exception as e: log.debug("Could not open FlatCAM Script file as App parameter due: %s" % str(e)) + elif 'quit' in argument or 'exit' in argument: + log.debug("App.on_startup_args() --> Quit event.") + sys.exit() + + elif 'save' in argument: + log.debug("App.on_startup_args() --> Save event. App Defaults saved.") + self.save_defaults() else: exc_list = self.ui.fa_defaults_form.fa_excellon_group.exc_list_text.get_value().split(',') proc_arg = argument.lower() diff --git a/README.md b/README.md index fcf78dbc..f8ba6ec4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ CAD program, and create G-Code for Isolation routing. - fixed issue #315 where a script run with the --shellfile argument crashed the program if it contained a TclCommand New - added messages in the Splash Screen when running FlatCAM with arguments at startup - fixed issue #313 where TclCommand drillcncjob is spitting errors in Tcl Shell which should be ignored -- fixed an bug where the pywrapcp name from Google OR-Tools is not defined +- fixed an bug where the pywrapcp name from Google OR-Tools is not defined; fix issue #316 +- if FlatCAM is started with the 'quit' or 'exit' as argument it will close immediately and it will close also another instance of FlatCAM that may be running 16.09.2019 diff --git a/camlib.py b/camlib.py index 8107773a..82ee4c07 100644 --- a/camlib.py +++ b/camlib.py @@ -5867,8 +5867,9 @@ class CNCjob(Geometry): self.app.inform.emit('%s...' % _("Starting G-Code")) + current_platform = platform.architecture()[0] - if current_platform != '64bit': + if current_platform == '64bit': used_excellon_optimization_type = excellon_optimization_type if used_excellon_optimization_type == 'M': log.debug("Using OR-Tools Metaheuristic Guided Local Search drill path optimization.") diff --git a/config/configuration.txt b/config/configuration.txt index 22bbfb42..0c76ec42 100644 --- a/config/configuration.txt +++ b/config/configuration.txt @@ -1 +1,2 @@ portable=False +headless=False