summaryrefslogtreecommitdiff
path: root/kberylsettings
diff options
context:
space:
mode:
authornatural <natural>2006-12-29 02:34:37 +0000
committernatural <natural>2006-12-29 02:34:37 +0000
commit3f0d8beae4fe502938aa8b15efa875159ebf3280 (patch)
tree7fc9601e8b05c05d537cae958ed6e9d7ee1fb467 /kberylsettings
parent6353813802ba776b05241f07cb8fee9c90310c40 (diff)
downloadkberylsettings-3f0d8beae4fe502938aa8b15efa875159ebf3280.tar.gz
kberylsettings-3f0d8beae4fe502938aa8b15efa875159ebf3280.tar.bz2
Added support for key-grabbing button to key binding widgets.
Limited search results to active plugins only.
Diffstat (limited to 'kberylsettings')
-rw-r--r--kberylsettings/lib.py6
-rw-r--r--kberylsettings/pluginframe.py6
-rw-r--r--kberylsettings/settingwidget.py66
3 files changed, 56 insertions, 22 deletions
diff --git a/kberylsettings/lib.py b/kberylsettings/lib.py
index a9986ff..d081719 100644
--- a/kberylsettings/lib.py
+++ b/kberylsettings/lib.py
@@ -48,6 +48,8 @@ class Signals:
itemClicked = SIGNAL('clicked(QListViewItem *)')
itemSelected = SIGNAL('selectionChanged(QListViewItem *)')
okClicked = SIGNAL('okClicked()')
+ cancelClicked = SIGNAL('cancelClicked()')
+ finished = SIGNAL('finished()')
activated = SIGNAL('activated()')
activatedIndex = SIGNAL('activated(int)')
textChanged = SIGNAL('textChanged(const QString&)')
@@ -62,7 +64,7 @@ class Signals:
SIGNAL('contextMenuRequested(QListViewItem*,const QPoint&,int)')
searchInput = PYSIGNAL('searchInput')
selectPrevious = PYSIGNAL('selectPrevious')
-
+ capturedShortcut = SIGNAL('capturedShortcut (const KShortcut &)')
class Slots:
""" class with SLOT attributes
@@ -71,7 +73,7 @@ class Slots:
clear = SLOT('clear()')
close = SLOT('close()')
messageText = SLOT('message( const QString & )')
-
+ captureShortcut = SLOT('captureShortcut()')
def iconLoader():
""" returns the global icon loader
diff --git a/kberylsettings/pluginframe.py b/kberylsettings/pluginframe.py
index d7e4e79..3d139be 100644
--- a/kberylsettings/pluginframe.py
+++ b/kberylsettings/pluginframe.py
@@ -80,6 +80,7 @@ class SearchView(Frame):
@param context berylsetting.Context instance
@return None
"""
+ self.context = context
index = self.index
index.clear()
itemKeywords = self.itemKeywords
@@ -116,9 +117,12 @@ class SearchView(Frame):
index = self.index
parent = self.keywordsList
parent.clear()
+ active = self.context.active
for keyword in self.index:
if searchtext in keyword.lower():
- item = ValueListViewItem(parent, keyword, index[keyword])
+ plugin, setting = index[keyword][0]
+ if plugin.Name in active:
+ item = ValueListViewItem(parent, keyword, index[keyword])
def showResults(self, item):
""" displays plugin/setting items from the selected keyword
diff --git a/kberylsettings/settingwidget.py b/kberylsettings/settingwidget.py
index 81297a0..4f671fd 100644
--- a/kberylsettings/settingwidget.py
+++ b/kberylsettings/settingwidget.py
@@ -6,16 +6,16 @@ editing berylsettings.Setting instances.
"""
from re import match
-from kdecore import i18n
-from kdeui import KIntNumInput, KDoubleNumInput, KComboBox, KLineEdit, \
- KColorButton, KEditListBox, KPushButton
+from kdecore import KShortcut, i18n
+from kdeui import KIntNumInput, KDialogBase, KDoubleNumInput, KComboBox, KLineEdit, \
+ KColorButton, KEditListBox, KPushButton, KKeyButton, KShortcutDialog
from kfile import KURLRequester, KURLComboBox, KURLComboRequester
from qt import QCheckBox, QFrame, QLabel, QObject, QWidget, QHBoxLayout, \
QVBoxLayout, QGridLayout, QColor, qRgba, Qt, QCheckListItem, \
- QSizePolicy, QSpacerItem, QHButtonGroup, QRadioButton
+ QSizePolicy, QSpacerItem, QHButtonGroup, QRadioButton, QPushButton
from sip import wrappertype
-from kberylsettings.lib import Signals
+from kberylsettings.lib import Signals, Slots
from kberylsettings.widget import GroupBox, ShortListView
@@ -565,24 +565,20 @@ class Binding(SettingWidget):
layout = QGridLayout(self, 4, 4, 0, 10)
layout.addMultiCellWidget(self.label, 0, 0, 0, 3, Qt.AlignTop|Qt.AlignLeft)
restrictions = setting.Restrictions
-
if restrictions[self.idxBell]:
self.controls[self.idxBell] = control = \
self.bellWidget('Bell')
layout.addMultiCellWidget(control.bellFrame, 1, 1, 0, 3)
-
if restrictions[self.idxKey]:
self.controls[self.idxKey] = control = \
self.bindingWidget('Key', self.idxKey)
layout.addLayout(control.headerLayout, 2, 1)
layout.addWidget(control.modifierList, 3, 1)
-
if restrictions[self.idxPointer]:
self.controls[self.idxPointer] = control = \
self.bindingWidget('Pointer Button', self.idxPointer)
layout.addLayout(control.headerLayout, 2, 2)
layout.addWidget(control.modifierList, 3, 2)
-
if restrictions[self.idxEdge]:
self.controls[self.idxEdge] = control = \
self.edgeBindingWidget('Edge')
@@ -591,10 +587,8 @@ class Binding(SettingWidget):
else:
layout.addItem(self.spacer(), 2, 3)
layout.addItem(self.spacer(), 3, 3)
-
return (None, None, self.bindingValue, self.bindingReset)
-
def bindingValue(self):
"""
@@ -602,7 +596,6 @@ class Binding(SettingWidget):
val = ['Disabled', 'Disabled', False, []]
res = self.setting.Restrictions
idxKey, idxPointer, idxBell, idxEdge = self.idxs
-
if res[idxKey]:
if self.controls[idxKey].enableCheck.isChecked():
key = self.controls[idxKey].keyLine.text()
@@ -610,7 +603,6 @@ class Binding(SettingWidget):
if i.state()==i.On]
mods = str.join('', ['<%s>' % m for m in mods])
val[idxKey] = '%s%s' % (mods, key)
-
if res[idxPointer]:
if self.controls[idxPointer].enableCheck.isChecked():
button = self.controls[idxPointer].buttonList.currentItem()
@@ -618,20 +610,18 @@ class Binding(SettingWidget):
if i.state()==i.On]
mods = str.join('', ['<%s>' % m for m in mods])
val[idxPointer] = '%sButton%s' % (mods, button+1)
-
if res[idxBell]:
val[idxBell] = self.controls[idxBell].bellCheck.isChecked()
-
if res[idxEdge]:
ctl = self.controls[idxEdge].edgeList
edges = val[idxEdge]
edges.extend([str(i.text(0)) for i in ctl if i.state()==i.On])
-
return tuple(val)
-
-
def bindingReset(self):
+ """
+
+ """
value = self.initial
def reset(index):
@@ -703,9 +693,10 @@ class Binding(SettingWidget):
enableCheck.setText(i18n('Enable Key'))
ctl.keyLine = keyLine = KLineEdit(self)
lineLayout.addWidget(keyLine)
- ctl.keyButton = keyButton = KPushButton(i18n('Grab'), self)
+ ctl.keyButton = keyButton = GrabKeyButton(self)
lineLayout.addWidget(keyButton)
connect(keyLine, Signals.textChanged, self, someChange)
+ connect(keyButton, Signals.capturedShortcut, self.grabKey)
connect(enableCheck, toggled, keyLine.setEnabled)
connect(enableCheck, toggled, keyButton.setEnabled)
elif which == self.idxPointer:
@@ -720,6 +711,21 @@ class Binding(SettingWidget):
connect(enableCheck, toggled, ctl.modifierList.setEnabled)
return ctl
+ def grabKey(self, key):
+ skey = str(key.toString())
+ skey = skey.replace('Win', 'Super')
+ skey = skey.replace('Ctl', 'Control')
+ skey = skey.split('+')
+ if len(skey) == 1:
+ skey = skey[0]
+ else:
+ skey = str.join('', ['<%s>' % i for i in skey[:-1]]) + skey[-1]
+ init = list(self.initial)
+ init[self.idxKey] = skey
+ self.initial = tuple(init)
+ self.reset()
+ self.emit(Signals.someChange, ())
+
def edgeBindingWidget(self, text):
connect = self.connect
ctl = self.control()
@@ -781,3 +787,25 @@ class Unknown(SettingWidget):
"""
return cls
query = classmethod(query)
+
+
+class GrabKeyButton(KKeyButton):
+ def __init__(self, parent):
+ KKeyButton.__init__(self, parent)
+ self.setText(i18n('Grab'))
+ self.disconnect(self, Signals.clicked, self, Slots.captureShortcut)
+ self.connect(self, Signals.clicked, self.captureShortcut)
+
+ def drawButton(self, painter):
+ QPushButton.drawButton(self, painter)
+
+ def setText(self, text):
+ QPushButton.setText(self, text)
+ self.setFixedSize(self.sizeHint().width(), self.sizeHint().height())
+
+ def captureShortcut(self):
+ dlg = KShortcutDialog(self.shortcut(), True, self)
+ dlg.showButton(KShortcutDialog.Details, False)
+ res = dlg.exec_loop()
+ if res == KShortcutDialog.Accepted:
+ self.emit(Signals.capturedShortcut, (dlg.shortcut(), ))