Commit a4c06f0f authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Remove unused concept of message actions

It got watered down over time, doesn't make sense anymore
parent db73463d
......@@ -80,26 +80,6 @@ DiscoverPage {
onTriggered: addSourceDialog.open()
}
MenuSeparator {
visible: messageActionsInst.count>0
}
Instantiator {
id: messageActionsInst
model: ActionsModel {
actions: settingsButton.backend ? settingsButton.backend.resourcesBackend.messageActions : null
}
delegate: MenuItem {
action: ActionBridge { action: model.action }
}
onObjectAdded: {
settingsMenu.insertItem(index, object)
}
onObjectRemoved: {
object.destroy()
}
}
MenuSeparator {
visible: backendActionsInst.count>0
}
......
......@@ -54,25 +54,6 @@ DummyBackend::DummyBackend(QObject* parent)
if (!m_fetching)
m_reviews->initialize();
QAction* randomAction = new QAction(this);
randomAction->setIcon(QIcon::fromTheme(QStringLiteral("kalarm")));
randomAction->setText(QStringLiteral("test bla bla"));
randomAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
randomAction->setPriority(QAction::LowPriority);
connect(randomAction, &QAction::triggered, this, [](){ qDebug() << "random action triggered"; });
// QAction* importantAction = new QAction(this);
// importantAction->setIcon(QIcon::fromTheme(QStringLiteral("kalarm"));
// importantAction->setText(QStringLiteral("Amaze!"));
// importantAction->setWhatsThis(QStringLiteral("Wo Wo I'm so important"));
// importantAction->setPriority(QAction::HighPriority);
// connect(importantAction, &QAction::triggered, this, [importantAction](){
// importantAction->setEnabled(false);
// qDebug() << "important action triggered";
// });
m_messageActions = QList<QAction*>() << randomAction /*<< importantAction*/;
SourcesModel::global()->addSourcesBackend(new DummySourcesBackend(this));
}
......
......@@ -42,7 +42,6 @@ public:
ResultsStream * findResourceByPackageName(const QUrl& search) override;
QHash<QString, DummyResource*> resources() const { return m_resources; }
bool isValid() const override { return true; } // No external file dependencies that could cause runtime errors
QList<QAction*> messageActions() const override { return m_messageActions; }
Transaction* installApplication(AbstractResource* app) override;
Transaction* installApplication(AbstractResource* app, const AddonList& addons) override;
......@@ -63,7 +62,6 @@ private:
DummyReviewsBackend* m_reviews;
bool m_fetching;
int m_startElements;
QList<QAction*> m_messageActions;
};
#endif // DUMMYBACKEND_H
......@@ -53,7 +53,6 @@ public:
ResultsStream * findResourceByPackageName(const QUrl &search) override;
QList<FlatpakResource*> resources() const { return m_resources.values(); }
bool isValid() const override;
QList<QAction*> messageActions() const override { return {}; }
Transaction* installApplication(AbstractResource* app) override;
Transaction* installApplication(AbstractResource* app, const AddonList& addons) override;
......
......@@ -48,7 +48,6 @@ public:
AbstractReviewsBackend* reviewsBackend() const override;
AbstractBackendUpdater* backendUpdater() const override;
bool isFetching() const override;
QList<QAction*> messageActions() const override { return QList<QAction*>(); }
ResultsStream* search(const AbstractResourcesBackend::Filters & filter) override;
ResultsStream* findResourceByPackageName(const QUrl & search) override;
......
......@@ -43,7 +43,6 @@
#include <PackageKit/Daemon>
#include <PackageKit/Details>
#include <KDesktopFile>
#include <KLocalizedString>
#include <QAction>
#include <QMimeDatabase>
......@@ -53,7 +52,7 @@
MUON_BACKEND_PLUGIN(PackageKitBackend)
static QString locateService(const QString &filename)
QString PackageKitBackend::locateService(const QString &filename)
{
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("applications/")+filename);
}
......@@ -75,16 +74,6 @@ PackageKitBackend::PackageKitBackend(QObject* parent)
m_delayedDetailsFetch.setInterval(0);
connect(&m_delayedDetailsFetch, &QTimer::timeout, this, &PackageKitBackend::performDetailsFetch);
// Kubuntu-based
auto service = locateService(QStringLiteral("software-properties-kde.desktop"));
if (!service.isEmpty())
m_messageActions += createActionForService(service);
// openSUSE-based
service = locateService(QStringLiteral("YaST2/sw_source.desktop"));
if (!service.isEmpty())
m_messageActions += createActionForService(service);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::updatesChanged, this, &PackageKitBackend::fetchUpdates);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::isRunningChanged, this, &PackageKitBackend::checkDaemonRunning);
connect(m_reviews.data(), &OdrsReviewsBackend::ratingsReady, this, &AbstractResourcesBackend::emitRatingsReady);
......@@ -113,20 +102,6 @@ void PackageKitBackend::delayedInit()
}
}
QAction* PackageKitBackend::createActionForService(const QString &servicePath)
{
QAction* action = new QAction(this);
KDesktopFile parser(servicePath);
action->setIcon(QIcon::fromTheme(parser.readIcon()));
action->setText(parser.readName());
connect(action, &QAction::triggered, action, [servicePath, this](){
bool b = QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice"), {servicePath});
if (!b)
qWarning() << "Could not start" << servicePath;
});
return action;
}
bool PackageKitBackend::isFetching() const
{
return m_isFetching;
......@@ -564,11 +539,6 @@ AbstractBackendUpdater* PackageKitBackend::backendUpdater() const
return m_updater;
}
QList<QAction*> PackageKitBackend::messageActions() const
{
return m_messageActions;
}
QVector<AppPackageKitResource*> PackageKitBackend::extendedBy(const QString& id) const
{
return m_packages.extendedBy[id];
......
......@@ -58,7 +58,6 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
bool isValid() const override { return true; }
QSet<AbstractResource*> upgradeablePackages() const;
bool isFetching() const override;
QList<QAction*> messageActions() const override;
bool isPackageNameUpgradeable(const PackageKitResource* res) const;
QString upgradeablePackageId(const PackageKitResource* res) const;
......@@ -73,6 +72,7 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
QString displayName() const override;
bool hasApplications() const override { return true; }
static QString locateService(const QString &filename);
public Q_SLOTS:
void reloadPackageList();
......@@ -101,7 +101,6 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
void includePackagesToAdd();
void performDetailsFetch();
AppPackageKitResource* addComponent(const AppStream::Component& component, const QStringList& pkgNames);
QAction* createActionForService(const QString &filename);
AppStream::Pool m_appdata;
PackageKitUpdater* m_updater;
......@@ -111,7 +110,6 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
bool m_hasSecurityUpdates = false;
QSet<PackageKitResource*> m_packagesToAdd;
QSet<PackageKitResource*> m_packagesToDelete;
QList<QAction*> m_messageActions;
struct Packages {
QHash<QString, AbstractResource*> packages;
......
......@@ -21,10 +21,15 @@
#include "PackageKitSourcesBackend.h"
#include <QStandardItemModel>
#include <KLocalizedString>
#include <KDesktopFile>
#include <PackageKit/Transaction>
#include <PackageKit/Daemon>
#include <QAction>
#include <QProcess>
#include <QDebug>
#include <resources/AbstractResourcesBackend.h>
#include "PackageKitBackend.h"
#include "config-paths.h"
class PKSourcesModel : public QStandardItemModel
{
......@@ -68,12 +73,36 @@ private:
PackageKitSourcesBackend* m_backend;
};
static QAction* createActionForService(const QString &servicePath, QObject* parent)
{
QAction* action = new QAction(parent);
KDesktopFile parser(servicePath);
action->setIcon(QIcon::fromTheme(parser.readIcon()));
action->setText(parser.readName());
QObject::connect(action, &QAction::triggered, action, [servicePath](){
bool b = QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice"), {servicePath});
if (!b)
qWarning() << "Could not start" << servicePath;
});
return action;
}
PackageKitSourcesBackend::PackageKitSourcesBackend(AbstractResourcesBackend* parent)
: AbstractSourcesBackend(parent)
, m_sources(new PKSourcesModel(this))
{
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::repoListChanged, this, &PackageKitSourcesBackend::resetSources);
resetSources();
// Kubuntu-based
auto service = PackageKitBackend::locateService(QStringLiteral("software-properties-kde.desktop"));
if (!service.isEmpty())
m_actions += createActionForService(service, this);
// openSUSE-based
service = PackageKitBackend::locateService(QStringLiteral("YaST2/sw_source.desktop"));
if (!service.isEmpty())
m_actions += createActionForService(service, this);
}
QString PackageKitSourcesBackend::name() const
......@@ -132,7 +161,7 @@ bool PackageKitSourcesBackend::removeSource(const QString& id)
QList<QAction *> PackageKitSourcesBackend::actions() const
{
return {};
return m_actions;
}
void PackageKitSourcesBackend::resetSources()
......
......@@ -50,6 +50,7 @@ class PackageKitSourcesBackend : public AbstractSourcesBackend
QStandardItem* findItemForId(const QString &id) const;
PKSourcesModel* m_sources;
QList<QAction*> m_actions;
};
#endif // PACKAGEKITSOURCESBACKEND_H
......@@ -44,7 +44,6 @@ public:
AbstractBackendUpdater* backendUpdater() const override;
AbstractReviewsBackend* reviewsBackend() const override;
bool isValid() const override { return m_valid; }
QList<QAction*> messageActions() const override { return {}; }
Transaction* installApplication(AbstractResource* app) override;
Transaction* installApplication(AbstractResource* app, const AddonList& addons) override;
......
......@@ -30,7 +30,6 @@
#include "discovercommon_export.h"
class QAction;
class Transaction;
class Category;
class AbstractReviewsBackend;
......@@ -78,7 +77,6 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
Q_PROPERTY(int updatesCount READ updatesCount NOTIFY updatesCountChanged)
Q_PROPERTY(bool hasSecurityUpdates READ hasSecurityUpdates NOTIFY updatesCountChanged)
Q_PROPERTY(bool isFetching READ isFetching NOTIFY fetchingChanged)
Q_PROPERTY(QList<QAction*> messageActions READ messageActions CONSTANT)
public:
/**
* Constructs an AbstractResourcesBackend
......@@ -142,15 +140,6 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
*/
virtual bool isFetching() const = 0;
/**
* This method is used to integrate advanced functions into the Muon GUI.
*
* In plasma-discover-updater, actions with HighPriority will be shown in a KMessageWidget,
* normal priority will go right on top of the more menu, low priority will go
* to the advanced menu.
*/
virtual QList<QAction*> messageActions() const = 0;
/**
* @returns the appstream ids that this backend extends
*/
......@@ -238,17 +227,6 @@ class DISCOVERCOMMON_EXPORT AbstractResourcesBackend : public QObject
QString m_name;
};
template <typename T, typename W>
static T containerValues(const W& container)
{
T ret;
ret.reserve(container.size());
for(auto a : container) {
ret.push_back(a);
}
return ret;
}
DISCOVERCOMMON_EXPORT QDebug operator<<(QDebug dbg, const AbstractResourcesBackend::Filters& filters);
/**
......
......@@ -248,16 +248,6 @@ void ResourcesModel::slotFetching()
}
}
QList<QAction*> ResourcesModel::messageActions() const
{
QList<QAction*> ret = m_ownActions;
foreach(AbstractResourcesBackend* b, m_backends) {
ret += b->messageActions();
}
Q_ASSERT(!ret.contains(nullptr));
return ret;
}
bool ResourcesModel::isBusy() const
{
return TransactionModel::global()->rowCount() > 0;
......
......@@ -70,7 +70,6 @@ class DISCOVERCOMMON_EXPORT ResourcesModel : public QObject
bool isBusy() const;
bool isFetching() const;
QList<QAction*> messageActions() const;
Q_SCRIPTABLE bool isExtended(const QString &id);
......
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