aboutsummaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authortassaron2017-08-14 18:41:45 -0400
committertassaron2017-08-14 18:41:45 -0400
commit733c005eeaf5d3ff15e0f60d320f5c03472bad60 (patch)
tree32176c185ca09a8f35d195fac257ca31313b84bb /src/core.py
parenta327bec4e42cc572fb84e559025e888a4a20edd3 (diff)
undoable removeComponent action
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/core.py b/src/core.py
index 4dfb210..20b9c1d 100644
--- a/src/core.py
+++ b/src/core.py
@@ -64,31 +64,39 @@ class Core:
for i, component in enumerate(self.selectedComponents):
component.compPos = i
- def insertComponent(self, compPos, moduleIndex, loader):
+ def insertComponent(self, compPos, component, loader):
'''
Creates a new component using these args:
- (compPos, moduleIndex in self.modules, MWindow/Command/Core obj)
+ (compPos, component obj or moduleIndex, MWindow/Command/Core obj)
'''
if compPos < 0 or compPos > len(self.selectedComponents):
compPos = len(self.selectedComponents)
if len(self.selectedComponents) > 50:
return None
- log.debug('Inserting Component from module #%s' % moduleIndex)
- component = self.modules[moduleIndex].Component(
- moduleIndex, compPos, self
+ if type(component) is int:
+ # create component using module index in self.modules
+ moduleIndex = int(component)
+ log.debug('Creating new component from module #%s' % moduleIndex)
+ component = self.modules[moduleIndex].Component(
+ moduleIndex, compPos, self
+ )
+ # init component's widget for loading/saving presets
+ component.widget(loader)
+ else:
+ moduleIndex = -1
+ log.debug(
+ 'Inserting previously-created %s component' % component.name)
+
+ component._error.connect(
+ loader.videoThreadError
)
self.selectedComponents.insert(
compPos,
component
)
self.componentListChanged()
- self.selectedComponents[compPos]._error.connect(
- loader.videoThreadError
- )
-
- # init component's widget for loading/saving presets
- self.selectedComponents[compPos].widget(loader)
- self.updateComponent(compPos)
+ if moduleIndex > -1:
+ self.updateComponent(compPos)
if hasattr(loader, 'insertComponent'):
loader.insertComponent(compPos)
@@ -156,6 +164,10 @@ class Core:
break
return saveValueStore
+ def getPresetDir(self, comp):
+ '''Get the preset subdir for a particular version of a component'''
+ return os.path.join(Core.presetDir, str(comp), str(comp.version))
+
def openProject(self, loader, filepath):
''' loader is the object calling this method which must have
its own showMessage(**kwargs) method for displaying errors.