Commit bdaaaedb authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[AppLauncher Containment Action] Add option to "show apps by name"

This will have it show the actual application name instead of the description.

BUG: 358423
FIXED-IN: 5.11.0

CHANGELOG: Application launcher mouse action can now be configured to show application names instead of their description

Differential Revision: https://phabricator.kde.org/D6441
parent c75e91f8
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_containmentactions_applauncher\")
set(applauncher_SRCS
launch.cpp
)
ki18n_wrap_ui(applauncher_SRCS config.ui)
add_library(plasma_containmentactions_applauncher MODULE ${applauncher_SRCS})
kcoreaddons_desktop_to_json(plasma_containmentactions_applauncher plasma-containmentactions-applauncher.desktop)
target_link_libraries(plasma_containmentactions_applauncher KF5::Plasma KF5::KIOCore KF5::KIOWidgets)
target_link_libraries(plasma_containmentactions_applauncher KF5::Plasma KF5::KIOCore KF5::KIOWidgets KF5::I18n)
install(TARGETS plasma_containmentactions_applauncher DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES plasma-containmentactions-applauncher.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
#! /usr/bin/env bash
$XGETTEXT *.cpp -o $podir/plasma_containmentactions_applauncher.pot
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Config</class>
<widget class="QWidget" name="Config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>123</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="showAppsByName">
<property name="text">
<string>Show applications by name</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -52,7 +52,13 @@ void AppLauncher::makeMenu(QMenu *menu, const KServiceGroup::Ptr group)
foreach (KSycocaEntry::Ptr p, group->entries(true, false, true)) {
if (p->isType(KST_KService)) {
const KService::Ptr service(static_cast<KService*>(p.data()));
QAction *action = new QAction(QIcon::fromTheme(service->icon()), service->genericName().isEmpty() ? service->name() : service->genericName(), this);
QString text = service->name();
if (!m_showAppsByName && !service->genericName().isEmpty()) {
text = service->genericName();
}
QAction *action = new QAction(QIcon::fromTheme(service->icon()), text, this);
connect(action, &QAction::triggered, [action](){
KService::Ptr service = KService::serviceByStorageId(action->data().toString());
new KRun(QUrl("file://"+service->entryPath()), 0);
......@@ -85,6 +91,31 @@ void AppLauncher::makeMenu(QMenu *menu, const KServiceGroup::Ptr group)
}
}
QWidget *AppLauncher::createConfigurationInterface(QWidget *parent)
{
QWidget *widget = new QWidget(parent);
m_ui.setupUi(widget);
widget->setWindowTitle(i18nc("plasma_containmentactions_applauncher", "Configure Application Launcher Plugin"));
m_ui.showAppsByName->setChecked(m_showAppsByName);
return widget;
}
void AppLauncher::configurationAccepted()
{
m_showAppsByName = m_ui.showAppsByName->isChecked();
}
void AppLauncher::restore(const KConfigGroup &config)
{
m_showAppsByName = config.readEntry(QStringLiteral("showAppsByName"), false);
}
void AppLauncher::save(KConfigGroup &config)
{
config.writeEntry(QStringLiteral("showAppsByName"), m_showAppsByName);
}
K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(applauncher, AppLauncher, "plasma-containmentactions-applauncher.json")
......
......@@ -26,6 +26,8 @@
#include <plasma/containmentactions.h>
#include "ui_config.h"
class QAction;
class QMenu;
......@@ -40,12 +42,21 @@ class AppLauncher : public Plasma::ContainmentActions
QList<QAction*> contextualActions() override;
QWidget *createConfigurationInterface(QWidget* parent) override;
void configurationAccepted() override;
void restore(const KConfigGroup &config) override;
void save(KConfigGroup &config) override;
protected:
void makeMenu(QMenu *menu, const KServiceGroup::Ptr group);
private:
KServiceGroup::Ptr m_group;
QList<QAction *> m_actions;
Ui::Config m_ui;
bool m_showAppsByName = false;
};
......
......@@ -165,3 +165,4 @@ X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-HasConfigurationInterface=true
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