diff --git a/CHANGELOG.md b/CHANGELOG.md index 16b5fd6f..b83a0df5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ CHANGELOG for FlatCAM beta - added a parameter to the FlatCAMDefaults class, whenever a value in the self.defaults dict change it will call a callback function and send to it the modified key - optimized and fixed some issues in the self.on_toggle_units() method - the Exclusion areas will have all the orange color but the color of the outline will differ according to the type of the object from where it was added (cosmetic use only as the Exclusion areas will be applied globally) +- removed the Apply theme button in the Preferences; it is now replaced by the more general buttons (either Save or Apply) +- added a confirmation/warning message when applying a new theme 7.05.2020 diff --git a/flatcamGUI/preferences/PreferencesUIManager.py b/flatcamGUI/preferences/PreferencesUIManager.py index 14fa8762..c49841ba 100644 --- a/flatcamGUI/preferences/PreferencesUIManager.py +++ b/flatcamGUI/preferences/PreferencesUIManager.py @@ -913,7 +913,39 @@ class PreferencesUIManager: # make sure we update the self.current_defaults dict used to undo changes to self.defaults self.defaults.current_defaults.update(self.defaults) - if save_to_file: + # deal with theme change + theme_settings = QtCore.QSettings("Open Source", "FlatCAM") + if theme_settings.contains("theme"): + theme = theme_settings.value('theme', type=str) + else: + theme = 'white' + + should_restart = False + val = self.ui.general_defaults_form.general_gui_group.theme_radio.get_value() + if val != theme: + msgbox = QtWidgets.QMessageBox() + msgbox.setText(_("Are you sure you want to continue?")) + msgbox.setWindowTitle(_("Application restart")) + msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/warning.png')) + + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) + msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.NoRole) + + msgbox.setDefaultButton(bt_yes) + msgbox.exec_() + response = msgbox.clickedButton() + + if response == bt_yes: + theme_settings.setValue('theme', val) + + # This will write the setting to the platform specific storage. + del theme_settings + + should_restart = True + else: + self.ui.general_defaults_form.general_gui_group.theme_radio.set_value(theme) + + if save_to_file or should_restart is True: self.save_defaults(silent=False) # load the defaults so they are updated into the app self.defaults.load(filename=os.path.join(self.data_path, 'current_defaults.FlatConfig')) @@ -951,6 +983,9 @@ class PreferencesUIManager: self.ui.plot_tab_area.closeTab(idx) break + if should_restart is True: + self.ui.app.on_app_restart() + def on_pref_close_button(self): # Preferences saved, update flag self.preferences_changed_flag = False diff --git a/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py b/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py index d71fab4c..baedacc7 100644 --- a/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py +++ b/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py @@ -56,13 +56,13 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): ) grid0.addWidget(self.gray_icons_cb, 1, 0, 1, 3) - self.theme_button = FCButton(_("Apply Theme")) - self.theme_button.setToolTip( - _("Select a theme for FlatCAM.\n" - "It will theme the plot area.\n" - "The application will restart after change.") - ) - grid0.addWidget(self.theme_button, 2, 0, 1, 3) + # self.theme_button = FCButton(_("Apply Theme")) + # self.theme_button.setToolTip( + # _("Select a theme for FlatCAM.\n" + # "It will theme the plot area.\n" + # "The application will restart after change.") + # ) + # grid0.addWidget(self.theme_button, 2, 0, 1, 3) separator_line = QtWidgets.QFrame() separator_line.setFrameShape(QtWidgets.QFrame.HLine) @@ -381,8 +381,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): self.layout.addStretch() - self.theme_button.clicked.connect(self.on_theme_change) - # ############################################################################# # ############################# GUI COLORS SIGNALS ############################ # ############################################################################# @@ -418,23 +416,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): self.layout_combo.activated.connect(self.on_layout) - def on_theme_change(self): - val = self.theme_radio.get_value() - - theme_settings = QtCore.QSettings("Open Source", "FlatCAM") - if theme_settings.contains("theme"): - theme = theme_settings.value('theme', type=str) - else: - theme = 'white' - - if val != theme: - theme_settings.setValue('theme', val) - - # This will write the setting to the platform specific storage. - del theme_settings - - self.app.on_app_restart() - @staticmethod def handle_style(style): # set current style