Commit 4dca72bd authored by Méven Car's avatar Méven Car
Browse files

Kicker/RecentDocuments: add icons to actions

Test Plan: {F7857520}

Reviewers: #plasma, ngraham, hein

Reviewed By: #plasma, ngraham, hein

Subscribers: hein, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26386
parent c3912e01
......@@ -52,11 +52,12 @@ using namespace KAStats::Terms;
namespace Kicker
{
QVariantMap createActionItem(const QString &label, const QString &actionId, const QVariant &argument)
QVariantMap createActionItem(const QString &label, const QString &icon, const QString &actionId, const QVariant &argument)
{
QVariantMap map;
map[QStringLiteral("text")] = label;
map[QStringLiteral("icon")] = icon;
map[QStringLiteral("actionId")] = actionId;
if (argument.isValid()) {
......@@ -96,8 +97,7 @@ QVariantList createActionListForFileItem(const KFileItem &fileItem)
foreach (const KService::Ptr service, services) {
const QString text = service->name().replace(QLatin1Char('&'), QStringLiteral("&&"));
QVariantMap item = createActionItem(text, QStringLiteral("_kicker_fileItem_openWith"), service->entryPath());
item[QStringLiteral("icon")] = service->icon();
QVariantMap item = createActionItem(text, service->icon(), QStringLiteral("_kicker_fileItem_openWith"), service->entryPath());
list << item;
}
......@@ -105,8 +105,7 @@ QVariantList createActionListForFileItem(const KFileItem &fileItem)
list << createSeparatorActionItem();
}
QVariantMap propertiesItem = createActionItem(i18n("Properties"), QStringLiteral("_kicker_fileItem_properties"));
propertiesItem[QStringLiteral("icon")] = QStringLiteral("document-properties");
const QVariantMap &propertiesItem = createActionItem(i18n("Properties"), QStringLiteral("document-properties"), QStringLiteral("_kicker_fileItem_properties"));
list << propertiesItem;
return list;
......@@ -150,20 +149,17 @@ QVariantList createAddLauncherActionList(QObject *appletInterface, const KServic
}
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) {
QVariantMap addToDesktopAction = Kicker::createActionItem(i18n("Add to Desktop"), QStringLiteral("addToDesktop"));
addToDesktopAction[QStringLiteral("icon")] = QStringLiteral("list-add");
QVariantMap addToDesktopAction = Kicker::createActionItem(i18n("Add to Desktop"), QStringLiteral("list-add"), QStringLiteral("addToDesktop"));
actionList << addToDesktopAction;
}
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) {
QVariantMap addToPanelAction = Kicker::createActionItem(i18n("Add to Panel (Widget)"), QStringLiteral("addToPanel"));
addToPanelAction[QStringLiteral("icon")] = QStringLiteral("list-add");
QVariantMap addToPanelAction = Kicker::createActionItem(i18n("Add to Panel (Widget)"), QStringLiteral("list-add"), QStringLiteral("addToPanel"));
actionList << addToPanelAction;
}
if (service && ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, Kicker::resolvedServiceEntryPath(service))) {
QVariantMap addToTaskManagerAction = Kicker::createActionItem(i18n("Pin to Task Manager"), QStringLiteral("addToTaskManager"));
addToTaskManagerAction[QStringLiteral("icon")] = QStringLiteral("pin");
QVariantMap addToTaskManagerAction = Kicker::createActionItem(i18n("Pin to Task Manager"), QStringLiteral("pin"), QStringLiteral("addToTaskManager"));
actionList << addToTaskManagerAction;
}
......@@ -221,8 +217,7 @@ QVariantList jumpListActions(KService::Ptr service)
continue;
}
QVariantMap item = createActionItem(action.text(), QStringLiteral("_kicker_jumpListAction"), action.exec());
item[QStringLiteral("icon")] = action.icon();
QVariantMap item = createActionItem(action.text(), action.icon(), QStringLiteral("_kicker_jumpListAction"), action.exec());
list << item;
}
......@@ -276,15 +271,13 @@ QVariantList recentDocumentActions(KService::Ptr service)
list << createTitleActionItem(i18n("Recent Documents"));
}
QVariantMap item = createActionItem(url.fileName(), QStringLiteral("_kicker_recentDocument"), resource);
item[QStringLiteral("icon")] = fileItem.iconName();
QVariantMap item = createActionItem(url.fileName(), fileItem.iconName(), QStringLiteral("_kicker_recentDocument"), resource);
list << item;
}
if (!list.isEmpty()) {
QVariantMap forgetAction = createActionItem(i18n("Forget Recent Documents"), QStringLiteral("_kicker_forgetRecentDocuments"));
forgetAction[QStringLiteral("icon")] = QStringLiteral("edit-clear-history");
QVariantMap forgetAction = createActionItem(i18n("Forget Recent Documents"), QStringLiteral("edit-clear-history"), QStringLiteral("_kicker_forgetRecentDocuments"));
list << forgetAction;
}
......@@ -341,8 +334,8 @@ QVariantList editApplicationAction(const KService::Ptr &service)
QVariantList actionList;
if (canEditApplication(service)) {
QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), QStringLiteral("editApplication"));
editAction[QStringLiteral("icon")] = QStringLiteral("kmenuedit"); // TODO: Using the KMenuEdit icon might be misleading.
// TODO: Using the KMenuEdit icon might be misleading.
QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), QStringLiteral("kmenuedit"), QStringLiteral("editApplication"));
actionList << editAction;
}
......@@ -388,8 +381,10 @@ QVariantList appstreamActions(const KService::Ptr &service)
for(const auto &component: components) {
const QString componentId = component.id();
QVariantMap appstreamAction = Kicker::createActionItem(i18nc("@action opens a software center with the application", "Uninstall or Manage Add-Ons..."), "manageApplication", QVariant(QLatin1String("appstream://") + componentId));
appstreamAction[QStringLiteral("icon")] = appStreamHandler->icon();
QVariantMap appstreamAction = Kicker::createActionItem(
i18nc("@action opens a software center with the application", "Uninstall or Manage Add-Ons..."),
appStreamHandler->icon(),
"manageApplication", QVariant(QLatin1String("appstream://") + componentId));
ret << appstreamAction;
}
#else
......
......@@ -43,7 +43,7 @@ enum {
UrlRole
};
QVariantMap createActionItem(const QString &label, const QString &actionId, const QVariant &argument = QVariant());
QVariantMap createActionItem(const QString &label, const QString &icon, const QString &actionId, const QVariant &argument = QVariant());
QVariantMap createTitleActionItem(const QString &label);
......
......@@ -179,8 +179,7 @@ QVariantList AppEntry::actions() const
const QStringList &hiddenApps = appletConfig->value(QLatin1String("hiddenApplications")).toStringList();
if (!hiddenApps.contains(m_service->menuId())) {
QVariantMap hideAction = Kicker::createActionItem(i18n("Hide Application"), QStringLiteral("hideApplication"));
hideAction[QStringLiteral("icon")] = QStringLiteral("hint");
QVariantMap hideAction = Kicker::createActionItem(i18n("Hide Application"), QStringLiteral("view-hidden"), QStringLiteral("hideApplication"));
actionList << hideAction;
}
}
......
......@@ -162,16 +162,14 @@ QVariant AppsModel::data(const QModelIndex &index, int role) const
if (!m_hiddenEntries.isEmpty()) {
actionList << Kicker::createSeparatorActionItem();
QVariantMap unhideSiblingApplicationsAction = Kicker::createActionItem(i18n("Unhide Applications in this Submenu"), QStringLiteral("unhideSiblingApplications"));
unhideSiblingApplicationsAction[QStringLiteral("icon")] = QStringLiteral("view-visible");
QVariantMap unhideSiblingApplicationsAction = Kicker::createActionItem(i18n("Unhide Applications in this Submenu"), QStringLiteral("view-visible"), QStringLiteral("unhideSiblingApplications"));
actionList << unhideSiblingApplicationsAction;
}
const AppsModel *appsModel = qobject_cast<const AppsModel *>(entry->childModel());
if (appsModel && !appsModel->hiddenEntries().isEmpty()) {
QVariantMap unhideChildApplicationsAction = Kicker::createActionItem(i18n("Unhide Applications in '%1'", entry->name()), QStringLiteral("unhideChildApplications"));
unhideChildApplicationsAction[QStringLiteral("icon")] = QStringLiteral("view-visible");
QVariantMap unhideChildApplicationsAction = Kicker::createActionItem(i18n("Unhide Applications in '%1'", entry->name()), QStringLiteral("view-visible"), QStringLiteral("unhideChildApplications"));
actionList << unhideChildApplicationsAction;
}
......
......@@ -114,7 +114,7 @@ QVariantList ContactEntry::actions() const
{
QVariantList actionList;
actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QStringLiteral("showContactInfo"));
actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QString("identity"), QStringLiteral("showContactInfo"));
return actionList;
}
......
......@@ -82,15 +82,15 @@ QVariant RecentContactsModel::data(const QModelIndex &index, int role) const
} else if (role == Kicker::ActionListRole) {
QVariantList actionList ;
const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Contact"), QStringLiteral("forget"));
const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Contact"), QStringLiteral("edit-clear-history"), QStringLiteral("forget"));
actionList << forgetAction;
const QVariantMap &forgetAllAction = Kicker::createActionItem(i18n("Forget All Contacts"), QStringLiteral("forgetAll"));
const QVariantMap &forgetAllAction = Kicker::createActionItem(i18n("Forget All Contacts"), QStringLiteral("edit-clear-history"), QStringLiteral("forgetAll"));
actionList << forgetAllAction;
actionList << Kicker::createSeparatorActionItem();
actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QStringLiteral("showContactInfo"));
actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QStringLiteral("identity"), QStringLiteral("showContactInfo"));
return actionList;
} else if (role == Kicker::DescriptionRole) {
......@@ -162,7 +162,7 @@ QVariantList RecentContactsModel::actions() const
QVariantList actionList;
if (rowCount()) {
actionList << Kicker::createActionItem(i18n("Forget All Contacts"), QStringLiteral("forgetAll"));
actionList << Kicker::createActionItem(i18n("Forget All Contacts"), QStringLiteral("edit-clear-history"), QStringLiteral("forgetAll"));
}
return actionList;
......
......@@ -227,10 +227,10 @@ QVariant RecentUsageModel::appData(const QString &resource, int role) const
actionList << recentDocuments << Kicker::createSeparatorActionItem();
}
const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Application"), QStringLiteral("forget"));
const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Application"), QStringLiteral("edit-clear-history"), QStringLiteral("forget"));
actionList << forgetAction;
const QVariantMap &forgetAllAction = Kicker::createActionItem(forgetAllActionName(), QStringLiteral("forgetAll"));
const QVariantMap &forgetAllAction = Kicker::createActionItem(forgetAllActionName(), QStringLiteral("edit-clear-history"), QStringLiteral("forgetAll"));
actionList << forgetAllAction;
return actionList;
......@@ -303,13 +303,13 @@ QVariant RecentUsageModel::docData(const QString &resource, int role) const
actionList << Kicker::createSeparatorActionItem();
const QVariantMap &openParentFolder = Kicker::createActionItem(i18n("Open Containing Folder"), QStringLiteral("openParentFolder"));
QVariantMap openParentFolder = Kicker::createActionItem(i18n("Open Containing Folder"), QStringLiteral("folder-open"), QStringLiteral("openParentFolder"));
actionList << openParentFolder;
const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Document"), QStringLiteral("forget"));
QVariantMap forgetAction = Kicker::createActionItem(i18n("Forget Document"), QStringLiteral("edit-clear-history"), QStringLiteral("forget"));
actionList << forgetAction;
const QVariantMap &forgetAllAction = Kicker::createActionItem(forgetAllActionName(), QStringLiteral("forgetAll"));
QVariantMap forgetAllAction = Kicker::createActionItem(forgetAllActionName(), QStringLiteral("edit-clear-history"), QStringLiteral("forgetAll"));
actionList << forgetAllAction;
return actionList;
......@@ -427,7 +427,7 @@ QVariantList RecentUsageModel::actions() const
QVariantList actionList;
if (rowCount()) {
actionList << Kicker::createActionItem(forgetAllActionName(), QStringLiteral("forgetAll"));
actionList << Kicker::createActionItem(forgetAllActionName(), QStringLiteral("edit-clear-history"), QStringLiteral("forgetAll"));
}
return actionList;
......
......@@ -105,7 +105,7 @@ QVariant RootModel::data(const QModelIndex& index, int role) const
actionList << model->actions();
actionList << Kicker::createSeparatorActionItem();
actionList << Kicker::createActionItem(i18n("Hide %1",
group->name()), QStringLiteral("hideCategory"));
group->name()), QStringLiteral("view-hidden"), QStringLiteral("hideCategory"));
return actionList;
}
}
......
......@@ -95,9 +95,8 @@ QVariant RunnerMatchesModel::data(const QModelIndex &index, int role) const
QVariantList actionList;
foreach (QAction *action, m_runnerManager->actionsForMatch(match)) {
QVariantMap item = Kicker::createActionItem(action->text(), QStringLiteral("runnerAction"),
QVariantMap item = Kicker::createActionItem(action->text(), action->icon().name(), QStringLiteral("runnerAction"),
QVariant::fromValue<QObject *>(action));
item[QStringLiteral("icon")] = action->icon();
actionList << item;
}
......
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