//write out
void Frontend::saveConfigToJson(QString file) {
	QVariantMap data;
	int i;

	data["device"] = m_controllers[0].device;

	QVariantList buttons;

	for(i=0;i<16;++i) {
		buttons.append(QVariant(m_controllers[0].buttons[i]));
	}

	data["buttons"] = QVariant(buttons);

	QVariantList gamepad;

	for(i=0;i<16;++i) {
		gamepad.append(QVariant(m_controllers[0].gamepad[i]));
	}

	data["gamepad"] = QVariant(gamepad);

	// Create a JsonDataAccess object and save the data to the file
	JsonDataAccess jda;
	jda.save(QVariant(data), file);
}
Beispiel #2
0
void AccountList::removeAccountAt(int i)
{
	JsonDataAccess jda;
	QVariantList list = jda.load(this->file).value<QVariantList>();
	list.removeAt(i);
	jda.save(QVariant(list), this->file);
	loadAccounts();
}
void HubCache::addItem(QVariantMap itemMap)
{
    _items.append(itemMap);
    _lastItemId++;

    _settings->setValue(_lastItemIdKey, _lastItemId);
    _settings->setValue(_itemsKey, _items);

    JsonDataAccess jda;
    jda.save(_items, "data/hub_items.json");
    jda.deleteLater();
}
Beispiel #4
0
void AccountList::editAccount(int i, QString name, int start, int stop)
{
	JsonDataAccess jda;
	QVariantList list = jda.load(this->file).value<QVariantList>();
	QVariantMap acc;
	acc["name"] = QVariant(name);
	acc["start"] = QVariant(start);
	acc["stop"] = QVariant(stop);
	list.removeAt(i);
	list.insert(i, QVariant(acc));
	jda.save(QVariant(list), this->file);
	loadAccounts();
}
Beispiel #5
0
void AccountList::addAccount(QString name, int start, int stop)
{
	JsonDataAccess jda;
	QVariantList list = jda.load(this->file).value<QVariantList>();
	QVariantMap acc;
	acc["name"] = QVariant(name);
	acc["start"] = QVariant(start);
	acc["stop"] = QVariant(stop);
	list.append(QVariant(acc));

	jda.save(QVariant(list), this->file);
	loadAccounts();
}
Beispiel #6
0
void ApplicationUI::saveState()
{
	qDebug() << "saving state to " << QDir::currentPath() + "/data/levelState.json";
	QVariantMap state;
	state["levelAvailable"] = m_levelAvailable;
	QFile file(QDir::currentPath() + "/data/levelState.json");
	if (file.open(QIODevice::WriteOnly)) {
		qDebug() << "opened file okay";
		JsonDataAccess jda;
		jda.save(state, &file);
		if (jda.hasError()) {
			qDebug("Failed to save: Json error\n");
		} else {
			qDebug("Saved");
		}
	}
}