Преглед изворни кода

- 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

Marius Stanciu пре 6 година
родитељ
комит
787d85391a
4 измењених фајлова са 36 додато и 23 уклоњено
  1. 8 18
      FlatCAMApp.py
  2. 2 0
      README.md
  3. 15 4
      flatcamGUI/PlotCanvasLegacy.py
  4. 11 1
      flatcamGUI/PreferencesUI.py

+ 8 - 18
FlatCAMApp.py

@@ -2935,15 +2935,6 @@ class App(QtCore.QObject):
                                 name)
                                 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):
     def on_app_restart(self):
 
 
         # make sure that the Sys Tray icon is hidden before restart otherwise it will
         # 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):
     def on_gui_clear(self):
         theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
         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 = QtWidgets.QMessageBox()
         msgbox.setText(_("Are you sure you want to delete the GUI Settings? "
         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])
             cursor.setPos(j_pos[0], j_pos[1])
             self.plotcanvas.mouse = [location[0], location[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():
         if self.grid_status():
             # Update cursor
             # Update cursor

+ 2 - 0
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
 - 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
 - further modifications in Preferences -> General GUI - extended the changes
 - 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
 25.12.2019
 
 

+ 15 - 4
flatcamGUI/PlotCanvasLegacy.py

@@ -407,8 +407,10 @@ class PlotCanvasLegacy(QtCore.QObject):
 
 
         :param x_pos: mouse x position
         :param x_pos: mouse x position
         :param y_pos: mouse y position
         :param y_pos: mouse y position
+        :param color: custom color of the mouse
         :return:
         :return:
         """
         """
+
         # there is no point in drawing mouse cursor when panning as it jumps in a confusing way
         # 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 self.app.app_cursor.enabled is True and self.panning is False:
             if color:
             if color:
@@ -446,7 +448,10 @@ class PlotCanvasLegacy(QtCore.QObject):
     def clear_cursor(self, state):
     def clear_cursor(self, state):
 
 
         if state is True:
         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:
         else:
             if self.big_cursor is True:
             if self.big_cursor is True:
                 self.ch_line.remove()
                 self.ch_line.remove()
@@ -791,7 +796,10 @@ class PlotCanvasLegacy(QtCore.QObject):
             self.panning = False
             self.panning = False
 
 
             # And update the cursor
             # 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):
     def on_mouse_move(self, event):
         """
         """
@@ -825,8 +833,10 @@ class PlotCanvasLegacy(QtCore.QObject):
             # #### Temporary place-holder for cached update #####
             # #### Temporary place-holder for cached update #####
             self.update_screen_request.emit([0, 0, 0, 0, 0])
             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)
         # self.canvas.blit(self.axes.bbox)
 
 
     def translate_coords(self, position):
     def translate_coords(self, position):
@@ -898,6 +908,7 @@ class FakeCursor(QtCore.QObject):
 
 
     def set_data(self, pos, **kwargs):
     def set_data(self, pos, **kwargs):
         """Internal event handler to draw the cursor when the mouse moves."""
         """Internal event handler to draw the cursor when the mouse moves."""
+        return
 
 
 
 
 class ShapeCollectionLegacy:
 class ShapeCollectionLegacy:

+ 11 - 1
flatcamGUI/PreferencesUI.py

@@ -676,7 +676,17 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
 
 
         self.layout.addStretch()
         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):
     def handle_style(self, style):
         # set current style
         # set current style