summaryrefslogtreecommitdiff
path: root/clPlugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'clPlugin.py')
-rw-r--r--clPlugin.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/clPlugin.py b/clPlugin.py
index a2522e9..7e82a99 100644
--- a/clPlugin.py
+++ b/clPlugin.py
@@ -1,5 +1,6 @@
from PyQt4 import QtGui, QtSvg, QtCore
+import plugins
from clMonty import monty
from clSettings import settings, mpdSettings
from misc import *
@@ -141,6 +142,31 @@ class Plugin:
return setting[3]
return None
+ def getSetting(self, setting, default=None, pluginClass=None):
+ if pluginClass==None:
+ pluginClass=self.__class__
+
+ # fetch the name
+ pluginClass=str(self.__class__).split('.')[-1].lower()[len('plugin'):]
+
+ if default==None:
+ # what module is this class in?
+ module='.'.join(str(self.__class__).split('.')[0:2])
+ # import the module
+ __import__(module, globals(), locals(), [], -1)
+ # set the default
+ default=eval("%s.%s_%s_DEFAULT"%(module, pluginClass.upper(), setting.upper()))
+
+ return settings.get("%s.%s"%(str(pluginClass).lower(), setting), default)
+
+ def setSetting(self, setting, value, pluginClass=None):
+ if pluginClass==None:
+ pluginClass=self.__class__
+ # fetch the name
+ pluginClass=str(self.__class__).split('.')[-1].lower()[len('plugin'):]
+ settings.set("%s.%s"%(str(pluginClass).lower(), setting), value)
+
+
def afterSaveSettings(self):
"""Override this one."""