def __init__(self, label='Choose a preset to add:', specials=None): QtGui.QDialog.__init__(self) self.label = QtGui.QLabel(label) self.label.setWordWrap(True) # can't be assed to create a model self.chooser = QtGui.QListWidget() settings = KP.app.settings import mapfile if settings.contains('AnimationPresets'): self.presetList = mapfile.load(str(settings.value('AnimationPresets').toPyObject())) self.presets = mapfile.load(str(settings.value('AnimationPresetData').toPyObject())) else: self.presetList = ["Circle", "Wiggle", "Drifting Cloud"] self.presets = [ [["Loop", "Sinusoidial", 200.0, "X Position", -200.0, 200.0, 0, 0], ["Loop", "Cosinoidial", 200.0, "Y Position", -200.0, 200.0, 0, 0]], [["Reversible Loop", "Sinusoidial", 50.0, "Y Scale", 100.0, 120.0, 0, 0], ["Loop", "Cosinoidial", 50.0, "X Scale", 100.0, 90.0, 0, 0], ["Reversible Loop", "Sinusoidial", 20.0, "Angle", 10.0, -10.0, 0, 0]], [["Loop", "Sinusoidial", 5000.0, "X Position", -400.0, 400.0, 0, 0], ["Loop", "Sinusoidial", 200.0, "Y Position", 10.0, -10.0, 0, 0], ["Reversible Loop", "Linear", 500.0, "Opacity", 80.0, 40.0, 0, 0]] ] settings.setValue('AnimationPresets', mapfile.dump(self.presetList)) settings.setValue('AnimationPresetData', mapfile.dump(self.presets)) self.chooser.addItems(self.presetList) self.chooser.currentRowChanged.connect(self.handleCurrentRowChanged) self.chooser.itemActivated.connect(self.handleItemActivated) self.buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) self.okButton = self.buttons.button(QtGui.QDialogButtonBox.Ok) self.okButton.setEnabled(False) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.layout = QtGui.QVBoxLayout() self.layout.addWidget(self.label) self.layout.addWidget(self.chooser) self.layout.addWidget(self.buttons) self.setLayout(self.layout)
def save(self): path = self.filePath if path is None: raise "no path specified for this map" KP.mainWindow.pathNodeList.setLayerFolders() self.associateLayers = KP.mainWindow.pathNodeList.getLayers() import mapfile dumped = mapfile.dump(self) open(path, 'wb').write(dumped)
def addToPreset(self): from dialogs import getTextDialog name = getTextDialog('Choose Preset Name', 'Preset name:') if name == None: print 'Returning' return print 'Adding.' preset = [] for row in xrange(self.model.rowCount()): listrow = [] for column in xrange(6): item = self.model.item(row, column) if (column == 0) or (column == 1) or (column == 2): data = str(item.data(Qt.EditRole).toString()) else: data = item.data(Qt.EditRole).toFloat()[0] listrow.append(data) preset.append(listrow) settings = KP.app.settings import mapfile if settings.contains('AnimationPresets'): presetList = mapfile.load(str(settings.value('AnimationPresets').toPyObject())) presets = mapfile.load(str(settings.value('AnimationPresetData').toPyObject())) else: presetList = [] presets = [] presetList.append(name) presets.append(preset) settings.setValue('AnimationPresets', mapfile.dump(presetList)) settings.setValue('AnimationPresetData', mapfile.dump(presets))
def save(self): path = self.filePath if path is None: raise "no path specified for this map" KP.mainWindow.pathNodeList.setLayerFolders() self.associateLayers = KP.mainWindow.pathNodeList.getLayers() import mapfile dumped = mapfile.dump(self) open(path, "wb").write(dumped)
def __init__(self, label='Choose a preset to add:', specials=None): QtWidgets.QDialog.__init__(self) self.label = QtWidgets.QLabel(label) self.label.setWordWrap(True) # can't be assed to create a model self.chooser = QtWidgets.QListWidget() settings = KP.app.settings import mapfile if settings.contains('AnimationPresets'): self.presetList = mapfile.load(settings.value('AnimationPresets')) self.presets = mapfile.load(settings.value('AnimationPresetData')) else: self.presetList = ["Circle", "Wiggle", "Drifting Cloud"] self.presets = [[[ "Loop", "Sinusoidial", 200.0, "X Position", -200.0, 200.0, 0, 0 ], [ "Loop", "Cosinoidial", 200.0, "Y Position", -200.0, 200.0, 0, 0 ]], [[ "Reversible Loop", "Sinusoidial", 50.0, "Y Scale", 100.0, 120.0, 0, 0 ], [ "Loop", "Cosinoidial", 50.0, "X Scale", 100.0, 90.0, 0, 0 ], [ "Reversible Loop", "Sinusoidial", 20.0, "Angle", 10.0, -10.0, 0, 0 ]], [[ "Loop", "Sinusoidial", 5000.0, "X Position", -400.0, 400.0, 0, 0 ], [ "Loop", "Sinusoidial", 200.0, "Y Position", 10.0, -10.0, 0, 0 ], [ "Reversible Loop", "Linear", 500.0, "Opacity", 80.0, 40.0, 0, 0 ]]] settings.setValue('AnimationPresets', mapfile.dump(self.presetList)) settings.setValue('AnimationPresetData', mapfile.dump(self.presets)) self.chooser.addItems(self.presetList) self.chooser.currentRowChanged.connect(self.handleCurrentRowChanged) self.chooser.itemActivated.connect(self.handleItemActivated) self.buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.okButton = self.buttons.button(QtWidgets.QDialogButtonBox.Ok) self.okButton.setEnabled(False) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.label) self.layout.addWidget(self.chooser) self.layout.addWidget(self.buttons) self.setLayout(self.layout)
def __deepcopy__(self, memo): return mapfile.load(mapfile.dump(self))