Commit 4a072216 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Integrate PackageKit dist upgrade into the notifier plasmoid

parent 5ac9d0b7
......@@ -129,6 +129,29 @@ uint PackageKitNotifier::updatesCount()
return m_normalUpdates;
}
void PackageKitNotifier::onDistroUpgrade(PackageKit::Transaction::DistroUpgrade type, const QString& name, const QString& description)
{
KNotification *notification = new KNotification(QLatin1String("distupgrade-notification"), KNotification::Persistent | KNotification::DefaultEvent);
notification->setIconName(QStringLiteral("system-software-update"));
notification->setActions(QStringList{QLatin1String("Upgrade")});
notification->setTitle(i18n("Upgrade available"));
switch(type) {
case PackageKit::Transaction::DistroUpgradeUnknown:
case PackageKit::Transaction::DistroUpgradeUnstable:
notification->setText(i18n("New unstable version: %1", description));
break;
case PackageKit::Transaction::DistroUpgradeStable:
notification->setText(i18n("New version: %1", description));
break;
}
connect(notification, &KNotification::action1Activated, this, [name] () {
PackageKit::Daemon::upgradeSystem(name, PackageKit::Transaction::UpgradeKindDefault);
});
notification->sendEvent();
}
void PackageKitNotifier::refreshDatabase()
{
if (!m_refresher) {
......@@ -138,6 +161,15 @@ void PackageKitNotifier::refreshDatabase()
delete m_refresher;
});
}
if (m_distUpgrades) {
m_distUpgrades = PackageKit::Daemon::getDistroUpgrades();
connect(m_distUpgrades, &PackageKit::Transaction::distroUpgrade, this, &PackageKitNotifier::onDistroUpgrade);
connect(m_distUpgrades.data(), &PackageKit::Transaction::finished, this, [this]() {
recheckSystemUpdateNeeded();
delete m_distUpgrades;
});
}
}
QProcess* PackageKitNotifier::checkAptVariable(const QString &aptconfig, const QLatin1String& varname, std::function<void(const QStringRef& val)> func)
......
......@@ -48,6 +48,7 @@ private Q_SLOTS:
void finished(PackageKit::Transaction::Exit exit, uint);
void onRequireRestart(PackageKit::Transaction::Restart type, const QString &packageID);
void transactionListChanged(const QStringList &tids);
void onDistroUpgrade(PackageKit::Transaction::DistroUpgrade type, const QString &name, const QString &description);
private:
QProcess* checkAptVariable(const QString &aptconfig, const QLatin1String& varname, std::function<void(const QStringRef& val)> func);
......@@ -55,6 +56,7 @@ private:
uint m_securityUpdates;
uint m_normalUpdates;
QPointer<PackageKit::Transaction> m_refresher;
QPointer<PackageKit::Transaction> m_distUpgrades;
QHash<QString, PackageKit::Transaction*> m_transactions;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment