From 08e6eaa084cb7b4f874d39e9ac3e02c2a25f64fc Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 18 Aug 2021 01:31:58 +0300 Subject: [PATCH] - when creating a nw project the user is asked if he wants to save the preferences --- CHANGELOG.md | 1 + appGUI/preferences/PreferencesUIManager.py | 2 +- app_Main.py | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 094341fc..45ac27dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta - fixed the "Set Color" functionality broken by recent changes - updated the "Set Color" functionality to store the used color in a correct way +- when creating a nw project the user is asked if he wants to save the preferences 17.08.2021 diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 7f00e8d0..d17aedec 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -1152,7 +1152,7 @@ class PreferencesUIManager: :param silent: Whether to display a message in status bar or not; boolean :param data_path: The path where to save the preferences file (current_defaults.FlatConfig) - When the application is portable it should be a mobile location. + When the application is portable it should be a mobile location. :param first_time: Boolean. If True will execute some code when the app is run first time :return: None """ diff --git a/app_Main.py b/app_Main.py index 181226d2..efb379ae 100644 --- a/app_Main.py +++ b/app_Main.py @@ -9861,6 +9861,23 @@ class MenuFileHandlers(QtCore.QObject): self.app.ui.plot_tab_area.insertTab(0, self.app.ui.plot_tab, _("Plot Area")) self.app.ui.plot_tab_area.protectTab(0) + msgbox = QtWidgets.QMessageBox() + msgbox.setText(_("Do you want to save the current settings/preferences?")) + msgbox.setWindowTitle(_("Save preferences")) + msgbox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) + + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) + # bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole) + + msgbox.setDefaultButton(bt_yes) + msgbox.exec() + response = msgbox.clickedButton() + + if response == bt_yes: + self.app.preferencesUiManager.save_defaults() + # take the focus of the Notebook on Project Tab. self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab)