2020-01-12 22:17:01 +01:00
|
|
|
|
#include "persistent_settings.h"
|
|
|
|
|
|
|
|
|
|
|
|
persistent_settings::persistent_settings(QObject* parent) : settings(parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Don't use the .ini file ending for now, as it will be confused for a regular gui_settings file.
|
2020-03-07 20:58:48 +01:00
|
|
|
|
m_settings.reset(new QSettings(ComputeSettingsDir() + gui::persistent::persistent_file_name + ".dat", QSettings::Format::IniFormat, parent));
|
2020-01-12 22:17:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void persistent_settings::SetPlaytime(const QString& serial, const qint64& elapsed)
|
|
|
|
|
|
{
|
2020-02-03 11:24:36 +01:00
|
|
|
|
m_playtime[serial] = std::max<qint64>(0, elapsed);
|
|
|
|
|
|
SetValue(gui::persistent::playtime, serial, m_playtime[serial]);
|
2020-01-12 22:17:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qint64 persistent_settings::GetPlaytime(const QString& serial)
|
|
|
|
|
|
{
|
2020-02-03 11:24:36 +01:00
|
|
|
|
return std::max<qint64>(0, m_playtime[serial]);
|
2020-01-12 22:17:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void persistent_settings::SetLastPlayed(const QString& serial, const QString& date)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_last_played[serial] = date;
|
|
|
|
|
|
SetValue(gui::persistent::last_played, serial, date);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString persistent_settings::GetLastPlayed(const QString& serial)
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_last_played[serial];
|
|
|
|
|
|
}
|