Update only last check date when needed

This commit is contained in:
Gres 2020-03-18 20:24:11 +03:00
parent b81bdc69eb
commit 8b84fef929
3 changed files with 19 additions and 6 deletions

View File

@ -62,12 +62,8 @@ Manager::Manager()
Manager::~Manager() Manager::~Manager()
{ {
if (updateAutoChecker_ && updateAutoChecker_->isLastCheckDateChanged()) { if (updateAutoChecker_ && updateAutoChecker_->isLastCheckDateChanged())
Settings settings; Settings::saveLastUpdateCheck(updateAutoChecker_->lastCheckDate());
settings.load();
settings.lastUpdateCheck = updateAutoChecker_->lastCheckDate();
settings.save();
}
} }
void Manager::updateSettings(const Settings &settings) void Manager::updateSettings(const Settings &settings)

View File

@ -254,6 +254,21 @@ void Settings::load()
settings.endGroup(); settings.endGroup();
} }
void Settings::saveLastUpdateCheck(const QDateTime& dt)
{
std::unique_ptr<QSettings> ptr;
if (QFile::exists(iniFileName)) {
ptr = std::make_unique<QSettings>(iniFileName, QSettings::IniFormat);
} else {
ptr = std::make_unique<QSettings>();
}
auto& settings = *ptr;
settings.beginGroup(qs_guiGroup);
settings.setValue(qs_lastUpdateCheck, dt);
settings.endGroup();
}
bool Settings::isPortable() const bool Settings::isPortable() const
{ {
return isPortable_; return isPortable_;

View File

@ -23,6 +23,8 @@ public:
void save() const; void save() const;
void load(); void load();
static void saveLastUpdateCheck(const QDateTime& dt);
bool isPortable() const; bool isPortable() const;
void setPortable(bool isPortable); void setPortable(bool isPortable);