Commit 139981be authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Allow to delete updatable entries

BUG: 260836

Also while at it add an icon for the use action in the QWidgets dialog:
BUG: 260836
parent 5e31f850
......@@ -120,7 +120,7 @@ KCM.SimpleKCM {
text: i18ndc("knewstuff5", "Request uninstallation of this item", "Uninstall");
icon.name: "uninstall"
onTriggered: { newStuffModel.uninstallItem(component.index); }
enabled: component.status == NewStuff.ItemsModel.InstalledStatus
enabled: component.status == NewStuff.ItemsModel.InstalledStatus || NewStuff.ItemsModel.UpdateableStatus
visible: enabled;
}
]
......
......@@ -51,7 +51,7 @@ Kirigami.SwipeListItem {
text: i18ndc("knewstuff5", "Request uninstallation of this item", "Uninstall");
iconName: "list-remove"
onTriggered: { listModel.uninstallItem(model.index); }
enabled: model.status == NewStuff.ItemsModel.InstalledStatus
enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus
visible: enabled;
}
]
......
......@@ -86,7 +86,7 @@ Private.GridTileDelegate {
text: root.uninstallLabel
iconName: "uninstall"
onTriggered: { newStuffModel.uninstallItem(model.index); }
enabled: model.status == NewStuff.ItemsModel.InstalledStatus
enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus
visible: enabled;
}
]
......
......@@ -79,7 +79,7 @@ KCM.GridDelegate {
text: component.uninstallLabel
iconName: "uninstall"
onTriggered: { newStuffModel.uninstallItem(model.index); }
enabled: model.status == NewStuff.ItemsModel.InstalledStatus
enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus
visible: enabled;
}
]
......
......@@ -87,7 +87,7 @@ Private.GridTileDelegate {
text: component.uninstallLabel
iconName: "uninstall"
onTriggered: { newStuffModel.uninstallItem(model.index); }
enabled: model.status == NewStuff.ItemsModel.InstalledStatus
enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus
visible: enabled && hovered;
},
Kirigami.Action {
......
......@@ -157,7 +157,8 @@ void ItemsViewDelegate::updateItemWidgets(const QList<QWidget *> widgets,
installButton->setIcon(icon);
installButton->setPopupMode(QToolButton::InstantPopup);
if (installable && entry.downloadLinkCount() > 1) {
// If there are multiple files we want to show a dropdown, but not if it is just an update
if (installable && entry.downloadLinkCount() > 1 && entry.status() != Entry::Updateable) {
QMenu *installMenu = new QMenu(installButton);
const auto lst = entry.downloadLinkInformationList();
for (const KNSCore::EntryInternal::DownloadLinkInformation &info : lst) {
......@@ -171,7 +172,9 @@ void ItemsViewDelegate::updateItemWidgets(const QList<QWidget *> widgets,
installButton->setMenu(installMenu);
} else if (entry.status() == Entry::Installed && m_engine->hasAdoptionCommand()) {
QMenu* m = new QMenu(installButton);
m->addAction(i18n("Use"), m, [this, entry](){
// Add icon to use dropdown, see also BUG: 385858
QAction *action = m->addAction(QIcon::fromTheme(QStringLiteral("checkmark")), i18n("Use"));
connect(action, &QAction::triggered, m, [this, entry](bool) {
QStringList args = KShell::splitArgs(m_engine->adoptionCommand(entry));
qCDebug(KNEWSTUFF) << "executing AdoptionCommand" << args;
QProcess::startDetached(args.takeFirst(), args);
......@@ -179,6 +182,19 @@ void ItemsViewDelegate::updateItemWidgets(const QList<QWidget *> widgets,
installButton->setPopupMode(QToolButton::MenuButtonPopup);
installButton->setMenu(m);
}
// Add uninstall option for updatable entries, BUG: 422047
if (entry.status() == Entry::Updateable) {
QMenu* m = installButton->menu();
if (!m) {
m = new QMenu(installButton);
}
QAction *action = m->addAction(m_iconDelete, i18n("Uninstall"));
connect(action, &QAction::triggered, m, [this, entry](bool){
m_engine->uninstall(entry);
});
installButton->setPopupMode(QToolButton::MenuButtonPopup);
installButton->setMenu(m);
}
}
QToolButton *detailsButton = qobject_cast<QToolButton *>(widgets.at(DelegateDetailsButton));
......
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