Ver Fonte

Settings and recent items now saved to propper location. Added missing icons.

Juan Pablo Caram há 11 anos atrás
pai
commit
c4aa90090b

+ 46 - 6
FlatCAMApp.py

@@ -76,9 +76,49 @@ class App(QtCore.QObject):
         """
 
         App.log.info("FlatCAM Starting...")
-        self.path = os.path.dirname(sys.argv[0])
+
+        ###################
+        ### OS-specific ###
+        ###################
+
+        if sys.platform == 'win32':
+            from win32com.shell import shell, shellcon
+            App.log.debug("Win32!")
+            self.data_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, None, 0) + \
+                '/FlatCAM'
+        else:  # Linux/Unix/MacOS
+            self.data_path = os.path.expanduser('~') + \
+                '/.FlatCAM'
+
+        ###############################
+        ### Setup folders and files ###
+        ###############################
+
+        if not os.path.exists(self.data_path):
+            os.makedirs(self.data_path)
+            App.log.debug('Created data folder: ' + self.data_path)
+
+        try:
+            f = open(self.data_path + '/defaults.json')
+            f.close()
+        except IOError:
+            App.log.debug('Creating empty defaults.json')
+            f = open(self.data_path + '/defaults.json', 'w')
+            json.dump({}, f)
+            f.close()
+
+        try:
+            f = open(self.data_path + '/recent.json')
+            f.close()
+        except IOError:
+            App.log.debug('Creating empty recent.json')
+            f = open(self.data_path + '/recent.json', 'w')
+            json.dump([], f)
+            f.close()
+
+        #self.path = os.path.dirname(sys.argv[0])
         #App.log.debug("Running in " + os.path.realpath(__file__))
-        App.log.debug("Running in " + self.path)
+        #App.log.debug("Running in " + self.path)
 
         QtCore.QObject.__init__(self)
 
@@ -571,7 +611,7 @@ class App(QtCore.QObject):
         :return: None
         """
         try:
-            f = open(self.path + "/defaults.json")
+            f = open(self.data_path + "/defaults.json")
             options = f.read()
             f.close()
         except IOError:
@@ -612,7 +652,7 @@ class App(QtCore.QObject):
             self.recent.pop()
 
         try:
-            f = open('recent.json', 'w')
+            f = open(self.data_path + '/recent.json', 'w')
         except IOError:
             App.log.error("Failed to open recent items file for writing.")
             self.inform.emit('Failed to open recent files file for writing.')
@@ -787,7 +827,7 @@ class App(QtCore.QObject):
 
         ## Read options from file ##
         try:
-            f = open(self.path + "/defaults.json")
+            f = open(self.data_path + "/defaults.json")
             options = f.read()
             f.close()
         except:
@@ -2209,7 +2249,7 @@ class App(QtCore.QObject):
 
         # Open file
         try:
-            f = open('recent.json')
+            f = open(self.data_path + '/recent.json')
         except IOError:
             App.log.error("Failed to load recent item list.")
             self.inform.emit("[error] Failed to load recent item list.")

BIN
share/cancel_edit16.png


BIN
share/cancel_edit32.png


BIN
share/circle32.png


BIN
share/copy32.png


BIN
share/edit16.png


BIN
share/edit32.png


BIN
share/edit_ok16.png


BIN
share/edit_ok32.png


BIN
share/flatcam_icon128_inv.png


BIN
share/graylight12.png


BIN
share/greenlight12.png


BIN
share/join16.png


BIN
share/join32.png


BIN
share/move32.png


BIN
share/new_geo16.png


BIN
share/new_geo32.png


BIN
share/path32.png


Diff do ficheiro suprimidas por serem muito extensas
+ 50 - 0
share/pointer.svg


BIN
share/pointer32.png


BIN
share/polygon32.png


BIN
share/rectangle32.png


BIN
share/redlight12.png


BIN
share/shell16.png


BIN
share/shell32.png


BIN
share/union16.png


BIN
share/union32.png


BIN
share/yellowlight12.png


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff