...
 
Commits (2)
......@@ -27,7 +27,7 @@ author = u'Fynn Laue'
# The short X.Y version
version = u'1.0'
# The full version, including alpha/beta/rc tags
release = u'v1.0.1'
release = u'v1.0.2'
# -- General configuration ---------------------------------------------------
......
......@@ -78,6 +78,17 @@ class Preferences(preferencesManager.Preferences):
knob.setFlag(nuke.STARTLINE)
self.addKnob(knob)
class Preferences2(preferencesManager.Preferences):
def __init__(self):
creator = "You"
appName = "Other Tool"
super(Preferences2, self).__init__(creator, appName)
def setup(self):
knob = nuke.Boolean_Knob("something", "something")
knob.setFlag(nuke.STARTLINE)
self.addKnob(knob, defaultValue=False)
#----------------------------------------
# EXEC
#----------------------------------------
......@@ -85,3 +96,5 @@ class Preferences(preferencesManager.Preferences):
if __name__ == '__main__':
PREFS = Preferences()
PREFS.setup()
PREFS2 = Preferences2()
PREFS2.setup()
......@@ -14,7 +14,7 @@ else:
#----------------------------------------
# VARIABLES
#----------------------------------------
VERSION = "1.0.1"
VERSION = "1.0.2"
#----------------------------------------
# CLASSES
......@@ -210,12 +210,19 @@ class Preferences(QtCore.QObject):
"""
addedKnob = None
# Remove existing knobs before adding new ones to preserve order and save their values to preserve them.
# Remove all other knobs by this creator
currentKnobs = OrderedDict()
creatorKnobs = OrderedDict()
for knob in self.preferencesNode.allKnobs():
knobName = knob.name()
if self._isValidKnobName(knobName):
currentKnobs[knobName] = knob
self.preferencesNode.removeKnob(knob)
elif self._isValidCreatorsKnob(knobName, self.creatorName):
if knobName != self._buildTabName(self.creatorName):
print knobName
creatorKnobs[knobName] = knob
self.preferencesNode.removeKnob(knob)
# TAB
# Remove and re-add tab to prevent knobs from being added to another creator's tab
tabKnobName = self._buildTabName(self.creatorName)
......@@ -224,6 +231,9 @@ class Preferences(QtCore.QObject):
self.preferencesNode.removeKnob(tabKnob)
tabKnob = nuke.Tab_Knob(tabKnobName, self.creatorName)
self.preferencesNode.addKnob(tabKnob)
# Add other creator's knobs back
for knobName, knob in creatorKnobs.iteritems():
self.preferencesNode.addKnob(knob)
# HEADING
# Remove and re-add heading to prevent knobs from being added to another apps's section
headingKnobName = self._buildAppHeading(self.creatorName, self.appName)
......@@ -233,7 +243,7 @@ class Preferences(QtCore.QObject):
self.preferencesNode.removeKnob(headingKnob)
headingKnob = nuke.Text_Knob(headingKnobName, headingKnobLabel)
self.preferencesNode.addKnob(headingKnob)
# KNOB(s)
# New Knob
# Add all knobs, except the heading, back again
for knobName, knob in currentKnobs.iteritems():
if knobName != headingKnobName:
......@@ -285,8 +295,7 @@ class Preferences(QtCore.QObject):
if defaultValue:
addedKnob.setValue(defaultValue)
self.knobDefaults[addedKnob.name()] = defaultValue
# self.changed.emit(addedKnob)
self._save()
self._save()
return addedKnob
def resetKnob(self, knobName, _save=True):
......