Add current value to completions for settings
This commit is contained in:
parent
062b7b177b
commit
93c6d8ea2f
1
TODO
1
TODO
@ -42,7 +42,6 @@ New big features
|
||||
Improvements / minor features
|
||||
=============================
|
||||
|
||||
- Add current value as completion item for settings
|
||||
- Reimplement tabbar to paint it by ourselves to look like dwb
|
||||
- Save cookies in Netscape format so it can be used by wget.
|
||||
http://www.cookiecentral.com/faq/#3.5
|
||||
|
@ -89,6 +89,11 @@ class SettingValueCompletionModel(BaseCompletionModel):
|
||||
|
||||
def __init__(self, section, option=None, parent=None):
|
||||
super().__init__(parent)
|
||||
cur_cat = self.new_category("Current")
|
||||
value = config.get(section, option, raw=True)
|
||||
if not value:
|
||||
value = '""'
|
||||
self.cur_item = self.new_item(cur_cat, value, "Current value")
|
||||
if hasattr(configdata.DATA[section], 'valtype'):
|
||||
# Same type for all values (ValueList)
|
||||
vals = configdata.DATA[section].valtype.complete()
|
||||
@ -99,10 +104,18 @@ class SettingValueCompletionModel(BaseCompletionModel):
|
||||
# Different type for each value (KeyValue)
|
||||
vals = configdata.DATA[section][option].typ.complete()
|
||||
if vals is not None:
|
||||
cat = self.new_category(section)
|
||||
cat = self.new_category("Allowed")
|
||||
for (val, desc) in vals:
|
||||
self.new_item(cat, val, desc)
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def on_config_changed(self, section, option):
|
||||
"""Update current value when config changed."""
|
||||
value = config.get(section, option)
|
||||
if not value:
|
||||
value = '""'
|
||||
self.setData(self.cur_item.index(), value, Qt.DisplayRole)
|
||||
|
||||
|
||||
class CommandCompletionModel(BaseCompletionModel):
|
||||
|
||||
|
@ -80,6 +80,7 @@ class Completer(QObject):
|
||||
for opt in configdata.DATA[sectname].keys():
|
||||
model = SettingValueCompletionModel(sectname, opt, self)
|
||||
self._models['value'][sectname][opt] = CFM(model)
|
||||
config.instance().changed.connect(model.on_config_changed)
|
||||
|
||||
def _get_new_completion(self, parts, cursor_part):
|
||||
"""Get a new completion model.
|
||||
|
Loading…
Reference in New Issue
Block a user