Qt: move some more settings to persistent_settings

This commit is contained in:
Megamouse 2020-08-02 16:03:30 +02:00
parent 70fb5712e5
commit 8799eebfe1
15 changed files with 176 additions and 88 deletions

View file

@ -1,4 +1,7 @@
#include "persistent_settings.h"
#include "stdafx.h"
#include "persistent_settings.h"
LOG_CHANNEL(cfg_log, "CFG");
persistent_settings::persistent_settings(QObject* parent) : settings(parent)
{
@ -27,3 +30,25 @@ QString persistent_settings::GetLastPlayed(const QString& serial)
{
return m_last_played[serial];
}
QString persistent_settings::GetCurrentUser(const QString& fallback) const
{
// Load user
QString user = GetValue(gui::persistent::active_user).toString();
if (user.isEmpty())
{
user = fallback;
}
bool is_valid_user;
const u32 user_id = user.toInt(&is_valid_user);
// Set user if valid
if (is_valid_user && user_id > 0)
{
return user;
}
cfg_log.fatal("Could not parse user setting: '%s' = '%d'.", user.toStdString(), user_id);
return QString();
}