keyboard_comm: use existing keyboard_id property
parent
f5d6963cce
commit
a45a8f9283
|
|
@ -58,7 +58,6 @@ class Keyboard:
|
||||||
self.encoders = []
|
self.encoders = []
|
||||||
self.macro_count = 0
|
self.macro_count = 0
|
||||||
self.macro_memory = 0
|
self.macro_memory = 0
|
||||||
self.uid = 0
|
|
||||||
self.macro = b""
|
self.macro = b""
|
||||||
self.vibl = False
|
self.vibl = False
|
||||||
|
|
||||||
|
|
@ -72,7 +71,6 @@ class Keyboard:
|
||||||
self.layout = dict()
|
self.layout = dict()
|
||||||
self.encoder_layout = dict()
|
self.encoder_layout = dict()
|
||||||
|
|
||||||
self.uid = struct.unpack(">Q", self.get_uid())[0]
|
|
||||||
self.reload_layout(sideload_json)
|
self.reload_layout(sideload_json)
|
||||||
self.reload_layers()
|
self.reload_layers()
|
||||||
self.reload_keymap()
|
self.reload_keymap()
|
||||||
|
|
@ -249,7 +247,7 @@ class Keyboard:
|
||||||
def save_layout(self):
|
def save_layout(self):
|
||||||
""" Serializes current layout to a binary """
|
""" Serializes current layout to a binary """
|
||||||
|
|
||||||
data = {"version": 1, "uid": self.uid}
|
data = {"version": 1, "uid": self.keyboard_id}
|
||||||
|
|
||||||
layout = []
|
layout = []
|
||||||
for l in range(self.layers):
|
for l in range(self.layers):
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ class KeyboardContainer(QWidget):
|
||||||
return self.keyboard.save_layout()
|
return self.keyboard.save_layout()
|
||||||
|
|
||||||
def restore_layout(self, data):
|
def restore_layout(self, data):
|
||||||
if json.loads(data.decode("utf-8")).get("uid") != self.keyboard.uid:
|
if json.loads(data.decode("utf-8")).get("uid") != self.keyboard.keyboard_id:
|
||||||
ret = QMessageBox.question(self, "", tr("KeyboardContainer", "Saved keymap belongs to a different keyboard,"
|
ret = QMessageBox.question(self, "", tr("KeyboardContainer", "Saved keymap belongs to a different keyboard,"
|
||||||
" are you sure you want to continue?"),
|
" are you sure you want to continue?"),
|
||||||
QMessageBox.Yes | QMessageBox.No)
|
QMessageBox.Yes | QMessageBox.No)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue