diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 55e284eb..c7584f8f 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -2935,15 +2935,6 @@ class App(QtCore.QObject): name) ) - def on_theme_change(self, val): - t_settings = QSettings("Open Source", "FlatCAM") - t_settings.setValue('theme', val) - - # This will write the setting to the platform specific storage. - del t_settings - - self.on_app_restart() - def on_app_restart(self): # make sure that the Sys Tray icon is hidden before restart otherwise it will @@ -4070,15 +4061,11 @@ class App(QtCore.QObject): def on_gui_clear(self): theme_settings = QtCore.QSettings("Open Source", "FlatCAM") - if theme_settings.contains("theme"): - theme = theme_settings.value('theme', type=str) - else: - theme = 'white' + theme_settings.setValue('theme', 'white') - if theme == 'white': - resource_loc = 'share' - else: - resource_loc = 'share' + del theme_settings + + resource_loc = 'share' msgbox = QtWidgets.QMessageBox() msgbox.setText(_("Are you sure you want to delete the GUI Settings? " @@ -7539,7 +7526,10 @@ class App(QtCore.QObject): ) cursor.setPos(j_pos[0], j_pos[1]) self.plotcanvas.mouse = [location[0], location[1]] - self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1]) + if self.defaults["global_cursor_color_enabled"] is True: + self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1], color=self.cursor_color_3D) + else: + self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1]) if self.grid_status(): # Update cursor diff --git a/README.md b/README.md index d2f216a6..db9f9c71 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ CAD program, and create G-Code for Isolation routing. - in Panelize Tool made sure that for Gerber objects if one of the apertures is without geometry then it is ignored - further modifications in Preferences -> General GUI - further modifications in Preferences -> General GUI - extended the changes +- in Legacy(2D) graphic engine made to work the mouse color change +- theme changing is no longer auto-reboot upon change; it require now to press a button 25.12.2019 diff --git a/flatcamGUI/PlotCanvasLegacy.py b/flatcamGUI/PlotCanvasLegacy.py index 5984e478..9e13f52f 100644 --- a/flatcamGUI/PlotCanvasLegacy.py +++ b/flatcamGUI/PlotCanvasLegacy.py @@ -407,8 +407,10 @@ class PlotCanvasLegacy(QtCore.QObject): :param x_pos: mouse x position :param y_pos: mouse y position + :param color: custom color of the mouse :return: """ + # there is no point in drawing mouse cursor when panning as it jumps in a confusing way if self.app.app_cursor.enabled is True and self.panning is False: if color: @@ -446,7 +448,10 @@ class PlotCanvasLegacy(QtCore.QObject): def clear_cursor(self, state): if state is True: - self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) + if self.app.defaults["global_cursor_color_enabled"] is True: + self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1], color=self.app.cursor_color_3D) + else: + self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) else: if self.big_cursor is True: self.ch_line.remove() @@ -791,7 +796,10 @@ class PlotCanvasLegacy(QtCore.QObject): self.panning = False # And update the cursor - self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) + if self.app.defaults["global_cursor_color_enabled"] is True: + self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1], color=self.app.cursor_color_3D) + else: + self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) def on_mouse_move(self, event): """ @@ -825,8 +833,10 @@ class PlotCanvasLegacy(QtCore.QObject): # #### Temporary place-holder for cached update ##### self.update_screen_request.emit([0, 0, 0, 0, 0]) - self.draw_cursor(x_pos=x, y_pos=y) - + if self.app.defaults["global_cursor_color_enabled"] is True: + self.draw_cursor(x_pos=x, y_pos=y, color=self.app.cursor_color_3D) + else: + self.draw_cursor(x_pos=x, y_pos=y) # self.canvas.blit(self.axes.bbox) def translate_coords(self, position): @@ -898,6 +908,7 @@ class FakeCursor(QtCore.QObject): def set_data(self, pos, **kwargs): """Internal event handler to draw the cursor when the mouse moves.""" + return class ShapeCollectionLegacy: diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index bf9990f6..de7e3e0b 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -676,7 +676,17 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): self.layout.addStretch() - self.theme_button.clicked.connect(self.app.on_theme_change) + self.theme_button.clicked.connect(self.on_theme_change) + + def on_theme_change(self): + val = self.theme_radio.get_value() + t_settings = QSettings("Open Source", "FlatCAM") + t_settings.setValue('theme', val) + + # This will write the setting to the platform specific storage. + del t_settings + + self.app.on_app_restart() def handle_style(self, style): # set current style