diff --git a/FlatCAMApp.py b/FlatCAMApp.py index fc3709c..a0b57bb 100644 --- a/FlatCAMApp.py +++ b/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.") diff --git a/share/cancel_edit16.png b/share/cancel_edit16.png new file mode 100644 index 0000000..6ee2bae Binary files /dev/null and b/share/cancel_edit16.png differ diff --git a/share/cancel_edit32.png b/share/cancel_edit32.png new file mode 100644 index 0000000..f087c71 Binary files /dev/null and b/share/cancel_edit32.png differ diff --git a/share/circle32.png b/share/circle32.png new file mode 100644 index 0000000..848a67e Binary files /dev/null and b/share/circle32.png differ diff --git a/share/copy32.png b/share/copy32.png new file mode 100644 index 0000000..1666def Binary files /dev/null and b/share/copy32.png differ diff --git a/share/edit16.png b/share/edit16.png new file mode 100644 index 0000000..9b64793 Binary files /dev/null and b/share/edit16.png differ diff --git a/share/edit32.png b/share/edit32.png new file mode 100644 index 0000000..5e29fe1 Binary files /dev/null and b/share/edit32.png differ diff --git a/share/edit_ok16.png b/share/edit_ok16.png new file mode 100644 index 0000000..5c04718 Binary files /dev/null and b/share/edit_ok16.png differ diff --git a/share/edit_ok32.png b/share/edit_ok32.png new file mode 100644 index 0000000..0674a1a Binary files /dev/null and b/share/edit_ok32.png differ diff --git a/share/flatcam_icon128_inv.png b/share/flatcam_icon128_inv.png new file mode 100644 index 0000000..60782f3 Binary files /dev/null and b/share/flatcam_icon128_inv.png differ diff --git a/share/graylight12.png b/share/graylight12.png new file mode 100644 index 0000000..b4dcf78 Binary files /dev/null and b/share/graylight12.png differ diff --git a/share/greenlight12.png b/share/greenlight12.png new file mode 100644 index 0000000..d15ca43 Binary files /dev/null and b/share/greenlight12.png differ diff --git a/share/join16.png b/share/join16.png new file mode 100644 index 0000000..be9eb59 Binary files /dev/null and b/share/join16.png differ diff --git a/share/join32.png b/share/join32.png new file mode 100644 index 0000000..fe731b4 Binary files /dev/null and b/share/join32.png differ diff --git a/share/move32.png b/share/move32.png new file mode 100644 index 0000000..839ecff Binary files /dev/null and b/share/move32.png differ diff --git a/share/new_geo16.png b/share/new_geo16.png new file mode 100644 index 0000000..fd495e8 Binary files /dev/null and b/share/new_geo16.png differ diff --git a/share/new_geo32.png b/share/new_geo32.png new file mode 100644 index 0000000..6fa8c21 Binary files /dev/null and b/share/new_geo32.png differ diff --git a/share/path32.png b/share/path32.png new file mode 100644 index 0000000..d762768 Binary files /dev/null and b/share/path32.png differ diff --git a/share/pointer.svg b/share/pointer.svg new file mode 100644 index 0000000..3468d2c --- /dev/null +++ b/share/pointer.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + 11 + computer + + + + + + + + + + + + + + + + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + diff --git a/share/pointer32.png b/share/pointer32.png new file mode 100644 index 0000000..d2b030c Binary files /dev/null and b/share/pointer32.png differ diff --git a/share/polygon32.png b/share/polygon32.png new file mode 100644 index 0000000..cee65d6 Binary files /dev/null and b/share/polygon32.png differ diff --git a/share/rectangle32.png b/share/rectangle32.png new file mode 100644 index 0000000..fc93303 Binary files /dev/null and b/share/rectangle32.png differ diff --git a/share/redlight12.png b/share/redlight12.png new file mode 100644 index 0000000..9a1817e Binary files /dev/null and b/share/redlight12.png differ diff --git a/share/shell16.png b/share/shell16.png new file mode 100644 index 0000000..573f4b9 Binary files /dev/null and b/share/shell16.png differ diff --git a/share/shell32.png b/share/shell32.png new file mode 100644 index 0000000..c8b266c Binary files /dev/null and b/share/shell32.png differ diff --git a/share/union16.png b/share/union16.png new file mode 100644 index 0000000..6326253 Binary files /dev/null and b/share/union16.png differ diff --git a/share/union32.png b/share/union32.png new file mode 100644 index 0000000..c31863c Binary files /dev/null and b/share/union32.png differ diff --git a/share/yellowlight12.png b/share/yellowlight12.png new file mode 100644 index 0000000..f1b2069 Binary files /dev/null and b/share/yellowlight12.png differ