summaryrefslogtreecommitdiff
path: root/kberylsettings
diff options
context:
space:
mode:
authornatural <natural>2006-12-29 22:15:55 +0000
committernatural <natural>2006-12-29 22:15:55 +0000
commit0aec17325b9df32be8a46d09efea611eb12fd5ec (patch)
tree4a067fc106af227d552377dc11f615fcaac67e7d /kberylsettings
parent83388f8fa04a23e09111d140f508d22667892202 (diff)
downloadkberylsettings-0aec17325b9df32be8a46d09efea611eb12fd5ec.tar.gz
kberylsettings-0aec17325b9df32be8a46d09efea611eb12fd5ec.tar.bz2
Now handles _ plugin and active_plugin setting with a group box and label.
Diffstat (limited to 'kberylsettings')
-rw-r--r--kberylsettings/contentframe.py54
-rw-r--r--kberylsettings/settingwidget.py54
2 files changed, 70 insertions, 38 deletions
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index 6890fd5..e9b096a 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -201,12 +201,13 @@ class SettingPage:
@return None
"""
- widgets = self.queryList('SettingFrame')
- for widget in widgets:
+ excs = []
+ for w in self.queryList('SettingWidget'):
try:
- widget.setDefault()
+ w.setDefault()
except (Exception, ), exc:
- print 'reset exception:', exc
+ excs.append((w.plugin.Name, w.setting.Name, exc))
+ self.settingExcDialog(excs, 'Exceptions During Set Default')
self.enableApplyReset(True, True)
def settingsReset(self):
@@ -214,12 +215,13 @@ class SettingPage:
@return None
"""
- widgets = self.queryList('SettingWidget')
- for widget in widgets:
+ excs = []
+ for w in self.queryList('SettingWidget'):
try:
- widget.reset()
+ w.reset()
except (Exception, ), exc:
- print 'reset exception:', exc
+ excs.append((w.plugin.Name, w.setting.Name, exc))
+ self.settingExcDialog(excs, 'Exceptions During Reset')
self.enableApplyReset(False, False)
def settingApply(self):
@@ -229,21 +231,22 @@ class SettingPage:
excs = []
for w in self.queryList('SettingWidget'):
try:
- v = w.value()
- w.setting.set(v)
- w.initial = v
+ w.setFromValue()
except (Exception, ), exc:
excs.append((w.plugin.Name, w.setting.Name, exc))
- if excs:
- excstrs = QStringList()
- for exc in excs:
- excstrs.append('Plugin:%s Setting:%s Exception:%s' % exc)
- KMessageBox.errorList(None, 'Exceptions Saving Settings',
- excstrs)
+ self.settingExcDialog(excs, 'Exceptions During Apply')
self.enableApplyReset(False, False)
self.emit(Signals.statusMessage, ('Saving settings...', ))
self.emit(Signals.berylSettingChanged, ())
+ def settingExcDialog(self, exceptions, caption):
+ if not exceptions:
+ return
+ excstrs = QStringList()
+ for exc in exceptions:
+ excstrs.append('Plugin:%s Setting:%s Exception:%s' % exc)
+ KMessageBox.errorList(None, caption, excstrs)
+
class SinglePage(Frame, SettingPage):
""" SinglePage -> frame to display a single group of settings
@@ -407,24 +410,9 @@ class SettingFrame(QFrame):
connect = self.connect
connect(info, Signals.clicked, self.showTip)
- connect(reset, Signals.clicked, self.setDefault)
+ connect(reset, Signals.clicked, self.settingWidget.setDefault)
connect(widget, Signals.someChange, self, Signals.someChange)
- def setDefault(self):
- """ set the setting value to its default
-
- The berylsettings extension module performs the reset directly
- on the setting object. In this method, we save the current
- value as defined by the widget and set that value again after
- the reset.
- """
- widget = self.settingWidget
- current = widget.value()
- widget.initial = widget.setting.ResetToDefault()
- widget.setting.set(current)
- widget.reset()
- widget.initial = current
-
def showTip(self):
""" show a balloon tip with the setting description
diff --git a/kberylsettings/settingwidget.py b/kberylsettings/settingwidget.py
index c1689dd..1ef4487 100644
--- a/kberylsettings/settingwidget.py
+++ b/kberylsettings/settingwidget.py
@@ -119,6 +119,25 @@ class SettingWidget(QFrame):
return (setting.Type in cls.queryTypes) and cls
query = classmethod(query)
+ def setFromValue(self):
+ value = self.value()
+ self.setting.set(value)
+ self.initial = value
+
+ def setDefault(self):
+ """ set the setting value to its default
+
+ The berylsettings extension module performs the reset directly
+ on the setting object. In this method, we save the current
+ value as defined by the widget and set that value again after
+ the reset.
+ """
+ current = self.value()
+ self.initial = self.setting.ResetToDefault()
+ self.setting.set(current)
+ self.reset()
+ self.initial = current
+
## MARKER
def checkBoxValue(self):
@@ -219,8 +238,9 @@ class SpecificNames(SettingWidget):
return self.lookup(plugin, setting)(self, parent, plugin, setting)
def lookup(cls, plugin, setting):
- name = '%s_%s' % (plugin.Name, setting.Name, )
- return getattr(cls, name, None)
+ name = '%s_%s' % (plugin.Name, setting.Name, )
+ alt = '_%s' % (setting.Name, )
+ return getattr(cls, name, getattr(cls, alt, None))
lookup = classmethod(lookup)
def query(cls, plugin, setting):
@@ -237,10 +257,10 @@ class SpecificNames(SettingWidget):
def switcher_icon_corner(self, parent, plugin, setting):
""" creates a combo box for the Switcher Icon Corner setting
- @param parent ignored
- @param plugin ignored
+ @param parent parent object of this widget
+ @param plugin berylsettings Plugin instance
@param setting better be a icon_corner setting instance
- @return None
+ @return four-item tuple of (widget, signal, valuemethod, resetmethod)
"""
self.combo = KComboBox(self)
for index, text in enumerate(self.iconCorners):
@@ -250,7 +270,31 @@ class SpecificNames(SettingWidget):
return (self.combo, Signals.activatedIndex,
self.comboIndex, self.comboIndexReset)
+ noActiveText = ('Active Plugins should not be edited directly.\n'
+ 'Use the Plugin dialog from the Settings menu instead.')
+
+ def _active_plugins(self, parent, plugin, setting):
+ """ creates a non-editable widget for the Active Plugin setting
+
+ @param parent parent object of this widget
+ @param plugin berylsettings Plugin instance
+ @param setting better be a icon_corner setting instance
+ @return four-item tuple of (widget, signal, valuemethod, resetmethod)
+ """
+ layout = QVBoxLayout(self)
+ self.groupBox = GroupBox(1, Qt.Vertical, setting.ShortDesc, self, 10, 10)
+ self.groupBox.setFlat(False)
+ layout.addWidget(self.groupBox)
+ self.noActiveLabel = QLabel(self.noActiveText, self.groupBox)
+ self.setFromValue = self.setDefault = self.noOp
+ return (None, None, self.noOp, self.noOp)
+
+ def noOp(self):
+ """ does nothing
+
+ """
+
class MatchNames(SettingWidget):
""" Setting widget for settings with matching names.