summaryrefslogtreecommitdiff
path: root/kberylsettings/contentframe.py
diff options
context:
space:
mode:
authornatural <natural>2006-12-23 13:15:14 +0000
committernatural <natural>2006-12-23 13:15:14 +0000
commit218899acc534b1d8d8896ecf5cbbda8c676732be (patch)
tree54fb6d8cf11ed7374f3e535d27e1cc4a9d70bfa5 /kberylsettings/contentframe.py
parenta4fcfeb8b855e88d8e662c562dfbd6c9370793a1 (diff)
downloadkberylsettings-218899acc534b1d8d8896ecf5cbbda8c676732be.tar.gz
kberylsettings-218899acc534b1d8d8896ecf5cbbda8c676732be.tar.bz2
Updated setting widget construction and splitter handling.
Diffstat (limited to 'kberylsettings/contentframe.py')
-rw-r--r--kberylsettings/contentframe.py75
1 files changed, 45 insertions, 30 deletions
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index 9880925..e0f53d8 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -5,9 +5,9 @@
"""
from os.path import abspath
-from qt import Qt, QFrame, QLabel, QHBoxLayout, QScrollView, QVBoxLayout, QStringList
+from qt import Qt, QFrame, QLabel, QHBoxLayout, QScrollView, QVBoxLayout, QStringList, QSizePolicy, QSize
from kdecore import KIcon
-from kdeui import KStdGuiItem, KPushButton, KMessageBox
+from kdeui import KStdGuiItem, KPushButton, KMessageBox, KSeparator
from kberylsettings.lib import App, Signals, buildPart, iconLoader
from kberylsettings.settingframe import SettingFrame
@@ -34,45 +34,51 @@ class ContentFrame(WidgetStack):
@return None
"""
self.aboutPage = Frame(self, margin=6, spacing=10)
+ self.addWidget(self.aboutPage, self.aboutPageId)
self.infoHtml = buildPart(self.aboutPage, 'text/html',
"Type == 'Service'", True)
- self.addWidget(self.aboutPage, self.aboutPageId)
+
def buildSettingsPage(self):
""" builds page for displaying one or more settings
@return None
"""
- self.settingsPage = Frame(self, margin=6, spacing=10)
- self.pluginHeader = QFrame(self.settingsPage)
- self.pluginIconLabel = QLabel(self.pluginHeader)
- self.pluginNameLabel = QLabel(self.pluginHeader)
- layout = QHBoxLayout(self.pluginHeader)
- layout.addWidget(self.pluginIconLabel)
- layout.addWidget(self.pluginNameLabel, 100)
-
- self.settingsMain = SettingsMainFrame(self)
- self.settingsScroller = ContentScroll(self.settingsPage, self.settingsMain)
- if not App.debug:
- self.settingsScroller.setFrameShape(Frame.NoFrame)
- self.settingsFooter = QFrame(self.settingsPage)
- layout = QHBoxLayout(self.settingsFooter)
+
+ self.settingsPage = page = Frame(self, 6, 10)
+ self.addWidget(page, self.settingsPageId)
+
+ self.pluginHeader = header = QFrame(page)
+ self.pluginIconLabel = QLabel(header)
+ self.pluginNameLabel = QLabel(header)
+
+ headerLayout = QHBoxLayout(header)
+ headerLayout.addWidget(self.pluginIconLabel, 1)
+ headerLayout.addWidget(self.pluginNameLabel, 10)
+ self.settingsMain = main = SettingsMainFrame(page)
+ ## ugly hack that took me 6 hours (!!) to find
+ self.any = Frame(page)
+ self.settingsScroller = scroller = ContentScroll(self.any, main)
+
+ sep = KSeparator(KSeparator.Horizontal, page)
+ self.settingsFooter = footer = QFrame(page)
+ footerLayout = QHBoxLayout(footer)
+
def contentButton(name):
gui = getattr(KStdGuiItem, name)()
button = KPushButton(gui.iconSet(), gui.text(), self.settingsFooter)
- layout.addWidget(button)
+ footerLayout.addWidget(button)
return button
self.helpButton = contentButton('help')
self.defaultsButton = contentButton('defaults')
- layout.addStretch(100)
+ footerLayout.addStretch(100)
self.applyButton = contentButton('apply')
self.applyButton.setEnabled(False)
self.resetButton = contentButton('reset')
- self.resetButton.setEnabled(False)
- self.addWidget(self.settingsPage, self.settingsPageId)
-
+ self.resetButton.setEnabled(False)
+
def buildConnections(self):
""" build the connections for this instance
@@ -112,6 +118,7 @@ class ContentFrame(WidgetStack):
self.infoHtml.write(htmlsrc % locals())
self.infoHtml.end()
self.raiseWidget(self.aboutPageId)
+
def showSettings(self, plugin, arg):
""" displays the settings page with individual setting frames
@@ -120,6 +127,7 @@ class ContentFrame(WidgetStack):
@param arg setting name or setting section name
@return None
"""
+ p = self.parent()
ico = plugin.icon(KIcon.SizeLarge, self.loader)
self.pluginIconLabel.setPixmap(ico)
if arg in plugin.settings:
@@ -131,8 +139,8 @@ class ContentFrame(WidgetStack):
self.pluginNameLabel.setText('<b>%s%s</b>' % (plugin.ShortDesc, extra))
self.settingsMain.addSettings(plugin, settings)
self.applyButton.setEnabled(False)
- self.resetButton.setEnabled(False)
- self.raiseWidget(self.settingsPageId)
+ self.resetButton.setEnabled(False)
+ self.raiseWidget(self.settingsPageId)
def settingHelp(self):
""" not implemented
@@ -182,24 +190,28 @@ class ContentFrame(WidgetStack):
self.emit(Signals.statusMessage, ('Saving settings...', ))
self.emit(Signals.berylSettingChanged, ())
+
class SettingsMainFrame(QFrame):
def __init__(self, parent):
QFrame.__init__(self, parent)
+ self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.settingFrames = []
- layout = QVBoxLayout(self)
+ layout = QVBoxLayout(self, 20)
def addSettings(self, plugin, settings):
self.clearFrames()
layout = self.layout()
+ changed = Signals.somethingChanged
for setting in settings:
frame = SettingFrame(self, plugin, setting)
self.settingFrames.append(frame)
layout.addWidget(frame, 0, Qt.AlignTop)
+ self.connect(frame, changed, self, changed)
+ layout.addStretch(100)
+ for frame in self.settingFrames:
frame.show()
- self.connect(frame, Signals.somethingChanged,
- self, Signals.somethingChanged)
- layout.addStretch(100)
-
+ self.updateGeometry()
+
def clearFrames(self):
for widget in self.settingFrames:
widget.close(True)
@@ -207,11 +219,14 @@ class SettingsMainFrame(QFrame):
self.settingFrames = []
+
class ContentScroll(QScrollView):
""" ContentScroll -> a scroll view fitted to a single child
"""
def __init__(self, parent, child):
QScrollView.__init__(self, parent)
- self.addChild(child)
self.setResizePolicy(QScrollView.AutoOneFit)
+ #self.setVScrollBarMode(self.AlwaysOn)
+ self.setFrameShape(self.Box)
+ self.addChild(child)