summaryrefslogtreecommitdiff
path: root/kberylsettings/contentframe.py
diff options
context:
space:
mode:
authornatural <natural>2006-12-19 13:03:14 +0000
committernatural <natural>2006-12-19 13:03:14 +0000
commite87833f32ea631dab7391484f0f89bedf669b80c (patch)
tree2a66917ce2bad8f7d6619ebbccf0d37598f12f22 /kberylsettings/contentframe.py
parent99b44818d60794aae11dca5f67722ab32c98f137 (diff)
downloadkberylsettings-e87833f32ea631dab7391484f0f89bedf669b80c.tar.gz
kberylsettings-e87833f32ea631dab7391484f0f89bedf669b80c.tar.bz2
Support for basic setting saves. Other refactorings and fixes.
Diffstat (limited to 'kberylsettings/contentframe.py')
-rw-r--r--kberylsettings/contentframe.py87
1 files changed, 61 insertions, 26 deletions
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index 72155b3..4e43628 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -5,11 +5,11 @@
"""
from os.path import abspath
-from qt import Qt, QFrame, QLabel, QHBoxLayout, QScrollView, QVBoxLayout
-from kdecore import KIcon, KIconLoader
-from kdeui import KStdGuiItem, KPushButton
+from qt import Qt, QFrame, QLabel, QHBoxLayout, QScrollView, QVBoxLayout, QStringList
+from kdecore import KIcon
+from kdeui import KStdGuiItem, KPushButton, KMessageBox
-from kberylsettings.lib import App, Signals, buildPart
+from kberylsettings.lib import App, Signals, buildPart, iconLoader
from kberylsettings.settingframe import SettingFrame
from kberylsettings.widget import Frame, WidgetStack
@@ -23,7 +23,7 @@ class ContentFrame(WidgetStack):
def __init__(self, parent):
WidgetStack.__init__(self, parent)
- self.loader = KIconLoader(self.__class__.__name__)
+ self.loader = iconLoader()
self.buildAboutPage()
self.buildSettingsPage()
self.buildConnections()
@@ -51,10 +51,7 @@ class ContentFrame(WidgetStack):
layout.addWidget(self.pluginIconLabel)
layout.addWidget(self.pluginNameLabel, 100)
- self.settingsMain = QFrame(self)
- self.settingsMain.settingsWidgets = []
- layout = QVBoxLayout(self.settingsMain)
-
+ self.settingsMain = SettingsMainFrame(self)
self.settingsScroller = ContentScroll(self.settingsPage, self.settingsMain)
if not App.debug:
self.settingsScroller.setFrameShape(Frame.NoFrame)
@@ -68,10 +65,14 @@ class ContentFrame(WidgetStack):
return button
self.helpButton = contentButton('help')
+ self.helpButton.setEnabled(False)
self.defaultsButton = contentButton('defaults')
+ self.defaultsButton.setEnabled(False)
layout.addStretch(100)
self.applyButton = contentButton('apply')
+ #self.applyButton.setEnabled(False)
self.resetButton = contentButton('reset')
+ self.resetButton.setEnabled(False)
self.addWidget(self.settingsPage, self.settingsPageId)
def buildConnections(self):
@@ -79,9 +80,13 @@ class ContentFrame(WidgetStack):
@return None
"""
- self.connect(self.helpButton, Signals.clicked, self.settingHelp)
- self.connect(self.defaultsButton, Signals.clicked, self.settingDefaults)
- self.connect(self.applyButton, Signals.clicked, self.settingApply)
+ connect = self.connect
+ connect(self.helpButton, Signals.clicked, self.settingHelp)
+ connect(self.defaultsButton, Signals.clicked, self.settingDefaults)
+ connect(self.applyButton, Signals.clicked, self.settingApply)
+ root = self.topLevelWidget()
+ connect(self, Signals.berylSettingChanged, root.onSettingChanged)
+ connect(self, Signals.statusMessage, root.showMessage)
def showAbout(self, plugin):
""" displays the About Plugin page with information from the plugin
@@ -109,27 +114,16 @@ class ContentFrame(WidgetStack):
@param arg setting name or setting section name
@return None
"""
- self.settingsMain.hide()
- for widget in self.settingsMain.settingsWidgets:
- widget.close()
- layout = self.settingsMain.layout()
- layout.deleteAllItems()
+ ico = plugin.icon(KIcon.SizeLarge, self.loader)
+ self.pluginIconLabel.setPixmap(ico)
if arg in plugin.settings:
settings = plugin.settings[arg]
extra = ' - %s' % (arg, )
else:
settings = [arg, ]
extra = ''
- ico = plugin.icon(KIcon.SizeLarge, self.loader)
- self.pluginIconLabel.setPixmap(ico)
self.pluginNameLabel.setText('<b>%s%s</b>' % (plugin.ShortDesc, extra))
- for setting in settings:
- frame = SettingFrame(self.settingsMain, setting)
- self.settingsMain.settingsWidgets.append(frame)
- layout.addWidget(frame, 0, Qt.AlignTop)
- frame.show()
- layout.addStretch(100)
- self.settingsMain.show()
+ self.settingsMain.addSettings(plugin, settings)
self.raiseWidget(self.settingsPageId)
def settingHelp(self):
@@ -146,6 +140,47 @@ class ContentFrame(WidgetStack):
""" not implemented
"""
+ frame = self.settingsPage
+ widgets = frame.queryList('BaseSettingWidget')
+ exceptions = []
+ for widget in widgets:
+ try:
+ widget.setting.set(widget.value())
+ print '****', widget.setting.ShortDesc, widget.setting.Value
+
+ except (Exception, ), exc:
+ exceptions.append((widget.plugin.Name, widget.setting.Name, exc))
+ if exceptions:
+ exclist = QStringList()
+ for exc in exceptions:
+ exclist.append('Plugin:%s Setting:%s Exception:%s' % exc)
+ ## KMessageBox.errorList isn't available!
+ KMessageBox.informationList(None, 'Exceptions Saving Settings',
+ exclist)
+ self.emit(Signals.statusMessage, ('Saving settings...', ))
+ self.emit(Signals.berylSettingChanged, ())
+
+class SettingsMainFrame(QFrame):
+ def __init__(self, parent):
+ QFrame.__init__(self, parent)
+ self.settingFrames = []
+ layout = QVBoxLayout(self)
+
+ def addSettings(self, plugin, settings):
+ self.clearFrames()
+ layout = self.layout()
+ for setting in settings:
+ frame = SettingFrame(self, plugin, setting)
+ self.settingFrames.append(frame)
+ layout.addWidget(frame, 0, Qt.AlignTop)
+ frame.show()
+ layout.addStretch(100)
+
+ def clearFrames(self):
+ for widget in self.settingFrames:
+ widget.close(True)
+ self.layout().deleteAllItems()
+ self.settingFrames = []
class ContentScroll(QScrollView):