Commit 52f609be authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Merge branch 'Plasma/5.11'

parents e070b126 bce4f5c6
......@@ -101,6 +101,7 @@ Kirigami.AbstractListItem
elide: Text.ElideRight
text: delegateArea.application.comment
maximumLineCount: 1
textFormat: Text.PlainText
}
QQC2.Label {
......
......@@ -47,6 +47,7 @@ DiscoverPage
currentIndex: -1
ResourcesUpdatesModel {
id: resourcesUpdatesModel
onPassiveMessage: window.showPassiveNotification(message)
onIsProgressingChanged: {
if (!isProgressing) {
resourcesUpdatesModel.prepare()
......
......@@ -493,8 +493,6 @@ void FlatpakBackend::addResource(FlatpakResource *resource)
// This will update also metadata (required runtime)
updateAppSize(installation, resource);
connect(resource, &FlatpakResource::stateChanged, this, &FlatpakBackend::updatesCountChanged);
m_resources.insert(resource->uniqueId(), resource);
}
......@@ -646,13 +644,8 @@ bool FlatpakBackend::loadInstalledApps(FlatpakInstallation *flatpakInstallation)
}
const auto name = QLatin1String(flatpak_ref_get_name(FLATPAK_REF(ref)));
const QString fnDesktop = pathApps + name + QLatin1String(".desktop");
if (!QFileInfo::exists(fnDesktop)) {
continue;
}
AppStream::Metadata metadata;
const QString fnDesktop = pathApps + name + QLatin1String(".desktop");
AppStream::Metadata::MetadataError error = metadata.parseFile(fnDesktop, AppStream::Metadata::FormatKindDesktopEntry);
if (error != AppStream::Metadata::MetadataErrorNoError) {
qWarning() << "Failed to parse appstream metadata: " << error << fnDesktop;
......@@ -860,7 +853,8 @@ void FlatpakBackend::updateAppInstalledMetadata(FlatpakInstalledRef *installedRe
resource->updateFromRef(FLATPAK_REF(installedRef));
resource->setInstalledSize(flatpak_installed_ref_get_installed_size(installedRef));
resource->setOrigin(QString::fromUtf8(flatpak_installed_ref_get_origin(installedRef)));
resource->setState(AbstractResource::Installed);
if (resource->state() < AbstractResource::Installed)
resource->setState(AbstractResource::Installed);
}
bool FlatpakBackend::updateAppMetadata(FlatpakInstallation* flatpakInstallation, FlatpakResource *resource)
......
......@@ -76,6 +76,7 @@ QString KNSResource::comment()
ret=ret.left(newLine);
}
ret = ret.replace(QRegularExpression(QStringLiteral("\\[/?[a-z]*\\]")), QString());
ret = ret.remove(QRegularExpression(QStringLiteral("<[^>]*>")));
}
return ret;
}
......
......@@ -126,7 +126,9 @@ QUrl AppPackageKitResource::homepage()
bool AppPackageKitResource::isTechnical() const
{
return false;
static QString desktop = QString::fromUtf8(qgetenv("XDG_CURRENT_DESKTOP"));
const auto desktops = m_appdata.compulsoryForDesktops();
return !desktops.isEmpty() && !desktops.contains(desktop);
}
void AppPackageKitResource::fetchScreenshots()
......
......@@ -387,13 +387,13 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
PackageKit::Transaction * tArch = PackageKit::Daemon::resolve(filter.search, PackageKit::Transaction::FilterArch);
connect(tArch, &PackageKit::Transaction::package, this, &PackageKitBackend::addPackageArch);
connect(tArch, &PackageKit::Transaction::package, this, [tArch](PackageKit::Transaction::Info /*info*/, const QString &packageId){
tArch->setProperty("packageId", packageId);
connect(tArch, &PackageKit::Transaction::package, stream, [stream](PackageKit::Transaction::Info /*info*/, const QString &packageId){
stream->setProperty("packageId", packageId);
});
connect(tArch, &PackageKit::Transaction::finished, stream, [stream, tArch, ids, this](PackageKit::Transaction::Exit status) {
connect(tArch, &PackageKit::Transaction::finished, stream, [stream, ids, this](PackageKit::Transaction::Exit status) {
getPackagesFinished();
if (status == PackageKit::Transaction::Exit::ExitSuccess) {
const auto packageId = tArch->property("packageId");
const auto packageId = stream->property("packageId");
if (!packageId.isNull()) {
const auto res = resourcesByPackageNames<QVector<AbstractResource*>>({PackageKit::Daemon::packageName(packageId.toString())});
stream->resourcesFound(kFilter<QVector<AbstractResource*>>(res, [ids](AbstractResource* res){ return !ids.contains(res->appstreamId()); }));
......
......@@ -52,7 +52,6 @@ PackageKitUpdater::PackageKitUpdater(PackageKitBackend * parent)
m_backend(parent),
m_isCancelable(false),
m_isProgressing(false),
m_status(PackageKit::Transaction::Status::StatusUnknown),
m_percentage(0),
m_lastUpdate()
{
......@@ -76,7 +75,6 @@ void PackageKitUpdater::setupTransaction(PackageKit::Transaction::TransactionFla
m_packagesRemoved.clear();
m_transaction = PackageKit::Daemon::updatePackages(involvedPackages(m_toUpgrade).toList(), flags);
m_isCancelable = m_transaction->allowCancel();
m_status = PackageKit::Transaction::Status::StatusUnknown;
connect(m_transaction.data(), &PackageKit::Transaction::finished, this, &PackageKitUpdater::finished);
connect(m_transaction.data(), &PackageKit::Transaction::package, this, &PackageKitUpdater::packageResolved);
......@@ -86,7 +84,6 @@ void PackageKitUpdater::setupTransaction(PackageKit::Transaction::TransactionFla
connect(m_transaction.data(), &PackageKit::Transaction::requireRestart, this, &PackageKitUpdater::requireRestart);
connect(m_transaction.data(), &PackageKit::Transaction::eulaRequired, this, &PackageKitUpdater::eulaRequired);
connect(m_transaction.data(), &PackageKit::Transaction::repoSignatureRequired, this, &PackageKitUpdater::repoSignatureRequired);
connect(m_transaction.data(), &PackageKit::Transaction::statusChanged, this, &PackageKitUpdater::statusChanged);
connect(m_transaction.data(), &PackageKit::Transaction::allowCancelChanged, this, &PackageKitUpdater::cancellableChanged);
connect(m_transaction.data(), &PackageKit::Transaction::percentageChanged, this, &PackageKitUpdater::percentageChanged);
connect(m_transaction.data(), &PackageKit::Transaction::itemProgress, this, &PackageKitUpdater::itemProgress);
......@@ -200,13 +197,6 @@ void PackageKitUpdater::percentageChanged()
}
}
void PackageKitUpdater::statusChanged()
{
if (m_status != m_transaction->status()) {
m_status = m_transaction->status();
}
}
bool PackageKitUpdater::hasUpdates() const
{
return m_backend->updatesCount() > 0;
......
......@@ -61,7 +61,6 @@ class PackageKitUpdater : public AbstractBackendUpdater
void requireRestart(PackageKit::Transaction::Restart restart, const QString& p);
void eulaRequired(const QString &eulaID, const QString &packageID, const QString &vendor, const QString &licenseAgreement);
void finished(PackageKit::Transaction::Exit exit, uint);
void statusChanged();
void cancellableChanged();
void percentageChanged();
void printMessage(PackageKit::Transaction::Message type, const QString &message);
......@@ -93,7 +92,6 @@ class PackageKitUpdater : public AbstractBackendUpdater
QSet<AbstractResource*> m_allUpgradeable;
bool m_isCancelable;
bool m_isProgressing;
PackageKit::Transaction::Status m_status;
int m_percentage;
QDateTime m_lastUpdate;
QStringList m_packagesRemoved;
......
......@@ -120,17 +120,15 @@ void ResourcesProxyModel::removeDuplicates(QVector<AbstractResource *>& resource
{
const auto cab = ResourcesModel::global()->currentApplicationBackend();
QHash<QString, QVector<AbstractResource *>::iterator> storedIds;
for(auto it = m_displayedResources.begin(); it != m_displayedResources.end(); )
for(auto it = m_displayedResources.begin(); it != m_displayedResources.end(); ++it)
{
const auto appstreamid = (*it)->appstreamId();
if (appstreamid.isEmpty()) {
++it;
continue;
}
auto at = storedIds.find(appstreamid);
if (at == storedIds.end()) {
storedIds[appstreamid] = it;
++it;
} else {
qWarning() << "We should have sanitized the displayed resources. There is a bug";
Q_UNREACHABLE();
......@@ -275,9 +273,7 @@ void ResourcesProxyModel::invalidateFilter()
endResetModel();
}
connect(m_currentStream, &AggregatedResultsStream::resourcesFound, this, [this](const QVector<AbstractResource*>& resources) {
addResources(resources);
});
connect(m_currentStream, &AggregatedResultsStream::resourcesFound, this, &ResourcesProxyModel::addResources);
connect(m_currentStream, &AggregatedResultsStream::finished, this, [this]() {
m_currentStream = nullptr;
Q_EMIT busyChanged(false);
......
......@@ -47,7 +47,6 @@ public:
foreach(auto updater, m_allUpdaters) {
connect(updater, &AbstractBackendUpdater::progressingChanged, this, &UpdateTransaction::slotProgressingChanged);
connect(updater, &AbstractBackendUpdater::progressChanged, this, &UpdateTransaction::slotUpdateProgress);
connect(updater, &AbstractBackendUpdater::passiveMessage, this, &Transaction::passiveMessage);
connect(updater, &AbstractBackendUpdater::proceedRequest, this, &UpdateTransaction::processProceedRequest);
cancelable |= updater->isCancelable();
}
......@@ -130,6 +129,7 @@ void ResourcesUpdatesModel::init()
connect(updater, &AbstractBackendUpdater::statusDetailChanged, this, &ResourcesUpdatesModel::message);
connect(updater, &AbstractBackendUpdater::downloadSpeedChanged, this, &ResourcesUpdatesModel::downloadSpeedChanged);
connect(updater, &AbstractBackendUpdater::resourceProgressed, this, &ResourcesUpdatesModel::resourceProgressed);
connect(updater, &AbstractBackendUpdater::passiveMessage, this, &ResourcesUpdatesModel::passiveMessage);
connect(updater, &AbstractBackendUpdater::destroyed, this, &ResourcesUpdatesModel::updaterDestroyed);
m_updaters += updater;
......
......@@ -64,6 +64,7 @@ class DISCOVERCOMMON_EXPORT ResourcesUpdatesModel : public QStandardItemModel
void progressingChanged();
void finished();
void resourceProgressed(AbstractResource* resource, qreal progress);
void passiveMessage(const QString &message);
public Q_SLOTS:
void updateAll();
......
......@@ -44,12 +44,16 @@ StandardBackendUpdater::StandardBackendUpdater(AbstractResourcesBackend* parent)
});
connect(TransactionModel::global(), &TransactionModel::transactionRemoved, this, &StandardBackendUpdater::transactionRemoved);
connect(TransactionModel::global(), &TransactionModel::transactionAdded, this, &StandardBackendUpdater::transactionAdded);
m_timer.setSingleShot(true);
m_timer.setInterval(10);
connect(&m_timer, &QTimer::timeout, this, &StandardBackendUpdater::refreshUpdateable);
}
void StandardBackendUpdater::resourcesChanged(AbstractResource* /*res*/, const QVector<QByteArray>& props)
void StandardBackendUpdater::resourcesChanged(AbstractResource* res, const QVector<QByteArray>& props)
{
if (props.contains("state"))
refreshUpdateable();
if (props.contains("state") && (res->state() == AbstractResource::Upgradeable || m_upgradeable.contains(res)))
m_timer.start();
}
bool StandardBackendUpdater::hasUpdates() const
......@@ -113,7 +117,12 @@ void StandardBackendUpdater::transactionRemoved(Transaction* t)
void StandardBackendUpdater::refreshUpdateable()
{
if (m_backend->isFetching() || !m_backend->isValid() || isProgressing()) {
if (m_backend->isFetching() || !m_backend->isValid()) {
return;
}
if (isProgressing()) {
m_timer.start(1000);
return;
}
......
......@@ -25,6 +25,7 @@
#include "AbstractResourcesBackend.h"
#include <QSet>
#include <QDateTime>
#include <QTimer>
class AbstractResourcesBackend;
......@@ -71,6 +72,7 @@ class DISCOVERCOMMON_EXPORT StandardBackendUpdater : public AbstractBackendUpdat
bool m_settingUp;
qreal m_progress;
QDateTime m_lastUpdate;
QTimer m_timer;
};
#endif // STANDARDBACKENDUPDATER_H
......
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