started to outline the new save and load methods

This commit is contained in:
sezanzeb 2020-11-17 23:49:11 +01:00 committed by sezanzeb
parent 71de04b626
commit 8e24782a61
2 changed files with 14 additions and 10 deletions

View File

@ -277,8 +277,8 @@ class Window:
try:
# new_preset = create_preset(self.selected_device)
# TODO create a preset file, tell custom_mapping to do so
# or something
# TODO create a preset file, tell custom_mapping to clear itself
# and dump itself into a new file
new_preset = 'new_preset'
self.get('preset_selection').append(new_preset, new_preset)
self.get('preset_selection').set_active_id(new_preset)
@ -339,7 +339,7 @@ class Window:
key_list.remove(single_key_mapping)
def save_config(self):
"""Write changes to disk"""
"""Write changes to disk."""
if self.selected_device is None or self.selected_preset is None:
return
@ -349,7 +349,7 @@ class Window:
self.selected_preset
)
# TODO tell the mapping to dump itself as JSON somewhere
custom_mapping.save(self.selected_device, self.selected_preset)
custom_mapping.changed = False
self.unhighlight_all_rows()

View File

@ -22,6 +22,8 @@
"""Contains and manages mappings."""
import json
from keymapper.logger import logger
@ -96,6 +98,14 @@ class Mapping:
self._mapping = {}
self.changed = True
def load(self, device, preset):
"""Load a dumped JSON from home to overwrite the mappings."""
# TODO
def save(self, device, preset):
"""Dump as JSON into home."""
# TODO
def get_keycode(self, character):
"""Get the keycode for that character."""
# TODO prepare this with .lower() instead to make it faster
@ -118,12 +128,6 @@ class Mapping:
"""
return self._mapping.get(keycode)
def has(self, keycode):
"""Check if this keycode is going to be a line in the symbols file.
TODO no symbols files anymore ^
"""
return self._mapping.get(keycode) is not None
# one mapping object for the whole application that holds all
# customizations