Commit de6c3619 authored by Kevin Whitaker's avatar Kevin Whitaker

Force model load on start. Make sure loading can handle no data existing.

parent fdf52eda
......@@ -94,12 +94,16 @@ class OPTListModel(QtCore.QAbstractListModel):
self._items = list
def load(self):
jsonDict = json.loads(keyring.get_password(SERVICE,"__config"))
config = keyring.get_password(SERVICE,"__config")
if(config == None):
return
jsonDict = json.loads(config)
size = len(self._items)
self._items = []
for item in jsonDict:
self._items.append(OTPModel(item["name"],item["OTPType"],keyring.get_password(SERVICE,item["name"]),item["icon"],item["timeout"],item["algo"]))
self.dataChanged.emit(self.index(0,0),self.index(size-1,0))
if(jsonDict != None):
for item in jsonDict:
self._items.append(OTPModel(item["name"],item["OTPType"],keyring.get_password(SERVICE,item["name"]),item["icon"],item["timeout"],item["algo"]))
self.dataChanged.emit(self.index(0,0),self.index(size-1,0))
def save(self):
dict=[]
......
......@@ -5,7 +5,7 @@ import OTPListModel
qapp = QApplication()
app = QQmlApplicationEngine()
model = OTPListModel.OPTListModel()
model.load()
app.rootContext().setContextProperty("otpListModel", model)
app.load("qml/main.qml")
qapp.exec_()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment