2017-12-18 22:18:24 +01:00
|
|
|
#include "updaterplugin.h"
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
2017-12-19 23:54:58 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QLocale>
|
2017-12-18 22:18:24 +01:00
|
|
|
|
2017-12-18 22:39:10 +01:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "zeiterfassungsettings.h"
|
|
|
|
|
#include "zeiterfassungapi.h"
|
|
|
|
|
|
2018-03-24 14:51:56 +01:00
|
|
|
#include "updatersettings.h"
|
2017-12-18 22:39:10 +01:00
|
|
|
#include "updaterdialog.h"
|
2018-03-24 14:58:59 +01:00
|
|
|
#include "updatersettingswidget.h"
|
2017-12-18 22:39:10 +01:00
|
|
|
|
2017-12-18 22:18:24 +01:00
|
|
|
UpdaterPlugin::UpdaterPlugin(QObject *parent) :
|
|
|
|
|
ZeiterfassungPlugin(parent)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "called";
|
2017-12-19 23:54:58 +01:00
|
|
|
|
|
|
|
|
static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations"));
|
|
|
|
|
|
|
|
|
|
if(m_translator.load(QLocale(), QStringLiteral("updaterplugin"), QStringLiteral("_"), dir))
|
|
|
|
|
{
|
|
|
|
|
if(!QCoreApplication::installTranslator(&m_translator))
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "could not install translation updaterplugin";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "could not load translation updaterplugin";
|
|
|
|
|
}
|
2017-12-18 22:18:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdaterPlugin::attachTo(MainWindow &mainWindow)
|
|
|
|
|
{
|
2018-03-24 14:51:56 +01:00
|
|
|
auto lastUpdateCheck = UpdaterSettings(mainWindow.settings()).lastUpdateCheck();
|
|
|
|
|
if(lastUpdateCheck.isNull() || lastUpdateCheck < QDate::currentDate())
|
2017-12-18 22:39:10 +01:00
|
|
|
new UpdaterDialog(mainWindow);
|
2017-12-18 22:18:24 +01:00
|
|
|
}
|
2018-03-24 14:58:59 +01:00
|
|
|
|
|
|
|
|
SettingsWidget *UpdaterPlugin::settingsWidget(ZeiterfassungSettings &settings, QWidget *parent) const
|
|
|
|
|
{
|
|
|
|
|
return new UpdaterSettingsWidget(settings, parent);
|
|
|
|
|
}
|