summaryrefslogtreecommitdiff
path: root/kberylsettings
diff options
context:
space:
mode:
authornatural <natural>2006-12-16 03:19:59 +0000
committernatural <natural>2006-12-16 03:19:59 +0000
commitfcfa23f8e1b16bc68329c9e9aa3cb31d906ee572 (patch)
treee848ae85999e5221acd8d001317807fd35068403 /kberylsettings
parentc32078c7602fd7a32100188aaa6b3fef3115afce (diff)
downloadkberylsettings-fcfa23f8e1b16bc68329c9e9aa3cb31d906ee572.tar.gz
kberylsettings-fcfa23f8e1b16bc68329c9e9aa3cb31d906ee572.tar.bz2
Added LICENCE file.
Removed TODO -- don't really need to see what's on my plate. Added plugindialog.py for selecting plugins. Updated pluginframe.py and main.py to reflect. Tweaked plugin.html -- still needs much work. Added Signals.okClicked and Signals.activated to lib.py.
Diffstat (limited to 'kberylsettings')
-rw-r--r--kberylsettings/html/plugin.html3
-rw-r--r--kberylsettings/lib.py2
-rw-r--r--kberylsettings/main.py44
-rw-r--r--kberylsettings/plugindialog.py81
-rw-r--r--kberylsettings/pluginframe.py9
5 files changed, 129 insertions, 10 deletions
diff --git a/kberylsettings/html/plugin.html b/kberylsettings/html/plugin.html
index 6c05a33..e2f4f9f 100644
--- a/kberylsettings/html/plugin.html
+++ b/kberylsettings/html/plugin.html
@@ -4,7 +4,7 @@
<link rel="stylesheet" href="help:/common/kde-default.css" type="text/css" />
</head>
- <body>
+ <body style="background-color:#5DACE5;">
<div style="background-image: url(help:/common/top-middle.png); width: 100%%; height: 131px;">
<div style="position: absolute; right: 0px;">
<img src="help:/common/top-right-konqueror.png" style="margin: 0px" alt="">
@@ -22,6 +22,7 @@
color: #444">
%(pluginname)s
</div>
+ <div style="position:absolute;top:131px;"><!-- plugin info --></div>
</div>
<div id="footer"><div id="footerL"/><div id="footerR"/></div>
</body>
diff --git a/kberylsettings/lib.py b/kberylsettings/lib.py
index 69843bd..5f2e484 100644
--- a/kberylsettings/lib.py
+++ b/kberylsettings/lib.py
@@ -30,6 +30,8 @@ class Signals:
clicked = SIGNAL('clicked()')
itemClicked = SIGNAL('clicked(QListViewItem *)')
itemSelected = SIGNAL('selectionChanged(QListViewItem *)')
+ okClicked = SIGNAL('okClicked()')
+ activated = SIGNAL('activated()')
contextMenuRequest = \
SIGNAL('contextMenuRequested(QListViewItem*,const QPoint&,int)')
diff --git a/kberylsettings/main.py b/kberylsettings/main.py
index be72de9..1d26493 100644
--- a/kberylsettings/main.py
+++ b/kberylsettings/main.py
@@ -3,7 +3,7 @@
from sys import argv
from os.path import abspath
-from qt import Qt, QFrame, QWidget, QHBoxLayout, QLabel, SLOT, QScrollView, SIGNAL
+from qt import Qt, QFrame, QWidget, QHBoxLayout, QLabel, SLOT, QScrollView
from kdecore import KCmdLineArgs, KApplication, KIconLoader, KWin, i18n, KIcon, KGlobal
from kdeui import KMainWindow, KStdGuiItem, KLineEdit, KPushButton
@@ -11,6 +11,7 @@ from kberylsettings.about import about
from kberylsettings.beryl import Context
from kberylsettings.lib import action, stdAction, Signals, buildPart, minSizePolicy
from kberylsettings.lib import appDebug, appBase, icon
+from kberylsettings.plugindialog import PluginDialog
from kberylsettings.pluginframe import PluginFrame
from kberylsettings.settingframe import SettingFrame
from kberylsettings.widget import Frame, Popup, SmallPushButton, Splitter
@@ -62,16 +63,17 @@ class KBerylSetttings(KMainWindow):
actions.setHighlightingEnabled(True)
## broken!
- connect(actions, SIGNAL('actionStatusText(const QString &)'),
- self.statusBar(), SLOT('message( const QString & )'))
- connect(actions, SIGNAL('clearStatusText()'),
- self.statusBar(), SLOT('clear()'))
+ #connect(actions, SIGNAL('actionStatusText(const QString &)'),
+ # self.statusBar(), SLOT('message( const QString & )'))
+ #connect(actions, SIGNAL('clearStatusText()'),
+ # self.statusBar(), SLOT('clear()'))
def buildMenus(self):
menu = self.menuBar()
menu.insertItem(i18n('&File'), self.fileMenu())
menu.insertItem(i18n('&View'), self.viewMenu())
+ menu.insertItem(i18n('&Settings'), self.settingsMenu())
menu.insertItem(i18n('&Help'), self.helpMenu())
@@ -95,6 +97,32 @@ class KBerylSetttings(KMainWindow):
return pop
+ def settingsMenu(self):
+ pop = Popup(self)
+ self.pluginsAction = action('plugins', 'Select Plugins...', '',
+ 'Select plugins', 'Select plugins',
+ self.actionCollection(), pop)
+ self.connect(self.pluginsAction, Signals.activated, self.selectPlugins)
+ return pop
+
+
+ def selectPlugins(self):
+ self.pluginDialog = PluginDialog(self, self.context)
+ self.connect(self.pluginDialog, Signals.okClicked, self.updatePlugins)
+ self.pluginDialog.exec_loop()
+
+
+ def updatePlugins(self):
+ active = [n for n, on in self.pluginDialog.pluginMap.items() if on]
+ context = self.context
+
+ for p in context.plugins:
+ self.emit(Signals.berylPluginEnabled, (p, p.Name in active))
+
+ context.active = active
+ self.emit(Signals.berylContextChanged, (context, ))
+
+
def modeMenu(self):
pop = self.modePopup = Popup(self)
ids = self.modePopupIds = {}
@@ -162,7 +190,8 @@ class KBerylSetttings(KMainWindow):
def buildFinal(self):
self.context = context = Context()
self.emit(Signals.berylContextChanged, (context, ))
- self.connect(context, Signals.statusMessage, self.showMessage)
+ connect = self.connect
+ connect(context, Signals.statusMessage, self.showMessage)
KWin.setIcons(self.winId(),
icon('configure', size=KIcon.SizeLarge),
icon('configure', size=KIcon.SizeSmall))
@@ -174,6 +203,9 @@ class KBerylSetttings(KMainWindow):
(config.readNumEntry('iconsize', self.iconSize), ))
self.emit(Signals.viewModeChanged,
(config.readNumEntry('viewmode', self.viewMode), ))
+
+ ## done after initial emit to prevent spurious context update
+ connect(self, Signals.berylContextChanged, self.settingsChanged)
self.showAboutPlugin(None)
diff --git a/kberylsettings/plugindialog.py b/kberylsettings/plugindialog.py
new file mode 100644
index 0000000..5c395a2
--- /dev/null
+++ b/kberylsettings/plugindialog.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from qt import QCheckListItem, QLabel
+from kdecore import i18n
+from kdeui import KDialogBase, KListView
+
+from kberylsettings.lib import Signals
+
+
+class PluginList(KListView):
+ """ PluginList -> list view for the select plugins dialog
+
+ """
+ def __init__(self, parent):
+ KListView.__init__(self, parent)
+ self.addColumn(i18n('Plugin'))
+ self.addColumn(i18n('Description'))
+
+ def addPlugins(self, context, loader):
+ """ creates list view items from plugins in context
+
+ @param context berylsetting Context instance
+ @param loader KIconLoader instance
+ @return mapping of plugin names and their enabled state
+ """
+ stateMap = {}
+ active = context.active
+ count = textlen = 0
+ for p in context.plugins:
+ item = QCheckListItem(self, p.ShortDesc, QCheckListItem.CheckBox)
+ item.setEnabled(not p.isGeneral)
+ item.setText(1, p.LongDesc)
+ item.setPixmap(0, p.icon(16, loader))
+ if p.Name in active:
+ stateMap[p.Name] = 1
+ item.setState(QCheckListItem.On)
+ else:
+ stateMap[p.Name] = 0
+ count += 1
+ textlen = max(textlen, len(p.ShortDesc + p.LongDesc))
+
+ self.adjustMinSize(count, textlen)
+ return stateMap
+
+ def adjustMinSize(self, count, maxlen):
+ """ adjusts minimum size based on child count and text length
+
+ @param count number of items
+ @param maxlen maximum length of item text (all columns)
+ @return None
+ """
+ height = count * self.fontMetrics().height()
+ self.setMinimumHeight(height * 0.5)
+ width = maxlen * self.fontMetrics().maxWidth() * 0.25
+ self.setMinimumWidth(width)
+
+
+class PluginDialog(KDialogBase):
+ """ PluginDialog -> a dialog for enabling and disabling plugins
+
+ """
+ def __init__(self, parent, context):
+ KDialogBase.__init__(self, parent, '', True, i18n('Select Plugins'),
+ KDialogBase.Ok|KDialogBase.Cancel)
+ self.context = context
+ main = self.makeVBoxMainWidget()
+ self.label = QLabel('Enable or disable plugins below.', main)
+ self.listView = PluginList(main)
+ self.connect(self.listView, Signals.itemClicked, self.changePlugin)
+ self.pluginMap = self.listView.addPlugins(context, parent.loader)
+
+
+ def changePlugin(self, item):
+ if not item:
+ return
+ state = item.state()
+ plugin = self.context.plugin(item.text(0))
+ if state == item.On:
+ self.pluginMap[plugin.Name] = 1
+ elif state == item.Off:
+ self.pluginMap[plugin.Name] = 0
diff --git a/kberylsettings/pluginframe.py b/kberylsettings/pluginframe.py
index 9ce1264..306a883 100644
--- a/kberylsettings/pluginframe.py
+++ b/kberylsettings/pluginframe.py
@@ -33,6 +33,7 @@ class PluginFrame(QFrame):
connect(view, Signals.pluginAbout, root.showAboutPlugin)
connect(view, Signals.statusMessage, root.showMessage)
connect(root, Signals.berylContextChanged, view.onBerylContext)
+ connect(root, Signals.berylPluginEnabled, view.enablePluginItem)
for receiver in views:
connect(view, Signals.berylPluginEnabled,
receiver.enablePluginItem)
@@ -98,7 +99,8 @@ class PluginView(KListView):
if not item:
item = QListViewItem(self, plugin.ShortDesc)
item.setVisible(True)
- item.setEnabled(plugin.Name in active or plugin.isGeneral)
+ ##item.setEnabled(plugin.Name in active or plugin.isGeneral)
+ item.setVisible(plugin.Name in active)
item.setPixmap(0, plugin.icon(self.iconSize, self.loader))
item.setText(0, plugin.ShortDesc)
return item
@@ -166,8 +168,9 @@ class PluginView(KListView):
"""
for item in self:
if item.text(0) == plugin.ShortDesc:
- item.setOpen(enable)
- item.setEnabled(enable)
+ #item.setOpen(enable)
+ #item.setEnabled(enable)
+ item.setVisible(enable)
class PluginIconView(PluginView):