diff --git a/src/plasma/private/associatedapplicationmanager.cpp b/src/plasma/private/associatedapplicationmanager.cpp index e71b07c33..4a171b07c 100644 --- a/src/plasma/private/associatedapplicationmanager.cpp +++ b/src/plasma/private/associatedapplicationmanager.cpp @@ -21,12 +21,16 @@ #include "config-plasma.h" +#include #include #include #include +#include #include #include +#include +#include #if !PLASMA_NO_KIO #include @@ -93,6 +97,12 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const d->applicationNames[applet] = application; if (!d->urlLists.contains(applet)) { connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*))); + } else { + QAction *a = applet->actions()->action("run associated application"); + if (a) { + a->setIcon(QIcon::fromTheme("system-run")); + a->setText(i18n("Run the Associated Application")); + } } } } @@ -105,6 +115,17 @@ QString AssociatedApplicationManager::application(const Plasma::Applet *applet) void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const QList &urls) { d->urlLists[applet] = urls; + if (!d->applicationNames.contains(applet)) { + QAction *a = applet->actions()->action("run associated application"); + if (a) { + QMimeDatabase mimeDb; + KService::List apps = KFileItemActions::associatedApplications(mimeDb.mimeTypeForUrl(urls.first()).aliases(), QString()); + if (!apps.isEmpty()) { + a->setIcon(QIcon::fromTheme(apps.first()->icon())); + a->setText(i18n("Open in %1", apps.first()->genericName().isEmpty() ? apps.first()->genericName() : apps.first()->name())); + } + } + } } QList AssociatedApplicationManager::urls(const Plasma::Applet *applet) const diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index a51dbd6d5..6ae344e0f 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -750,6 +750,11 @@ void ContainmentInterface::addAppletActions(QMenu &desktopMenu, Plasma::Applet * } if (!applet->failedToLaunch()) { + QAction *runAssociatedApplication = applet->actions()->action("run associated application"); + if (runAssociatedApplication && runAssociatedApplication->isEnabled()) { + desktopMenu.addAction(runAssociatedApplication); + } + QAction *configureApplet = applet->actions()->action("configure"); if (configureApplet && configureApplet->isEnabled()) { desktopMenu.addAction(configureApplet); @@ -758,11 +763,6 @@ void ContainmentInterface::addAppletActions(QMenu &desktopMenu, Plasma::Applet * if (appletAlternatives && appletAlternatives->isEnabled()) { desktopMenu.addAction(appletAlternatives); } - - QAction *runAssociatedApplication = applet->actions()->action("run associated application"); - if (runAssociatedApplication && runAssociatedApplication->isEnabled()) { - desktopMenu.addAction(runAssociatedApplication); - } } QMenu *containmentMenu = new QMenu(i18nc("%1 is the name of the containment", "%1 Options", m_containment->title()), &desktopMenu); @@ -845,6 +845,10 @@ void ContainmentInterface::addContainmentActions(QMenu &desktopMenu, QEvent *eve desktopMenu.addAction(m_containment->actions()->action("configure")); } } else { + QAction *runAssociatedApplication = m_containment->actions()->action("run associated application"); + if (runAssociatedApplication && runAssociatedApplication->isEnabled()) { + desktopMenu.addAction(runAssociatedApplication); + } desktopMenu.addActions(actions); }