diff options
author | natural <natural> | 2006-12-23 23:03:53 +0000 |
---|---|---|
committer | natural <natural> | 2006-12-23 23:03:53 +0000 |
commit | 5dbd7720a4e446d8f12c1456584e354a3facdd7c (patch) | |
tree | 87219a0b522de31d9dcbcd110459ceebed481be2 /kberylsettings | |
parent | 218899acc534b1d8d8896ecf5cbbda8c676732be (diff) | |
download | kberylsettings-5dbd7720a4e446d8f12c1456584e354a3facdd7c.tar.gz kberylsettings-5dbd7720a4e446d8f12c1456584e354a3facdd7c.tar.bz2 |
Added popup balloons for setting.LongDesc.
Initial add of (gimped) kberylsettings.png.
Fixed no-save-settings-on-quit-action bug.
Tweaks to contentframe.py.
Diffstat (limited to 'kberylsettings')
-rw-r--r-- | kberylsettings/contentframe.py | 126 | ||||
-rw-r--r-- | kberylsettings/main.py | 4 | ||||
-rw-r--r-- | kberylsettings/pixmaps/kberylsettings.png | bin | 0 -> 5106 bytes | |||
-rw-r--r-- | kberylsettings/settingframe.py | 39 |
4 files changed, 83 insertions, 86 deletions
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py index e0f53d8..bcea158 100644 --- a/kberylsettings/contentframe.py +++ b/kberylsettings/contentframe.py @@ -3,15 +3,15 @@ """ kberylsettings.contentframe -> defines the right side about/setting views. """ -from os.path import abspath - -from qt import Qt, QFrame, QLabel, QHBoxLayout, QScrollView, QVBoxLayout, QStringList, QSizePolicy, QSize from kdecore import KIcon -from kdeui import KStdGuiItem, KPushButton, KMessageBox, KSeparator +from kdeui import KMessageBox, KPassivePopup, KPushButton, \ + KSeparator, KStdGuiItem +from qt import Qt, QFrame, QHBoxLayout, QLabel, QScrollView, QSize, \ + QSizePolicy, QStringList, QVBoxLayout -from kberylsettings.lib import App, Signals, buildPart, iconLoader -from kberylsettings.settingframe import SettingFrame -from kberylsettings.widget import Frame, WidgetStack +from kberylsettings.lib import App, Signals, buildPart, icon, iconLoader, iconSet +from kberylsettings.widget import Frame, SmallPushButton, WidgetStack +from kberylsettings.settingwidget import settingWidget class ContentFrame(WidgetStack): @@ -44,7 +44,6 @@ class ContentFrame(WidgetStack): @return None """ - self.settingsPage = page = Frame(self, 6, 10) self.addWidget(page, self.settingsPageId) @@ -56,28 +55,27 @@ class ContentFrame(WidgetStack): 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) + self.settingsMain = main = SettingsContainer(page) + self.scrollerWrap = wrap = Frame(page) + self.settingsScroller = scroller = ContentScroll(wrap, main) - sep = KSeparator(KSeparator.Horizontal, page) + 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) + button = KPushButton(gui.iconSet(), gui.text(), footer) footerLayout.addWidget(button) return button self.helpButton = contentButton('help') self.defaultsButton = contentButton('defaults') - footerLayout.addStretch(100) - self.applyButton = contentButton('apply') - self.applyButton.setEnabled(False) - self.resetButton = contentButton('reset') - self.resetButton.setEnabled(False) + footerLayout.addStretch(2) + self.applyButton = applyButton = contentButton('apply') + applyButton.setEnabled(False) + self.resetButton = resetButton = contentButton('reset') + resetButton.setEnabled(False) def buildConnections(self): """ build the connections for this instance @@ -105,13 +103,13 @@ class ContentFrame(WidgetStack): @param plugin berylsettings Plugin instance @return None """ - logofile = 'file://%s' % (abspath(App.basedir + '/html/beryl-manager.png'), ) - htmlsrc = open(abspath(App.basedir + '/html/plugin.html')).read() + logofile = 'file://%s' % App.basedir + '/html/beryl-manager.png' + htmlsrc = open(App.basedir + '/html/plugin.html').read() if plugin is None: pluginname = 'Beryl Settings' plugindesc = 'Beryl Settings - Get Your Effects On!' else: - #logofile = 'file://%s' % (abspath(App.basedir + '/pixmaps/beryl-settings-section-%s.png' % plugin.Name), ) + #logofile = 'file://%s' % App.basedir + '/pixmaps/beryl-settings-section-%s.png' % plugin.Name pluginname = plugin.ShortDesc plugindesc = plugin.LongDesc self.infoHtml.begin() @@ -164,39 +162,35 @@ class ContentFrame(WidgetStack): self.resetButton.setEnabled(False) def settingApply(self): - """ not implemented + """ not final """ - frame = self.settingsPage - widgets = frame.queryList('SettingWidgetBase') - exceptions = [] - for widget in widgets: + excs = [] + for w in self.settingsPage.queryList('SettingWidgetBase'): try: - value = widget.value() - widget.setting.set(value) - widget.initial = value - print '****', widget.setting.ShortDesc, widget.setting.Value + v = w.value() + w.setting.set(v) + w.initial = v 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) + 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.applyButton.setEnabled(False) self.resetButton.setEnabled(False) self.emit(Signals.statusMessage, ('Saving settings...', )) self.emit(Signals.berylSettingChanged, ()) -class SettingsMainFrame(QFrame): +class SettingsContainer(QFrame): def __init__(self, parent): QFrame.__init__(self, parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.settingFrames = [] - layout = QVBoxLayout(self, 20) + layout = QVBoxLayout(self, 5) def addSettings(self, plugin, settings): self.clearFrames() @@ -207,7 +201,7 @@ class SettingsMainFrame(QFrame): self.settingFrames.append(frame) layout.addWidget(frame, 0, Qt.AlignTop) self.connect(frame, changed, self, changed) - layout.addStretch(100) + layout.addStretch(5) for frame in self.settingFrames: frame.show() self.updateGeometry() @@ -219,7 +213,52 @@ class SettingsMainFrame(QFrame): self.settingFrames = [] - +class SettingFrame(QFrame): + """ SettingFrame -> displays editing widgets for a single Setting instance. + + """ + def __init__(self, parent, plugin, setting): + QFrame.__init__(self, parent) + mainLayout = QVBoxLayout(self) + innerLayout = QHBoxLayout(mainLayout, 3) + self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) + self.infoCaption = setting.ShortDesc + self.infoText = setting.LongDesc + self.infoButton = info = SmallPushButton(iconSet('help'), '', self) + self.resetButton = reset = SmallPushButton(iconSet('reload'), '', self) + self.settingWidget = widget = settingWidget(self, plugin, setting) + if isinstance(widget.layout(), QHBoxLayout): + align = Qt.AlignLeft | Qt.AlignVCenter + else: + align = Qt.AlignLeft | Qt.AlignTop + innerLayout.addWidget(info, 0, align) + innerLayout.addWidget(reset, 0, align) + innerLayout.addWidget(widget, 10) + mainLayout.addSpacing(10) + + connect = self.connect + connect(info, Signals.clicked, self.showInfo) + connect(widget, Signals.somethingChanged, + self, Signals.somethingChanged) + + def showInfo(self): + """ show a balloon tip with the setting description + + @return None + """ + parent = self.resetButton + ico = icon('help', size=KIcon.SizeLarge) + txt = self.infoText + cap = self.infoCaption + msg = KPassivePopup.message + pop = msg(KPassivePopup.Balloon, cap, txt, ico, parent) + pos = pop.pos() + pos.setY(pos.y() + (parent.height() / 2)) + pos.setX(pos.x() + (parent.width() * 2)) + pop.show() + pop.move(pos) + + class ContentScroll(QScrollView): """ ContentScroll -> a scroll view fitted to a single child @@ -227,6 +266,5 @@ class ContentScroll(QScrollView): def __init__(self, parent, child): QScrollView.__init__(self, parent) self.setResizePolicy(QScrollView.AutoOneFit) - #self.setVScrollBarMode(self.AlwaysOn) self.setFrameShape(self.Box) self.addChild(child) diff --git a/kberylsettings/main.py b/kberylsettings/main.py index ab827cd..3a301fc 100644 --- a/kberylsettings/main.py +++ b/kberylsettings/main.py @@ -42,12 +42,9 @@ class KBerylSettings(KMainWindow): """ actions = self.actionCollection() actions.setHighlightingEnabled(True) - self.mainSplitter = splitter = Splitter(self, Qt.Horizontal) self.leftFrame = left = Frame(splitter) self.contentFrame = ContentFrame(splitter) - #splitter.setResizeMode(self.contentFrame, splitter.FollowSizeHint) - self.searchWidget = search = QWidget(self.leftFrame) searchLayout = QHBoxLayout(search, 6, 6) searchLayout.setAutoAdd(True) @@ -277,6 +274,7 @@ class KBerylSettings(KMainWindow): @return None """ self.quitFlag = True + self.queryClose() KApplication.kApplication().quit() def onSelectPlugins(self): diff --git a/kberylsettings/pixmaps/kberylsettings.png b/kberylsettings/pixmaps/kberylsettings.png Binary files differnew file mode 100644 index 0000000..20524ca --- /dev/null +++ b/kberylsettings/pixmaps/kberylsettings.png diff --git a/kberylsettings/settingframe.py b/kberylsettings/settingframe.py deleted file mode 100644 index 261f8c1..0000000 --- a/kberylsettings/settingframe.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" kberylsettings.settingframe -> defines SettingFrame for displaying -berylsettings.Setting instances. - -""" -from qt import Qt, QFrame, QHBoxLayout, QSizePolicy, QToolTip, QVBoxLayout - -from kberylsettings.lib import App, Signals, iconSet -from kberylsettings.settingwidget import settingWidget -from kberylsettings.widget import SmallPushButton - - -class SettingFrame(QFrame): - """ SettingFrame -> displays editing widgets for a single Setting instance. - - """ - def __init__(self, parent, plugin, setting): - QFrame.__init__(self, parent) - vlayout = QVBoxLayout(self) - layout = QHBoxLayout(vlayout, 3) - self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, - QSizePolicy.Minimum)) - self.infoButton = SmallPushButton(iconSet('help'), '', self) - self.resetButton = SmallPushButton(iconSet('reload'), '', self) - self.settingWidget = settingWidget(self, plugin, setting) - - if isinstance(self.settingWidget.layout(), QHBoxLayout): - align = Qt.AlignLeft | Qt.AlignVCenter - else: - align = Qt.AlignLeft | Qt.AlignTop - - tooltip = QToolTip.add(self.infoButton, setting.LongDesc) - layout.addWidget(self.infoButton, 0, align) - layout.addWidget(self.resetButton, 0, align) - layout.addWidget(self.settingWidget, 10) - vlayout.addSpacing(10) - self.connect(self.settingWidget, Signals.somethingChanged, - self, Signals.somethingChanged) |