From 6079c4fd24aecf2ecfed0528c1427a74d596993f Mon Sep 17 00:00:00 2001 From: tassaron Date: Thu, 8 Jun 2017 09:56:57 -0400 Subject: drag'n'drop componentList, move component code to core.py FIXME: finish implementing drag'n'drop, Down button --- presetmanager.py | 56 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'presetmanager.py') diff --git a/presetmanager.py b/presetmanager.py index f67dbb9..50efd8d 100644 --- a/presetmanager.py +++ b/presetmanager.py @@ -86,28 +86,35 @@ class PresetManager(QtGui.QDialog): if window.listWidget_componentList.currentRow() == -1: return while True: - dialog = QtGui.QInputDialog( - QtGui.QWidget(), 'Audio Visualizer', 'New Preset Name:') - dialog.setTextValue() - newName, OK = dialog.getText() - badName = False - for letter in newName: - if letter in string.punctuation: - badName = True - if badName: - # some filesystems don't like bizarre characters - self.parent.showMessage(msg=\ -'''Preset names must contain only letters, numbers, and spaces.''') - continue - if OK and newName: - index = window.listWidget_componentList.currentRow() - if index != -1: - saveValueStore = \ - self.parent.selectedComponents[index].savePreset() - componentName = str(self.parent.selectedComponents[index]).strip() - vers = self.parent.selectedComponents[index].version() - self.createPresetFile( - componentName, vers, saveValueStore, newName) + index = window.listWidget_componentList.currentRow() + currentPreset = self.parent.selectedComponents[index].currentPreset + newName, OK = QtGui.QInputDialog.getText( + self.parent.window, + 'Audio Visualizer', + 'New Preset Name:', + QtGui.QLineEdit.Normal, + currentPreset + ) + if OK: + badName = False + for letter in newName: + if letter in string.punctuation: + badName = True + if badName: + # some filesystems don't like bizarre characters + self.parent.showMessage( + msg='Preset names must contain only letters,' + 'numbers, and spaces.') + continue + if newName: + if index != -1: + saveValueStore = \ + self.parent.selectedComponents[index].savePreset() + componentName = str(self.parent.selectedComponents[index]).strip() + vers = self.parent.selectedComponents[index].version() + self.createPresetFile( + componentName, vers, saveValueStore, newName) + self.parent.selectedComponents[index].currentPreset = newName break def createPresetFile(self, compName, vers, saveValueStore, filename): @@ -139,6 +146,9 @@ class PresetManager(QtGui.QDialog): for line in f: saveValueStore = dict(eval(line.strip())) break - self.parent.selectedComponents[index].loadPreset(saveValueStore) + self.parent.selectedComponents[index].loadPreset( + saveValueStore, + presetName + ) self.parent.drawPreview() -- cgit v1.2.3