show message on no updates

This commit is contained in:
arcan1s
2015-09-07 01:47:50 +03:00
parent d00ab81fe9
commit f5e40d084d
13 changed files with 376 additions and 236 deletions

View File

@ -93,7 +93,7 @@ Item {
onNewData: {
if (debug) console.debug("Update source", sourceName)
// systemmonitorDE.interval = plasmoid.configuration.interval
systemmonitorDE.interval = plasmoid.configuration.interval
awKeys.dataUpdateReceived(sourceName, data, settings)
}
@ -113,7 +113,7 @@ Item {
onNewData: {
if (debug) console.debug("Update source", sourceName)
// extsysmonDE.interval = plasmoid.configuration.interval
extsysmonDE.interval = plasmoid.configuration.interval
awKeys.dataUpdateReceived(sourceName, data, settings)
}
@ -176,7 +176,7 @@ Item {
awKeys.needTextToBeUpdated.connect(needTextUpdate)
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
// check updates if required
if (plasmoid.configuration.checkUpdates) return action_checkUpdates()
if (plasmoid.configuration.checkUpdates) return awActions.checkUpdates(false)
}
onDropSource: {
@ -235,7 +235,7 @@ Item {
function action_checkUpdates() {
if (debug) console.debug()
return awActions.checkUpdates()
return awActions.checkUpdates(true)
}
function action_showReadme() {

View File

@ -52,12 +52,15 @@ AWActions::~AWActions()
}
void AWActions::checkUpdates()
void AWActions::checkUpdates(const bool showAnyway)
{
qCDebug(LOG_AW);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
connect(manager, &QNetworkAccessManager::finished,
[showAnyway, this](QNetworkReply *reply) {
return versionReplyRecieved(reply, showAnyway);
});
manager->get(QNetworkRequest(QUrl(VERSION_API)));
}
@ -94,12 +97,6 @@ void AWActions::runCmd(const QString cmd) const
}
void AWActions::sendEmail() const
{
qCDebug(LOG_AW);
}
void AWActions::showReadme() const
{
qCDebug(LOG_AW);
@ -228,9 +225,21 @@ void AWActions::sendNotification(const QString eventId, const QString message,
}
void AWActions::showUpdates(QString version) const
void AWActions::showInfo(const QString version) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Version" << version;
QString text = i18n("You are using the actual version %1", version);
QMessageBox::information(nullptr, i18n("No new version found"), text);
}
void AWActions::showUpdates(const QString version) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Version" << version;
QString text;
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
@ -247,7 +256,7 @@ void AWActions::showUpdates(QString version) const
}
void AWActions::versionReplyRecieved(QNetworkReply *reply) const
void AWActions::versionReplyRecieved(QNetworkReply *reply, const bool showAnyway) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Return code" << reply->error();
@ -278,4 +287,6 @@ void AWActions::versionReplyRecieved(QNetworkReply *reply) const
((old_major == new_major) && (old_minor < new_minor)) ||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
return showUpdates(version);
else if (showAnyway)
return showInfo(version);
}

View File

@ -33,11 +33,10 @@ public:
explicit AWActions(QObject *parent = nullptr);
virtual ~AWActions();
Q_INVOKABLE void checkUpdates();
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
Q_INVOKABLE bool dropCache() const;
Q_INVOKABLE bool isDebugEnabled() const;
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true")) const;
Q_INVOKABLE void sendEmail() const;
Q_INVOKABLE void showReadme() const;
// configuration slots
Q_INVOKABLE QString getAboutText(const QString type = QString("header")) const;
@ -51,8 +50,9 @@ public slots:
const bool enablePopup = false);
private slots:
void showUpdates(QString version) const;
void versionReplyRecieved(QNetworkReply *reply) const;
void showInfo(const QString version) const;
void showUpdates(const QString version) const;
void versionReplyRecieved(QNetworkReply *reply, const bool showAnyway) const;
private:
};