aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/main.py b/main.py
index 2dbefe7..d3fa52c 100644
--- a/main.py
+++ b/main.py
@@ -377,7 +377,20 @@ class Main(QtCore.QObject):
dirname = os.path.join(self.dataDir, 'presets', componentName, str(version))
if not os.path.exists(dirname):
os.makedirs(dirname)
- with open(os.path.join(dirname, filename), 'w') as f:
+ filepath = os.path.join(dirname, filename)
+ if os.path.exists(filepath):
+ msg = QtGui.QMessageBox()
+ msg.setIcon(QtGui.QMessageBox.Warning)
+ msg.setText("%s already exists! Overwrite it?" % filename)
+ msg.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
+ ch = msg.exec_()
+ if ch != 1024: # 1024 = OK
+ return
+ # remove old copies of the preset
+ for i in range(0, self.windowcomboBox_openPreset.count()):
+ if self.window.comboBox_openPreset.itemText(i) == filename:
+ self.window.comboBox_openPreset.removeItem(i)
+ with open(filepath, 'w') as f:
f.write('%s' % repr(saveValueStore))
self.window.comboBox_openPreset.addItem(filename)