summaryrefslogtreecommitdiff
path: root/kberylsettings
diff options
context:
space:
mode:
authornatural <natural>2006-12-24 10:20:10 +0000
committernatural <natural>2006-12-24 10:20:10 +0000
commitefa1df0939d879cf18e0cf9fa342aaf86d3e9ea1 (patch)
tree486d072a630c5720689ccb13f48a76485e346e6c /kberylsettings
parent5dbd7720a4e446d8f12c1456584e354a3facdd7c (diff)
downloadkberylsettings-efa1df0939d879cf18e0cf9fa342aaf86d3e9ea1.tar.gz
kberylsettings-efa1df0939d879cf18e0cf9fa342aaf86d3e9ea1.tar.bz2
Updates for most recent berylsettings.pyx.
Added setting widget for strings with fewer than 5 restrictions; uses radio buttons instead of a list box. Added profile menus to main.py (not yet functional). Changed color setting widgets; they now work! Other minor fixes and changes. Enabled "Defaults" and "Reset" buttons.
Diffstat (limited to 'kberylsettings')
-rw-r--r--kberylsettings/beryl.py15
-rw-r--r--kberylsettings/contentframe.py62
-rw-r--r--kberylsettings/lib.py3
-rw-r--r--kberylsettings/main.py41
-rw-r--r--kberylsettings/plugindialog.py4
-rw-r--r--kberylsettings/pluginframe.py4
-rw-r--r--kberylsettings/settingwidget.py204
-rw-r--r--kberylsettings/widget.py16
8 files changed, 244 insertions, 105 deletions
diff --git a/kberylsettings/beryl.py b/kberylsettings/beryl.py
index 5bb91b6..f26c32f 100644
--- a/kberylsettings/beryl.py
+++ b/kberylsettings/beryl.py
@@ -24,7 +24,7 @@ class Context(QObject):
QObject.__init__(self)
if context is None:
context = berylsettings.Context()
- context.read()
+ context.Read()
self.context = context
def getPlugins(self):
@@ -88,7 +88,7 @@ class Context(QObject):
@return None
"""
self.emit(Signals.statusMessage, ('Saving Beryl settings....', ))
- self.context.write()
+ self.context.Write()
self.reload()
def reload(self):
@@ -228,6 +228,17 @@ class Setting:
return settingLabelMap.get(value, value)
label = property(label)
+ def getValue(self):
+ try:
+ return self.setting.Value
+ except (IndexError, ):
+ return ''
+
+ def setValue(self, value):
+ self.set(value)
+ Value = property(getValue, setValue)
+
+
fixes = [
(' A ', ' a '),
(' And ', ' and '),
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index bcea158..68e8582 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -3,11 +3,11 @@
""" kberylsettings.contentframe -> defines the right side about/setting views.
"""
-from kdecore import KIcon
+from kdecore import KIcon, i18n
from kdeui import KMessageBox, KPassivePopup, KPushButton, \
KSeparator, KStdGuiItem
from qt import Qt, QFrame, QHBoxLayout, QLabel, QScrollView, QSize, \
- QSizePolicy, QStringList, QVBoxLayout
+ QSizePolicy, QStringList, QToolTip, QVBoxLayout
from kberylsettings.lib import App, Signals, buildPart, icon, iconLoader, iconSet
from kberylsettings.widget import Frame, SmallPushButton, WidgetStack
@@ -90,7 +90,7 @@ class ContentFrame(WidgetStack):
root = self.topLevelWidget()
connect(self, Signals.berylSettingChanged, root.onContextChanged)
connect(self, Signals.statusMessage, root.showMessage)
- connect(self.settingsMain, Signals.somethingChanged,
+ connect(self.settingsMain, Signals.someChange,
self.onSomethingChanged)
def onSomethingChanged(self):
@@ -117,7 +117,11 @@ class ContentFrame(WidgetStack):
self.infoHtml.end()
self.raiseWidget(self.aboutPageId)
-
+ unsavedText = """There are unsaved changes in the active settings.
+
+ Do you want to apply the changes before changing views or discard the changes?
+ """
+
def showSettings(self, plugin, arg):
""" displays the settings page with individual setting frames
@@ -125,7 +129,15 @@ class ContentFrame(WidgetStack):
@param arg setting name or setting section name
@return None
"""
- p = self.parent()
+ if self.applyButton.isEnabled():
+ msg = KMessageBox.warningYesNoCancel
+ res = msg(self, self.unsavedText, i18n('Unsaved Changes'),
+ KStdGuiItem.apply(), KStdGuiItem.discard())
+ if res == KMessageBox.Cancel:
+ return
+ elif res == KMessageBox.Yes:
+ self.settingApply()
+ #else it's no/discard so fall thru
ico = plugin.icon(KIcon.SizeLarge, self.loader)
self.pluginIconLabel.setPixmap(ico)
if arg in plugin.settings:
@@ -146,13 +158,27 @@ class ContentFrame(WidgetStack):
"""
def settingDefaults(self):
- """ not implemented
+ """ set each setting to its default value
+ @return None
"""
+ frame = self.settingsPage
+ widgets = frame.queryList('SettingFrame')
+ for widget in widgets:
+ try:
+ widget.setDefault()
+ except (Exception, ), exc:
+ print 'reset exception:', exc
+ self.applyButton.setEnabled(True)
+ self.resetButton.setEnabled(True)
def settingsReset(self):
+ """ set each setting to its previous value
+
+ @return None
+ """
frame = self.settingsPage
- widgets = frame.queryList('SettingWidgetBase')
+ widgets = frame.queryList('SettingWidget')
for widget in widgets:
try:
widget.reset()
@@ -166,7 +192,7 @@ class ContentFrame(WidgetStack):
"""
excs = []
- for w in self.settingsPage.queryList('SettingWidgetBase'):
+ for w in self.settingsPage.queryList('SettingWidget'):
try:
v = w.value()
w.setting.set(v)
@@ -195,7 +221,7 @@ class SettingsContainer(QFrame):
def addSettings(self, plugin, settings):
self.clearFrames()
layout = self.layout()
- changed = Signals.somethingChanged
+ changed = Signals.someChange
for setting in settings:
frame = SettingFrame(self, plugin, setting)
self.settingFrames.append(frame)
@@ -225,7 +251,9 @@ class SettingFrame(QFrame):
self.infoCaption = setting.ShortDesc
self.infoText = setting.LongDesc
self.infoButton = info = SmallPushButton(iconSet('help'), '', self)
- self.resetButton = reset = SmallPushButton(iconSet('reload'), '', self)
+ self.resetButton = reset = \
+ SmallPushButton(iconSet('locationbar_erase'), '', self)
+ QToolTip.add(reset, i18n('Reset to default value'))
self.settingWidget = widget = settingWidget(self, plugin, setting)
if isinstance(widget.layout(), QHBoxLayout):
align = Qt.AlignLeft | Qt.AlignVCenter
@@ -238,8 +266,16 @@ class SettingFrame(QFrame):
connect = self.connect
connect(info, Signals.clicked, self.showInfo)
- connect(widget, Signals.somethingChanged,
- self, Signals.somethingChanged)
+ connect(reset, Signals.clicked, self.setDefault)
+ connect(widget, Signals.someChange,
+ self, Signals.someChange)
+
+ def setDefault(self):
+ w = self.settingWidget
+ curv = w.value()
+ newv = w.initial = w.setting.ResetToDefault()
+ w.setting.set(curv) # because it's not applied yet
+ w.reset()
def showInfo(self):
""" show a balloon tip with the setting description
@@ -266,5 +302,5 @@ class ContentScroll(QScrollView):
def __init__(self, parent, child):
QScrollView.__init__(self, parent)
self.setResizePolicy(QScrollView.AutoOneFit)
- self.setFrameShape(self.Box)
+ self.setFrameShape(self.NoFrame)
self.addChild(child)
diff --git a/kberylsettings/lib.py b/kberylsettings/lib.py
index 16096a8..2eebdd3 100644
--- a/kberylsettings/lib.py
+++ b/kberylsettings/lib.py
@@ -40,8 +40,9 @@ class Signals:
pluginAbout = PYSIGNAL('pluginAbout')
showSettings = PYSIGNAL('showSettings')
statusMessage = PYSIGNAL('statusMessage')
- somethingChanged = PYSIGNAL('somethingChanged')
+ someChange = PYSIGNAL('someChange')
clicked = SIGNAL('clicked()')
+ clickedId = SIGNAL('clicked(int)')
changed = SIGNAL('changed()')
itemClicked = SIGNAL('clicked(QListViewItem *)')
itemSelected = SIGNAL('selectionChanged(QListViewItem *)')
diff --git a/kberylsettings/main.py b/kberylsettings/main.py
index 3a301fc..98a3031 100644
--- a/kberylsettings/main.py
+++ b/kberylsettings/main.py
@@ -3,6 +3,8 @@
""" kberylsettings.main -> defines KBerylSettings main window.
"""
+from os import listdir
+from os.path import expanduser
from sys import argv
from kdecore import KApplication, KCmdLineArgs, KIcon, KGlobal, KWin, i18n
@@ -74,15 +76,22 @@ class KBerylSettings(KMainWindow):
"""
self.quitFlag = False
self.sysTray = KSystemTray(self)
- pixmap = icon(self.iconFile(), size=KIcon.SizeSmallMedium)
+ pixmap = icon(self.iconFile, size=KIcon.SizeSmallMedium)
self.sysTray.setPixmap(pixmap)
pop = self.sysTray.contextMenu()
- pop.changeTitle(pop.idAt(0), pixmap,
- KApplication.kApplication().caption())
+ self.pluginsAction.plug(pop)
+ cap = KApplication.kApplication().caption()
+ pop.changeTitle(pop.idAt(0), pixmap, cap)
+ pop.insertItem(i18n('Named &Profiles'), self.profileMenu())
self.sysTray.show()
def iconFile(self):
+ """ names the default icon file
+
+ @return icon filename
+ """
return App.basedir + '/pixmaps/kberylsettings.svg'
+ iconFile = property(iconFile)
def buildConnections(self):
""" builds the connections for this instance
@@ -93,8 +102,10 @@ class KBerylSettings(KMainWindow):
connect(self, Signals.viewModeChanged, self.onMode)
connect(self, Signals.iconSizeChanged, self.onIconSize)
connect(self, Signals.pluginAbout, self.contentFrame.showAbout)
- connect(self.pluginList, Signals.showSettings, self.contentFrame.showSettings)
- connect(self.inputSearch, Signals.textChanged, self.pluginList.showSearch)
+ connect(self.pluginList, Signals.showSettings,
+ self.contentFrame.showSettings)
+ connect(self.inputSearch, Signals.textChanged,
+ self.pluginList.showSearch)
connect(self.clearSearch, Signals.clicked, self.onClearSearch)
statusBar = self.statusBar()
connect(self.sysTray, Signals.quitSelected, self.onQuitSelected)
@@ -114,10 +125,10 @@ class KBerylSettings(KMainWindow):
self.emit(Signals.berylContextChanged, (context, ))
connect = self.connect
connect(context, Signals.statusMessage, self.showMessage)
- self.setIcon(icon(self.iconFile(), size=KIcon.SizeSmall))
+ self.setIcon(icon(self.iconFile, size=KIcon.SizeSmall))
KWin.setIcons(self.winId(),
- icon(self.iconFile(), size=KIcon.SizeLarge),
- icon(self.iconFile(), size=KIcon.SizeSmall))
+ icon(self.iconFile, size=KIcon.SizeLarge),
+ icon(self.iconFile, size=KIcon.SizeSmall))
config = self.config('mainwindow')
self.restoreWindowSize(config)
self.mainSplitter.setSizes([self.width()*0.25, self.width()*0.75])
@@ -157,9 +168,23 @@ class KBerylSettings(KMainWindow):
'Export settings to a file.',
pop)
pop.insertSeparator()
+ pop.insertItem(i18n('Named &Profiles'), self.profileMenu())
self.quitAction = stdAction('quit', self.close, actions, '', pop)
return pop
+ def profileMenu(self):
+ """ creates a new Named Profiles menu
+
+ """
+ pop = Popup(self)
+ names = [n for n in listdir(expanduser('~/.beryl'))
+ if n.endswith('.Profile')]
+ names.sort()
+ for name in names:
+ pop.insertItem(name)
+ return pop
+
+
def viewMenu(self):
""" creates a new View menu
diff --git a/kberylsettings/plugindialog.py b/kberylsettings/plugindialog.py
index ddd150d..eec70c0 100644
--- a/kberylsettings/plugindialog.py
+++ b/kberylsettings/plugindialog.py
@@ -5,7 +5,7 @@
Tried to use KActionSelector instead of KListView, but it didn't make
much sense.
"""
-from kdecore import i18n
+from kdecore import KIcon, i18n
from kdeui import KDialogBase, KListView, KMessageBox
from qt import QCheckListItem, QLabel
@@ -35,7 +35,7 @@ class PluginList(KListView):
item = QCheckListItem(self, p.ShortDesc, QCheckListItem.CheckBox)
item.setEnabled(not p.isGeneral)
item.setText(1, p.LongDesc)
- item.setPixmap(0, p.icon(16, loader))
+ item.setPixmap(0, p.icon(KIcon.SizeSmall, loader))
if p.Name in active:
stateMap[p.Name] = 1
item.setState(QCheckListItem.On)
diff --git a/kberylsettings/pluginframe.py b/kberylsettings/pluginframe.py
index 5eacb2c..be043dd 100644
--- a/kberylsettings/pluginframe.py
+++ b/kberylsettings/pluginframe.py
@@ -7,7 +7,7 @@ and search view.
from re import sub
from qt import QLabel, QListViewItem
-from kdecore import i18n
+from kdecore import KIcon, i18n
from kberylsettings.beryl import Setting
from kberylsettings.lib import Signals, icon, iconLoader
@@ -136,7 +136,7 @@ class SearchView(Frame):
if item is None:
value = (plugin, None)
item = cache[plugin] = ValueListViewItem(parent, desc, value)
- item.setPixmap(0, plugin.icon(16, self.loader))
+ item.setPixmap(0, plugin.icon(KIcon.SizeSmall, self.loader))
if setting:
desc = setting.ShortDesc
sub = cache.get((plugin, setting))
diff --git a/kberylsettings/settingwidget.py b/kberylsettings/settingwidget.py
index fc3507d..1aaf54c 100644
--- a/kberylsettings/settingwidget.py
+++ b/kberylsettings/settingwidget.py
@@ -11,12 +11,12 @@ from kdeui import KIntNumInput, KDoubleNumInput, KComboBox, KLineEdit, \
KColorButton, KEditListBox, KPushButton
from kfile import KURLRequester, KURLComboBox, KURLComboRequester
from qt import QCheckBox, QFrame, QLabel, QObject, QWidget, QHBoxLayout, \
- QVBoxLayout, QGridLayout, QColor, qRgba, Qt, QGroupBox, QCheckListItem, \
- QSizePolicy, QSpacerItem
+ QVBoxLayout, QGridLayout, QColor, qRgba, Qt, QCheckListItem, \
+ QSizePolicy, QSpacerItem, QHButtonGroup, QRadioButton
from sip import wrappertype
from kberylsettings.lib import Signals
-from kberylsettings.widget import ShortListView
+from kberylsettings.widget import GroupBox, ShortListView
def settingWidget(parent, plugin, setting):
@@ -36,7 +36,7 @@ def settingWidget(parent, plugin, setting):
class SettingWidgetDetector(wrappertype):
- """ Small metaclass to gather subclasses of SettingWidgetBase as
+ """ Small metaclass to gather subclasses of SettingWidget as
they're created.
"""
@@ -45,19 +45,23 @@ class SettingWidgetDetector(wrappertype):
def __init__(cls, name, bases, ns):
super(SettingWidgetDetector, cls).__init__(name, bases, ns)
types = SettingWidgetDetector.types
- if name != 'SettingWidgetBase' and cls not in types:
+ if name != 'SettingWidget' and cls not in types:
types.append(cls)
-class SettingWidgetBase(QFrame):
+class SettingWidget(QFrame):
""" Base class for setting widgets.
Subclasses must define a 'build' method to construct their
widgets. This method must return a tuple of:
- (primary widget, widget change signal, value method, reset method)
+ (primary widget, change signal, value method, reset method)
- The last two items may be None.
+ If both the primary widget and the change signal are not None,
+ they're used to relay the 'something changed' signal. In this
+ manner, subclass build methods can indicate which widget/signal
+ combination should indicate that the setting is changed and may be
+ applied.
Setting Widget classes inherit this class to participate in
automatic discovery. They also recieve a default implementation
@@ -69,19 +73,16 @@ class SettingWidgetBase(QFrame):
QFrame.__init__(self, parent)
self.plugin = plugin
self.setting = setting
- try:
- self.initial = setting.Value
- except (IndexError, ):
- self.initial = ''
+ self.initial = setting.Value
self.primaryWidget, self.changeSignal, self.value, self.reset = \
self.build(parent, plugin, setting)
try:
self.reset()
except (ValueError, ):
pass
- if self.changeSignal:
+ if self.changeSignal and self.primaryWidget:
self.connect(self.primaryWidget, self.changeSignal,
- self, Signals.somethingChanged)
+ self, Signals.someChange)
def labeledLayout(self, setting, stretch=1, layoutType=QVBoxLayout):
""" create a layout object and a label for the setting
@@ -143,11 +144,11 @@ class SettingWidgetBase(QFrame):
## it only sets the current item.
self.combo.setCurrentItem(self.setting.Value)
- def inputValue(self):
- return self.input.value()
+ def numInputValue(self):
+ return self.numInput.value()
- def inputReset(self):
- self.input.setValue(self.initial)
+ def numInputReset(self):
+ self.numInput.setValue(self.initial)
def lineText(self):
return str(self.line.text())
@@ -173,6 +174,21 @@ class SettingWidgetBase(QFrame):
for value in self.initial:
self.listEditor.insertItem(value)
+ def radioGroupValue(self):
+ radioId = self.radioGroup.selectedId()
+ return self.setting.Restrictions[radioId]
+
+ def radioGroupReset(self):
+ group = self.radioGroup
+ initial = self.initial
+ restrictions = self.setting.Restrictions
+ for idx, value in enumerate(restrictions):
+ button = group.find(idx)
+ if not button:
+ button = QRadioButton(value, group)
+ group.insert(button, idx)
+ group.setButton(restrictions.index(value))
+
def requesterValue(self):
return str(self.requester.url())
@@ -184,7 +200,7 @@ class SettingWidgetBase(QFrame):
return str(widget.text()).replace('&', '')
-class NamedSettingWidget(SettingWidgetBase):
+class SpecificNames(SettingWidget):
""" Setting widget for specific named settings.
Method names are in the form 'pluginname_settingname'.
@@ -230,13 +246,14 @@ class NamedSettingWidget(SettingWidgetBase):
self.comboIndex, self.comboIndexReset)
-class MatchNamedSettingWidget(SettingWidgetBase):
+class MatchNames(SettingWidget):
""" Setting widget for settings with matching names.
"""
lookups = (
#((plugin name re, setting name re), method name)
(('.*', '.*_file'), 'fileSelector'),
+ (('annotate', 'tool'), 'fileSelector'),
(('.*', 'skydome_image'), 'fileSelector'),
(('.*', 'default_icon'), 'fileSelector'),
(('.*', '(.*_)?window_types'), 'wmTypeSelector'),
@@ -284,18 +301,18 @@ class MatchNamedSettingWidget(SettingWidgetBase):
self.listEditorValue, self.listEditorReset)
def wmTypeSelector(self, parent, plugin, setting):
- self.group = LocalGroupBox(3, Qt.Horizontal, setting.ShortDesc, self)
+ self.group = GroupBox(3, Qt.Horizontal, setting.ShortDesc, self)
for text in setting.Restrictions:
checkBox = QCheckBox(text, self.group)
self.connect(checkBox, Signals.clicked,
- self, Signals.somethingChanged)
+ self, Signals.someChange)
layout = QVBoxLayout(self)
layout.addWidget(self.group, 2)
## return signal None because we've already connected the checkboxes
return (self.group, None, self.checkBoxesValue, self.checkBoxesReset)
-class BoolSettingWidget(SettingWidgetBase):
+class Choice(SettingWidget):
""" Setting widget for true/false values.
"""
@@ -318,9 +335,7 @@ class BoolSettingWidget(SettingWidgetBase):
self.checkBoxValue, self.checkBoxReset)
-## TODO: add slider for opacity
-## TODO: add reset and value functions
-class ColorSettingWidget(SettingWidgetBase):
+class Color(SettingWidget):
""" Setting widget for colors.
"""
@@ -334,15 +349,52 @@ class ColorSettingWidget(SettingWidgetBase):
@param setting berylsettings Setting instance
@return four-item tuple of (widget, signal, valuemethod, resetmethod)
"""
- self.color = QColor(qRgba(*[a/256 for a in setting.Value]))
- self.colorButton = KColorButton(self)
- self.colorButton.setColor(self.color)
- layout = self.labeledLayout(setting, 100, QHBoxLayout)
- layout.addWidget(self.colorButton)
- return (self.colorButton, Signals.colorChanged, None, None)
-
-
-class NumericSettingWidget(SettingWidgetBase):
+ group = GroupBox(1, Qt.Vertical, setting.ShortDesc, self)
+ layout = QVBoxLayout(self)
+ layout.addWidget(group)
+
+ frame = QFrame(group)
+ self.colorLabel = colorLabel = QLabel(i18n('Select Color:'), frame)
+ self.colorButton = colorButton = KColorButton(frame)
+ self.opacityInput = opacityInput = KIntNumInput(frame)
+
+ opacityInput.setRange(0, 255)
+ opacityInput.setSteps(1, 10)
+ opacityInput.setLabel(i18n('Select Opacity:'),
+ Qt.AlignVCenter|Qt.AlignLeft)
+ opacityInput.setSpecialValueText(i18n('Clear'))
+
+ layout = QHBoxLayout(frame)
+ layout.addWidget(colorLabel, 2)
+ layout.addWidget(colorButton, 1)
+ layout.addStretch(2)
+ layout.addWidget(opacityInput, 10)
+
+ self.connect(colorButton, Signals.colorChanged,
+ self, Signals.someChange)
+ self.connect(colorButton, Signals.colorChanged,
+ self.updateColor)
+ self.connect(opacityInput, Signals.intValueChanged,
+ self, Signals.someChange)
+ return (colorButton, None, self.colorValue, self.colorReset)
+
+ def updateColor(self, color):
+ self.color = color
+
+ def colorValue(self):
+ c = self.color
+ rgba = (c.red(), c.green(), c.blue(), self.opacityInput.value())
+ return tuple([v*256 for v in rgba])
+
+ def colorReset(self):
+ self.color = color = QColor()
+ color.setRgb(*[a/256 for a in self.setting.Value[0:3]])
+ self.colorButton.setColor(color)
+ v = (self.setting.Value[3] / 256)
+ self.opacityInput.setValue(v)
+
+
+class Number(SettingWidget):
""" Setting widget for numeric ranges. Integers and floats supported.
"""
@@ -364,20 +416,44 @@ class NumericSettingWidget(SettingWidgetBase):
@param setting berylsettings Setting instance
@return four-item tuple of (widget, signal, valuemethod, resetmethod)
"""
- self.input = self.queryTypes[setting.Type](self)
+ self.numInput = self.queryTypes[setting.Type](self)
try:
minvalue, maxvalue, stepvalue = setting.Restrictions
except (ValueError, ):
minvalue, maxvalue = setting.Restrictions
stepvalue = 1
- self.input.setRange(minvalue, maxvalue, stepvalue, True)
+ self.numInput.setRange(minvalue, maxvalue, stepvalue, True)
layout = self.labeledLayout(setting, layoutType=QHBoxLayout)
- layout.addWidget(self.input, 2)
- return (self.input, self.changeSignals[setting.Type],
- self.inputValue, self.inputReset)
+ layout.addWidget(self.numInput, 2)
+ return (self.numInput, self.changeSignals[setting.Type],
+ self.numInputValue, self.numInputReset)
+
+
+class FewChoices(SettingWidget):
+ queryTypes = ('String', )
+
+ def query(cls, plugin, setting):
+ if setting.Type in cls.queryTypes and setting.Restrictions:
+ return len(setting.Restrictions) < 5
+ query = classmethod(query)
+
+ def build(self, parent, plugin, setting):
+ """ create widget(s) for setting display and edit
+ @param parent parent object of this widget
+ @param plugin berylsettings Plugin instance
+ @param setting berylsettings Setting instance
+ @return four-item tuple of (widget, signal, valuemethod, resetmethod)
+ """
+ self.radioGroup = QHButtonGroup(setting.ShortDesc, self)
+ layout = QHBoxLayout(self)
+ layout.addWidget(self.radioGroup, 1)
+ layout.addStretch(2)
+ return (self.radioGroup, Signals.clickedId,
+ self.radioGroupValue, self.radioGroupReset)
-class StringSettingWidget(SettingWidgetBase):
+
+class String(SettingWidget):
""" Setting widget for strings.
"""
@@ -404,7 +480,7 @@ class StringSettingWidget(SettingWidgetBase):
return res
-class StringListSettingWidget(SettingWidgetBase):
+class StringList(SettingWidget):
""" Setting widget for lists of strings.
"""
@@ -418,6 +494,8 @@ class StringListSettingWidget(SettingWidgetBase):
@param setting berylsettings Setting instance
@return four-item tuple of (widget, signal, valuemethod, resetmethod)
"""
+ if plugin.Name == '_' and setting.Name == 'active_plugins':
+ self.setEnabled(False)
self.listEditor = KEditListBox(setting.ShortDesc, self)
layout = QVBoxLayout(self)
layout.addWidget(self.listEditor, 2)
@@ -425,7 +503,7 @@ class StringListSettingWidget(SettingWidgetBase):
self.listEditorValue, self.listEditorReset)
-class BindingSettingWidget(SettingWidgetBase):
+class Binding(SettingWidget):
""" Setting widget for keyboard/pointer/edge bindings.
restrictions example:
@@ -514,19 +592,14 @@ class BindingSettingWidget(SettingWidgetBase):
def reset(index):
enabled = value[index] != 'Disabled'
control = self.controls[index]
-
def valuenomod():
return value[index].split('>')[-1]
-
try:
control.keyLine.setText(enabled and valuenomod() or '')
- except (AttributeError, ):
- pass
-
+ except (AttributeError, ): pass
try:
buttonList = control.buttonList
- except (AttributeError, ):
- pass
+ except (AttributeError, ): pass
else:
buttonList.clear()
for text in self.pointerButtons:
@@ -537,29 +610,22 @@ class BindingSettingWidget(SettingWidgetBase):
buttonList.setCurrentItem(int(buttonNo) - 1)
except (Exception, ), exc:
pass
-
def resetView(v, s):
v.clear()
for t in s[::-1]:
i = QCheckListItem(v, t, QCheckListItem.CheckBox)
i.setState(t in value[index] and i.On or i.Off)
-
try:
resetView(control.modifierList, self.modifiers)
- except (AttributeError, ):
- pass
-
+ except (AttributeError, ): pass
try:
resetView(control.edgeList, self.edges)
- except (AttributeError, ):
- pass
-
+ except (AttributeError, ): pass
try:
checkBox = control.enableCheck
checkBox.setChecked(enabled)
checkBox.emit(Signals.toggled, (enabled,))
- except (AttributeError, ):
- pass
+ except (AttributeError, ): pass
## use the closure
restrictions = self.setting.Restrictions
@@ -571,7 +637,7 @@ class BindingSettingWidget(SettingWidgetBase):
connect = self.connect
ctl = self.control()
toggled = Signals.toggled
- someChange = Signals.somethingChanged
+ someChange = Signals.someChange
ctl.headerLayout = headerLayout = QVBoxLayout()
ctl.enableCheck = enableCheck = QCheckBox(i18n('Enable'), self)
@@ -607,7 +673,7 @@ class BindingSettingWidget(SettingWidgetBase):
ctl = self.control()
ctl.typeLabel = QLabel(text, self)
ctl.edgeList = edgeList = ShortListView(self, i18n('Edges'), 5)
- connect(edgeList, Signals.itemSelected, self, Signals.somethingChanged)
+ connect(edgeList, Signals.itemSelected, self, Signals.someChange)
return ctl
class control(object):
@@ -623,7 +689,7 @@ class BindingSettingWidget(SettingWidgetBase):
return QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)
-class UnknownSettingWidget(SettingWidgetBase):
+class Unknown(SettingWidget):
""" Setting widget for unknown values.
Because this class is defined last, it's caught by the metaclass
@@ -655,15 +721,3 @@ class UnknownSettingWidget(SettingWidgetBase):
"""
return True
query = classmethod(query)
-
-
-class LocalGroupBox(QGroupBox):
- def __init__(self, strips, orient, text, parent, margin=0, spacing=0):
- QGroupBox.__init__(self, strips, orient, text, parent)
- self.setFlat(True)
- self.setInsideMargin(margin)
- self.setInsideSpacing(spacing)
-
- def addSpaces(self, count, size=0):
- for i in range(count):
- self.addSpace(size)
diff --git a/kberylsettings/widget.py b/kberylsettings/widget.py
index f86a73a..2f9e6ca 100644
--- a/kberylsettings/widget.py
+++ b/kberylsettings/widget.py
@@ -3,8 +3,8 @@
""" kberylsettings.widget -> various common widgets.
"""
-from qt import Qt, QFrame, QListViewItem, QListViewItemIterator, QSizePolicy, \
- QSplitter, QVBoxLayout, QWidgetStack
+from qt import Qt, QFrame, QGroupBox, QListViewItem, QListViewItemIterator, \
+ QSizePolicy, QSplitter, QVBoxLayout, QWidgetStack
from kdeui import KListView, KPopupMenu, KPushButton
@@ -97,3 +97,15 @@ class WidgetStack(QWidgetStack):
QWidgetStack.__init__(self, parent)
layout = QVBoxLayout(self)
layout.setAutoAdd(True)
+
+
+class GroupBox(QGroupBox):
+ def __init__(self, strips, orient, text, parent, margin=0, spacing=0):
+ QGroupBox.__init__(self, strips, orient, text, parent)
+ self.setFlat(True)
+ self.setInsideMargin(margin)
+ self.setInsideSpacing(spacing)
+
+ def addSpaces(self, count, size=0):
+ for i in range(count):
+ self.addSpace(size)