diff --git a/containmentactions/applauncher/CMakeLists.txt b/containmentactions/applauncher/CMakeLists.txt --- a/containmentactions/applauncher/CMakeLists.txt +++ b/containmentactions/applauncher/CMakeLists.txt @@ -1,12 +1,15 @@ +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}) diff --git a/containmentactions/applauncher/Messages.sh b/containmentactions/applauncher/Messages.sh new file mode 100755 --- /dev/null +++ b/containmentactions/applauncher/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT *.cpp -o $podir/plasma_containmentactions_applauncher.pot diff --git a/containmentactions/applauncher/config.ui b/containmentactions/applauncher/config.ui new file mode 100644 --- /dev/null +++ b/containmentactions/applauncher/config.ui @@ -0,0 +1,25 @@ + + + Config + + + + 0 + 0 + 397 + 123 + + + + + + + Show applications by name + + + + + + + + diff --git a/containmentactions/applauncher/launch.h b/containmentactions/applauncher/launch.h --- a/containmentactions/applauncher/launch.h +++ b/containmentactions/applauncher/launch.h @@ -26,6 +26,8 @@ #include +#include "ui_config.h" + class QAction; class QMenu; @@ -40,12 +42,21 @@ QList 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 m_actions; + + Ui::Config m_ui; + bool m_showAppsByName = false; }; diff --git a/containmentactions/applauncher/launch.cpp b/containmentactions/applauncher/launch.cpp --- a/containmentactions/applauncher/launch.cpp +++ b/containmentactions/applauncher/launch.cpp @@ -52,7 +52,13 @@ foreach (KSycocaEntry::Ptr p, group->entries(true, false, true)) { if (p->isType(KST_KService)) { const KService::Ptr service(static_cast(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 @@ } } +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") diff --git a/containmentactions/applauncher/plasma-containmentactions-applauncher.desktop b/containmentactions/applauncher/plasma-containmentactions-applauncher.desktop --- a/containmentactions/applauncher/plasma-containmentactions-applauncher.desktop +++ b/containmentactions/applauncher/plasma-containmentactions-applauncher.desktop @@ -165,3 +165,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true +X-Plasma-HasConfigurationInterface=true