Warn if version might be outdated
This commit is contained in:
parent
ee899c1b23
commit
56bacbfc7e
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -49,6 +50,8 @@ Manager::Manager()
|
|||||||
if (settings_->showMessageOnStart)
|
if (settings_->showMessageOnStart)
|
||||||
tray_->showInformation(QObject::tr("Screen translator started"));
|
tray_->showInformation(QObject::tr("Screen translator started"));
|
||||||
|
|
||||||
|
warnIfOutdated();
|
||||||
|
|
||||||
QObject::connect(updater_.get(), &update::Loader::error, //
|
QObject::connect(updater_.get(), &update::Loader::error, //
|
||||||
tray_.get(), &TrayIcon::showError);
|
tray_.get(), &TrayIcon::showError);
|
||||||
QObject::connect(updater_.get(), &update::Loader::updated, //
|
QObject::connect(updater_.get(), &update::Loader::updated, //
|
||||||
@ -71,6 +74,22 @@ Manager::~Manager()
|
|||||||
setupTrace(false);
|
setupTrace(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Manager::warnIfOutdated()
|
||||||
|
{
|
||||||
|
const auto now = QDateTime::currentDateTime();
|
||||||
|
const auto binaryInfo = QFileInfo(QApplication::applicationFilePath());
|
||||||
|
const auto date = binaryInfo.fileTime(QFile::FileTime::FileBirthTime);
|
||||||
|
const auto deadlineDays = 90;
|
||||||
|
if (date.daysTo(now) < deadlineDays)
|
||||||
|
return;
|
||||||
|
const auto updateDate = settings_->lastUpdateCheck;
|
||||||
|
if (updateDate.isValid() && updateDate.daysTo(now) < deadlineDays)
|
||||||
|
return;
|
||||||
|
tray_->showInformation(
|
||||||
|
QObject::tr("Current version might be outdated.\n"
|
||||||
|
"Check for updates to silence this warning"));
|
||||||
|
}
|
||||||
|
|
||||||
void Manager::updateSettings()
|
void Manager::updateSettings()
|
||||||
{
|
{
|
||||||
LTRACE() << "updateSettings";
|
LTRACE() << "updateSettings";
|
||||||
|
@ -33,6 +33,7 @@ private:
|
|||||||
void setupUpdates(const Settings &settings);
|
void setupUpdates(const Settings &settings);
|
||||||
void setupTrace(bool isOn);
|
void setupTrace(bool isOn);
|
||||||
void finishTask(const TaskPtr &task);
|
void finishTask(const TaskPtr &task);
|
||||||
|
void warnIfOutdated();
|
||||||
|
|
||||||
std::unique_ptr<Settings> settings_;
|
std::unique_ptr<Settings> settings_;
|
||||||
std::unique_ptr<TrayIcon> tray_;
|
std::unique_ptr<TrayIcon> tray_;
|
||||||
|
Loading…
Reference in New Issue
Block a user