- 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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user