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

- added checkboxes in Preferences -> General -> Global Preferences to switch on/off version check at application startup and also to control if the app will send anonymous statistics about FlatCAM usage to help improve FlatCAM

Marius Stanciu пре 7 година
родитељ
комит
dd49aaa68d
3 измењених фајлова са 58 додато и 8 уклоњено
  1. 25 8
      FlatCAMApp.py
  2. 29 0
      FlatCAMGUI.py
  3. 4 0
      README.md

+ 25 - 8
FlatCAMApp.py

@@ -88,8 +88,8 @@ class App(QtCore.QObject):
 
     # Version
     version = 8.901
-    version_date = "2019/01/07"
-    beta = True
+    version_date = "2019/01/08"
+    beta = False
 
     # URL for update checks and statistics
     version_url = "http://flatcam.org/version"
@@ -290,6 +290,8 @@ class App(QtCore.QObject):
         self.defaults_form_fields = {
             "units": self.general_defaults_form.general_group.units_radio,
             "global_shell_at_startup": self.general_defaults_form.general_group.shell_startup_cb,
+            "global_version_check": self.general_defaults_form.general_group.version_check_cb,
+            "global_send_stats": self.general_defaults_form.general_group.send_stats_cb,
             "global_gridx": self.general_defaults_form.general_group.gridx_entry,
             "global_gridy": self.general_defaults_form.general_group.gridy_entry,
             "global_plot_fill": self.general_defaults_form.general_group.pf_color_entry,
@@ -404,6 +406,8 @@ class App(QtCore.QObject):
             "global_serial": 0,
             "global_stats": {},
             "units": "IN",
+            "global_version_check": True,
+            "global_send_stats": True,
             "global_gridx": 1.0,
             "global_gridy": 1.0,
             "global_plot_fill": '#BBF268BF',
@@ -1142,7 +1146,9 @@ class App(QtCore.QObject):
         ###########################
 
         # Separate thread (Not worker)
-        if self.beta is False or self.beta is None:
+        # Check for updates on startup but only if the user consent and the app is not in Beta version
+        if (self.beta is False or self.beta is None) and \
+                self.general_defaults_form.general_group.version_check_cb.get_value() is True:
             App.log.info("Checking for updates in backgroud (this is version %s)." % str(self.version))
 
             self.thr2 = QtCore.QThread()
@@ -5686,11 +5692,22 @@ class App(QtCore.QObject):
 
         self.log.debug("version_check()")
 
-        full_url = App.version_url + \
-                   "?s=" + str(self.defaults['global_serial']) + \
-                   "&v=" + str(self.version) + \
-                   "&os=" + str(self.os) + \
-                   "&" + urllib.parse.urlencode(self.defaults["global_stats"])
+        if self.general_defaults_form.general_group.send_stats_cb.get_value() is True:
+            full_url = App.version_url + \
+                       "?s=" + str(self.defaults['global_serial']) + \
+                       "&v=" + str(self.version) + \
+                       "&os=" + str(self.os) + \
+                       "&" + urllib.parse.urlencode(self.defaults["global_stats"])
+        else:
+            # no_stats dict; just so it won't break things on website
+            no_ststs_dict = {}
+            no_ststs_dict["global_ststs"] = {}
+            full_url = App.version_url + \
+                       "?s=" + str(self.defaults['global_serial']) + \
+                       "&v=" + str(self.version) + \
+                       "&os=" + str(self.os) + \
+                       "&" + urllib.parse.urlencode(no_ststs_dict["global_ststs"])
+
         App.log.debug("Checking for updates @ %s" % full_url)
         ### Get the data
         try:

+ 29 - 0
FlatCAMGUI.py

@@ -909,6 +909,32 @@ class GeneralPrefGroupUI(OptionsGroupUI):
             "start automatically at startup."
         )
 
+        # Version Check CB
+        self.version_check_label = QtWidgets.QLabel('Version Check:')
+        self.version_check_label.setToolTip(
+            "Check this box if you want to check\n"
+            "for a new version automatically at startup."
+        )
+        self.version_check_cb = FCCheckBox(label='')
+        self.version_check_cb.setToolTip(
+            "Check this box if you want to check\n"
+            "for a new version automatically at startup."
+        )
+
+        # Send Stats CB
+        self.send_stats_label = QtWidgets.QLabel('Send Stats:')
+        self.send_stats_label.setToolTip(
+            "Check this box if you agree to send anonymous\n"
+            "stats automatically at startup, to help improve FlatCAM."
+        )
+        self.send_stats_cb= FCCheckBox(label='')
+        self.send_stats_cb.setToolTip(
+            "Check this box if you agree to send anonymous\n"
+            "stats automatically at startup, to help improve FlatCAM."
+        )
+
+        self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
+
         # Grid X Entry
         self.gridx_label = QtWidgets.QLabel('Grid X value:')
         self.gridx_label.setToolTip(
@@ -1151,6 +1177,9 @@ class GeneralPrefGroupUI(OptionsGroupUI):
         self.form_box.addRow(self.unitslabel, self.units_radio)
         self.form_box.addRow(self.spacelabel, self.spacelabel)
         self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
+        self.form_box.addRow(self.version_check_label, self.version_check_cb)
+        self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
+
         self.form_box.addRow(self.gridx_label, self.gridx_entry)
         self.form_box.addRow(self.gridy_label, self.gridy_entry)
         self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)

+ 4 - 0
README.md

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+8.01.2019
+
+- added checkboxes in Preferences -> General -> Global Preferences to switch on/off version check at application startup and also to control if the app will send anonymous statistics about FlatCAM usage to help improve FlatCAM
+
 7.01.2019
 
 - added tooltips in Edit->Convert menu